Skip to content

Commit c75e210

Browse files
authored
fix(amazonq): @workspace command shown in all tab types #6022
## Problem The `@workspace` [context command](https://github.com/aws/mynah-ui/blob/main/docs/DATAMODEL.md#contextcommands-default-) is being shown in all tab types, even though it is only relevant to Amazon Q chat ('cwc' tabType). ## Solution Move the context command to the tab specific config file. This change also allows other tab types to specify their own context commands if applicable.
1 parent e7c8784 commit c75e210

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Amazon Q chat: `@workspace` command shown in all tab types"
4+
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,23 @@
44
*/
55
import { isSQLTransformReady } from '../../../../dev/config'
66
import { TabType } from '../storages/tabsStorage'
7+
import { QuickActionCommandGroup } from '@aws/mynah-ui'
78

89
export type TabTypeData = {
910
title: string
1011
placeholder: string
1112
welcome: string
13+
contextCommands?: QuickActionCommandGroup[]
14+
}
15+
16+
const workspaceCommand: QuickActionCommandGroup = {
17+
groupName: 'Mention code',
18+
commands: [
19+
{
20+
command: '@workspace',
21+
description: '(BETA) Reference all code in workspace.',
22+
},
23+
],
1224
}
1325

1426
const commonTabData: TabTypeData = {
@@ -17,6 +29,7 @@ const commonTabData: TabTypeData = {
1729
welcome: `Hi, I'm Amazon Q. I can answer your software development questions.
1830
Ask me to explain, debug, or optimize your code.
1931
You can enter \`/\` to see a list of quick actions. Add @workspace to beginning of your message to include your entire workspace as context.`,
32+
contextCommands: [workspaceCommand],
2033
}
2134

2235
export const TabTypeDataMap: Record<TabType, TabTypeData> = {

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,7 @@ export class TabDataGenerator {
3535
'Amazon Q Developer uses generative AI. You may need to verify responses. See the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/).',
3636
quickActionCommands: this.quickActionsGenerator.generateForTab(tabType),
3737
promptInputPlaceholder: TabTypeDataMap[tabType].placeholder,
38-
contextCommands: [
39-
{
40-
groupName: 'Mention code',
41-
commands: [
42-
{
43-
command: '@workspace',
44-
description: '(BETA) Reference all code in workspace.',
45-
},
46-
],
47-
},
48-
],
38+
contextCommands: TabTypeDataMap[tabType].contextCommands,
4939
chatItems: needWelcomeMessages
5040
? [
5141
{

0 commit comments

Comments
 (0)