Skip to content

Commit 73ce888

Browse files
authored
Merge branch 'feature/agentic-chat' into feature/agentic-chat
2 parents 4150566 + 4b23600 commit 73ce888

File tree

6 files changed

+47
-8
lines changed

6 files changed

+47
-8
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
@@ -933,10 +933,19 @@ export class ChatController {
933933
private async processPromptInputOptionChange(message: PromptInputOptionChange) {
934934
const session = this.sessionStorage.getSession(message.tabID)
935935
const promptTypeValue = message.optionsValues['prompt-type']
936-
// TODO: display message: You turned off pair programmer mode. Q will not include code diffs or run commands in the chat.
937936
if (promptTypeValue === 'pair-programming-on') {
938937
session.setPairProgrammingModeOn(true)
938+
this.messenger.sendDirectiveMessage(
939+
message.tabID,
940+
promptTypeValue,
941+
i18n('AWS.amazonq.chat.directive.pairProgrammingModeOn')
942+
)
939943
} else {
944+
this.messenger.sendDirectiveMessage(
945+
message.tabID,
946+
promptTypeValue,
947+
i18n('AWS.amazonq.chat.directive.pairProgrammingModeOff')
948+
)
940949
session.setPairProgrammingModeOn(false)
941950
}
942951
}

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

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ export class Messenger {
287287
toolUse.input = JSON.parse(toolUseInput)
288288
} catch (error: any) {
289289
getLogger().error(`JSON parse error for toolUseInput: ${toolUseInput}`)
290-
// set toolUse.input to the raw value
291-
toolUse.input = toolUseInput
290+
// set toolUse.input to be empty valid json object
291+
toolUse.input = {}
292292
error.message = `Tool input has invalid JSON format: ${error.message}`
293293
// throw it out to allow the error to be handled in the catch block
294294
throw error
@@ -950,8 +950,28 @@ export class Messenger {
950950
)
951951
)
952952
}
953-
954-
/**
953+
954+
public sendDirectiveMessage(tabID: string, triggerID: string, message: string) {
955+
this.dispatcher.sendChatMessage(
956+
new ChatMessage(
957+
{
958+
message,
959+
messageType: 'directive',
960+
followUps: undefined,
961+
followUpsHeader: undefined,
962+
relatedSuggestions: undefined,
963+
triggerID,
964+
messageID: '',
965+
userIntent: undefined,
966+
codeBlockLanguage: undefined,
967+
contextList: undefined,
968+
},
969+
tabID
970+
)
971+
)
972+
}
973+
974+
/**
955975
* Check if a trigger has been cancelled and should not proceed
956976
* @param triggerId The trigger ID to check
957977
* @returns true if the trigger is cancelled and should not proceed
@@ -960,7 +980,6 @@ export class Messenger {
960980
if (!triggerId) {
961981
return false
962982
}
963-
964983
const conversationTracker = ConversationTracker.getInstance()
965984
return conversationTracker.isTriggerCancelled(triggerId)
966985
}

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 { ConversationTracker } from '../storages/conversationTracker'
13+
import { i18n } from '../../shared/i18n-helper'
1314

1415
/**
1516
* A writable stream that feeds each chunk/line to the chat UI.
@@ -29,6 +30,13 @@ export class ChatStream extends Writable {
2930
) {
3031
super()
3132
this.logger.debug(`ChatStream created for tabID: ${tabID}, triggerID: ${triggerID}`)
33+
if (validation.requiresAcceptance) {
34+
this.messenger.sendDirectiveMessage(
35+
tabID,
36+
triggerID,
37+
i18n('AWS.amazonq.chat.directive.runCommandToProceed')
38+
)
39+
}
3240
this.messenger.sendInitalStream(tabID, triggerID)
3341
}
3442

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)