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
This commit is contained in:
axb 2025-04-24 12:12:07 +08:00 • committed by GitHub
parent c228e638b9
commit 3b65023d0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -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,

View file

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