Repository navigation
fix(ai-vault): resume sessions whose worktree was deleted - #24236
Conversation
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)📝 WalkthroughWalkthroughCodex resume startup commands now specify the launch working directory. Before an SSH session resumes, the flow checks whether its recorded working directory exists on the remote host. If the path is missing, the flow clears the session’s working directory and resume command before building the startup. Unit and end-to-end tests cover missing directories and resume command arguments. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to Some SSH Codex resumes may still prompt for their recorded folder. This is a bounded issue that can be fixed before merge or accepted for follow-up. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The recovery preserves important safeguards: an unreachable host does not trigger directory fallback, and directory-dependent agents are excluded. A remaining ownership gap is that the selected target is validated before the remote check but not checked again before launch. Wrong-host execution has not been established. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation Issue Resolution Apply the missing-directory fallback to the remaining supported Agent Session History resume paths, including copied commands and drag-and-drop. When the recorded directory is missing, use the selected target worktree or prompt. Add tests for those paths.
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.
✅ No new issues found.
Reviewed changes — full read of the single commit c044ba8 and its surrounding seams.
- SSH existence gate for resume —
dropDeletedSshResumeCwd(ai-vault-session-resume-preparation.ts) probes the owning SSH host withwindow.api.fs.pathExists, and only a definite miss drops the sessioncwdplus the scanner-builtresumeCommand. A thrown probe (host lost) leaves the session untouched, matching thelive/unverifiable/exitedboundary. - Rebuild without
cd— droppingresumeCommandmakesbuildAiVaultResumeForWorktreeskip its remote early-return and rebuild for the target host, so the terminal opens at the workspace root. - Codex
-c tui.resume_cwd=current— new opt-inresumeInLaunchCwdonbuildAgentResumeStartupPlan, inserted beforeresume, so the account-unverified fallback indropAgentResumeArgvFromCommandstill strips only the resume argv. - Tests — unit coverage for the gone-folder rebuild and the can't-answer no-op, plus a Docker SSH e2e asserting the delivered argv and the real fake-codex
pwd.
Verified locally: the four changed unit files (47 tests) and five adjacent resume files (172 tests) all pass. Two mechanical notes, neither actionable:
getSshTargetIdForExecutionHostdecodes the encoded host id, which matches how providers are registered by rawtargetIdinssh-relay-session.ts:1230— the gate does reach the right provider.resumeInLaunchCwd: truelives in the shared AI Vault builder, so it also reaches the copy-command and drag-and-drop repin paths, not only Agent Session History as the PR body says. This is benign: existing-folder SSH resumes still take the scanner command with no-c, and local resumes already open at the session cwd.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — incremental re-review of 6be104b, the only commit since the prior pullfrog review of c044ba8.
- Folder-scoped agents keep their recorded cwd —
dropDeletedSshResumeCwdnow returns the session untouched forkimiandmusethrough a newRESUMES_ONLY_IN_RECORDED_CWDset, so an SSH resume whose recorded folder is gone keeps the honestcdfailure instead of relaunching from the workspace root. This matches the existing scoping contract already documented atsrc/shared/ai-vault-resume-command.ts:207(Kimi is work-dir-scoped) and:215(Muse resume is workspace-scoped), and it resolves the greptile P1 from the prior round. - Falsifiable regression test — the new case stubs
fs.pathExiststofalseand asserts the kimi session is returned by object identity; removing the guard makes it fail, so it can actually catch a regression.
Verified locally: the five changed/adjacent unit files pass (50 tests), including the new guard case. No blocking issues.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — incremental re-review of 9ee2b59, the only commit since the prior pullfrog review of 6be104b.
- Centralized the resume session shape — exported
AiVaultResumeCommandSessionfromai-vault-resume-command.tsand reused it as the parameter and return type ofdropDeletedSshResumeCwd, replacing the bespoke generic constraint. The sole caller and the tests still typecheck; the type-only import introduces no runtime coupling. - Aligned the launch-actions type —
buildResumeStartupnow names the exported type instead of re-deriving it throughParameters<...>, an equivalent and more readable spelling. - Added regression tests — a live SSH session is returned by identity with the exact
pathExistsarguments, and a local session is never probed. Both fail if the short-circuit or the live-folder branch regresses.
Verified locally: the two changed test files pass (23 tests) and pnpm tc:web is clean. Known gaps remain as the author documented; none are introduced here.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
SSH resumes typed `cd <deleted folder> &&`, so the agent never started, and Codex preselected the deleted folder when resumed anywhere else. Fixes stablyai#17745 Co-authored-by: kaluli123123 <[email protected]>
Kimi resumed from another folder opens a new empty session under the same id.
… shape it feeds Replaces the generic `T | Omit<T,'resumeCommand'>` return (and the `Parameters<typeof ...>` leak it forced onto the launch hook) with the exported session shape every resume builder already takes. Adds the two uncovered branches: a live SSH folder keeps its scanner command, and a local session is never probed at all.
9ee2b59 to
76b51e4
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Apply the Codex resume setting to saved SSH commands. · ai-vault-resume-command.ts:144-146
src/renderer/src/lib/ai-vault-resume-command.ts:144-146
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winApply the Codex resume setting to saved SSH commands.
With no command override, a remote Codex session with non-null
codexHomeand a savedresumeCommandreturns the stored command before the resume plan addstui.resume_cwd=current. Codex can still prompt for its recorded folder. When that folder exists, the missing-directory preparation preserves this path. Build this case with the Codex resume plan, or add the setting using the remote host’s command syntax.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
9ed14136-4e3a-4f6d-9df8-91d34b21adba
📥 Commits
Reviewing files that changed from the base of the PR and between 9ee2b592a4cbe9b6cd0f4ac5f0316e9d72940358 and 76b51e4.
📒 Files selected for processing (3)
src/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.tssrc/renderer/src/lib/ai-vault-resume-command.test.tssrc/renderer/src/lib/ai-vault-resume-command.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
nwparker
left a comment
There was a problem hiding this comment.
Targeted SSH-host stat discards stale cwd only after confirmed absence, retains transport/permission failures and protects folder-scoped agents. 52 tests, web typecheck and quality gate pass. Adds one SSH round trip only on explicit resume.
Required PR Checks verify passed on this exact commit: 76b51e4.
|
Pre-merge bot audit on 76b51e4: confirmed the outside-diff Codex finding. A saved remote command still bypasses tui.resume_cwd=current when its recorded folder exists; copy and drag retain a deleted cwd. These paths already exist on main and are unchanged here. This PR fixes Resume in New Tab: confirmed SSH absence clears both cwd and the saved command, then rebuilds in the chosen workspace with the Codex setting, including sessions with a non-null Codex home. Unknown host results and Kimi/Muse retain their behavior. The copy/drag paths remain known gaps outside this fix. All inline threads are resolved. The generic docstring-coverage suggestion is declined under AGENTS.md's concise, non-obvious-comment policy. Focused validation passed 52 tests, and current CI checks passed. |
…how remote hit previews Since #27214 every SSH session is retagged runtime:<env>, so the #24236 check that drops a deleted cwd (and its prebuilt `cd`) before resuming only ever ran for the legacy ssh: spelling. Resume on a paired or SSH-managed server therefore ran `cd '<deleted folder>' &&` and failed. The check now covers runtime hosts too, probing the folder with the existing files.browseServerDir RPC; only a definite "missing" answer drops the cwd, so an older or unreachable host keeps today's behaviour. Search-hit cards carry no turns and remote hosts cannot reparse a first prompt, so a server session found through search showed "No first prompt" and "No conversation preview". Hits now borrow the preview of their scanned history row.
…how remote hit previews (#33965) Since #27214 every SSH session is retagged runtime:<env>, so the #24236 check that drops a deleted cwd (and its prebuilt `cd`) before resuming only ever ran for the legacy ssh: spelling. Resume on a paired or SSH-managed server therefore ran `cd '<deleted folder>' &&` and failed. The check now covers runtime hosts too, probing the folder with the existing files.browseServerDir RPC; only a definite "missing" answer drops the cwd, so an older or unreachable host keeps today's behaviour. Search-hit cards carry no turns and remote hosts cannot reparse a first prompt, so a server session found through search showed "No first prompt" and "No conversation preview". Hits now borrow the preview of their scanned history row.

ELI5
You can reopen an old agent chat from Agent Session History. If the folder that chat ran in has since been deleted, Orca should reopen the chat in the workspace you're in now. On a remote (SSH) machine it failed outright instead: Orca tried to step into the deleted folder first, the shell said "no such file or directory", and the agent never started. Codex made it worse by stopping to ask which folder to use, with the deleted one already picked.
Now Orca asks the remote machine whether that folder is still there. Only a clear "it's gone" makes Orca skip it and open the chat in your current workspace instead; if the machine can't be reached, Orca changes nothing, because an unreachable machine is not proof that a folder was deleted. And it tells Codex to stay in the folder Orca opened rather than ask.
What Changed
cd '<deleted folder>' && codex resume …into the new terminal. The shell printedNo such file or directoryand the agent never started.-c tui.resume_cwd=current, so Codex stays in the folder Orca opened.How it works:
fs.pathExistscheck on that host. Only a definite "not found" drops the recorded folder and the command the remote scanner built (the one with thecd). The resume is then rebuilt with nocdand no start folder. If the host can't answer, for example because the connection dropped, nothing changes.buildAgentResumeStartupPlantakes a new opt-in,resumeInLaunchCwd, and only the AI Vault resume builder (buildAiVaultResumeForWorktree) sets it, so it reaches the Resume button, the copied command and the drag-and-drop repin — but never sleep/wake or cold restore. On the copy and drag paths the terminal already opens in the recorded folder, so the setting selects the folder Codex would have picked anyway; it only changes the outcome when Orca deliberately opened somewhere else. The setting goes beforeresume <id>, so the existing fallback that strips the resume arguments from a command still strips only that part.Local resumes needed no change to the folder handling. Main already opens at the workspace root when a terminal's start folder is gone (#7847, #13420), which is why local Claude resumes already worked.
Why
docs/reference/ssh-execution-boundary.md).cdbuilt into the scanner's command.Linked Issue
Fixes #17745
Visual Proof
Docker SSH host, hidden Orca window, Resume in New Tab on a Codex session whose folder doesn't exist. A stand-in
codexon the host prints the folder it runs in and the arguments it received.Before:
After:
Testing
Ran the flow above against a Docker SSH host (Linux) from macOS, before and after the fix.
Checked the Codex prompt against the real Codex 0.157.1: it appears when resuming from another folder and pre-selects the recorded folder even after that folder is deleted.
-c tui.resume_cwd=currentremoves it. Codex 0.40.0 and 0.140.0 accept the setting without error.Unit tests:
cd, no start folder, and the Codex setting.codexlaunch when the setting is present.E2E:
ORCA_E2E_SSH_DOCKER=1 pnpm exec playwright test tests/e2e/ssh-ai-vault-session-history.spec.ts --config tests/playwright.config.ts --project electron-headless(2 passed, including the new case).Also ran:
pnpm tc,oxlintandoxfmton changed files,pnpm run check:code-quality:changed, and the focused and dependent test files.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Known gaps, left out to keep this PR to one fix:
cdinto the deleted folder.cd <folder> && ….runtime:hosts) are not checked.cderror once it's gone. Locally, Orca's existing fallback already opens them at the workspace root, where Kimi 1.52 silently starts a new empty session under the same id. That predates this PR.tui.resume_cwdhas to exist in the installed Codex. Versions that predate it accept-c tui.resume_cwd=currentwithout complaint and ignore it, so they still show the folder prompt. The resume itself still starts in the right folder on those versions, because Orca no longer types thecd.[Orca opened this terminal at the workspace root because its saved start folder no longer exists.]into the pane, because main detects the missing folder itself and reports it back; the renderer-side SSH check has no equivalent channel, so the remote resume just opens at the workspace root. The session row is already badged "Unavailable worktree" before the click.cds somewhere else, Codex now resumes there without asking. Every agent launch in Orca already relies on the terminal staying in the folder Orca opened it in.Wire compatibility: nothing new crosses the client–host boundary. The check reuses the existing
fs.statover SSH. Mobile is unaffected.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)