mirror of
https://github.com/cline/cline.git
synced 2026-09-21 13:21:23 +08:00
* feat(sdk): expose edit-executor internals for host diff previews Extract computePatchChanges() from createApplyPatchExecutor so hosts can compute a patch's per-file proposed content without writing to disk (behavior-identical refactor; the executor now calls the helper), and widen the @cline/core root exports with createEditorExecutor, createApplyPatchExecutor, computePatchChanges, PatchActionType and the related types. Needed by the VS Code adapter to restore the editor diff view for SDK edit tools. * fix(vscode): restore editor diff view for SDK edit tools Adds SdkDiffEditCoordinator, which owns per-toolCallId diff sessions over the legacy DiffViewProvider abstraction (HostProvider factory, so the external/JetBrains gRPC DiffService path keeps working): - the diff editor opens populated before the approval ask renders (the SDK surfaces tool input only after the model stream completes, so the approval callback is the only pre-execution point with full input) - an overridden editor executor saves through the diff document: user edits in the editable right pane and post-save auto-formatting flow back to the model via formatResponse.fileEditWithUserChanges, plus 'new problems' diagnostics - Reject/abort reverts (new files: file + created dirs removed) - auto-approved edits open the diff during execution with the legacy 3.5s diagnostics settle; Background Edit keeps the headless disk path - apply_patch gets a preview-only diff of its first changed file; on approve the preview is reverted and the untouched SDK executor applies the whole patch - any diff-pipeline failure reverts and falls back to the SDK disk executor, preserving canonical error strings Fixes #11934 (CLINE-2580). * refactor(vscode): make edit diff preview a read-only virtual-document diff Reworks the diff view restoration after EDH testing showed the editable real-document design breaking on same-file multi-edits (tab reuse opened the actual file instead of a diff; sibling saves closed other sessions' tabs; right-pane edits misbehaved). New design per review: - EditPreview abstraction (mirrors CommentReviewController pattern): VscodeEditPreview renders vscode.diff with BOTH sides as virtual cline-diff documents (unique fragment per preview, so same-file edits get distinct tabs and close is an exact tab match, never the real file); ExternalEditPreview uses the existing openMultiFileDiff/ closeAllDiffs host-bridge RPCs. New createEditPreview factory on HostProvider. - The preview never touches disk: executors close the preview and delegate to the SDK's default disk executors, whose results and error strings reach the model unchanged. Reject/abort just closes a tab. - Dropped by design decision: editing in the diff view, user-edit feedback to the model, and diagnostics passback (the SDK already prompts the model to check). - Auto-approved edits show a brief preview that lingers ~1.5s after the write; an abort cuts the linger short without failing the applied edit. - A newer same-file preview supersedes an older pending one (approvals resolve sequentially), eliminating cross-session interference. - Legacy DiffViewProvider stack returns to untouched dead code. * fix(vscode): state that denied edits did not modify the file Repro: ask Cline to edit a file, then answer the approval with feedback instead of Approve/Reject. The denial reached the model as just {"error":"make them bigger"} — nothing said the edit was NOT applied — so the model treated the feedback as iteration on an applied change and built its next old_text against content that never landed on disk. From then on old_text no longer matched the real file and the diff preview silently stopped appearing (and the eventual executor run would fail the same way). Denial reasons now come from buildToolApprovalDenialReason(): edit tools get 'The user denied this edit. The file was NOT modified and still contains its original content.' (legacy parity), and all tools get user feedback wrapped in <feedback> tags instead of the bare prompt as the whole reason. isKnownToolApprovalDenial also matches the new edit-denial marker so translator suppression keeps working. * feat(vscode): simulated streaming animation for edit previews Brings back the legacy 'yellow sweep' feel on the virtual diff preview. The SDK only surfaces complete tool input, so this is a deliberate simulation of the legacy streaming look (which legacy also showed when it already had the full content in memory). The sweep covers the whole file like legacy did, with diff-aware pacing: - Park at the top: whole document under the faded-yellow overlay, cursor highlight on line 0, viewport pinned to the top, ~400ms hold so the animation unambiguously starts from the top. - Zip through unchanged spans in small fast steps (~8 lines per 16ms frame, capped per span) so they read as continuous motion. - Slow down through each change: one line per 45ms frame with a ~350ms minimum dwell per hunk so even a one-line change visibly pauses. - Changed runs come from a real line diff (diffLines), so multi-hunk edits slow at EACH hunk and the gaps between hunks zip; pure deletions pause at the deletion point. - Zip frames chase the cursor (InCenter) for continuous scroll; typing frames scroll only when leaving the viewport (no per-frame judder). - After the sweep reaches the bottom: short beat, then settle centered on the first changed line for review. Mechanics: edit previews move from base64-query cline-diff URIs to a new mutable cline-edit-preview content provider (content set programmatically, re-rendered via onDidChange) so the virtual right side can update in place. DecorationController is reused as-is. The approval ask renders while the animation plays (legacy simultaneity); close() cancels mid-animation; files >3000 lines render the final diff immediately. External hosts keep the static openMultiFileDiff preview. * chore(vscode): remove test artifact comment from memory-monitor * fix(vscode): address review nits — skip diff computation for large files, close partially-opened previews - buildEditPreviewAnimation (which runs a full line diff) now runs after the MAX_ANIMATED_LINES guard; oversized files use a cheap prefix scan just to aim the viewport. - If preview.open() throws after partially opening, the tab is closed directly — the session was never registered, so discardPreview could not have reached it. * fix(vscode): keep tsconfig valid JSON for test setup * fix(vscode): bound diff preview animation
77 lines
1.4 KiB
JSON
77 lines
1.4 KiB
JSON
{
|
|
"compilerOptions": {
|
|
"esModuleInterop": true,
|
|
"experimentalDecorators": true,
|
|
"forceConsistentCasingInFileNames": true,
|
|
"isolatedModules": true,
|
|
"jsx": "react",
|
|
"lib": [
|
|
"es2022",
|
|
"DOM"
|
|
],
|
|
"module": "esnext",
|
|
"moduleResolution": "Bundler",
|
|
"noFallthroughCasesInSwitch": true,
|
|
"noImplicitOverride": true,
|
|
"noImplicitReturns": true,
|
|
"noUnusedLocals": false,
|
|
"resolveJsonModule": true,
|
|
"rootDir": ".",
|
|
"skipLibCheck": true,
|
|
"sourceMap": true,
|
|
"strict": true,
|
|
"target": "es2022",
|
|
"typeRoots": [
|
|
"./node_modules/@types",
|
|
"../../node_modules/@types",
|
|
"./src/types"
|
|
],
|
|
"useDefineForClassFields": true,
|
|
"useUnknownInCatchVariables": false,
|
|
"paths": {
|
|
"@/*": [
|
|
"./src/*"
|
|
],
|
|
"@api/*": [
|
|
"./src/core/api/*"
|
|
],
|
|
"@core/*": [
|
|
"./src/core/*"
|
|
],
|
|
"@generated/*": [
|
|
"./src/generated/*"
|
|
],
|
|
"@hosts/*": [
|
|
"./src/hosts/*"
|
|
],
|
|
"@integrations/*": [
|
|
"./src/integrations/*"
|
|
],
|
|
"@packages/*": [
|
|
"./src/packages/*"
|
|
],
|
|
"@services/*": [
|
|
"./src/services/*"
|
|
],
|
|
"@shared/*": [
|
|
"./src/shared/*"
|
|
],
|
|
"@utils/*": [
|
|
"./src/utils/*"
|
|
]
|
|
}
|
|
},
|
|
"include": [
|
|
"./src/**/*"
|
|
],
|
|
"exclude": [
|
|
"node_modules",
|
|
".vscode-test",
|
|
"webview-ui",
|
|
"src/test/e2e/**/*",
|
|
"src/test/scenarios/**/*",
|
|
"src/test/cline-core-vitest-stub.ts",
|
|
"src/test/bun-test-preload.ts"
|
|
]
|
|
}
|