Skip to content

Commit f9fd3b0

Browse files
committed
add keybinding for stop chat
1 parent 947c471 commit f9fd3b0

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

packages/amazonq/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,11 @@
543543
]
544544
},
545545
"commands": [
546+
{
547+
"command": "aws.amazonq.stopToolExecution",
548+
"title": "Stop Amazon Q Tool Execution",
549+
"category": "%AWS.amazonq.title%"
550+
},
546551
{
547552
"command": "_aws.amazonq.notifications.dismiss",
548553
"title": "%AWS.generic.dismiss%",
@@ -894,6 +899,11 @@
894899
"command": "aws.amazonq.inline.waitForUserDecisionRejectAll",
895900
"key": "escape",
896901
"when": "editorTextFocus && aws.codewhisperer.connected && amazonq.inline.codelensShortcutEnabled"
902+
},
903+
{
904+
"command": "aws.amazonq.stopToolExecution",
905+
"key": "cmd+alt+h",
906+
"mac": "cmd+alt+h"
897907
}
898908
],
899909
"icons": {

packages/amazonq/src/lsp/chat/commands.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ import { AmazonQChatViewProvider } from './webviewProvider'
1313
*/
1414
export function registerCommands(provider: AmazonQChatViewProvider) {
1515
globals.context.subscriptions.push(
16+
Commands.register('aws.amazonq.stopToolExecution', async () => {
17+
void focusAmazonQPanel().then(() => {
18+
void provider.webview?.postMessage({
19+
command: 'stopChatResponse',
20+
params: {}, // how to get the current tabId?
21+
})
22+
})
23+
}),
1624
registerGenericCommand('aws.amazonq.explainCode', 'Explain', provider),
1725
registerGenericCommand('aws.amazonq.refactorCode', 'Refactor', provider),
1826
registerGenericCommand('aws.amazonq.fixCode', 'Fix', provider),

packages/amazonq/src/lsp/chat/messages.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ export function registerMessageListeners(
132132
}
133133

134134
const webview = provider.webview
135+
if (message.command === 'stopChatResponse') {
136+
const tabId = (message as StopChatResponseMessage).params.tabId
137+
const token = chatStreamTokens.get(tabId)
138+
token?.cancel()
139+
token?.dispose()
140+
chatStreamTokens.delete(tabId)
141+
}
135142
switch (message.command) {
136143
case COPY_TO_CLIPBOARD:
137144
languageClient.info('[VSCode Client] Copy to clipboard event received')
@@ -234,7 +241,6 @@ export function registerMessageListeners(
234241
void handlePartialResult<ChatResult>(partialResult, encryptionKey, provider, chatParams.tabId)
235242
}
236243
)
237-
238244
const editor =
239245
vscode.window.activeTextEditor ||
240246
vscode.window.visibleTextEditors.find((editor) => editor.document.languageId !== 'Log')
@@ -458,7 +464,7 @@ export function registerMessageListeners(
458464
context: {
459465
activeFileContext: {
460466
filePath: params.originalFileUri,
461-
fileText: params.originalFileContent ?? '',
467+
fileText: '',
462468
fileLanguage: undefined,
463469
matchPolicy: undefined,
464470
},

0 commit comments

Comments
 (0)