Skip to content

Commit 7bed944

Browse files
samhvw8daniel-lxsellipsis-dev[bot]
authored
feat: Enhance apply_diff with XML for multi-file/multi-diff operations & batch UI (#3342)
* feat: add BatchDiffApproval component for multi-file diff application - Introduced a new component `BatchDiffApproval` to handle the approval of batch changes across multiple files. - Integrated the `BatchDiffApproval` component into `ChatRow` to display batch diff requests. - Updated experimental settings to include a toggle for multi-file apply diff functionality. - Enhanced localization files to support new strings related to batch changes in multiple languages. - Updated tests to cover the new multi-file apply diff feature. * revert this * fix: update applyDiff parameter type to accept string or DiffItem * refactor: keep original file name for apply diff tool * revert this * Update src/core/webview/__tests__/ClineProvider.test.ts * revert this * fix: keep the original path if the experiment is disabled * test: add dynamic strategy selection tests for MultiSearchReplaceDiffStrategy and MultiFileSearchReplaceDiffStrategy * fix: mock applyDiffTool module and ensure legacy tool resolves successfully in tests * remove this * ellipsis suggestion Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * refactor: mirror concurrent file reads --------- Co-authored-by: Daniel Riccio <[email protected]> Co-authored-by: Daniel <[email protected]> Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
1 parent 8b6f5f8 commit 7bed944

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1855
-32
lines changed

packages/types/src/experiment.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ import type { Keys, Equals, AssertEqual } from "./type-fu.js"
66
* ExperimentId
77
*/
88

9-
export const experimentIds = [
10-
"powerSteering",
11-
"marketplace",
12-
"concurrentFileReads",
13-
"disableCompletionCommand",
14-
] as const
9+
export const experimentIds = ["powerSteering", "concurrentFileReads", "disableCompletionCommand", "marketplace", "multiFileApplyDiff"] as const
1510

1611
export const experimentIdsSchema = z.enum(experimentIds)
1712

@@ -26,6 +21,7 @@ export const experimentsSchema = z.object({
2621
marketplace: z.boolean(),
2722
concurrentFileReads: z.boolean(),
2823
disableCompletionCommand: z.boolean(),
24+
multiFileApplyDiff: z.boolean(),
2925
})
3026

3127
export type Experiments = z.infer<typeof experimentsSchema>

src/core/assistant-message/presentAssistantMessage.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { fetchInstructionsTool } from "../tools/fetchInstructionsTool"
1111
import { listFilesTool } from "../tools/listFilesTool"
1212
import { getReadFileToolDescription, readFileTool } from "../tools/readFileTool"
1313
import { writeToFileTool } from "../tools/writeToFileTool"
14-
import { applyDiffTool } from "../tools/applyDiffTool"
14+
import { applyDiffTool } from "../tools/multiApplyDiffTool"
1515
import { insertContentTool } from "../tools/insertContentTool"
1616
import { searchAndReplaceTool } from "../tools/searchAndReplaceTool"
1717
import { listCodeDefinitionNamesTool } from "../tools/listCodeDefinitionNamesTool"
@@ -31,6 +31,8 @@ import { formatResponse } from "../prompts/responses"
3131
import { validateToolUse } from "../tools/validateToolUse"
3232
import { Task } from "../task/Task"
3333
import { codebaseSearchTool } from "../tools/codebaseSearchTool"
34+
import { experiments, EXPERIMENT_IDS } from "../../shared/experiments"
35+
import { applyDiffToolLegacy } from "../tools/applyDiffTool"
3436

3537
/**
3638
* Processes and presents assistant message content to the user interface.
@@ -384,9 +386,33 @@ export async function presentAssistantMessage(cline: Task) {
384386
case "write_to_file":
385387
await writeToFileTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
386388
break
387-
case "apply_diff":
388-
await applyDiffTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
389+
case "apply_diff": {
390+
// Get the provider and state to check experiment settings
391+
const provider = cline.providerRef.deref()
392+
let isMultiFileApplyDiffEnabled = false
393+
394+
if (provider) {
395+
const state = await provider.getState()
396+
isMultiFileApplyDiffEnabled = experiments.isEnabled(
397+
state.experiments ?? {},
398+
EXPERIMENT_IDS.MULTI_FILE_APPLY_DIFF,
399+
)
400+
}
401+
402+
if (isMultiFileApplyDiffEnabled) {
403+
await applyDiffTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
404+
} else {
405+
await applyDiffToolLegacy(
406+
cline,
407+
block,
408+
askApproval,
409+
handleError,
410+
pushToolResult,
411+
removeClosingTag,
412+
)
413+
}
389414
break
415+
}
390416
case "insert_content":
391417
await insertContentTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag)
392418
break

0 commit comments

Comments
 (0)