Skip to content

Commit 8f73a7e

Browse files
committed
Fix: Removing the spinner component after Reject and code diff is clicked
1 parent 6b35107 commit 8f73a7e

File tree

6 files changed

+19
-10
lines changed

6 files changed

+19
-10
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,9 +777,7 @@ export class ChatController {
777777
}
778778
const tool: Tool = result
779779
await ToolUtils.validate(tool)
780-
781-
const chatStream = new ChatStream(this.messenger, message.tabID, randomUUID(), clonedToolUse)
782-
await ToolUtils.invoke(tool, chatStream)
780+
await ToolUtils.invoke(tool)
783781

784782
// Check if fileExists=false, If yes, return instead of showing broken diff experience.
785783
if (!tempFilePath) {

packages/core/src/codewhispererChat/tools/executeBash.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,19 @@ export class ExecuteBash {
6565
}
6666
}
6767

68-
public async invoke(updates: Writable): Promise<InvokeOutput> {
68+
public async invoke(updates?: Writable): Promise<InvokeOutput> {
6969
this.logger.info(`Invoking bash command: "${this.command}" in cwd: "${this.workingDirectory}"`)
70+
if (!updates) {
71+
// updates passed as undefined only in the code diff is clicked to avoid showing Q Streaming spinner component to the user.
72+
return new Promise(async (resolve) => {
73+
resolve({
74+
output: {
75+
kind: OutputKind.Json,
76+
content: '',
77+
},
78+
})
79+
})
80+
}
7081

7182
return new Promise(async (resolve, reject) => {
7283
this.logger.debug(`Spawning process with command: bash -c "${this.command}" (cwd=${this.workingDirectory})`)

packages/core/src/codewhispererChat/tools/fsRead.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class FsRead {
5757
updates.end()
5858
}
5959

60-
public async invoke(updates: Writable): Promise<InvokeOutput> {
60+
public async invoke(updates?: Writable): Promise<InvokeOutput> {
6161
try {
6262
const fileUri = vscode.Uri.file(this.fsPath)
6363

packages/core/src/codewhispererChat/tools/fsWrite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class FsWrite {
4444

4545
constructor(private readonly params: FsWriteParams) {}
4646

47-
public async invoke(updates: Writable): Promise<InvokeOutput> {
47+
public async invoke(updates?: Writable): Promise<InvokeOutput> {
4848
const sanitizedPath = sanitizePath(this.params.path)
4949

5050
switch (this.params.command) {

packages/core/src/codewhispererChat/tools/toolUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class ToolUtils {
4343
}
4444
}
4545

46-
static async invoke(tool: Tool, updates: Writable): Promise<InvokeOutput> {
46+
static async invoke(tool: Tool, updates?: Writable): Promise<InvokeOutput> {
4747
switch (tool.type) {
4848
case ToolType.FsRead:
4949
return tool.tool.invoke(updates)

packages/core/src/test/codewhispererChat/tools/toolShared.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('ToolUtils', function () {
9090
const result = await ToolUtils.invoke(tool, mockWritable as unknown as Writable)
9191

9292
assert.deepStrictEqual(result, expectedOutput)
93-
assert(mockFsRead.invoke.calledOnceWith(mockWritable))
93+
assert(mockFsRead.invoke.calledOnceWith(mockWritable as unknown as Writable | undefined))
9494
})
9595

9696
it('delegates to FsWrite tool invoke method', async function () {
@@ -106,7 +106,7 @@ describe('ToolUtils', function () {
106106
const result = await ToolUtils.invoke(tool, mockWritable as unknown as Writable)
107107

108108
assert.deepStrictEqual(result, expectedOutput)
109-
assert(mockFsWrite.invoke.calledOnceWith(mockWritable))
109+
assert(mockFsWrite.invoke.calledOnceWith(mockWritable as unknown as Writable | undefined))
110110
})
111111

112112
it('delegates to ExecuteBash tool invoke method', async function () {
@@ -122,7 +122,7 @@ describe('ToolUtils', function () {
122122
const result = await ToolUtils.invoke(tool, mockWritable as unknown as Writable)
123123

124124
assert.deepStrictEqual(result, expectedOutput)
125-
assert(mockExecuteBash.invoke.calledOnceWith(mockWritable))
125+
assert(mockExecuteBash.invoke.calledOnceWith(mockWritable as unknown as Writable | undefined))
126126
})
127127
})
128128

0 commit comments

Comments
 (0)