The Sentrius AI-Powered Tooltip System provides contextual help and descriptions for UI elements using LLM integration and indexed codebase documentation. Users can right-click on UI elements to get intelligent, context-aware tooltips and have conversational assistance about features.
-
Frontend Integration (
ai-helper.js)- Right-click context menu for element descriptions
- Chat modal for conversational assistance
- Automatic element context extraction (tag, ID, classes, attributes, text content)
-
Backend API (
TooltipController)/api/v1/tooltip/describe- Get AI description for a UI element/api/v1/tooltip/chat- Chat with AI about features and elements/api/v1/tooltip/admin/index- Trigger manual codebase indexing (admin only)
-
Services
- TooltipService - Orchestrates tooltip generation using document search and LLM
- CodebaseIndexingService - Indexes Java source files and markdown documentation
- DocumentService - Provides semantic search over indexed content
- LLMService - Integrates with OpenAI/LLM providers for text generation
-
Data Transfer Objects
TooltipDescribeRequest/TooltipDescribeResponseTooltipChatRequest/TooltipChatResponse
- User right-clicks on a UI element
- Frontend extracts element context (tag, ID, classes, text, attributes, DOM path)
- Context is sent to
/api/v1/tooltip/describeendpoint - Backend:
- Builds search query from element context
- Searches indexed documentation using semantic search
- Combines relevant docs with element info
- Calls LLM to generate concise description (2-3 sentences)
- Description is displayed in a notification popup
- User opens AI chat modal (via right-click menu or directly)
- User types a question about a feature or element
- Message is sent to
/api/v1/tooltip/chatendpoint - Backend:
- Searches documentation based on the question
- Optionally includes element context if provided
- Calls LLM to generate helpful response
- Response is displayed in chat conversation
-
Automatic (on application startup if configured):
- Scans codebase directory for
.mdand*Controller.java/*Service.javafiles - Extracts metadata (title, summary, package, class name, JavaDoc)
- Generates embeddings for semantic search
- Stores in Document repository
- Scans codebase directory for
-
Manual (via admin endpoint):
- Admin users can trigger
/api/v1/tooltip/admin/index - Re-indexes codebase on demand
- Returns statistics (files processed, success/error counts)
- Admin users can trigger
Add to application.properties or application.yml:
# Tooltip Configuration
sentrius.tooltip.max-context-documents=5
sentrius.tooltip.similarity-threshold=0.5
sentrius.tooltip.llm-model=gpt-4o-mini
# Indexing Configuration
sentrius.tooltip.index.enabled=true
sentrius.tooltip.index.codebase-path=/path/to/sentrius/codebase
# LLM Endpoint (if not using default)
agent.open.ai.endpoint=http://localhost:8080Include the AI Helper library in your HTML templates:
<script th:inline="javascript">
var csrf = [[${session._csrf}]];
</script>
<script src="/js/ai-helper.js"></script>
<script>
// Initialize AI Helper
const aiHelper = new AIHelper({
apiEndpoint: '/api/v1/tooltip',
enableDescriptions: true,
enableChat: true
});
</script>Get AI-powered description for a UI element.
Request:
{
"context": {
"tagName": "BUTTON",
"id": "submit-btn",
"className": "btn btn-primary",
"textContent": "Submit Form",
"attributes": {
"type": "button",
"aria-label": "Submit the form"
},
"path": "body > div.container > form > button#submit-btn"
},
"timestamp": 1234567890
}Response:
{
"description": "This button submits the form data to the server. Click it after filling in all required fields to save your changes.",
"message": "This button submits the form data to the server. Click it after filling in all required fields to save your changes.",
"success": true
}Chat with AI assistant about features and elements.
Request:
{
"message": "How do I configure SSH access policies?",
"context": null,
"timestamp": 1234567890
}Response:
{
"response": "To configure SSH access policies in Sentrius, navigate to the Access Policies page. You can define rules based on user attributes, time windows, and resource tags. Policies use ABAC (Attribute-Based Access Control) to enforce zero-trust security.",
"message": "To configure SSH access policies in Sentrius...",
"success": true
}Trigger manual indexing of codebase and documentation (admin only).
Response:
{
"success": true,
"message": "Indexing completed successfully",
"totalFiles": 150,
"successCount": 148,
"errorCount": 2,
"errors": [
"Error indexing docs/broken.md: File not found",
"Error indexing src/BrokenController.java: Parse error"
]
}- All endpoints require user authentication (CAN_LOG_IN permission)
- Admin indexing endpoint requires CAN_MANAGE_SYSTEMS permission
- CSRF protection via X-CSRF-TOKEN header
- User context is preserved for audit logging
- Semantic Search: Uses vector embeddings for fast similarity search
- Result Limiting: Configurable
max-context-documents(default: 5) - Similarity Threshold: Configurable minimum similarity score (default: 0.5)
- LLM Token Limits: Descriptions limited to 300 tokens, context limited to first 200 chars per document
- Check that indexing has been run (
/api/v1/tooltip/admin/index) - Verify
sentrius.tooltip.index.enabled=true - Ensure LLM service is available and configured
- Increase
sentrius.tooltip.max-context-documentsfor more context - Lower
sentrius.tooltip.similarity-thresholdfor more results - Re-index with updated documentation
- Verify
sentrius.tooltip.index.codebase-pathis correct and accessible - Check file permissions for reading source files
- Review error messages in response for specific file issues
- Real-time indexing on file changes
- Support for additional file types (XML, YAML, properties)
- User-specific tooltip customization
- Tooltip analytics and feedback
- Caching layer for frequently requested tooltips
- Multi-language support
To index additional content types, extend CodebaseIndexingService:
- Add a new
index[Type]Filemethod - Update
indexCodebase()to call the new method - Add glob patterns to
findFiles()call
Edit the prompt templates in TooltipService:
generateDescription()- For element descriptionsgenerateChatResponse()- For chat interactions
Run tests:
mvn test -pl api -Dtest=TooltipControllerTestAll tooltip functionality is unit tested with mocked dependencies.
Copyright © 2024 Sentrius LLC. All rights reserved.