mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-11 22:51:26 +00:00
fix: ensure write_to_file returns error response to LLM on failure
- Add pushToolResult() call in error handler to return formatted error message - Extract toolProtocol from callbacks for error formatting - Update test to verify pushToolResult is called with error message - Fixes ROO-320: UI buttons getting stuck after file write errors
This commit is contained in:
parent
802b40a790
commit
0a59d92964
2 changed files with 4 additions and 2 deletions
|
|
@ -34,7 +34,7 @@ export class WriteToFileTool extends BaseTool<"write_to_file"> {
|
|||
}
|
||||
|
||||
async execute(params: WriteToFileParams, task: Task, callbacks: ToolCallbacks): Promise<void> {
|
||||
const { pushToolResult, handleError, askApproval, removeClosingTag } = callbacks
|
||||
const { pushToolResult, handleError, askApproval, removeClosingTag, toolProtocol } = callbacks
|
||||
const relPath = params.path
|
||||
let newContent = params.content
|
||||
|
||||
|
|
@ -194,6 +194,7 @@ export class WriteToFileTool extends BaseTool<"write_to_file"> {
|
|||
return
|
||||
} catch (error) {
|
||||
await handleError("writing file", error as Error)
|
||||
pushToolResult(formatResponse.toolError((error as Error).message, toolProtocol))
|
||||
await task.diffViewProvider.reset()
|
||||
this.resetPartialState()
|
||||
return
|
||||
|
|
|
|||
|
|
@ -443,12 +443,13 @@ describe("writeToFileTool", () => {
|
|||
})
|
||||
|
||||
describe("error handling", () => {
|
||||
it("handles general file operation errors", async () => {
|
||||
it("handles general file operation errors and returns error to LLM", async () => {
|
||||
mockCline.diffViewProvider.open.mockRejectedValue(new Error("General error"))
|
||||
|
||||
await executeWriteFileTool({})
|
||||
|
||||
expect(mockHandleError).toHaveBeenCalledWith("writing file", expect.any(Error))
|
||||
expect(mockPushToolResult).toHaveBeenCalledWith("Error: General error")
|
||||
expect(mockCline.diffViewProvider.reset).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue