Skip to content

Commit 2e600fe

Browse files
authored
feat(chat): add directive messages (aws#7010)
## Problem Missing the following UI elements: - Pair programmer mode toggle message - ExecuteBash confirmation direction ## Solution Make use of the new directive message type introduced in aws/mynah-ui#273 --- - 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 8b53de4 commit 2e600fe

File tree

6 files changed

+43
-3
lines changed

6 files changed

+43
-3
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
@@ -893,10 +893,19 @@ export class ChatController {
893893
private async processPromptInputOptionChange(message: PromptInputOptionChange) {
894894
const session = this.sessionStorage.getSession(message.tabID)
895895
const promptTypeValue = message.optionsValues['prompt-type']
896-
// TODO: display message: You turned off pair programmer mode. Q will not include code diffs or run commands in the chat.
897896
if (promptTypeValue === 'pair-programming-on') {
898897
session.setPairProgrammingModeOn(true)
898+
this.messenger.sendDirectiveMessage(
899+
message.tabID,
900+
promptTypeValue,
901+
i18n('AWS.amazonq.chat.directive.pairProgrammingModeOn')
902+
)
899903
} else {
904+
this.messenger.sendDirectiveMessage(
905+
message.tabID,
906+
promptTypeValue,
907+
i18n('AWS.amazonq.chat.directive.pairProgrammingModeOff')
908+
)
900909
session.setPairProgrammingModeOn(false)
901910
}
902911
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,4 +875,24 @@ export class Messenger {
875875
)
876876
)
877877
}
878+
879+
public sendDirectiveMessage(tabID: string, triggerID: string, message: string) {
880+
this.dispatcher.sendChatMessage(
881+
new ChatMessage(
882+
{
883+
message,
884+
messageType: 'directive',
885+
followUps: undefined,
886+
followUpsHeader: undefined,
887+
relatedSuggestions: undefined,
888+
triggerID,
889+
messageID: '',
890+
userIntent: undefined,
891+
codeBlockLanguage: undefined,
892+
contextList: undefined,
893+
},
894+
tabID
895+
)
896+
)
897+
}
878898
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Messenger } from '../controllers/chat/messenger/messenger'
99
import { ToolUse } from '@amzn/codewhisperer-streaming'
1010
import { CommandValidation } from './executeBash'
1111
import { Change } from 'diff'
12+
import { i18n } from '../../shared/i18n-helper'
1213

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

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)