Skip to content

Commit e3e84c2

Browse files
committed
fix(chat): Add more logs and permission fix
1 parent 79bf0bc commit e3e84c2

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,11 @@ export class Messenger {
250250
const actionId =
251251
tool.type === ToolType.ExecuteBash ? 'run-shell-command' : 'generic-tool-execution'
252252

253-
this.dispatcher.sendCustomFormActionMessage(
254-
new CustomFormActionMessage(tabID, { id: actionId })
255-
)
253+
if (!validation.requiresAcceptance) {
254+
this.dispatcher.sendCustomFormActionMessage(
255+
new CustomFormActionMessage(tabID, { id: actionId })
256+
)
257+
}
256258
} else {
257259
// TODO: Handle the error
258260
}

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

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,31 @@ export class ChatStream extends Writable {
3232
}
3333

3434
override _write(chunk: Buffer, encoding: BufferEncoding, callback: (error?: Error | null) => void): void {
35-
const text = chunk.toString()
36-
this.accumulatedLogs += text
37-
this.logger.debug(`ChatStream received chunk: ${text}`)
38-
this.messenger.sendPartialToolLog(
39-
this.accumulatedLogs,
40-
this.tabID,
41-
this.triggerID,
42-
this.toolUse,
43-
this.validation,
44-
this.changeList
45-
)
46-
callback()
35+
try {
36+
const text = chunk.toString()
37+
this.accumulatedLogs += text
38+
this.logger.debug(`ChatStream received chunk: ${text}`)
39+
this.messenger.sendPartialToolLog(
40+
this.accumulatedLogs,
41+
this.tabID,
42+
this.triggerID,
43+
this.toolUse,
44+
this.validation,
45+
this.changeList
46+
)
47+
callback()
48+
} catch (error) {
49+
this.logger.error(`Error in ChatStream.write: ${error}`)
50+
callback(error instanceof Error ? error : new Error(String(error)))
51+
}
4752
}
4853

4954
override _final(callback: (error?: Error | null) => void): void {
50-
callback()
55+
try {
56+
callback()
57+
} catch (error) {
58+
this.logger.error(`Error in ChatStream.final: ${error}`)
59+
callback(error instanceof Error ? error : new Error(String(error)))
60+
}
5161
}
5262
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ export class FsRead {
5050
public queueDescription(updates: Writable): void {
5151
const fileName = path.basename(this.fsPath)
5252
const fileUri = vscode.Uri.file(this.fsPath)
53-
updates.write(`Reading file: [${fileName}](${fileUri}), `)
53+
updates.write(`Reading file: [${fileName}](${fileUri}) `)
5454

5555
const [start, end] = this.readRange ?? []
5656

5757
if (start && end) {
58-
updates.write(`from line ${start} to ${end}`)
58+
updates.write(`L${start} to L${end}`)
5959
} else if (start) {
6060
if (start > 0) {
61-
updates.write(`from line ${start} to end of file`)
61+
updates.write(`from L${start} to end of file`)
6262
} else {
6363
updates.write(`${start} line from the end of file to end of file`)
6464
}

packages/core/src/shared/utilities/messageUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface MessageErrorInfo {
1313
}
1414

1515
export function extractErrorInfo(error: any): MessageErrorInfo {
16-
let errorMessage = 'Error reading chat stream.'
16+
let errorMessage = 'Error reading chat stream: ' + error.message
1717
let statusCode = undefined
1818
let requestId = undefined
1919

0 commit comments

Comments
 (0)