Repository navigation
fix(ai-vault): repin resumes from deleted worktrees - #18085
kaluli123123 wants to merge 10 commits into
Conversation
|
Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 0a9b38d09fff49b2f27a84fa58274ade8172aefa and 6c18fbf9a45a6a717461b7a9454677f7a6950b38. 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughAI Vault resume handling now separates CWD, runtime, and command-prefix resolution into dedicated modules. It checks session directories, falls back to workspace paths, and normalizes WSL UNC paths. It selects the target platform and shell, maps provider session metadata, and repins cached commands. Resume and drop-repin launch flows now await asynchronous builders and use resolved startup CWD metadata. Tests cover POSIX, Windows, WSL, remote sessions, missing paths, nested directories, and legacy Windows wrappers. Merge Risk: ⚪ Minimal · up to Resume and drag-drop launches now repin deleted session directories to the selected workspace while preserving valid nested and platform-specific paths. Current coverage indicates no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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: 44ac2980-2d8d-4fce-8892-0039b88211cb
📥 Commits
Reviewing files that changed from the base of the PR and between 4f4872c and d15adc5935d6fa96d8d35334443fbd910c717fda.
📒 Files selected for processing (7)
src/renderer/src/lib/ai-vault-resume-command.test.tssrc/renderer/src/lib/ai-vault-resume-command.tssrc/renderer/src/lib/ai-vault-resume-cwd.tssrc/renderer/src/lib/ai-vault-resume-repin.test.tssrc/renderer/src/lib/ai-vault-resume-runtime.tssrc/renderer/src/lib/ai-vault-resume-shell.tssrc/shared/ai-vault-resume-command.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
There was a problem hiding this comment.
ℹ️ No critical issues — two minor points inline.
Reviewed changes
- Repin a stale resume cwd to the selected workspace — new
resolveAiVaultResumeCwdkeeps a session cwd when it still lives under the selected worktree/folder, otherwise repins to the workspace root (with WSL-UNC and Windows-drive guards), andbuildAiVaultResumeForWorktreenow routes every path through it. - Strip the persisted cwd wrapper before repinning remote sessions — new
stripAiVaultResumeCwdPrefixremoves the scanner'scd … &&(orcmd /d /s /c "cd /d …") prefix so a stale remoteresumeCommandcan be rebuilt against the new target. - Extract shared runtime helpers —
getAiVaultResumePlatform/getAiVaultAgentProviderSession/getAiVaultResumeCodexHome/resolveAiVaultResumeShellmove toai-vault-resume-runtime.ts;getAiVaultResumeWorkspacePathmoves toai-vault-resume-cwd.ts(re-exported for existing importers).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 4c026b46-6c05-487f-89f2-32dedb2547dc
📥 Commits
Reviewing files that changed from the base of the PR and between d15adc5935d6fa96d8d35334443fbd910c717fda and b41d1ff24489b5d5bbe1ddb1d222ac2487d584fb.
📒 Files selected for processing (6)
src/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.tssrc/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsxsrc/renderer/src/lib/ai-vault-resume-command.drop-repin.test.tssrc/renderer/src/lib/ai-vault-resume-command.tssrc/renderer/src/lib/ai-vault-resume-cwd.tssrc/renderer/src/lib/ai-vault-resume-repin.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/renderer/src/lib/ai-vault-resume-cwd.ts
- src/renderer/src/lib/ai-vault-resume-repin.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
Important
One must-address issue: aiVaultResumeCwdExists can throw for runtime-owned sessions instead of returning false, which turns the deleted-worktree fix into a failure toast on exactly the remote case it targets.
Reviewed changes
- Validate the resume cwd before launching — new
aiVaultResumeCwdExistschecks whether the recorded cwd still exists (routing to the runtime host, SSH host, or local shell), and async variants of the copy/startup builders (buildAiVaultResumeCopyCommandForWorktreeAsync,buildAiVaultResumeStartupForWorktreeAsync,buildAiVaultDropRepinStartup) await it before repinning. - Repin to the workspace root when the cwd is gone —
resolveAiVaultResumeCwdnow takessessionCwdExistsand returns the target root when the recorded cwd no longer exists, in addition to the existing lexicographic inside/equal check. - Wire the drop layer to the resolved cwd — the drag-drop launch now prefers
startup.cwdover the stalepayload.sessionCwd. - Address prior review feedback — the copy rebuild hardcodes
shell: undefined, and remote startupcwdis gated onstaleCwd.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
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: 14e33699-5c30-43e1-9c5a-47b0aa662161
📥 Commits
Reviewing files that changed from the base of the PR and between b41d1ff24489b5d5bbe1ddb1d222ac2487d584fb and e3ca4b5d2056b2325b7b7539eec64755d97c5f04.
📒 Files selected for processing (8)
src/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsxsrc/renderer/src/components/tab-group/ai-vault-session-drop-target.test.tssrc/renderer/src/components/tab-group/ai-vault-session-drop-target.tssrc/renderer/src/lib/ai-vault-drop-resume-startup.tssrc/renderer/src/lib/ai-vault-resume-command.drop-repin.test.tssrc/renderer/src/lib/ai-vault-resume-command.tssrc/renderer/src/lib/ai-vault-resume-cwd.tssrc/renderer/src/lib/ai-vault-resume-repin.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Guard runtime-owned CWDs before probing the runtime host —
aiVaultResumeCwdExistsnow returnsfalsewhen a runtime-owned session CWD falls outside the selected workspace (viacreateNormalizedPathInsideOrEqualMatcher), resolving the prior review finding: the deleted-worktree case repins to the workspace root instead of throwing and surfacing a failure toast. The guard is consistent withgetRelativePathInsideWorktree, soruntimePathExistsis only reached when it cannot throw. - Route drag/drop launches through the async CWD check — the drop layer resolves its startup via the new async
buildAiVaultDropLaunchStartup(backed bybuildAiVaultDropResumeStartup/buildAiVaultDropRepinStartupinai-vault-drop-resume-startup.ts), preserving therealHomeStartupfallback for older serializers, and prefers the resolvedstartup.cwdover the stalepayload.sessionCwd. - Extract drop-target geometry helpers —
containsPoint/resolvePaneDropTargetmove toai-vault-session-drop-target.tswith a focused happy-dom unit test. - Thread the target platform through the existence probe —
buildAiVaultResumeCopyCommandForWorktreeAsyncandbuildAiVaultResumeStartupForWorktreeAsynccompute the platform up front (getAiVaultResumeWorktreePlatform) and pass it toaiVaultResumeCwdExists.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
# Conflicts: # src/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsx
# Conflicts: # src/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsx
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
…o HEAD # Conflicts: # src/renderer/src/lib/ai-vault-resume-command.drop-repin.test.ts # src/renderer/src/lib/ai-vault-resume-repin.test.ts
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsx (1)
203-214: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winDo not fall back to
payload.sessionCwdwhenstartup.cwdis absent. When the selected worktree has no resolvable path,buildAiVaultDropLaunchStartupreturns a startup object withoutcwd. The fallback reintroduces the stale drag-payload directory, whichlaunchAiVaultSessionInNewTabstores or forwards tosession.tabs.createTerminal. Useundefinedwhenstartup.cwdis absent so the launch uses the provider’s normal working-directory resolution.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: d162fd3d-7615-439b-938e-33a3f926dcc7
📥 Commits
Reviewing files that changed from the base of the PR and between 3f4793b and 0a9b38d09fff49b2f27a84fa58274ade8172aefa.
📒 Files selected for processing (13)
src/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.tssrc/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsxsrc/renderer/src/components/tab-group/ai-vault-session-drop-target.test.tssrc/renderer/src/components/tab-group/ai-vault-session-drop-target.tssrc/renderer/src/lib/ai-vault-drop-resume-startup.tssrc/renderer/src/lib/ai-vault-resume-command.drop-repin.test.tssrc/renderer/src/lib/ai-vault-resume-command.test.tssrc/renderer/src/lib/ai-vault-resume-command.tssrc/renderer/src/lib/ai-vault-resume-cwd.tssrc/renderer/src/lib/ai-vault-resume-repin.test.tssrc/renderer/src/lib/ai-vault-resume-runtime.tssrc/renderer/src/lib/ai-vault-resume-shell.tssrc/shared/ai-vault-resume-command.ts
🚧 Files skipped from review as they are similar to previous changes (11)
- src/renderer/src/lib/ai-vault-resume-shell.ts
- src/renderer/src/components/tab-group/ai-vault-session-drop-target.ts
- src/renderer/src/components/tab-group/ai-vault-session-drop-target.test.ts
- src/renderer/src/lib/ai-vault-drop-resume-startup.ts
- src/renderer/src/lib/ai-vault-resume-command.drop-repin.test.ts
- src/renderer/src/lib/ai-vault-resume-command.test.ts
- src/renderer/src/lib/ai-vault-resume-command.ts
- src/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsx
- src/renderer/src/lib/ai-vault-resume-runtime.ts
- src/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.ts
- src/shared/ai-vault-resume-command.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
There was a problem hiding this comment.
Important
The WSL probe path is normalized but its worktreePath context isn't, so a runtime-owned WSL resume still throws instead of repinning — details inline.
Reviewed changes
- Removed the
?? args.payloadfallback from the drop launch path —buildAiVaultDropLaunchStartupnow returnsnull(surfacing the "legacy session" toast) for older-serializer payloads whosesessionCwd/sessionFilePath/codexHomecan't be validated, instead of silently launching their stalecdcommand. - Probe runtime-owned WSL cwds with their Linux path —
aiVaultResumeCwdExistsnow passes the platform-normalizedsessionPathtoruntimePathExists, with a regression test asserting the Linux path is probed. - Reconciled main-branch renames — the drop layer imports
activateAiVaultStructuredSession, and the launch action renamed tohandleResumeInNewChat.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Normalized the runtime probe root —
aiVaultResumeCwdExistsnow passesworktreePath: targetCwd(the Linux-normalized workspace path) toruntimePathExists, so a runtime-owned WSL worktree probesrelativePathInsideRoot('/home/alice/repo', '/home/alice/repo/packages/app')instead of comparing a//wsl/…root against a/home/…candidate and throwingRemote file is outside the owning runtime worktree. This closes the prior must-address finding. - Tightened the regression test — the runtime-owned WSL probe test now asserts
expect.objectContaining({ worktreePath: '/home/alice/repo' })(previouslyexpect.any(Object), which could not catch the UNC/Linux mismatch), and the missing-workspace case now also assertsstartup.cwdisundefined.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
6c18fbf to
709006d
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — the fallback removal is correct; one minor test-coverage note inline.
Reviewed changes
- Removed the
payload.sessionCwdfallback from the drop launch path —AiVaultSessionDropLayer.tsxnow derives the launch cwd solely fromgetAiVaultDropLaunchCwd(startup), so a startup without a validatedcwdlaunches via the provider's normal working-directory resolution instead of the stale drag-payload directory. - Added
getAiVaultDropLaunchCwd— a thin accessor inai-vault-drop-resume-startup.tsreturning only the cwd validated by the async drop resolver, plus a unit test asserting it yieldsundefinedwhen the startup omitscwd.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Inlined the drop-launch cwd accessor —
AiVaultSessionDropLayer.tsxnow readsstartup.cwddirectly, and thegetAiVaultDropLaunchCwdidentity wrapper inai-vault-drop-resume-startup.tswas deleted along with its tautological unit test. - Added real coverage for the fallback removal — new
AiVaultSessionDropLayer.test.tsxrenders the drop layer, mocksbuildAiVaultDropLaunchStartupto return a startup with nocwd, and assertslaunchAiVaultSessionInNewTabis called without acwdproperty even though the drag payload carries asessionCwd. This fails if thepayload.sessionCwdfallback ever returns, resolving the prior coverage nit.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
@kaluli123123 — this PR looks to have been idle for about two weeks, so I wanted to surface that the issue is still reproducible for me in the exact path this PR touches: clicking Resume from the right sidebar can still show “session unavailable” after the original worktree/folder has moved or been recreated. The provider transcript still exists, so could you please verify the |
Drive useAiVaultSessionLaunchActions().handleResume with a recorded cwd that was moved away or removed from a recreated worktree, asserting the launch cwd falls back to the selected workspace root.
|
@JanPlessow thanks for the report. I checked the right-sidebar path specifically. This fix is not in any release yet. This PR is still open and unmerged, so every released build (including the latest, v1.4.215) still launches a sidebar Resume with the recorded cwd as-is ( The PR head already covers the right-sidebar Resume path. To pin down your exact scenario, I pushed 1ed5571, which adds
Against the pre-PR code (merge base If you are able to test a build from this branch and still see the failure, please share the agent (Claude/Codex/…) and the exact text shown. "Session unavailable" is not a message the resume launch path emits, so it may come from a different layer. #22657 (sleep record dropped on wake) and #20803 (retained rows not navigating) are separate code paths that this PR does not touch. |
There was a problem hiding this comment.
ℹ️ No critical issues — the new coverage is meaningful; one test-hygiene nit inline.
Reviewed changes
- Added right-sidebar resume coverage after a workspace move — new
ai-vault-session-launch-actions.test.tsdrives the realuseAiVaultSessionLaunchActions().handleResumethrough the realbuildAiVaultResumeStartupForWorktreeAsync, mocking onlywindow.api's path probe and the launcher. It covers a recorded cwd outside the selected workspace, an in-workspace cwd the probe reports gone (the existence-gated repin — the case that fails ifaiVaultResumeCwdExistsis unwired), and an in-workspace cwd the probe reports present. I ran it: 3/3 pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| import type { AppState } from '@/store/types' | ||
| import { makeWorktree, TEST_REPO } from '@/store/slices/store-test-helpers' | ||
| import type { AiVaultSession } from '../../../../shared/ai-vault-types' | ||
| import { useAiVaultSessionLaunchActions } from './ai-vault-session-launch-actions' |
There was a problem hiding this comment.
This file never sets globalThis.IS_REACT_ACT_ENVIRONMENT = true, so every act() call emits The current testing environment is not configured to support act(...) to stderr (six times per run here). The sibling AiVaultSessionDropLayer.test.tsx sets it at module scope for exactly this reason.
The visible assertions still hold today because the async work is awaited via vi.waitFor, but the act wrappers are not doing their job without it.
| import { useAiVaultSessionLaunchActions } from './ai-vault-session-launch-actions' | |
| import { useAiVaultSessionLaunchActions } from './ai-vault-session-launch-actions' | |
| globalThis.IS_REACT_ACT_ENVIRONMENT = true |
|
Thanks for digging into this, @kaluli123123. Your investigation helped a lot, and I've credited you as co-author on the replacement. I've opened #24236 as a narrower fix for #17745, and I'm closing this one in its favour. Two reasons:
Drag-and-drop resume on SSH is still open, and it's listed as a known gap in #24236. |

ELI5
AI Vault resumes now check whether the saved working directory is still usable before launching. If it is gone, Orca starts the resumed session from the selected workspace instead of trying to launch from a deleted folder.
What Changed
Why
This fixes the remaining review feedback: a deleted recorded CWD could still reach drag/drop launch paths, and runtime-owned stale paths outside the selected worktree could fail with an error toast instead of repinning to the selected workspace.
Linked Issue
Fixes #17745
Visual Proof
N/A — no visual layout or copy changes; this changes launch-path behavior for AI Vault resume commands.
Testing
Automated validation run locally on macOS:
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/lib/ai-vault-resume-repin.test.ts src/renderer/src/lib/ai-vault-resume-command.drop-repin.test.ts— PASS (13), FAIL (0)pnpm tc:web— PASSpnpm run check:code-quality:changed— PASS, 0 new findings across changed filesgit --no-pager diff --check— PASSManual Electron drag/drop was not run locally in this pass.
AI Disclosure
Codex assisted with the review-fix implementation and validation.
Review
Addressed the latest CodeRabbit and Pullfrog review findings for stale AI Vault resume CWD handling.
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
Security, cross-platform path handling, SSH/runtime boundaries, folder workspaces, WSL path normalization, and remote command compatibility were considered. No mobile impact.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)