-
Notifications
You must be signed in to change notification settings - Fork 747
fix(amazonq): handle explain, refactor, fix, optimize, sendToPrompt #7169
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,6 @@ | |
| import { commandPalette } from '../../codewhisperer/commands/types' | ||
| import { CodeScanIssue } from '../../codewhisperer/models/model' | ||
| import { Commands, VsCodeCommandArg, placeholder } from '../../shared/vscode/commands2' | ||
| import { ChatControllerMessagePublishers } from '../controllers/chat/controller' | ||
|
|
||
| /** | ||
| * Opens the Amazon Q panel, showing the correct View that should | ||
|
|
@@ -37,73 +36,13 @@ export const focusAmazonQPanelKeybinding = Commands.declare('_aws.amazonq.focusC | |
| await focusAmazonQPanel.execute(placeholder, 'keybinding') | ||
| }) | ||
|
|
||
| const getCommandTriggerType = (data: any): EditorContextCommandTriggerType => { | ||
| // data is undefined when commands triggered from keybinding or command palette. Currently no | ||
| // way to differentiate keybinding and command palette, so both interactions are recorded as keybinding | ||
| return data === undefined ? 'keybinding' : 'contextMenu' | ||
| } | ||
|
|
||
| export function registerCommands(controllerPublishers: ChatControllerMessagePublishers) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to verify, these still register properly on non-hybrid chat right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah this is only broken for hybrid chat, everything works fine for the regular main branch |
||
| Commands.register('aws.amazonq.explainCode', async (data) => { | ||
| return focusAmazonQPanel.execute(placeholder, 'amazonq.explainCode').then(() => { | ||
| controllerPublishers.processContextMenuCommand.publish({ | ||
| type: 'aws.amazonq.explainCode', | ||
| triggerType: getCommandTriggerType(data), | ||
| }) | ||
| }) | ||
| }) | ||
| Commands.register('aws.amazonq.refactorCode', async (data) => { | ||
| return focusAmazonQPanel.execute(placeholder, 'amazonq.refactorCode').then(() => { | ||
| controllerPublishers.processContextMenuCommand.publish({ | ||
| type: 'aws.amazonq.refactorCode', | ||
| triggerType: getCommandTriggerType(data), | ||
| }) | ||
| }) | ||
| }) | ||
| Commands.register('aws.amazonq.fixCode', async (data) => { | ||
| return focusAmazonQPanel.execute(placeholder, 'amazonq.fixCode').then(() => { | ||
| controllerPublishers.processContextMenuCommand.publish({ | ||
| type: 'aws.amazonq.fixCode', | ||
| triggerType: getCommandTriggerType(data), | ||
| }) | ||
| }) | ||
| }) | ||
| Commands.register('aws.amazonq.optimizeCode', async (data) => { | ||
| return focusAmazonQPanel.execute(placeholder, 'amazonq.optimizeCode').then(() => { | ||
| controllerPublishers.processContextMenuCommand.publish({ | ||
| type: 'aws.amazonq.optimizeCode', | ||
| triggerType: getCommandTriggerType(data), | ||
| }) | ||
| }) | ||
| }) | ||
| Commands.register('aws.amazonq.sendToPrompt', async (data) => { | ||
| return focusAmazonQPanel.execute(placeholder, 'amazonq.sendToPrompt').then(() => { | ||
| controllerPublishers.processContextMenuCommand.publish({ | ||
| type: 'aws.amazonq.sendToPrompt', | ||
| triggerType: getCommandTriggerType(data), | ||
| }) | ||
| }) | ||
| }) | ||
| Commands.register('aws.amazonq.explainIssue', async (issue) => { | ||
| return focusAmazonQPanel.execute(placeholder, 'amazonq.explainIssue').then(() => { | ||
| controllerPublishers.processContextMenuCommand.publish({ | ||
| type: 'aws.amazonq.explainIssue', | ||
| triggerType: 'click', | ||
| issue, | ||
| }) | ||
| }) | ||
| }) | ||
| Commands.register('aws.amazonq.generateUnitTests', async (data) => { | ||
| return focusAmazonQPanel.execute(placeholder, 'amazonq.generateUnitTests').then(() => { | ||
| controllerPublishers.processContextMenuCommand.publish({ | ||
| type: 'aws.amazonq.generateUnitTests', | ||
| triggerType: getCommandTriggerType(data), | ||
| }) | ||
| }) | ||
| }) | ||
| Commands.register('aws.amazonq.updateContextCommandItems', () => { | ||
| controllerPublishers.processContextCommandUpdateMessage.publish() | ||
| }) | ||
| export function registerCommands() { | ||
| /** | ||
| * make these no-ops, since theres still callers that need to be deprecated | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are these commands still exposed to the user? Should we disable them until they are hooked up?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They're only still enabled because other parts of the extension (like security scan) call them. In a future PR i'm going to fully deprecate them here and implement them in commands.ts but for now this just avoids spamming the logs with command not found |
||
| */ | ||
| Commands.register('aws.amazonq.explainIssue', async (issue) => {}) | ||
| Commands.register('aws.amazonq.generateUnitTests', async (data) => {}) | ||
| Commands.register('aws.amazonq.updateContextCommandItems', () => {}) | ||
| } | ||
|
|
||
| export type EditorContextBaseCommandType = | ||
|
|
||
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.
I am assuming this fixes the double registering that was happening before?
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.
yeah I think what was happening was we were creating the commands here + the commands from commands.ts