fix(workspace-fs): allow saving files outside the workspace root
Merged
SA
1mo ago+50+50+01234567890123456789-67-67-01234567890123456789
Summary
- Saving a file from the UI failed when the file was outside the workspace root, even though the editor can open it since #7897.
writeFileinpackages/workspace-fs/src/fs.tsno longer checks root containment. It keeps the atomic write, writes through symlinks, keeps the file mode, and keeps theifMatchconflict check.- Create directory, create unique entry, delete, move and copy stay confined to the root.
Why this is safe
The host-service caller can already read any host file and run any command in a terminal, so write confinement was not a real boundary. Related history: #7828 (reverted in #7834), #7897.
Tests
- Flipped 2 unit tests (
fs.test.ts) and 2 host-service bug-hunt integration tests from "rejects" to "writes". workspace-fs: 45 pass; host-service bug-hunt suites: 35 pass; typecheck clean in both packages.- Not verified by saving in the running desktop app.
Summary by cubic
Allows saving files that live outside the workspace root, or through an in-root symlink pointing outside, which the UI editor previously rejected with "Path is outside workspace root". writeFile in packages/workspace-fs now follows the read policy: the same caller can already read any host file and run terminal commands, so write confinement was not a real boundary.
- Removes the root-containment check from
writeFile; create, delete, move, and copy stay confined to the root. - Keeps atomic writes, symlink resolution, file mode preservation, and the
ifMatchconflict check. - Updates unit and integration tests to expect writes instead of rejections.
Summary by CodeRabbit
- Behavior Changes
- File writes can now target paths outside the workspace, including paths reached through directory symlinks. Existing write options and revision checks remain available.
- Structural changes, such as creating or removing filesystem entries, remain confined to the workspace.