From 67f53899f96c04007e186fb66bd76dde80655c89 Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:10:09 -0800 Subject: [PATCH] Fixes --- src/core/Cline.ts | 22 ++++++++++++---------- src/core/assistant-message/diff.ts | 2 +- webview-ui/src/components/chat/ChatRow.tsx | 4 ++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/core/Cline.ts b/src/core/Cline.ts index 8f609c840d..9c2187e20c 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -1134,8 +1134,7 @@ export class Cline { const sharedMessageProps: ClineSayTool = { tool: fileExists ? "editedExistingFile" : "newFileCreated", path: getReadablePath(cwd, removeClosingTag("path", relPath)), - content: fileExists ? undefined : newContent, - diff: fileExists ? diff : undefined, + content: diff || content, } if (block.partial) { @@ -1191,8 +1190,7 @@ export class Cline { const completeMessage = JSON.stringify({ ...sharedMessageProps, - content: fileExists ? undefined : newContent, - diff: fileExists ? diff : undefined, + content: diff || content, // ? formatResponse.createPrettyPatch( // relPath, // this.diffViewProvider.originalContent, @@ -1204,6 +1202,9 @@ export class Cline { if (this.shouldAutoApproveTool(block.name)) { await this.say("tool", completeMessage, undefined, false) this.consecutiveAutoApprovedRequestsCount++ + + // we need an artificial delay to let the diagnostics catch up to the changes + await delay(3_500) } else { // If auto-approval is enabled but this tool wasn't auto-approved, send notification showNotificationForApprovalIfAutoApprovalEnabled( @@ -1649,12 +1650,13 @@ export class Cline { try { if (block.partial) { if (this.shouldAutoApproveTool(block.name)) { - await this.say( - "command", - removeClosingTag("command", command), - undefined, - block.partial, - ).catch(() => {}) + // since depending on an upcoming parameter, requiresApproval this may become an ask - we cant partially stream a say prematurely. So in this particular case we have to wait for the requiresApproval parameter to be completed before presenting it. + // await this.say( + // "command", + // removeClosingTag("command", command), + // undefined, + // block.partial, + // ).catch(() => {}) } else { await this.ask( "command", diff --git a/src/core/assistant-message/diff.ts b/src/core/assistant-message/diff.ts index 34c1deb387..f492c2f461 100644 --- a/src/core/assistant-message/diff.ts +++ b/src/core/assistant-message/diff.ts @@ -205,7 +205,7 @@ export async function constructNewFileContent( ;[searchMatchIndex, searchEndIndex] = fallbackMatch } else { throw new Error( - `The SEARCH block:\n${currentSearchContent.trimEnd()}\n...does not match anything in the file.`, + `The SEARCH block:\n${currentSearchContent.trimEnd()}\n...does not match anything in the file.\nThis is likely due to differences in whitespace or line endings between the SEARCH block and the actual file. Try again with a more precise SEARCH block.\n(If you keep running into this error, you may use the write_to_file tool as a workaround.)`, ) } } diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index 19e0cbf5a4..6992fe486c 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -281,7 +281,7 @@ export const ChatRowContent = ({ - The model has determined this command requires explicit approval + The model has determined this command requires explicit approval. )}