Skip to content

Commit da57517

Browse files
committed
fix(amazonq): highlightCommand missing @ prefix
1 parent df6ebb0 commit da57517

File tree

1 file changed

+23
-4
lines changed
  • packages/core/src/codewhispererChat/controllers/chat

1 file changed

+23
-4
lines changed

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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,13 @@ export class ChatController {
417417
}
418418
}
419419

420+
private getHighlightCommand() {
421+
const highlightCommand = FeatureConfigProvider.getFeature(Features.highlightCommand)
422+
const commandName = highlightCommand?.value.stringValue
423+
const commandDescription = highlightCommand?.variation
424+
return commandName ? { commandName, commandDescription } : undefined
425+
}
426+
420427
private async processContextCommandUpdateMessage() {
421428
// when UI is ready, refresh the context commands
422429
this.registerUserPromptsWatcher()
@@ -461,10 +468,9 @@ export class ChatController {
461468
},
462469
]
463470

464-
const feature = FeatureConfigProvider.getFeature(Features.highlightCommand)
465-
const commandName = feature?.value.stringValue
466-
if (commandName) {
467-
const commandDescription = feature.variation
471+
const highlightCommand = this.getHighlightCommand()
472+
if (highlightCommand) {
473+
const { commandName, commandDescription } = highlightCommand
468474
contextCommand.push({
469475
groupName: 'Additional Commands',
470476
commands: [{ command: commandName, description: commandDescription }],
@@ -1056,6 +1062,19 @@ export class ChatController {
10561062
triggerPayload.context?.some(
10571063
(context) => typeof context !== 'string' && context.command === '@workspace'
10581064
) || false
1065+
1066+
// Fix for mynah-ui removing @ from commandName
1067+
const feature = this.getHighlightCommand()
1068+
const commandName = feature?.commandName
1069+
if (
1070+
commandName &&
1071+
triggerPayload.message &&
1072+
triggerPayload.context?.find((context) => typeof context !== 'string' && context.command === commandName)
1073+
) {
1074+
const truncatedCommand = commandName.startsWith('@') ? commandName.slice(1) : commandName
1075+
triggerPayload.message = triggerPayload.message.replace(truncatedCommand, commandName)
1076+
}
1077+
10591078
triggerPayload.documentReferences = []
10601079
if (triggerPayload.useRelevantDocuments && triggerPayload.message) {
10611080
triggerPayload.message = triggerPayload.message.replace(/workspace/, '')

0 commit comments

Comments
 (0)