Repository navigation
fix(terminal): allow terminals to spawn outside the worktree (#7685) - #7750
Conversation
The startup-cwd guard threw 'Terminal cwd must be inside the selected worktree' whenever a requested/inherited cwd resolved outside the worktree root. That gate landed incidentally with the file-explorer 'open in terminal' feature and collided with split-pane cwd inheritance: after 'cd ..', splitting a terminal inherited the out-of-worktree cwd and the guard killed the new pane with an error banner. The gate provided no real containment (a shell spawned at the worktree root can cd anywhere immediately), so remove it and spawn at the resolved cwd. Delete the now-dead local realpath canonicalizer that only existed to soften the gate. Co-authored-by: Orca <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthroughChangesTerminal startup working-directory resolution was changed to no longer enforce that a requested cwd stays inside the selected worktree and no longer performs symlink canonicalization. The shared resolver functions dropped their Sequence Diagram(s)See hidden artifact diagrams above. Related PRs: None specified. Suggested labels: terminal, refactor, breaking-change Suggested reviewers: None specified. 🐰 A canonicalizer hopped away today, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
After #7750 removed the containment guard, the residual #7239 failure mode is a persisted/inherited startupCwd whose directory no longer exists: every spawn dies with the provider's missing-directory error. Fresh local renderer spawns now opt in (cwdFallback: 'worktree') to recover at the workspace root with a generic in-terminal notice; reattach, SSH, remote-runtime, runtime/API and mobile callers keep exact cwd semantics, and existing directories — including outside the worktree (#7685) — spawn as requested. Co-authored-by: Orca <[email protected]>
) After #7750 removed the containment guard, the residual #7239 failure mode is a persisted/inherited startupCwd whose directory no longer exists: every spawn dies with the provider's missing-directory error. Fresh local renderer spawns now opt in (cwdFallback: 'worktree') to recover at the workspace root with a generic in-terminal notice; reattach, SSH, remote-runtime, runtime/API and mobile callers keep exact cwd semantics, and existing directories — including outside the worktree (#7685) — spawn as requested. Co-authored-by: Orca <[email protected]>
…i#7685) (stablyai#7750) Co-authored-by: Orca <[email protected]>
…ablyai#7847) After stablyai#7750 removed the containment guard, the residual stablyai#7239 failure mode is a persisted/inherited startupCwd whose directory no longer exists: every spawn dies with the provider's missing-directory error. Fresh local renderer spawns now opt in (cwdFallback: 'worktree') to recover at the workspace root with a generic in-terminal notice; reattach, SSH, remote-runtime, runtime/API and mobile callers keep exact cwd semantics, and existing directories — including outside the worktree (stablyai#7685) — spawn as requested. Co-authored-by: Orca <[email protected]>
Summary
Fixes #7685 — right-click → Split Terminal created a dead pane with the banner "Terminal cwd must be inside the selected worktree." whenever the source shell had navigated outside the worktree root (e.g. after
cd ..).Root cause
A terminal startup-cwd containment guard (
resolveTerminalStartupCwd) throws whenever a requested/inherited cwd resolves outside the worktree root. That guard was added incidentally alongside the file-explorer "Open in Terminal" feature (#7029) and sits on the sharedpty.spawnpath — so it also rejects split-pane cwd inheritance (a feature since April). Aftercd .., splitting inherits the out-of-worktree cwd, the guard throws, and the new pane dies.The guard provided no real containment: a shell spawned at the worktree root can
cdanywhere immediately, so restricting only the startup cwd blocked a legitimate feature without adding a security boundary. Terminals should be allowed to open/split outside the worktree.Fix
resolveTerminalStartupCwdnow resolves the requested cwd (relative paths still anchor to the worktree root;..normalized) and returns it without throwing.canonicalizePathplumbing and deleted the deadterminal-cwd-realpathmodule that only existed to soften the gate.Supersedes the clamp approach in
#7728(which forced the split back to the worktree root — the opposite of the desired behavior).Testing
terminal-startup-cwd.test.ts+orca-runtime-terminal-cwd.test.tsto assert out-of-worktree cwds now resolve/spawn (they fail if the throw is reintroduced). Touched suites: 235 passing. Typecheck + lint clean.pwdconfirms it started at the out-of-worktree directory.Made with Orca 🐋