|
|
@@ -525,9 +525,10 @@ ${errorDetails ? `\nTechnical details:\n${errorDetails}\n` : ""}
|
|
|
isProtected: isWriteProtected,
|
|
|
}
|
|
|
|
|
|
- // If single file, ask for approval
|
|
|
+ // If single file, handle based on PREVENT_FOCUS_DISRUPTION setting
|
|
|
let didApprove = true
|
|
|
if (operationsToApprove.length === 1) {
|
|
|
+ // Prepare common data for single file operation
|
|
|
const diffContents = diffItems.map((item) => item.content).join("\n\n")
|
|
|
const operationMessage = JSON.stringify({
|
|
|
...sharedMessageProps,
|
|
|
@@ -535,7 +536,6 @@ ${errorDetails ? `\nTechnical details:\n${errorDetails}\n` : ""}
|
|
|
} satisfies ClineSayTool)
|
|
|
|
|
|
let toolProgressStatus
|
|
|
-
|
|
|
if (cline.diffStrategy && cline.diffStrategy.getProgressStatus) {
|
|
|
toolProgressStatus = cline.diffStrategy.getProgressStatus(
|
|
|
{
|
|
|
@@ -546,40 +546,69 @@ ${errorDetails ? `\nTechnical details:\n${errorDetails}\n` : ""}
|
|
|
)
|
|
|
}
|
|
|
|
|
|
- // Check if file is write-protected
|
|
|
+ // Set up diff view
|
|
|
+ cline.diffViewProvider.editType = "modify"
|
|
|
+
|
|
|
+ // Show diff view if focus disruption prevention is disabled
|
|
|
+ if (!isPreventFocusDisruptionEnabled) {
|
|
|
+ await cline.diffViewProvider.open(relPath)
|
|
|
+ await cline.diffViewProvider.update(originalContent!, true)
|
|
|
+ cline.diffViewProvider.scrollToFirstDiff()
|
|
|
+ } else {
|
|
|
+ // For direct save, we still need to set originalContent
|
|
|
+ cline.diffViewProvider.originalContent = await fs.readFile(absolutePath, "utf-8")
|
|
|
+ }
|
|
|
+
|
|
|
+ // Ask for approval (same for both flows)
|
|
|
const isWriteProtected = cline.rooProtectedController?.isWriteProtected(relPath) || false
|
|
|
didApprove = await askApproval("tool", operationMessage, toolProgressStatus, isWriteProtected)
|
|
|
- }
|
|
|
|
|
|
- if (!didApprove) {
|
|
|
- if (!isPreventFocusDisruptionEnabled) {
|
|
|
- await cline.diffViewProvider.revertChanges()
|
|
|
+ if (!didApprove) {
|
|
|
+ // Revert changes if diff view was shown
|
|
|
+ if (!isPreventFocusDisruptionEnabled) {
|
|
|
+ await cline.diffViewProvider.revertChanges()
|
|
|
+ }
|
|
|
+ results.push(`Changes to ${relPath} were not approved by user`)
|
|
|
+ continue
|
|
|
}
|
|
|
- results.push(`Changes to ${relPath} were not approved by user`)
|
|
|
- continue
|
|
|
- }
|
|
|
|
|
|
- if (isPreventFocusDisruptionEnabled) {
|
|
|
- // Direct file write without diff view or opening the file
|
|
|
- cline.diffViewProvider.editType = "modify"
|
|
|
- cline.diffViewProvider.originalContent = await fs.readFile(absolutePath, "utf-8")
|
|
|
- await cline.diffViewProvider.saveDirectly(
|
|
|
- relPath,
|
|
|
- originalContent!,
|
|
|
- false,
|
|
|
- diagnosticsEnabled,
|
|
|
- writeDelayMs,
|
|
|
- )
|
|
|
+ // Save the changes
|
|
|
+ if (isPreventFocusDisruptionEnabled) {
|
|
|
+ // Direct file write without diff view or opening the file
|
|
|
+ await cline.diffViewProvider.saveDirectly(
|
|
|
+ relPath,
|
|
|
+ originalContent!,
|
|
|
+ false,
|
|
|
+ diagnosticsEnabled,
|
|
|
+ writeDelayMs,
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ // Call saveChanges to update the DiffViewProvider properties
|
|
|
+ await cline.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs)
|
|
|
+ }
|
|
|
} else {
|
|
|
- // Original behavior with diff view
|
|
|
- // Show diff view before asking for approval (only for single file or after batch approval)
|
|
|
- cline.diffViewProvider.editType = "modify"
|
|
|
- await cline.diffViewProvider.open(relPath)
|
|
|
- await cline.diffViewProvider.update(originalContent!, true)
|
|
|
- cline.diffViewProvider.scrollToFirstDiff()
|
|
|
-
|
|
|
- // Call saveChanges to update the DiffViewProvider properties
|
|
|
- await cline.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs)
|
|
|
+ // Batch operations - already approved above
|
|
|
+ if (isPreventFocusDisruptionEnabled) {
|
|
|
+ // Direct file write without diff view or opening the file
|
|
|
+ cline.diffViewProvider.editType = "modify"
|
|
|
+ cline.diffViewProvider.originalContent = await fs.readFile(absolutePath, "utf-8")
|
|
|
+ await cline.diffViewProvider.saveDirectly(
|
|
|
+ relPath,
|
|
|
+ originalContent!,
|
|
|
+ false,
|
|
|
+ diagnosticsEnabled,
|
|
|
+ writeDelayMs,
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ // Original behavior with diff view
|
|
|
+ cline.diffViewProvider.editType = "modify"
|
|
|
+ await cline.diffViewProvider.open(relPath)
|
|
|
+ await cline.diffViewProvider.update(originalContent!, true)
|
|
|
+ cline.diffViewProvider.scrollToFirstDiff()
|
|
|
+
|
|
|
+ // Call saveChanges to update the DiffViewProvider properties
|
|
|
+ await cline.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Track file edit operation
|