Skip to content

Commit f984597

Browse files
committed
Display text after /scan in Q chat panel
1 parent 4a59da4 commit f984597

File tree

7 files changed

+25
-15
lines changed

7 files changed

+25
-15
lines changed

packages/core/src/amazonq/webview/ui/apps/cwChatConnector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ export class Connector {
213213
onRunSecurityScans = (tabID: string): void => {
214214
this.sendMessageToExtension({
215215
tabID: tabID,
216-
command: 'runProjectScan',
217-
chatMessage: 'Security scan started and you can see results in terminal',
216+
command: 'scan',
217+
chatMessage: '',
218218
tabType: 'cwc',
219219
})
220220
}

packages/core/src/amazonq/webview/ui/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ type MessageCommand =
3131
| 'file-click'
3232
| 'form-action-click'
3333
| 'open-settings'
34-
| 'runProjectScan'
34+
| 'scan'
3535

3636
export type ExtensionMessage = Record<string, any> & { command: MessageCommand }

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const commonTabData: TabTypeData = {
2121
export const TabTypeDataMap: Record<TabType, TabTypeData> = {
2222
unknown: commonTabData,
2323
cwc: commonTabData,
24-
// scan:commonTabData,
2524
featuredev: {
2625
title: 'Q - Dev',
2726
placeholder: 'Describe your task or issue in as much detail as possible',
@@ -38,9 +37,4 @@ To get started, describe the task you are trying to accomplish.`,
3837
3938
I can help you upgrade your Java 8 and 11 codebases to Java 17.`,
4039
},
41-
// scan: {
42-
// title: 'Q Security Scans',
43-
// placeholder: 'Open a new Tab to run security scans',
44-
// welcome: `Welcome to Security scans!`,
45-
// }
4640
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ export class ChatController {
204204
.extractContextForTrigger('QuickAction')
205205
.then((context) => {
206206
const triggerID = randomUUID()
207-
208207
this.messenger.sendQuickActionMessage(quickActionCommand, triggerID)
209208

210209
this.triggerEventsStorage.addTriggerEvent({
@@ -215,7 +214,11 @@ export class ChatController {
215214
quickAction: quickActionCommand,
216215
context,
217216
})
218-
217+
if (quickActionCommand === 'scan') {
218+
void this.generateStaticTextResponse('quick-action-scan', triggerID)
219+
//TODO: Do telemetry
220+
return
221+
}
219222
if (quickActionCommand === 'help') {
220223
void this.generateStaticTextResponse('quick-action-help', triggerID)
221224
recordTelemetryChatRunCommand('help')

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ import { marked } from 'marked'
3434
import { JSDOM } from 'jsdom'
3535
import { LspController } from '../../../../amazonq/lsp/lspController'
3636

37-
export type StaticTextResponseType = 'quick-action-help' | 'onboarding-help' | 'transform' | 'help'
37+
export type StaticTextResponseType =
38+
| 'quick-action-help'
39+
| 'onboarding-help'
40+
| 'transform'
41+
| 'help'
42+
| 'quick-action-scan'
3843

3944
export class Messenger {
4045
public constructor(
@@ -376,6 +381,9 @@ export class Messenger {
376381
\n\n- Do not enter any confidential, sensitive, or personal information.
377382
\n\n*For additional help, visit the [Amazon Q User Guide](${userGuideURL}).*`
378383
break
384+
case 'quick-action-scan':
385+
message = `This is security scans message shown in the Q chat panel` //TODO: modify the code acc to UX
386+
break
379387
case 'onboarding-help':
380388
message = `### What I can do:
381389
\n\n- Answer questions about AWS
@@ -427,6 +435,11 @@ export class Messenger {
427435
case 'help':
428436
message = 'What can Amazon Q help me with?'
429437
break
438+
/* Optional
439+
case 'scan':
440+
message = 'What can Amazon QSA help me with?'
441+
break
442+
*/
430443
}
431444

432445
this.dispatcher.sendQuickActionMessage(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export interface CopyCodeToClipboard {
6262
export type ChatPromptCommandType =
6363
| 'help'
6464
| 'clear'
65+
| 'scan'
6566
| 'follow-up-was-clicked'
6667
| 'onboarding-page-cwc-button-clicked'
6768
| 'chat-prompt'

packages/core/src/codewhispererChat/view/messages/messageListener.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,9 @@ export class UIMessageListener {
9898
case 'footer-info-link-click':
9999
this.processFooterInfoLinkClick(msg)
100100
break
101-
case 'runProjectScan':
101+
case 'scan':
102102
showSecurityScan.execute(placeholder, cwQuickPickSource)
103-
// void vscode.window.setStatusBarMessage('Got Message from Chat')
104-
// this.processChatMessage(msg)
103+
this.processChatMessage(msg)
105104
break
106105
case 'open-settings':
107106
this.processOpenSettings(msg)

0 commit comments

Comments
 (0)