Skip to content

Commit 52edbca

Browse files
authored
Merge branch 'feature/agentic-chat' into feature/agentic-chat
2 parents 940e55a + d0a6bc1 commit 52edbca

File tree

6 files changed

+34
-15
lines changed

6 files changed

+34
-15
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) {
@@ -288,14 +289,15 @@ export class Connector extends BaseConnector {
288289
}
289290

290291
if (messageData.type === 'asyncEventProgressMessage') {
291-
const enableStopAction = true
292+
const enableStopAction = false
293+
const isPromptInputDisabled = true
292294
this.onAsyncEventProgress(
293295
messageData.tabID,
294296
messageData.inProgress,
295297
messageData.message ?? undefined,
296298
messageData.messageId ?? undefined,
297299
enableStopAction,
298-
false
300+
isPromptInputDisabled
299301
)
300302
return
301303
}

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
@@ -443,7 +443,7 @@ export const createMynahUI = (
443443
}
444444

445445
if (item.contextList !== undefined && item.contextList.length > 0) {
446-
item.header = createFileListHeader(item.contextList, item.title)
446+
item.header = createFileListHeader(item.contextList, item.rootFolderTitle)
447447
}
448448

449449
if (

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,7 @@ export class ChatController {
15051505
let response: MessengerResponseType | undefined = undefined
15061506
session.createNewTokenSource()
15071507
try {
1508-
if (!session.context) {
1508+
if (!session.context && triggerPayload.context.length) {
15091509
// Only show context for the first message in the loop
15101510
this.messenger.sendContextMessage(tabID, triggerID, triggerPayload.documentReferences)
15111511
session.setContext(triggerPayload.context)

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

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class Messenger {
134134
new ChatMessage(
135135
{
136136
message: '',
137-
messageType: 'answer',
137+
messageType: 'answer-stream',
138138
followUps: undefined,
139139
followUpsHeader: undefined,
140140
relatedSuggestions: undefined,
@@ -143,7 +143,8 @@ export class Messenger {
143143
userIntent: undefined,
144144
codeBlockLanguage: undefined,
145145
contextList: mergedRelevantDocuments,
146-
title: 'Context',
146+
title: '',
147+
rootFolderTitle: 'Context',
147148
buttons: undefined,
148149
fileList: undefined,
149150
canBeVoted: false,
@@ -496,11 +497,16 @@ export class Messenger {
496497
)
497498
}
498499

500+
const agenticLoopEnded = !eventCounts.has('toolUseEvent')
501+
if (agenticLoopEnded) {
502+
// Reset context for the next request
503+
session.setContext(undefined)
504+
}
499505
this.dispatcher.sendChatMessage(
500506
new ChatMessage(
501507
{
502508
message: undefined,
503-
messageType: 'answer',
509+
messageType: agenticLoopEnded ? 'answer' : 'answer-stream',
504510
followUps: followUps,
505511
followUpsHeader: undefined,
506512
relatedSuggestions: undefined,
@@ -524,11 +530,6 @@ export class Messenger {
524530
toolUse.input !== '' && { toolUses: [{ ...toolUse }] }),
525531
},
526532
})
527-
const agenticLoopEnded = !eventCounts.has('toolUseEvent')
528-
if (agenticLoopEnded) {
529-
// Reset context for the next request
530-
session.setContext(undefined)
531-
}
532533

533534
getLogger().info(
534535
`All events received. requestId=%s counts=%s`,
@@ -850,6 +851,20 @@ export class Messenger {
850851
}
851852

852853
private showChatExceptionMessage(e: ChatException, tabID: string, requestID: string | undefined) {
854+
const title = 'An error occurred while processing your request.'
855+
// TODO: once the server sends the correct exception back, fix this
856+
if (e.statusCode && e.statusCode === '500') {
857+
// Send throttling message
858+
this.dispatcher.sendErrorMessage(
859+
new ErrorMessage(
860+
title,
861+
'We are experiencing heavy traffic, please try again shortly.'.trimEnd().trimStart(),
862+
tabID
863+
)
864+
)
865+
return
866+
}
867+
853868
let message = 'This error is reported to the team automatically. We will attempt to fix it as soon as possible.'
854869
if (e.errorMessage !== undefined) {
855870
message += `\n\nDetails: ${e.errorMessage}`
@@ -865,9 +880,7 @@ export class Messenger {
865880
message += `\n\nRequest ID: ${requestID}`
866881
}
867882

868-
this.dispatcher.sendErrorMessage(
869-
new ErrorMessage('An error occurred while processing your request.', message.trimEnd().trimStart(), tabID)
870-
)
883+
this.dispatcher.sendErrorMessage(new ErrorMessage(title, message.trimEnd().trimStart(), tabID))
871884
}
872885

873886
public sendOpenSettingsMessage(triggerId: string, tabID: string) {

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)