Skip to content

Commit 60a7fc6

Browse files
authored
Merge branch 'feature/agentic-chat' into revert-reading
2 parents 2028754 + 4b23600 commit 60a7fc6

File tree

6 files changed

+45
-5
lines changed

6 files changed

+45
-5
lines changed

packages/core/package.nls.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,9 @@
457457
"AWS.amazonq.opensettings:": "Open settings",
458458
"AWS.amazonq.executeBash.run": "Run",
459459
"AWS.amazonq.executeBash.reject": "Reject",
460+
"AWS.amazonq.chat.directive.pairProgrammingModeOn": "You are using **pair programming mode**: Q can now list files, preview code diffs and allow you to run shell commands.",
461+
"AWS.amazonq.chat.directive.pairProgrammingModeOff": "You turned off **pair programming mode**. Q will not include code diffs or run commands in the chat.",
462+
"AWS.amazonq.chat.directive.runCommandToProceed": "Run the command to proceed.",
460463
"AWS.toolkit.lambda.walkthrough.quickpickTitle": "Application Builder Walkthrough",
461464
"AWS.toolkit.lambda.walkthrough.title": "Get started building your application",
462465
"AWS.toolkit.lambda.walkthrough.description": "Your quick guide to build an application visually, iterate locally, and deploy to the cloud!",

packages/core/src/amazonq/webview/ui/tabs/generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export class TabDataGenerator {
9494
type: 'toggle',
9595
id: 'prompt-type',
9696
value: 'pair-programming-on',
97-
tooltip: 'Pair programmar on',
97+
tooltip: 'Pair programmer on',
9898
options: [
9999
{
100100
value: 'pair-programming-on',

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,10 +903,19 @@ export class ChatController {
903903
private async processPromptInputOptionChange(message: PromptInputOptionChange) {
904904
const session = this.sessionStorage.getSession(message.tabID)
905905
const promptTypeValue = message.optionsValues['prompt-type']
906-
// TODO: display message: You turned off pair programmer mode. Q will not include code diffs or run commands in the chat.
907906
if (promptTypeValue === 'pair-programming-on') {
908907
session.setPairProgrammingModeOn(true)
908+
this.messenger.sendDirectiveMessage(
909+
message.tabID,
910+
promptTypeValue,
911+
i18n('AWS.amazonq.chat.directive.pairProgrammingModeOn')
912+
)
909913
} else {
914+
this.messenger.sendDirectiveMessage(
915+
message.tabID,
916+
promptTypeValue,
917+
i18n('AWS.amazonq.chat.directive.pairProgrammingModeOff')
918+
)
910919
session.setPairProgrammingModeOn(false)
911920
}
912921
}

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ export class Messenger {
272272
toolUse.input = JSON.parse(toolUseInput)
273273
} catch (error: any) {
274274
getLogger().error(`JSON parse error for toolUseInput: ${toolUseInput}`)
275-
// set toolUse.input to the raw value
276-
toolUse.input = toolUseInput
275+
// set toolUse.input to be empty valid json object
276+
toolUse.input = {}
277277
error.message = `Tool input has invalid JSON format: ${error.message}`
278278
// throw it out to allow the error to be handled in the catch block
279279
throw error
@@ -995,4 +995,24 @@ export class Messenger {
995995
)
996996
)
997997
}
998+
999+
public sendDirectiveMessage(tabID: string, triggerID: string, message: string) {
1000+
this.dispatcher.sendChatMessage(
1001+
new ChatMessage(
1002+
{
1003+
message,
1004+
messageType: 'directive',
1005+
followUps: undefined,
1006+
followUpsHeader: undefined,
1007+
relatedSuggestions: undefined,
1008+
triggerID,
1009+
messageID: '',
1010+
userIntent: undefined,
1011+
codeBlockLanguage: undefined,
1012+
contextList: undefined,
1013+
},
1014+
tabID
1015+
)
1016+
)
1017+
}
9981018
}

packages/core/src/codewhispererChat/tools/chatStream.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ToolUse } from '@amzn/codewhisperer-streaming'
1010
import { CommandValidation } from './executeBash'
1111
import { Change } from 'diff'
1212
import { ChatSession } from '../clients/chat/v0/chat'
13+
import { i18n } from '../../shared/i18n-helper'
1314

1415
/**
1516
* A writable stream that feeds each chunk/line to the chat UI.
@@ -39,6 +40,13 @@ export class ChatStream extends Writable {
3940
if (!emitEvent) {
4041
return
4142
}
43+
if (validation.requiresAcceptance) {
44+
this.messenger.sendDirectiveMessage(
45+
tabID,
46+
triggerID,
47+
i18n('AWS.amazonq.chat.directive.runCommandToProceed')
48+
)
49+
}
4250
// For FsRead and ListDirectory tools If messageIdToUpdate is undefined, we need to first create an empty message with messageId so it can be updated later
4351
if (isReadorList && !messageIdToUpdate) {
4452
this.messenger.sendInitialToolMessage(tabID, triggerID, toolUse?.toolUseId)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export class SearchView extends UiMessage {
113113
override type = 'drawNewSearchViewState'
114114
}
115115

116-
export type ChatMessageType = 'answer-stream' | 'answer-part' | 'answer'
116+
export type ChatMessageType = 'answer-stream' | 'answer-part' | 'answer' | 'directive'
117117

118118
export interface CodeReference {
119119
licenseName?: string

0 commit comments

Comments
 (0)