-
Couldn't load subscription status.
- Fork 10
feat: Add pinned context support for Amazon Q chat #470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add pinned context commands to ChatUIInboundCommandName and Command enums - Implement LSP server methods for pinned context operations - Add active editor change listener for automatic context tracking - Enable pinnedContextEnabled flag in client capabilities - Route pinned context commands through ChatCommunicationManager - Add support for pinnedContextAdd, pinnedContextRemove, and sendPinnedContext - Include active editor tracking with 100ms debouncing This allows users to pin files to chat conversations for persistent context, improving the relevance of Amazon Q responses.
| } | ||
|
|
||
| // Schedule a new notification after the debounce period | ||
| debounceTask = executor.schedule(() -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why debounce?
| Map<String, Object> params = new HashMap<>(); | ||
|
|
||
| if (editor != null) { | ||
| IEditorInput editorInput = editor.getEditorInput(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is already logic in QEclipseEditorUtils class to get this information(entirety of this function's logic). Please reuse that instead of creating a new one. We also have logic in addEditorState in ChatCommunicationManager that does something very similar. Please reference these two
| public static ActiveEditorChangeListener register(final AmazonQLspServer languageServer, final ScheduledExecutorService executor) { | ||
| ActiveEditorChangeListener listener = new ActiveEditorChangeListener(languageServer, executor); | ||
|
|
||
| // Register with all workbench windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we have to register all workbench windows. We only the texteditor right?
| } | ||
|
|
||
| Object updatedParams = params; | ||
| if (activeEditor != null && activeEditor instanceof ITextEditor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logic is also the same as previous comment. Same comment applies here.If needed try to use or extend existing logic to achieve the same instead of de-dup in
| } | ||
|
|
||
| @Override | ||
| public final void activeEditorChanged(final Object params) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why has this been added here if its not implemented yet
| case CHAT_SEND_PROMPT: | ||
| message.addValueForKey("context", message.getValueForKey("prompt.context")); | ||
| // Log the message data to see if pinnedContext is included | ||
| Activator.getLogger().info("CHAT_SEND_PROMPT message data: " + message.getData()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this log
- Remove unused imports in ChatCommunicationManager and ActiveEditorChangeListener - Clean up trailing whitespace in AmazonQLspServer and AmazonQLspClientImpl - Make ActiveEditorChangeListener final to address DesignForExtension warnings - Add missing newline at end of ActiveEditorChangeListener.java All 17 checkstyle violations have been resolved.
The debug log in CHAT_SEND_PROMPT case was causing test failures by potentially affecting the execution flow. Removed to ensure chatPartialResultMap.setEntry() is called as expected by tests.
- ActiveEditorChangeListener: Use QEclipseEditorUtils methods instead of duplicating logic - AmazonQLspClientImpl: Leverage existing editor utilities in sendPinnedContext() - Simplified window registration logic to focus only on text editors - Removed ~50 lines of duplicate code across both files - Fixed remaining checkstyle violations (unused imports, trailing spaces) Addresses @shruti0085 feedback on code duplication and complexity
|
Closing this in favor of #473 |
Summary
This PR implements pinned context functionality for Amazon Q Eclipse plugin, allowing users to pin files
to their chat conversations for persistent context. This feature improves the relevance of Amazon Q
responses by maintaining important context throughout the conversation.
What does this PR do?
@Pin Contextfeature visible in the chat UIScreenshot
Key Changes
1. Command Infrastructure
Added new commands to
ChatUIInboundCommandName.java:PinnedContextAdd- Pin a file to the conversationPinnedContextRemove- Unpin a fileSendPinnedContext- Send pinned context with chat messagesListRules- List available context rulesRuleClick- Handle rule selectionExtended
Command.javaenum with corresponding command values2. LSP Server Integration
AmazonQLspServer.javainterfaceAmazonQLspClient.javaandAmazonQLspClientImpl.java3. Active Editor Tracking
ActiveEditorChangeListener.java:IPartListener2for editor lifecycle events4. Client Capabilities
pinnedContextEnabled: trueflag inAmazonQLspServerBuilder.java5. Command Routing
AmazonQChatViewActionHandler.javato route pinned context commandsChatCommunicationManager.javafor processing commandsTesting Performed
mvn clean installKnown Issues
How to Test
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.