From 3b65023d0b7e1470c46788f070519a8b16a41be9 Mon Sep 17 00:00:00 2001 From: axb Date: Thu, 24 Apr 2025 12:12:07 +0800 Subject: [PATCH] feat(diff): improve progress indicator for apply_diff tool (#2758) 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 b7c2dffe8a..00cebd2bea 100644 --- a/src/core/diff/strategies/multi-search-replace.ts +++ b/src/core/diff/strategies/multi-search-replace.ts @@ -574,12 +574,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 f8fd5944b8..967b881d31 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