fix(desktop): open terminal links to files outside the workspace root

Closed
QF
5mo ago
+137-11

Closes #5510

Ctrl+clicking a terminal path to a file outside the worktree root opened the viewer as "File not found": detection validated it with an unjailed stat, but the viewer read through the workspace-fs jail.

filesystem.readFile now reads out-of-root absolute paths through an unjailed readFileAtPath (extracted from the jailed readFile), matching what detection already validated. In-root reads are unchanged.

Editing/saving an out-of-root file still goes through the jailed write and errors — left out of scope (viewing only).

Test: readFileAtPath reads a path the jailed readFile rejects (packages/workspace-fs/src/fs.test.ts).


Open in Stage

Summary by cubic

Fixes opening terminal links to files outside the workspace root. The viewer can now opt in to unjailed reads for explicit absolute paths, so out-of-root files open instead of "File not found"; all other reads stay jailed.

  • Bug Fixes
    • Gate out-of-root reads behind allowOutsideRoot on the desktop filesystem.readFile; only the viewer sets it. In-root reads remain jailed and symlink escapes from within the root still error.
    • Added readFileAtPath in @superset/workspace-fs and readWorkspaceFile to route absolute out-of-root paths to an unjailed read; added tests. Writes remain jailed.

Summary by CodeRabbit

  • New Features
    • Added optional support to read files from absolute paths outside the workspace root (opt-in).
    • File viewer content can now open referenced locations that fall outside the configured workspace root.
  • Bug Fixes
    • Improved reliability when reading files affected by root-jail and symlink/path validation edge cases.
    • Reads now correctly succeed for valid absolute paths while preserving existing workspace-scoped safeguards by default.
  • Tests
    • Expanded coverage for absolute-path reads and outside-root fallback behavior.