You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ENHANCEMENT] Separate file approval targets from display paths #2467
File approval messages combine display paths with filesystem information. A path formatted for the chat can lose information that a filesystem operation needs. The approval API should make the intended file target explicit.
Context
This affects file tools on Windows and POSIX, including single-file, batch, and legacy requests. PR #2454 changes workspace-root matching. This issue tracks the broader path contract separately from that PR and its local compatibility guards.
Desired behavior
Permission checks and filesystem operations must use the same resolved target. Display formatting must not affect access decisions. Users should keep the current readable paths in the interface.
Acceptance criteria
Carry typed filesystem targets separately from display paths and generic message content.
Compute each target in the file tool and use that target for both authorization and the operation.
Check every target in a batch. Ask for approval if required target information is missing, invalid, or incomplete.
Cover all applicable file tools and their single, batch, and legacy entry points.
Keep existing read/write permission boundaries, exclusion ordering, and protected-file policy.
Cover POSIX literal filename characters, Windows drives and UNC shares, and symlink workspace roots with focused tests.
Verify the complete route from tool arguments through approval to filesystem access. Keep UI formatting independent.
Scope
Implement the shared target/display contract as a focused follow-up. PR #2454 retains its workspace-root matching scope and includes only local measures against regressions. This issue remains separate from that PR.
Request checklist
I searched the existing Issues and Discussions for duplicates.
This describes a specific problem with clear context and impact.
Repro on main (2a082ce5a), macOS:getReadablePath posix-normalizes backslashes, which on POSIX are literal filename characters. With allowedWriteFiles: ["my/**"], an editedExistingFile ask for the file my\file is displayed as my/file and auto-approved; matching the actual target my\file returns ask. #2454's hasConflictingReadPaths guard covers reads only; write tools carry no native target at all.
Approach: add a typed fileTargets field to AutoApprovalContext (already threaded askApproval → Task.ask → checkAutoApproval for the DCG verdict). Each tool computes its targets from the same resolved path it passes to the filesystem, and checkAutoApproval uses them for allowlist and outside-workspace decisions. ClineSayTool and the webview keep the readable display path unchanged.
Planned PRs (each under the 500-line mutation budget):
Contract + read_file single/batch; remove hasConflictingReadPaths and the content-as-target reliance.
apply_patch (per-file targets, including move source and destination), generate_image, list_files, search_files.
Fail closed: missing or invalid targets on a file-tool ask route to the user; drop display-path matching; route tests from tool arguments through approval to filesystem access on POSIX and Windows (drives, UNC, symlinked roots).
Existing read/write boundaries, exclusion order and the protected-file policy stay as they are.
Activity
kanchinadd98 commentedon Nov 22, 2026
I'd like to take this one.
Repro on main (
2a082ce5a), macOS:getReadablePathposix-normalizes backslashes, which on POSIX are literal filename characters. WithallowedWriteFiles: ["my/**"], aneditedExistingFileask for the filemy\fileis displayed asmy/fileand auto-approved; matching the actual targetmy\filereturnsask. #2454'shasConflictingReadPathsguard covers reads only; write tools carry no native target at all.Approach: add a typed
fileTargetsfield toAutoApprovalContext(already threadedaskApproval→Task.ask→checkAutoApprovalfor the DCG verdict). Each tool computes its targets from the same resolved path it passes to the filesystem, andcheckAutoApprovaluses them for allowlist and outside-workspace decisions.ClineSayTooland the webview keep the readable display path unchanged.Planned PRs (each under the 500-line mutation budget):
read_filesingle/batch; removehasConflictingReadPathsand thecontent-as-target reliance.write_to_file,apply_diff,edit,search_and_replace,edit_file(fixes the repro above). Will rebase around U9 re cut, rung 3 of 4: diff view publish, apply patch and the three edit tools (492 counted lines, 102 selector ranges, headroom 8) #2444, since it only changes the approval call.apply_patch(per-file targets, including move source and destination),generate_image,list_files,search_files.Existing read/write boundaries, exclusion order and the protected-file policy stay as they are.
fix(auto-approval): decide read_file approval on its file targets (Zo…