Add more friendly diff edit failed message

This commit is contained in:
Saoud Rizwan 2024-12-19 15:54:40 -08:00
parent b7b5d28bb1
commit 9176bf74b1
3 changed files with 32 additions and 7 deletions

View file

@ -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()

View file

@ -92,6 +92,7 @@ export type ClineSay =
| "mcp_server_request_started"
| "mcp_server_response"
| "use_mcp_server"
| "diff_error"
export interface ClineSayTool {
tool:

View file

@ -794,6 +794,35 @@ export const ChatRowContent = ({
<p style={{ ...pStyle, color: "var(--vscode-errorForeground)" }}>{message.text}</p>
</>
)
case "diff_error":
return (
<>
<div
style={{
display: "flex",
flexDirection: "column",
backgroundColor: "rgba(255, 191, 0, 0.1)",
padding: 8,
borderRadius: 3,
fontSize: 12,
}}>
<div style={{ display: "flex", alignItems: "center", marginBottom: 4 }}>
<i
className="codicon codicon-error"
style={{
marginRight: 8,
fontSize: 18,
color: "#FFA500",
}}></i>
<span style={{ fontWeight: 500, color: "#FFA500" }}>Diff Edit Failed</span>
</div>
<div>
This usually happens when the model uses search patterns that don't match anything
in the file. Retrying...
</div>
</div>
</>
)
case "completion_result":
return (
<>