Skip to content

Commit eed4803

Browse files
authored
feat(amazonq): Adding diff view UX for generated files in Agentic chat (aws#6876)
## Problem - Existing UX accepts the generated files without permission check. ## Solution - Added code diff view using VSC native diff functionality, Users can click on the generated files and see the code diff. - Users can now accept/reject the generated code. - Close the diff view once user clicks on Accept or Reject. - Fix: If user clicks on `Confirm` button to execute the bash command change this to `Confirmed` state. - In read tool execution and safe bash command execution use different id: `generic-tool-execution` in processCustomFormAction as this helps the above step to execute. - Fix: Removing the Q spinner component if user clicks on reject button or code diff filePath. https://github.com/user-attachments/assets/be672101-aed4-4fa7-95d7-6a932d0f95ac --- - 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 10bb1c7 commit eed4803

File tree

11 files changed

+259
-200
lines changed

11 files changed

+259
-200
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,10 @@ export class Connector extends BaseConnector {
264264
tabID: tabId,
265265
})
266266

267-
if (!this.onChatAnswerUpdated || !['accept-code-diff', 'reject-code-diff'].includes(action.id)) {
267+
if (
268+
!this.onChatAnswerUpdated ||
269+
!['accept-code-diff', 'reject-code-diff', 'confirm-tool-use'].includes(action.id)
270+
) {
268271
return
269272
}
270273
const answer: ChatItem = {
@@ -297,6 +300,18 @@ export class Connector extends BaseConnector {
297300
},
298301
]
299302
break
303+
case 'confirm-tool-use':
304+
answer.buttons = [
305+
{
306+
keepCardAfterClick: true,
307+
text: 'Confirmed',
308+
id: 'confirmed-tool-use',
309+
status: 'success',
310+
position: 'outside',
311+
disabled: true,
312+
},
313+
]
314+
break
300315
default:
301316
break
302317
}

packages/core/src/codewhispererChat/clients/chat/v0/chat.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,9 @@ export class ChatSession {
1919
private sessionId?: string
2020
/**
2121
* _readFiles = list of files read from the project to gather context before generating response.
22-
* _filePath = The path helps the system locate exactly where to make the necessary changes in the project structure
23-
* _tempFilePath = Used to show the code diff view in the editor including LLM changes.
2422
* _showDiffOnFileWrite = Controls whether to show diff view (true) or file context view (false) to the user
2523
*/
2624
private _readFiles: string[] = []
27-
private _filePath: string | undefined
28-
private _tempFilePath: string | undefined
2925
private _toolUse: ToolUse | undefined
3026
private _showDiffOnFileWrite: boolean = false
3127

@@ -61,24 +57,12 @@ export class ChatSession {
6157
public get readFiles(): string[] {
6258
return this._readFiles
6359
}
64-
public get filePath(): string | undefined {
65-
return this._filePath
66-
}
67-
public get tempFilePath(): string | undefined {
68-
return this._tempFilePath
69-
}
7060
public get showDiffOnFileWrite(): boolean {
7161
return this._showDiffOnFileWrite
7262
}
7363
public setShowDiffOnFileWrite(value: boolean) {
7464
this._showDiffOnFileWrite = value
7565
}
76-
public setFilePath(filePath: string | undefined) {
77-
this._filePath = filePath
78-
}
79-
public setTempFilePath(tempFilePath: string | undefined) {
80-
this._tempFilePath = tempFilePath
81-
}
8266
public addToReadFiles(filePath: string) {
8367
this._readFiles.push(filePath)
8468
}

0 commit comments

Comments
 (0)