Skip to content

Commit 43658ff

Browse files
committed
feat(amazonq): add stop chat repsponse
1 parent 86079da commit 43658ff

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
UiMessageResultParams,
1515
CHAT_PROMPT_OPTION_ACKNOWLEDGED,
1616
ChatPromptOptionAcknowledgedMessage,
17+
STOP_CHAT_RESPONSE,
18+
StopChatResponseMessage,
1719
} from '@aws/chat-client-ui-types'
1820
import {
1921
ChatResult,
@@ -98,6 +100,7 @@ export function registerMessageListeners(
98100
provider: AmazonQChatViewProvider,
99101
encryptionKey: Buffer
100102
) {
103+
const chatStreamTokens = new Map<string, CancellationTokenSource>() // tab id -> token
101104
provider.webview?.onDidReceiveMessage(async (message) => {
102105
languageClient.info(`[VSCode Client] Received ${JSON.stringify(message)} from chat`)
103106

@@ -110,8 +113,6 @@ export function registerMessageListeners(
110113
return
111114
}
112115

113-
const chatStreamTokens = new Map<string, CancellationTokenSource>() // tab id -> token
114-
115116
const webview = provider.webview
116117
switch (message.command) {
117118
case COPY_TO_CLIPBOARD:
@@ -184,8 +185,8 @@ export function registerMessageListeners(
184185
void openUrl(vscode.Uri.parse(linkParams.link))
185186
break
186187
}
187-
case STOP_RESPONSE: {
188-
const tabId = (message as StopResponseMessage).tabId
188+
case STOP_CHAT_RESPONSE: {
189+
const tabId = (message as StopChatResponseMessage).params.tabId
189190
const token = chatStreamTokens.get(tabId)
190191
token?.cancel()
191192
token?.dispose()
@@ -226,10 +227,14 @@ export function registerMessageListeners(
226227

227228
const chatRequest = await encryptRequest<ChatParams>(chatParams, encryptionKey)
228229
try {
229-
const chatResult = await languageClient.sendRequest<string | ChatResult>(chatRequestType.method, {
230-
...chatRequest,
231-
partialResultToken,
232-
})
230+
const chatResult = await languageClient.sendRequest<string | ChatResult>(
231+
chatRequestType.method,
232+
{
233+
...chatRequest,
234+
partialResultToken,
235+
},
236+
cancellationToken.token
237+
)
233238
await handleCompleteResult<ChatResult>(
234239
chatResult,
235240
encryptionKey,

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@
442442
"devDependencies": {
443443
"@aws-sdk/types": "^3.13.1",
444444
"@aws/chat-client": "^0.1.4",
445-
"@aws/chat-client-ui-types": "^0.1.22",
445+
"@aws/chat-client-ui-types": "^0.1.24",
446446
"@aws/language-server-runtimes": "^0.2.58",
447447
"@aws/language-server-runtimes-types": "^0.1.13",
448448
"@cspotcode/source-map-support": "^0.8.1",

0 commit comments

Comments
 (0)