Skip to content

Commit d7bfb5d

Browse files
authored
Merge pull request aws#6383 from Randall-Jiang/master
fix(amazonq): User can view file diff by file click
2 parents f192573 + 07ae50c commit d7bfb5d

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "`/test`: view diffs by clicking files in the file tree, aligning the behavior with the 'View Diff' button."
4+
}

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

+38-9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { TabsStorage, TabType } from '../storages/tabsStorage'
1313
import { TestMessageType } from '../../../../amazonqTest/chat/views/connector/connector'
1414
import { ChatPayload } from '../connector'
1515
import { BaseConnector, BaseConnectorProps } from './baseConnector'
16+
import { FollowUpTypes } from '../../../commons/types'
1617

1718
export interface ConnectorProps extends BaseConnectorProps {
1819
sendMessageToExtension: (message: ExtensionMessage) => void
@@ -107,15 +108,43 @@ export class Connector extends BaseConnector {
107108
}
108109

109110
onFileDiff = (tabID: string, filePath: string, deleted: boolean, messageId?: string): void => {
110-
// TODO: add this back once we can advance flow from here
111-
// this.sendMessageToExtension({
112-
// command: 'open-diff',
113-
// tabID,
114-
// filePath,
115-
// deleted,
116-
// messageId,
117-
// tabType: 'testgen',
118-
// })
111+
if (this.onChatAnswerReceived === undefined) {
112+
return
113+
}
114+
// Open diff view
115+
this.sendMessageToExtension({
116+
command: 'open-diff',
117+
tabID,
118+
filePath,
119+
deleted,
120+
messageId,
121+
tabType: 'testgen',
122+
})
123+
this.onChatAnswerReceived(
124+
tabID,
125+
{
126+
type: ChatItemType.ANSWER,
127+
messageId: messageId,
128+
followUp: {
129+
text: ' ',
130+
options: [
131+
{
132+
type: FollowUpTypes.AcceptCode,
133+
pillText: 'Accept',
134+
status: 'success',
135+
icon: MynahIcons.OK,
136+
},
137+
{
138+
type: FollowUpTypes.RejectCode,
139+
pillText: 'Reject',
140+
status: 'error',
141+
icon: MynahIcons.REVERT,
142+
},
143+
],
144+
},
145+
},
146+
{}
147+
)
119148
}
120149

121150
private processChatMessage = async (messageData: any): Promise<void> => {

0 commit comments

Comments
 (0)