Skip to content

feat(amazonq): add keyboard shortcut for stop/reject/run commands #7703

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

Merged
merged 5 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions packages/amazonq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,21 @@
]
},
"commands": [
{
"command": "aws.amazonq.stopCmdExecution",
"title": "Stop Amazon Q Command Execution",
"category": "%AWS.amazonq.title%"
},
{
"command": "aws.amazonq.runCmdExecution",
"title": "Run Amazon Q Command Execution",
"category": "%AWS.amazonq.title%"
},
{
"command": "aws.amazonq.rejectCmdExecution",
"title": "Reject Amazon Q Command Execution",
"category": "%AWS.amazonq.title%"
},
{
"command": "_aws.amazonq.notifications.dismiss",
"title": "%AWS.generic.dismiss%",
Expand Down Expand Up @@ -850,6 +865,24 @@
}
],
"keybindings": [
{
"command": "aws.amazonq.stopCmdExecution",
"key": "ctrl+shift+backspace",
"mac": "cmd+shift+backspace",
"when": "aws.amazonq.amazonqChatLSP.isFocus"
},
{
"command": "aws.amazonq.runCmdExecution",
"key": "ctrl+shift+enter",
"mac": "cmd+shift+enter",
"when": "aws.amazonq.amazonqChatLSP.isFocus"
},
{
"command": "aws.amazonq.rejectCmdExecution",
"key": "ctrl+shift+r",
"mac": "cmd+shift+r",
"when": "aws.amazonq.amazonqChatLSP.isFocus"
},
{
"command": "_aws.amazonq.focusChat.keybinding",
"win": "win+alt+i",
Expand Down
16 changes: 15 additions & 1 deletion packages/amazonq/src/lsp/chat/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
params: {},
})
})
})
}),
registerShellCommandShortCut('aws.amazonq.runCmdExecution', 'run-shell-command', provider),
registerShellCommandShortCut('aws.amazonq.rejectCmdExecution', 'reject-shell-command', provider),
registerShellCommandShortCut('aws.amazonq.stopCmdExecution', 'stop-shell-command', provider)
)
}

Expand Down Expand Up @@ -156,3 +159,14 @@ export async function focusAmazonQPanel() {
await Commands.tryExecute('aws.amazonq.AmazonQChatView.focus')
await Commands.tryExecute('aws.amazonq.AmazonCommonAuth.focus')
}

function registerShellCommandShortCut(commandName: string, buttonId: string, provider: AmazonQChatViewProvider) {
return Commands.register(commandName, async () => {
void focusAmazonQPanel().then(() => {
void provider.webview?.postMessage({
command: 'aws/chat/executeShellCommandShortCut',
params: { id: buttonId },
})
})
})
}
14 changes: 14 additions & 0 deletions packages/amazonq/src/lsp/chat/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import {
openUrl,
isTextEditor,
globals,
setContext,
} from 'aws-core-vscode/shared'
import {
DefaultAmazonQAppInitContext,
Expand Down Expand Up @@ -490,6 +491,11 @@ export function registerMessageListeners(
}
default:
if (isServerEvent(message.command)) {
if (enterFocus(message.params)) {
await setContext('aws.amazonq.amazonqChatLSP.isFocus', true)
} else if (exitFocus(message.params)) {
await setContext('aws.amazonq.amazonqChatLSP.isFocus', false)
}
languageClient.sendNotification(message.command, message.params)
}
break
Expand Down Expand Up @@ -699,6 +705,14 @@ function isServerEvent(command: string) {
return command.startsWith('aws/chat/') || command === 'telemetry/event'
}

function enterFocus(params: any) {
return params.name === 'enterFocus'
}

function exitFocus(params: any) {
return params.name === 'exitFocus'
}

/**
* Decodes partial chat responses from the language server before sending them to mynah UI
*/
Expand Down
3 changes: 2 additions & 1 deletion packages/amazonq/src/lsp/chat/webviewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Webview,
} from 'vscode'
import * as path from 'path'
import * as os from 'os'
import {
globals,
isSageMaker,
Expand Down Expand Up @@ -149,7 +150,7 @@ export class AmazonQChatViewProvider implements WebviewViewProvider {
const vscodeApi = acquireVsCodeApi()
const hybridChatConnector = new HybridChatAdapter(${(await AuthUtil.instance.getChatAuthState()).amazonQ === 'connected'},${featureConfigData},${welcomeCount},${disclaimerAcknowledged},${regionProfileString},${disabledCommands},${isSMUS},${isSM},vscodeApi.postMessage)
const commands = [hybridChatConnector.initialQuickActions[0]]
qChat = amazonQChat.createChat(vscodeApi, {disclaimerAcknowledged: ${disclaimerAcknowledged}, pairProgrammingAcknowledged: ${pairProgrammingAcknowledged}, agenticMode: true, quickActionCommands: commands, modelSelectionEnabled: ${modelSelectionEnabled}}, hybridChatConnector, ${JSON.stringify(featureConfigData)});
qChat = amazonQChat.createChat(vscodeApi, {os: "${os.platform()}", disclaimerAcknowledged: ${disclaimerAcknowledged}, pairProgrammingAcknowledged: ${pairProgrammingAcknowledged}, agenticMode: true, quickActionCommands: commands, modelSelectionEnabled: ${modelSelectionEnabled}}, hybridChatConnector, ${JSON.stringify(featureConfigData)});
}
window.addEventListener('message', (event) => {
/**
Expand Down
1 change: 1 addition & 0 deletions packages/amazonq/src/lsp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export async function startLanguageServer(
pinnedContextEnabled: true,
imageContextEnabled: true,
mcp: true,
shortcut: true,
reroute: true,
modelSelection: true,
workspaceFilePath: vscode.workspace.workspaceFile?.fsPath,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/shared/vscode/setContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export type contextKey =
| 'gumby.wasQCodeTransformationUsed'
| 'amazonq.inline.codelensShortcutEnabled'
| 'aws.toolkit.lambda.walkthroughSelected'
| 'aws.amazonq.amazonqChatLSP.isFocus'

const contextMap: Partial<Record<contextKey, any>> = {}

Expand Down
Loading