Skip to content
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

feat(amazonq): add commands to command palette #4965

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ivikash
Copy link
Member

@ivikash ivikash commented May 8, 2024

Problem

Add commands in Command Palette for Amazon Q to improve feature discoverability

Solution

Commands Added

  • Amazon Q: Sign Out
  • Amazon Q: Open Code Reference Log
  • Amazon Q: Select Customization
  • Amazon Q: Try inline suggestion examples
  • Amazon Q: Open Chat Panel
  • Amazon Q: Resume Auto-Suggestions
  • Amazon Q: Pause Auto-Suggestions
  • Amazon Q: Resume Auto-Scans
  • Amazon Q: Pause Auto-Scans

TODO:

  • Discuss FromCommandPalette pattern. -- Discussed offline, this is the right approach. Going forward use the same prefix and add .commandPalette as prefix.
  • Discuss telemetry/metrics

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ivikash ivikash requested a review from a team as a code owner May 8, 2024 23:47
@ivikash ivikash requested a review from leigaol May 8, 2024 23:47
Copy link
Contributor

@justinmk3 justinmk3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"toggle auto-suggestions" would be another good one to have in the palette

Commands Added
- Amazon Q: Sign Out
- Amazon Q: Open Code Reference Log
- Amazon Q: Select Customization
@ivikash ivikash requested review from a team as code owners May 10, 2024 05:15
@ivikash
Copy link
Member Author

ivikash commented May 10, 2024

TODO / Fixes

  • Invalid source - example -
    2024-05-10 09:13:39.725 [error] Commands/Telemetry: "aws.amazonq.signout" executed with invalid "source" type: "[]"
    2024-05-10 09:13:39.725 [debug] command: running "aws.amazonq.signout" with arguments: [ <1 empty item>, 'sourceImproperlySet' ]
    2024-05-10 09:13:39.726 [debug] command: running "aws.amazonq.focusChat" with arguments: [ 'placeholder**', 'sourceImproperlySet' ]
  • Duplicating commands in package.json with suffix FromCommandPalette.

Metric Details

Command / Label Metric Completed Error
Amazon Q: Sign out
2024-05-10 09:13:39.725 [error] Commands/Telemetry: "aws.amazonq.signout" executed with invalid "source" type: "[]"
2024-05-10 09:13:39.725 [debug] command: running "aws.amazonq.signout" with arguments: [ <1 empty item>, 'sourceImproperlySet' ]
2024-05-10 09:13:39.726 [debug] command: running "aws.amazonq.focusChat" with arguments: [ 'placeholder**', 'sourceImproperlySet' ]

2024-05-10 09:13:39.748 [debug] telemetry: vscode_executeCommand {
Metadata: {
parentMetric: 'vscode_executeCommand',
command: 'aws.amazonq.focusChat',
source: 'sourceImproperlySet',
duration: '22',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
2024-05-10 09:13:39.748 [debug] telemetry: vscode_executeCommand {
Metadata: {
command: 'aws.amazonq.signout',
source: 'sourceImproperlySet',
duration: '24',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
2024-05-10 09:13:39.754 [debug] telemetry: auth_signInPageOpened {
Metadata: {
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
2024-05-10 09:13:39.859 [debug] Registered event handler for: onActiveConnectionModified
2024-05-10 09:13:39.859 [debug] Webview called command "refreshAuthState" with args: []
2024-05-10 09:13:39.863 [debug] Webview called command "getAuthState" with args: []
2024-05-10 09:13:39.869 [debug] Webview called command "getDefaultStartUrl" with args: []
2024-05-10 09:13:39.872 [debug] Webview called command "getRegions" with args: []
2024-05-10 09:13:39.872 [debug] Webview called command "fetchConnections" with args: []
2024-05-10 09:13:39.872 [debug] Webview called command "resetStoredMetricMetadata" with args: []
2024-05-10 09:13:39.897 [debug] Webview called command "listConnections" with args: []
2024-05-10 09:18:21.209 [info] telemetry: sent batch (size=6)
2024-05-10 09:13:39.725 [error] Commands/Telemetry: "aws.amazonq.signout" executed with invalid "source" type: "[]"
2024-05-10 09:13:39.725 [debug] command: running "aws.amazonq.signout" with arguments: [ <1 empty item>, 'sourceImproperlySet' ]
2024-05-10 09:13:39.726 [debug] command: running "aws.amazonq.focusChat" with arguments: [ 'placeholder**', 'sourceImproperlySet' ]
Amazon Q: Open Code Reference Log
2024-05-10 09:36:01.983 [debug] command: running "aws.amazonq.openReferencePanelFromCommandPalette" with arguments: []
2024-05-10 09:36:01.984 [debug] command: running "aws.amazonq.openReferencePanel" with arguments: [ 'placeholder**', 'CommandPalette' ]
2024-05-10 09:36:01.997 [debug] telemetry: vscode_executeCommand {
Metadata: {
parentMetric: 'vscode_executeCommand',
command: 'aws.amazonq.openReferencePanel',
source: 'CommandPalette',
duration: '14',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
2024-05-10 09:36:01.997 [debug] telemetry: vscode_executeCommand {
Metadata: {
command: 'aws.amazonq.openReferencePanelFromCommandPalette',
duration: '14',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
Amazon Q: Select Customization
2024-05-10 09:37:04.247 [error] Commands/Telemetry: "aws.amazonq.selectCustomization" executed with invalid "source" type: "[]"
2024-05-10 09:37:04.247 [debug] command: running "aws.amazonq.selectCustomization" with arguments: [ <1 empty item>, 'sourceImproperlySet' ]

2024-05-10 09:37:04.247 [debug] telemetry: ui_click {
Metadata: {
parentMetric: 'vscode_executeCommand',
elementId: 'cw_selectCustomization_Cta',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: false
}
2024-05-10 09:37:04.247 [debug] telemetry: vscode_executeCommand {
Metadata: {
command: 'aws.amazonq.selectCustomization',
source: 'sourceImproperlySet',
duration: '1',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
2024-05-10 09:37:04.251 [debug] icons: using override for "vscode-help"
2024-05-10 09:37:04.263 [debug] SSO token cache: loaded key: 4ceb1ad5-5395-445d-828f-94c1fe90478d
2024-05-10 09:37:04.263 [info] current client registration id=_ULgRtooSoe1lvaNHR8mhHVzLWVhc3QtMQ,
expires at Thu Aug 08 2024 09:35:23 GMT-0700 (Pacific Daylight Time),
key = 4ceb1ad5-5395-445d-828f-94c1fe90478d
2024-05-10 09:37:05.926 [debug] amazonq: listAvailableCustomizations API request:
RequestID: c4bb17fe-e95b-4de6-8743-70bc095f16a5,
Customizations:
00: Amazon-Internal-V1
01: NGDE-Custom-Finetuning-7K-V2
02: NGDE-Custom-V13
2024-05-10 09:37:04.247 [error] Commands/Telemetry: "aws.amazonq.selectCustomization" executed with invalid "source" type: "[]"
2024-05-10 09:37:04.247 [debug] command: running "aws.amazonq.selectCustomization" with arguments: [ <1 empty item>, 'sourceImproperlySet' ]
Amazon Q: Try inline suggestion examples
2024-05-10 09:37:44.203 [debug] command: running "CodeWhispererCommandBackend.showGettingStartedPage" (id: aws.amazonq.gettingStarted) with arguments: []
2024-05-10 09:37:44.203 [debug] telemetry: ui_click {
Metadata: {
parentMetric: 'vscode_executeCommand',
elementId: 'codewhisperer_Learn_PageOpen',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
2024-05-10 09:37:44.204 [debug] telemetry: vscode_executeCommand {
Metadata: {
command: 'aws.amazonq.gettingStarted',
duration: '4',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
2024-05-10 09:37:44.325 [debug] Webview called command "getOSType" with args: []
`
Amazon Q: Open Chat Panel
2024-05-10 09:38:06.945 [debug] command: running "aws.amazonq.openChatPanelFromCommandPalette" with arguments: []
2024-05-10 09:38:06.945 [debug] command: running "aws.amazonq.openChatPanel" with arguments: [ 'placeholder**', 'CommandPalette' ]
2024-05-10 09:38:06.945 [error] Commands/Telemetry: "aws.amazonq.focusChat" executed with invalid "source" type: "[]"
2024-05-10 09:38:06.945 [debug] command: running "aws.amazonq.focusChat" with arguments: [ <1 empty item>, 'sourceImproperlySet' ]

2024-05-10 09:38:06.947 [debug] telemetry: vscode_executeCommand {
Metadata: {
parentMetric: 'vscode_executeCommand',
command: 'aws.amazonq.focusChat',
source: 'sourceImproperlySet',
duration: '1',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
2024-05-10 09:38:06.947 [debug] telemetry: vscode_executeCommand {
Metadata: {
parentMetric: 'vscode_executeCommand',
command: 'aws.amazonq.openChatPanel',
source: 'CommandPalette',
duration: '2',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
2024-05-10 09:38:06.947 [debug] telemetry: vscode_executeCommand {
Metadata: {
command: 'aws.amazonq.openChatPanelFromCommandPalette',
duration: '2',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
2024-05-10 09:38:07.000 [debug] telemetry: amazonq_enterFocusChat {
Metadata: {
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
2024-05-10 09:38:08.535 [debug] telemetry: amazonq_exitFocusChat {
Metadata: {
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
2024-05-10 09:38:06.945 [error] Commands/Telemetry: "aws.amazonq.focusChat" executed with invalid "source" type: "[]"
2024-05-10 09:38:06.945 [debug] command: running "aws.amazonq.focusChat" with arguments: [ <1 empty item>, 'sourceImproperlySet' ]
Amazon Q: Resume Auto-Suggestions
2024-05-10 09:40:13.946 [debug] command: running "aws.amazonq.resumeAutoSuggestions" with arguments: []
2024-05-10 09:40:13.946 [debug] telemetry: collapsing 1 "aws.amazonq.toggleCodeSuggestion" metrics. key={ '1': 'source' }
2024-05-10 09:40:13.946 [debug] command: running "aws.amazonq.toggleCodeSuggestion" with arguments: [ 'placeholder**', 'CommandPalette' ]
2024-05-10 09:40:13.952 [debug] telemetry: aws_modifySetting {
Metadata: {
parentMetric: 'vscode_executeCommand',
settingId: 'codewhisperer_autoSuggestionActivation',
settingState: 'Activated',
duration: '6',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: false
}
2024-05-10 09:40:13.952 [debug] telemetry: vscode_executeCommand {
Metadata: {
command: 'aws.amazonq.resumeAutoSuggestions',
duration: '8',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
Amazon Q: Pause Auto-Suggestions
2024-05-10 09:39:50.151 [debug] command: running "aws.amazonq.pauseAutoSuggestions" with arguments: []
2024-05-10 09:39:50.151 [debug] command: running "aws.amazonq.toggleCodeSuggestion" with arguments: [ 'placeholder**', 'CommandPalette' ]
2024-05-10 09:39:50.159 [debug] telemetry: aws_modifySetting {
Metadata: {
parentMetric: 'vscode_executeCommand',
settingId: 'codewhisperer_autoSuggestionActivation',
settingState: 'Deactivated',
duration: '9',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: false
}
2024-05-10 09:39:50.159 [debug] telemetry: vscode_executeCommand {
Metadata: {
parentMetric: 'vscode_executeCommand',
command: 'aws.amazonq.toggleCodeSuggestion',
source: 'CommandPalette',
duration: '9',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
2024-05-10 09:39:50.159 [debug] telemetry: vscode_executeCommand {
Metadata: {
command: 'aws.amazonq.pauseAutoSuggestions',
duration: '10',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
Amazon Q: Resume Auto-Scans
2024-05-10 09:39:07.165 [debug] command: running "aws.amazonq.resumeAutoScans" with arguments: []
2024-05-10 09:39:07.165 [debug] command: running "aws.codeWhisperer.toggleCodeScan" with arguments: [ 'placeholder**', 'CommandPalette' ]
2024-05-10 09:39:07.177 [debug] telemetry: aws_modifySetting {
Metadata: {
parentMetric: 'vscode_executeCommand',
settingId: 'codewhisperer_autoScansActivation',
settingState: 'Activated',
duration: '12',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: false
}
2024-05-10 09:39:07.177 [debug] telemetry: vscode_executeCommand {
Metadata: {
parentMetric: 'vscode_executeCommand',
command: 'aws.codeWhisperer.toggleCodeScan',
source: 'CommandPalette',
duration: '12',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
2024-05-10 09:39:07.177 [debug] telemetry: vscode_executeCommand {
Metadata: {
command: 'aws.amazonq.resumeAutoScans',
duration: '14',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}
Amazon Q: Pause Auto-Scan
2024-05-10 09:39:29.603 [debug] command: running "aws.amazonq.pauseAutoScans" with arguments: []
2024-05-10 09:39:29.603 [debug] telemetry: collapsing 1 "aws.codeWhisperer.toggleCodeScan" metrics. key={ '1': 'source' }
2024-05-10 09:39:29.603 [debug] command: running "aws.codeWhisperer.toggleCodeScan" with arguments: [ 'placeholder**', 'CommandPalette' ]
2024-05-10 09:39:29.608 [debug] telemetry: aws_modifySetting {
Metadata: {
parentMetric: 'vscode_executeCommand',
settingId: 'codewhisperer_autoScansActivation',
settingState: 'Deactivated',
duration: '6',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: false
}
2024-05-10 09:39:29.609 [debug] telemetry: vscode_executeCommand {
Metadata: {
command: 'aws.amazonq.pauseAutoScans',
duration: '7',
result: 'Succeeded',
awsAccount: 'not-set',
awsRegion: 'us-east-1'
},
Value: 1,
Unit: 'None',
Passive: true
}

Comment on lines +639 to +645
"command": "aws.amazonq.resumeAutoScans",
"title": "%AWS.amazonq.resumeAutoScans%",
"category": "%AWS.amazonq.title%",
"enablement": "!aws.codewhisperer.isScanEnabled"
},
{
"command": "aws.amazonq.pauseAutoScans",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can these be one "toggle" command instead of 2 separate commands? that allows users to define a single keybinding

Comment on lines +627 to +633
"command": "aws.amazonq.resumeAutoSuggestions",
"title": "%AWS.amazonq.resumeAutoSuggestions%",
"category": "%AWS.amazonq.title%",
"enablement": "!aws.codewhisperer.isSuggestionsEnabled"
},
{
"command": "aws.amazonq.pauseAutoSuggestions",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question for these 2

"category": "%AWS.amazonq.title%"
},
{
"command": "aws.amazonq.gettingStarted",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this need to be the command palette? vscode already exposes all walkthroughs via Welcome: Open Walkthrough...

Comment on lines +55 to +59
const isSuggestionsEnabled = CodeSuggestionsState.instance.isSuggestionsEnabled()
await vscode.commands.executeCommand('setContext', 'aws.codewhisperer.isSuggestionsEnabled', isSuggestionsEnabled)

const isScansEnabled = CodeScansState.instance.isScansEnabled()
await vscode.commands.executeCommand('setContext', 'aws.codewhisperer.isScanEnabled', isScansEnabled)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't need these if we had "toggle" command instead

@@ -84,13 +90,15 @@ export const toggleCodeScans = Commands.declare(
})

const isScansEnabled = await scansState.toggleScans()
await vscode.commands.executeCommand('setContext', 'aws.codewhisperer.isScanEnabled', isScansEnabled)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't need this either, if we have the toggle command

@@ -16,6 +16,8 @@ export const amazonQChatSource = 'amazonQChat'
export const firstStartUpSource = ExtStartUpSources.firstStartUp
/** Indicates a CodeWhisperer command was executed as a result of selecting an ellipses menu item */
export const cwEllipsesMenu = 'ellipsesMenu'
/** Indicates a CodeWhisperer command was executed from the command palette */
export const commandPalette = 'CommandPalette'
Copy link
Contributor

@justinmk3 justinmk3 May 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, always use the existing code as a hint about conventions. none of the other ids above use PascalCase.

is this actually needed? it is assumed that all commands are from the command palette, unless they have another source id.

Suggested change
export const commandPalette = 'CommandPalette'
export const commandPalette = 'commandPalette'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly. To clarify, I initially preferred to use camelCase in this context. However, upon reviewing the existing code, I noticed and believed that the CommandPalette convention is already implemented as seen in here -

telemetry.record({ source: 'CommandPalette' })

I will update it in the next revision.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the CommandPalette convention is already implemented as seen in here

Great, thank you for noting that. In that case, yes we should keep the existing name, but please update that code to use the constant you defined here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw another place relying on commandPalette so I am erring on the side of using lowecase and updating codecatalyst/commands.ts to use the same with smaller case.

I am making sure all instances use the same variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants