Repository navigation
fix(remote): resolve the spawn cwd, the node manager dir, the vault host and the scrollback seed - #17952
Conversation
|
Warning Review limit reachedNext included review available in 1 minute. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (25)
📝 WalkthroughWalkthroughThe change removes Merge Risk: 🟡 Moderate · up to The PR improves remote workspace and terminal handling, but agent launches may still be blocked for valid worktree setups when the workspace path is unavailable on the relay host. Request-derived working directories also lack demonstrated ownership or containment checks, leaving a bounded security risk. Merge should wait for the launch-refusal fix and explicit path-authorization confirmation. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and covers the changes, rationale, linked issues, implementation notes, caveats, and verification results. It does not use all template headings or provide visual proof, but the core required information is present. ✨ Finishing Touches 💡 1📝 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 009948b1-4d97-4fea-8f16-e3ef54a58ae4
📒 Files selected for processing (24)
src/main/ipc/pty-buffer-snapshot-dispatch.test.tssrc/main/ipc/pty/ipc/serialize-buffer.tssrc/main/ipc/pty/runtime/controller-deps.tssrc/main/ipc/pty/runtime/operations.tssrc/main/ipc/pty/session.tssrc/main/runtime/orca-runtime-maybe-hydrate-headless-from-renderer.tssrc/main/runtime/orca-runtime-serialize-terminal-buffer-from-available-state.tssrc/main/runtime/orca-runtime-tests/headless-snapshots.spec.tssrc/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-09.spec.tssrc/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-10.spec.tssrc/main/runtime/orca-runtime-visible-snapshot-preview.tssrc/main/runtime/runtime-pty-controller-contract.tssrc/main/ssh/ssh-remote-node-probe-script.tssrc/main/ssh/ssh-remote-node-resolution.test.tssrc/main/ssh/ssh-remote-node-resolution.tssrc/preload/api/pty-api.tssrc/preload/api/pty-bridge-part-2.tssrc/relay/pty-handler-spawn-cwd.test.tssrc/relay/pty-handler.tssrc/relay/pty-spawn-cwd.tssrc/renderer/src/components/right-sidebar/ai-vault-host-scope.test.tssrc/renderer/src/components/right-sidebar/ai-vault-host-scope.tssrc/renderer/src/components/terminal-pane/pty-buffer-serializer.tssrc/renderer/src/components/terminal-pane/pty-connection/pane-serializer-register.ts
💤 Files with no reviewable changes (1)
- src/renderer/src/components/terminal-pane/pty-buffer-serializer.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Relay spawn cwd (#15296) —
resolveRelaySpawnCwdinsrc/relay/pty-spawn-cwd.tsresolvesexplicit cwd → worktree path (via splitWorktreeIdForFilesystem) → ORCA_WORKSPACE_ROOT → host default, with existence checked on the relay host. A singlerequireRelaySpawnCwdhelper feeds both the admission fence and the native spawn, so the two can never disagree on the directory. The refusal is correctly narrow: only a TUI-agent spawn for a folder workspace whose root is absent/unavailable on the relay throws; plain shells and missing worktree paths (Windows relay → WSL) still fall through to the host default. - mise Node discovery (#11733) — the NVM dotfile scrape is generalized into a parameterized
orca_dotfile_dirsinssh-remote-node-probe-script.ts, and mise is now driven off${MISE_DATA_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/mise}plus the scrape. The extracted script is exercised end-to-end through/bin/shagainst a fakeHOMEin the tests. - AI Vault host scope (#13713) —
useAiVaultExecutionHostScopenow defaults an unresolvable workspace host toALL_EXECUTION_HOSTS_SCOPEinstead oflocal, while no-workspace and local cases are unchanged; the effect self-corrects once the store hydrates. - Scrollback seed (#6106) —
altScreenForcesZeroRowsis removed end-to-end (renderer opts, IPC/preload shape, runtime contract, all four call sites), so the serializer always honorsscrollbackRowsand hydration no longer drops the pre-TUI shell history.
I traced each branch of the cwd resolver against its tests (folder root present/absent, worktree path present, no workspace, explicit cwd, plain-shell fallthrough), verified the folder:/worktree:/plain-id parsing paths, and confirmed the altScreenForcesZeroRows removal left no prod references behind. The changes are coherent, the refusal semantics match the documented intent, and the tests exercise the real paths rather than asserting trivially.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Run failed. View the logs →
|
…rollback honestly #15296 relay: a folder workspace id (`folder:<uuid>`) carries no path, so the worktree-id split yielded nothing and $HOME silently won. Resolve the spawn cwd through worktreeId -> ORCA_WORKSPACE_ROOT -> host default, and refuse an agent spawn outright when a folder workspace names a root this host cannot resolve. #11733 ssh: generalize the NVM dotfile scrape into `orca_dotfile_dirs` and drive mise off `MISE_DATA_DIR` / `XDG_DATA_HOME` instead of a hardcoded `$HOME/.local/share/mise`. #13713 ai-vault: an unresolvable workspace host is `unverifiable`, not local. Widen the default scope to every host rather than scanning the client's own history and reporting "No agent sessions found". #6106 terminal: hydration asked the renderer for `scrollback: 0` while an alt-screen TUI was up, which drops the normal buffer's shell history rather than the TUI bytes. Drop the flag; readers already split the two buffers apart.
…ution host Three findings from review of the spawn-cwd resolver, all the same shape: a path question answered against the wrong host, or with the wrong key. - resolveRelaySpawnCwd refused an agent launch whenever a folder workspace named a root that did not stat on the relay. But relayHostDirectoryExists stats the relay's *own* filesystem, and the relay supports WSL shells, so a folder workspace on a Windows relay launching into WSL now threw where it previously spawned -- contradicting the function's own doc comment, which says an absent path for that exact host pair is a miss, not a refusal. Thread the shell's execution host in and demote the refusal to a miss when the spawn does not run on the relay's filesystem. - requireRelaySpawnCwd's doc claims both call sites route through one resolver so the fence can never be keyed on a directory the spawn won't use, but the fence key was still computed with the non-stripping splitWorktreeId while the cwd used splitWorktreeIdForFilesystem. For a `::workspace:<uuid>` id those disagree by construction, in adjacent lines: the removal fence guarded a path no spawn ever enters. Same defect in shutdownForWorktreePath and the revive path; all three now use the filesystem split. - The remote Node probe expanded `$HOME` and `~/` prefixes out of a dotfile assignment but not `$XDG_DATA_HOME`, so `MISE_DATA_DIR=$XDG_DATA_HOME/...` was used as a literal directory name. Add the case arm, defaulting to the POSIX `$HOME/.local/share` the seed value already uses -- sshd's exec channel usually has no XDG_DATA_HOME at all.
cab2fb1 to
8f04715
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior review the branch was rebased and one refinement commit (8f04715) landed on top of the original work.
- WSL guest execution-host demotion —
resolveRelaySpawnCwdgained anexecutesOnRelayFilesystemflag. When the resolved shell is WSL (isRelayWslShell), the relay's ownstatSynccannot see a guest path, so the agent refusal is demoted to a miss rather than failing an agent launch thewsl.exewrapper would havecd-ed into correctly.resolveRelaySpawnShellmirrorsspawnAfterAdmission's shell resolution (non-throwing on unsupported overrides, which fail the spawn later anyway). splitWorktreeIdForFilesystemfence unification — fence bookkeeping ingetPtysByWorktreePath,spawnAfterAdmission, and revive now uses the filesystem split everywhere, so the admission fence is keyed on the same directory the spawn enters rather than a::workspace:<uuid>instance suffix.$XDG_DATA_HOMEdotfile expansion —orca_dotfile_dirsnow expands an unbraced$XDG_DATA_HOMEassignment (e.g.export MISE_DATA_DIR=$XDG_DATA_HOME/custom-mise) to${XDG_DATA_HOME:-$HOME/.local/share}/custom-mise; braced forms already expand naturally.isFlattenedNodePtyLoaderMessagecleanup and thepty-bridge-part-2.ts→pty-bridge-stream-and-serialization.tsrename — no behavior change.
I traced the WSL demotion against windows-shell-args.ts (which returns Windows home as the effective cwd and injects the Linux cd into wsl.exe shellArgs), confirmed resolveRelaySpawnShell matches the spawn path's shell resolution, and verified the $XDG_DATA_HOME case order and fallback against the two new /bin/sh-executed tests. The demotion is narrowly scoped (only the refusal case, only when a TUI agent is present), and explicit cwd still short-circuits before any host-filesystem question.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Rebased onto current The one failing check was Three findings addressed in 8f04715, all the same shape: a path question answered against the wrong host, or with the wrong key. 1.
|
…ost and the scrollback seed (stablyai#17952) * fix(remote): resolve workspace cwd, mise Node, host scope, and TUI scrollback honestly stablyai#15296 relay: a folder workspace id (`folder:<uuid>`) carries no path, so the worktree-id split yielded nothing and $HOME silently won. Resolve the spawn cwd through worktreeId -> ORCA_WORKSPACE_ROOT -> host default, and refuse an agent spawn outright when a folder workspace names a root this host cannot resolve. stablyai#11733 ssh: generalize the NVM dotfile scrape into `orca_dotfile_dirs` and drive mise off `MISE_DATA_DIR` / `XDG_DATA_HOME` instead of a hardcoded `$HOME/.local/share/mise`. stablyai#13713 ai-vault: an unresolvable workspace host is `unverifiable`, not local. Widen the default scope to every host rather than scanning the client's own history and reporting "No agent sessions found". stablyai#6106 terminal: hydration asked the renderer for `scrollback: 0` while an alt-screen TUI was up, which drops the normal buffer's shell history rather than the TUI bytes. Drop the flag; readers already split the two buffers apart. * fix(remote): stop the relay answering host questions for a guest execution host Three findings from review of the spawn-cwd resolver, all the same shape: a path question answered against the wrong host, or with the wrong key. - resolveRelaySpawnCwd refused an agent launch whenever a folder workspace named a root that did not stat on the relay. But relayHostDirectoryExists stats the relay's *own* filesystem, and the relay supports WSL shells, so a folder workspace on a Windows relay launching into WSL now threw where it previously spawned -- contradicting the function's own doc comment, which says an absent path for that exact host pair is a miss, not a refusal. Thread the shell's execution host in and demote the refusal to a miss when the spawn does not run on the relay's filesystem. - requireRelaySpawnCwd's doc claims both call sites route through one resolver so the fence can never be keyed on a directory the spawn won't use, but the fence key was still computed with the non-stripping splitWorktreeId while the cwd used splitWorktreeIdForFilesystem. For a `::workspace:<uuid>` id those disagree by construction, in adjacent lines: the removal fence guarded a path no spawn ever enters. Same defect in shutdownForWorktreePath and the revive path; all three now use the filesystem split. - The remote Node probe expanded `$HOME` and `~/` prefixes out of a dotfile assignment but not `$XDG_DATA_HOME`, so `MISE_DATA_DIR=$XDG_DATA_HOME/...` was used as a literal directory name. Add the case arm, defaulting to the POSIX `$HOME/.local/share` the seed value already uses -- sshd's exec channel usually has no XDG_DATA_HOME at all.

Four issues where a remote environment detail was resolved wrongly. Three are substitution-on-absence — the pattern #17945 and #17948 have been closing: a client-side or unresolvable answer treated as licence to pick a default.
#15296 — an agent spawning in
$HOMEinstead of the workspacepty-handler.ts:1626and:1726both didparams.cwd || resolveDefaultCwd(), andresolveDefaultCwdreturns$HOME. When the client sends no explicit cwd, the relay had two other pieces of workspace identity in the same request and consulted neither:worktreeIdandenv.ORCA_WORKSPACE_ROOT. AndsplitWorktreeIdreturnsnullfor afolder:<uuid>id — no::— so a folder workspace has no path anywhere in the relay's reach and$HOMEwon silently.The client does deliver the root:
ORCA_WORKSPACE_ROOTis set on both spawn paths and survives to the relay throughbuildSshPtySpawnEnv, which strips nothing.New
resolveRelaySpawnCwd, called from a single helper used by both the admission fence and the native spawn — so the fence can never be keyed on a directory the spawn will not use. Order: explicitcwd→ worktree path (viasplitWorktreeIdForFilesystem, which strips the::workspace:<uuid>suffix — the #17948 collision) →ORCA_WORKSPACE_ROOT→ host default. Existence is checked on the relay host, because the relay is the execution host.The refusal is deliberately narrow: when a folder workspace names a root that does not resolve here and the spawn carries
launchAgent, the relay throws rather than spawning. A worktree path absent on the relay host (a Windows relay launching into WSL, where the wrapper owns thecd) still falls through as before, and a plain shell is never refused. Only the agent case — the one that can do real damage — refuses.Honest caveat: the reporter's exact fallback directory was not reproduced — their
OLDPWD/PWDevidence is also consistent with a login shell's own rccd-ing after a correct spawn. The code defect they name is real and is what is fixed. Also noted, not fixed:createDesktopTerminallacks the?? workspace.pathfallback its background sibling has, a latent second source of an undefined cwd that the renderer currently covers.#11733 —
MISE_DATA_DIRappeared nowhere in the repoNVM was the only manager whose custom directory was honoured — it read
${NVM_DIR:-…}and scrapedNVM_DIR=out of five dotfiles. mise got two hardcoded$HOME/.local/share/mise/…lines.The dotfile scrape is the load-bearing half: the probe runs over sshd's exec channel under
/bin/sh -cwith no profile sourced, so a bare${MISE_DATA_DIR:-…}would have no-opped for the reporter — it is set in their~/.zshrc, which that shell never reads.Generalised the NVM scrape into a POSIX
orca_dotfile_dirs <VAR> <seed>function reused by both managers rather than duplicated, and drove mise off${MISE_DATA_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/mise}plus the scrape.Three of those tests write a real fake
nodeinto a tmpHOMEand execute the generated script through/bin/sh. Left alone but worth filing: the local resolver has the identical hardcode, and the login-shell fallback takesstdout.split('\n')[0]with no banner fencing — the SSH analogue ofbuildWslCapturedLoginShellCommand, which has no SSH equivalent.#13713 — the title is a paraphrase; it is the AI Vault empty state
The string in the screenshot is the AI Vault empty state, not a terminal error.
ai-vault-host-scope.ts:39didactiveExecutionHostScope ?? LOCAL_EXECUTION_HOST_ID, and the resolver returnsnullwhen the worktree is missing from the client'sworktreesByRepoindex. That registry is client-side, so its silence isunverifiable— but it was coerced tolocal, and main then scanned the desktop's own~/.claude. A user whose sessions all live on an SSH box gets a clean, error-free, banner-free empty list.Now "no workspace selected" keeps
local; "workspace named, host unresolvable" defaults toALL_EXECUTION_HOSTS_SCOPE, which already fans out to every host. Self-corrects once the store hydrates.The thread's own theory was ruled out:
isRemoteSessionInScopecannot cause this —scopePathsis purely additive on top of an unscoped recency top-N, so a scope mismatch can hide old sessions but never produce zero.Also noted: the empty state guards on
!errorbut not onblockingAiVaultScanIssue, so a real "relay not ready" renders as both a banner and "No agent sessions found" — which is what makes this class near-undiagnosable from a screenshot.#6106 — an option that did the opposite of its documented purpose
pane-serializer-register.ts:46produced{ scrollback: 0 }whenaltScreenForcesZeroRowswas set and the pane was on the alternate screen. ButSerializeAddonemits the normal buffer honouringscrollbackand then appends?1049hplus the alt buffer, and readers split them apart again. Soscrollback: 0never suppressed "transient TUI bytes" — it dropped precisely the normal-buffer shell history the seed exists to carry.Hydration re-arms on model dispose/demote, both of which fire on SSH attach, so a re-hydration while Codex is on the alt screen permanently strips pre-TUI scrollback from main's model. Every later hidden restore then legitimately paints only the TUI.
The serializer now always honours
scrollbackRows, and the meaningless flag is removed end-to-end — renderer opts, runtime contract, preload/IPC shape, all four call sites — so nothing is left claiming an option that no longer exists.Two further contributors not touched, both larger: the relay-replay fallback emits
CSI 3 J(which erases xterm's scrollback) before rewriting only the 100 KiB tail; and the remote-runtime wire foldsscrollbackAnsiintodataand never transmits it — a capability-negotiated wire change.Verification
Fixes #15296, #11733, #13713, #6106