From 18b05ffb532ef02f3100ddde65923303339dcdfd Mon Sep 17 00:00:00 2001 From: Roo Code Date: Wed, 7 Jan 2026 01:52:23 +0000 Subject: [PATCH] fix: add progress indicator for background editing in all file edit tools When the preventFocusDisruption (Background Editing) experiment is enabled, file writing operations now display a progress indicator (spinner) in the chat UI before file operations begin. This addresses Issue #10504 where users would see no visual feedback while Roo was preparing and writing files in the background, causing confusion about whether the app had frozen. Files updated: - WriteToFileTool.ts - ApplyDiffTool.ts - MultiApplyDiffTool.ts - SearchAndReplaceTool.ts - SearchReplaceTool.ts - EditFileTool.ts --- src/core/tools/ApplyDiffTool.ts | 4 ++++ src/core/tools/EditFileTool.ts | 6 ++++++ src/core/tools/MultiApplyDiffTool.ts | 4 ++++ src/core/tools/SearchAndReplaceTool.ts | 6 ++++++ src/core/tools/SearchReplaceTool.ts | 6 ++++++ src/core/tools/WriteToFileTool.ts | 4 ++++ 6 files changed, 30 insertions(+) diff --git a/src/core/tools/ApplyDiffTool.ts b/src/core/tools/ApplyDiffTool.ts index 7161c7c08e..067f423f58 100644 --- a/src/core/tools/ApplyDiffTool.ts +++ b/src/core/tools/ApplyDiffTool.ts @@ -152,6 +152,10 @@ export class ApplyDiffTool extends BaseTool<"apply_diff"> { } if (isPreventFocusDisruptionEnabled) { + // Show progress indicator in UI while preparing the file + const partialMessage = JSON.stringify(sharedMessageProps) + await task.ask("tool", partialMessage, true).catch(() => {}) + // Direct file write without diff view const completeMessage = JSON.stringify({ ...sharedMessageProps, diff --git a/src/core/tools/EditFileTool.ts b/src/core/tools/EditFileTool.ts index 8d04fe2301..f3867af5b2 100644 --- a/src/core/tools/EditFileTool.ts +++ b/src/core/tools/EditFileTool.ts @@ -276,6 +276,12 @@ export class EditFileTool extends BaseTool<"edit_file"> { diffStats, } satisfies ClineSayTool) + // Show progress indicator in UI while preparing the file when background editing is enabled + if (isPreventFocusDisruptionEnabled) { + const partialMessage = JSON.stringify(sharedMessageProps) + await task.ask("tool", partialMessage, true).catch(() => {}) + } + // Show diff view if focus disruption prevention is disabled if (!isPreventFocusDisruptionEnabled) { await task.diffViewProvider.open(relPath) diff --git a/src/core/tools/MultiApplyDiffTool.ts b/src/core/tools/MultiApplyDiffTool.ts index 94cdb3fd49..0da37485ce 100644 --- a/src/core/tools/MultiApplyDiffTool.ts +++ b/src/core/tools/MultiApplyDiffTool.ts @@ -631,6 +631,10 @@ ${errorDetails ? `\nTechnical details:\n${errorDetails}\n` : ""} await cline.diffViewProvider.update(originalContent!, true) cline.diffViewProvider.scrollToFirstDiff() } else { + // Show progress indicator in UI while preparing the file + const partialMessage = JSON.stringify(sharedMessageProps) + await cline.ask("tool", partialMessage, true).catch(() => {}) + // For direct save, we still need to set originalContent cline.diffViewProvider.originalContent = await fs.readFile(absolutePath, "utf-8") } diff --git a/src/core/tools/SearchAndReplaceTool.ts b/src/core/tools/SearchAndReplaceTool.ts index 7d03a6a22c..bd36181d6d 100644 --- a/src/core/tools/SearchAndReplaceTool.ts +++ b/src/core/tools/SearchAndReplaceTool.ts @@ -211,6 +211,12 @@ export class SearchAndReplaceTool extends BaseTool<"search_and_replace"> { diffStats, } satisfies ClineSayTool) + // Show progress indicator in UI while preparing the file when background editing is enabled + if (isPreventFocusDisruptionEnabled) { + const partialMessage = JSON.stringify(sharedMessageProps) + await task.ask("tool", partialMessage, true).catch(() => {}) + } + // Show diff view if focus disruption prevention is disabled if (!isPreventFocusDisruptionEnabled) { await task.diffViewProvider.open(relPath) diff --git a/src/core/tools/SearchReplaceTool.ts b/src/core/tools/SearchReplaceTool.ts index dadb97fde5..82b193c06b 100644 --- a/src/core/tools/SearchReplaceTool.ts +++ b/src/core/tools/SearchReplaceTool.ts @@ -198,6 +198,12 @@ export class SearchReplaceTool extends BaseTool<"search_replace"> { diffStats, } satisfies ClineSayTool) + // Show progress indicator in UI while preparing the file when background editing is enabled + if (isPreventFocusDisruptionEnabled) { + const partialMessage = JSON.stringify(sharedMessageProps) + await task.ask("tool", partialMessage, true).catch(() => {}) + } + // Show diff view if focus disruption prevention is disabled if (!isPreventFocusDisruptionEnabled) { await task.diffViewProvider.open(relPath) diff --git a/src/core/tools/WriteToFileTool.ts b/src/core/tools/WriteToFileTool.ts index d9c20115ea..01c70c32c5 100644 --- a/src/core/tools/WriteToFileTool.ts +++ b/src/core/tools/WriteToFileTool.ts @@ -116,6 +116,10 @@ export class WriteToFileTool extends BaseTool<"write_to_file"> { ) if (isPreventFocusDisruptionEnabled) { + // Show progress indicator in UI while preparing the file + const partialMessage = JSON.stringify(sharedMessageProps) + await task.ask("tool", partialMessage, true).catch(() => {}) + task.diffViewProvider.editType = fileExists ? "modify" : "create" if (fileExists) { const absolutePath = path.resolve(task.cwd, relPath)