From 36b17d8ac8660ed9f084dbc9733e484cc1fbe724 Mon Sep 17 00:00:00 2001 From: axb Date: Fri, 18 Apr 2025 19:54:12 +0800 Subject: [PATCH] feat(diff): improve progress indicator for apply_diff tool Add animated dots to progress indicator based on content length Optimize when progress updates are shown (every 10 characters) Move searchBlockCount calculation inside conditional blocks Skip unnecessary ask operations when toolProgressStatus is empty --- src/core/diff/strategies/multi-search-replace.ts | 5 +++-- src/core/tools/applyDiffTool.ts | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/diff/strategies/multi-search-replace.ts b/src/core/diff/strategies/multi-search-replace.ts index 075a768fba..2e13b7ca53 100644 --- a/src/core/diff/strategies/multi-search-replace.ts +++ b/src/core/diff/strategies/multi-search-replace.ts @@ -583,12 +583,13 @@ Only use a single line of '=======' between search and replacement content, beca const diffContent = toolUse.params.diff if (diffContent) { const icon = "diff-multiple" - const searchBlockCount = (diffContent.match(/SEARCH/g) || []).length if (toolUse.partial) { - if (diffContent.length < 1000 || (diffContent.length / 50) % 10 === 0) { + if (Math.floor(diffContent.length / 10) % 10 === 0) { + const searchBlockCount = (diffContent.match(/SEARCH/g) || []).length return { icon, text: `${searchBlockCount}` } } } else if (result) { + const searchBlockCount = (diffContent.match(/SEARCH/g) || []).length if (result.failParts?.length) { return { icon, diff --git a/src/core/tools/applyDiffTool.ts b/src/core/tools/applyDiffTool.ts index ca0adb9e33..9957d019b8 100644 --- a/src/core/tools/applyDiffTool.ts +++ b/src/core/tools/applyDiffTool.ts @@ -42,6 +42,10 @@ export async function applyDiffTool( toolProgressStatus = cline.diffStrategy.getProgressStatus(block) } + if (toolProgressStatus && Object.keys(toolProgressStatus).length === 0) { + return + } + const partialMessage = JSON.stringify(sharedMessageProps) await cline.ask("tool", partialMessage, block.partial, toolProgressStatus).catch(() => {}) return