From 9176bf74b12742fbd0cbccc416596b0357e84f11 Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:54:40 -0800 Subject: [PATCH] Add more friendly diff edit failed message --- src/core/Cline.ts | 9 ++----- src/shared/ExtensionMessage.ts | 1 + webview-ui/src/components/chat/ChatRow.tsx | 29 ++++++++++++++++++++++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/core/Cline.ts b/src/core/Cline.ts index 79dac08c45..42bfd9db86 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -1113,14 +1113,9 @@ export class Cline { !block.partial, ) } catch (error) { - await this.say( - "error", - `Failed to apply changes to ${relPath}. The model's diff instructions could not be processed correctly. This usually happens when the search patterns don't match the file content exactly.`, - ) + await this.say("diff_error", relPath) pushToolResult( - formatResponse.toolError( - `Error writing file: ${JSON.stringify(serializeError(error))}`, - ), + formatResponse.toolError(`Error writing file: ${(error as Error)?.message}`), ) await this.diffViewProvider.revertChanges() await this.diffViewProvider.reset() diff --git a/src/shared/ExtensionMessage.ts b/src/shared/ExtensionMessage.ts index 3889f0e1c6..b3e58bc4a6 100644 --- a/src/shared/ExtensionMessage.ts +++ b/src/shared/ExtensionMessage.ts @@ -92,6 +92,7 @@ export type ClineSay = | "mcp_server_request_started" | "mcp_server_response" | "use_mcp_server" + | "diff_error" export interface ClineSayTool { tool: diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index 6992fe486c..200b75a93d 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -794,6 +794,35 @@ export const ChatRowContent = ({
{message.text}
> ) + case "diff_error": + return ( + <> +