Skip to content

Commit d0a6bc1

Browse files
authored
fix(chat): disable prompt during loop (aws#6986)
## Problem Chat input prompt should be disabled during the agentic loop ## Solution - Disable chat prompt - Removed stop button for now --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent ca07d7f commit d0a6bc1

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

packages/core/src/amazonq/webview/ui/apps/cwChatConnector.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export class Connector extends BaseConnector {
125125
padding: messageData.padding ?? undefined,
126126
fullWidth: messageData.fullWidth ?? undefined,
127127
codeBlockActions: messageData.codeBlockActions ?? undefined,
128+
rootFolderTitle: messageData.rootFolderTitle ?? undefined,
128129
}
129130

130131
if (messageData.relatedSuggestions !== undefined) {
@@ -257,14 +258,15 @@ export class Connector extends BaseConnector {
257258
}
258259

259260
if (messageData.type === 'asyncEventProgressMessage') {
260-
const enableStopAction = true
261+
const enableStopAction = false
262+
const isPromptInputDisabled = true
261263
this.onAsyncEventProgress(
262264
messageData.tabID,
263265
messageData.inProgress,
264266
messageData.message ?? undefined,
265267
messageData.messageId ?? undefined,
266268
enableStopAction,
267-
false
269+
isPromptInputDisabled
268270
)
269271
return
270272
}

packages/core/src/amazonq/webview/ui/connector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export interface CWCChatItem extends ChatItem {
6666
codeBlockLanguage?: string
6767
contextList?: Context[]
6868
title?: string
69+
rootFolderTitle?: string
6970
}
7071

7172
export interface Context {

packages/core/src/amazonq/webview/ui/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ export const createMynahUI = (
409409
fileList: {
410410
fileTreeTitle: '',
411411
filePaths: item.contextList.map((file) => file.relativeFilePath),
412-
rootFolderTitle: item.title,
412+
rootFolderTitle: item.rootFolderTitle,
413413
flatList: true,
414414
collapsed: true,
415415
hideFileCount: true,

packages/core/src/codewhispererChat/controllers/chat/controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ export class ChatController {
14951495
let response: MessengerResponseType | undefined = undefined
14961496
session.createNewTokenSource()
14971497
try {
1498-
if (!session.context) {
1498+
if (!session.context && triggerPayload.context.length) {
14991499
// Only show context for the first message in the loop
15001500
this.messenger.sendContextMessage(tabID, triggerID, triggerPayload.documentReferences)
15011501
session.setContext(triggerPayload.context)

packages/core/src/codewhispererChat/controllers/chat/messenger/messenger.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class Messenger {
130130
new ChatMessage(
131131
{
132132
message: '',
133-
messageType: 'answer',
133+
messageType: 'answer-stream',
134134
followUps: undefined,
135135
followUpsHeader: undefined,
136136
relatedSuggestions: undefined,
@@ -139,7 +139,8 @@ export class Messenger {
139139
userIntent: undefined,
140140
codeBlockLanguage: undefined,
141141
contextList: mergedRelevantDocuments,
142-
title: 'Context',
142+
title: '',
143+
rootFolderTitle: 'Context',
143144
buttons: undefined,
144145
fileList: undefined,
145146
canBeVoted: false,
@@ -452,11 +453,16 @@ export class Messenger {
452453
)
453454
}
454455

456+
const agenticLoopEnded = !eventCounts.has('toolUseEvent')
457+
if (agenticLoopEnded) {
458+
// Reset context for the next request
459+
session.setContext(undefined)
460+
}
455461
this.dispatcher.sendChatMessage(
456462
new ChatMessage(
457463
{
458464
message: undefined,
459-
messageType: 'answer',
465+
messageType: agenticLoopEnded ? 'answer' : 'answer-stream',
460466
followUps: followUps,
461467
followUpsHeader: undefined,
462468
relatedSuggestions: undefined,
@@ -480,11 +486,6 @@ export class Messenger {
480486
toolUse.input !== '' && { toolUses: [{ ...toolUse }] }),
481487
},
482488
})
483-
const agenticLoopEnded = !eventCounts.has('toolUseEvent')
484-
if (agenticLoopEnded) {
485-
// Reset context for the next request
486-
session.setContext(undefined)
487-
}
488489

489490
getLogger().info(
490491
`All events received. requestId=%s counts=%s`,

packages/core/src/codewhispererChat/view/connector/connector.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ export interface ChatMessageProps {
352352
readonly fullWidth?: boolean
353353
readonly padding?: boolean
354354
readonly codeBlockActions?: CodeBlockActions | null
355+
readonly rootFolderTitle?: string
355356
}
356357

357358
export class ChatMessage extends UiMessage {
@@ -375,6 +376,7 @@ export class ChatMessage extends UiMessage {
375376
readonly padding?: boolean
376377
readonly codeBlockActions?: CodeBlockActions | null
377378
readonly canBeVoted?: boolean = false
379+
readonly rootFolderTitle?: string
378380
override type = 'chatMessage'
379381

380382
constructor(props: ChatMessageProps, tabID: string) {
@@ -398,6 +400,7 @@ export class ChatMessage extends UiMessage {
398400
this.fullWidth = props.fullWidth
399401
this.padding = props.padding
400402
this.codeBlockActions = props.codeBlockActions
403+
this.rootFolderTitle = props.rootFolderTitle
401404
}
402405
}
403406

0 commit comments

Comments
 (0)