You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(accounts): cover the workspace-folder fallback for account-restart resume cwd - #34203
#34202 fixed a typecheck break in the account-switch restart code, but added no test for the behavior that line guards. This adds that test. It's test-only.
What Changed
When an account switch restarts a Claude pane whose tab recorded no start folder, the restart falls back to the workspace folder. It then compares that folder with the folder the session ran in, so a session started in a subfolder resumes with cd '<subfolder>' && claude --resume …. Two PRs merging together (#33629 and #33659) broke that fallback, and #34202 restored it. Nothing tested it.
New case in agent-account-restart-startup.test.ts: the tab has no start folder, the workspace is /repo, and the Claude session ran in /repo/pkg, so the command must start with cd '/repo/pkg'.
The Claude block's beforeEach now also resets tabsByWorktree and worktreesByRepo, so the store state these tests set up doesn't carry into the next case.
Why
A regression test, so the next refactor of this function can't drop the fallback silently. No production code changes.
Linked Issue
N/A (follow-up to #34202; this PR was #34203's original fix, now reduced to its test).
Visual Proof
N/A: test-only.
Testing
All 17 tests in the file pass.
The new case fails if the workspace-folder fallback is removed (the command has no cd).
pnpm tc:web, oxlint, the ast-grep gates and the changed-code gate pass.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Test-only.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
When a tab has no startupCwd, the restart startup plan now gets its fallback path from state.getKnownWorktreeById(args.worktreeId). A new test verifies that a Claude session resumes from its recorded working directory when the worktree identifies the workspace folder.
Priority: Normal
Merge Risk: Low · up to fe7dc
In a narrow stale-state case, Claude may resume from the wrong directory after an account switch.
Pre-merge checks: 5
Check name
Status
Explanation
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description covers the change, reason, testing, visual proof, scope, and checklist. It is clear and aligned with the pull request.
Title check
The title clearly identifies the account-restart resume working-directory fallback test. It is specific and related to the main change.
Full details: Docstring Coverage
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.
Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
Commit to this branch
Create a new PR
📝 Generate docstrings
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
set -o pipefail
printf'%s\n''--- account-switch flow ---'
sed -n '250,430p' src/renderer/src/lib/claude-session-account-move.ts
sed -n '1,120p' src/renderer/src/lib/claude-account-switch-sessions.ts
printf'%s\n''--- restart queue and execution ---'
sed -n '1,110p' src/renderer/src/store/terminals/terminal-restart-state.ts
rg -n -F --glob '*.ts' -e 'buildPaneAccountRestartStartup' -e 'resolveAgentAccountRestartResumeStartup' -e 'pendingPaneAccountRestarts' src/renderer/src/components src/renderer/src/store src/renderer/src/lib ||test"$?" -eq 1
printf'%s\n''--- tab and path-bearing state definitions ---'
rg -n -F --glob '*.ts' -e 'export type TerminalTab' -e 'interface TerminalTab' -e 'startupCwd' -e 'worktreePath' -e 'path:' src/shared/terminal-tab-types.ts src/renderer/src/store/slices/worktrees src/renderer/src/store/terminals ||test"$?" -eq 1
printf'%s\n''--- producer diff against requested base ---'
git diff --find-renames 584b11288dea158da59b230daf8c6c41534b080b3 fe7dc02b098372bd225a581fc291e7cf5e2292f3 -- src/renderer/src/lib/agent-account-restart-startup.ts src/renderer/src/lib/claude-session-account-move.ts src/shared/tui-agent-resume-startup.ts
Repository: stablyai/orca
Length of output: 37823
Script executed:
set -o pipefail
printf'%s\n''--- resume plan and consumer ---'
rg -n -F --glob '*.ts' -e 'function buildAgentResumeStartupPlan' -e 'export function buildAgentResumeStartupPlan' -e 'agentCwd' -e 'launchCwd' src/shared/tui-agent-resume-startup.ts src/renderer/src/lib/tui-agent-startup.ts src/shared ||test"$?" -eq 1
sed -n '1,150p' src/shared/tui-agent-resume-startup.ts
printf'%s\n''--- provider session and cwd contracts ---'
rg -n -F --glob '*.ts' -e 'type AgentProviderSessionMetadata' -e 'interface AgentProviderSessionMetadata' -e 'cwd:' -e 'providerSession.cwd' -e 'transcriptPath' src/shared src/renderer/src/lib src/renderer/src/store | head -220
printf'%s\n''--- tab type and worktree-id path helpers ---'
sed -n '35,85p' src/shared/terminal-tab-types.ts
rg -n -F --glob '*.ts' -e 'splitWorktreeIdForFilesystem' -e 'worktreeIdFrom' -e 'folderWorkspaceKey' src/shared src/renderer/src/store | head -160
printf'%s\n''--- restart spawn cwd usage ---'
rg -n -F --glob '*.ts' -e 'startupPlan.launchCommand' -e 'startup.command' -e 'buildPaneAccountRestartStartup' src/renderer/src/components/terminal-pane src/renderer/src/store | head -180
Repository: stablyai/orca
Length of output: 41619
Do not drop the session-directory correction for stale worktree IDs.
During an account switch, a stale tab entry can reach this producer before stale-worktree cleanup runs. If the tab has no startupCwd, the missing worktree makes launchCwd undefined. The resume builder then omits the cd to providerSession.cwd, so Claude can resume in the wrong directory.
Retain a valid launch path for this restart case. The available source does not establish a safe replacement path, so no patch is included.
nwparker
changed the title
fix(accounts): restore the workspace-folder fallback for account-restart resume cwd
test(accounts): cover the workspace-folder fallback for account-restart resume cwd
Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
#34202 fixed a typecheck break in the account-switch restart code, but added no test for the behavior that line guards. This adds that test. It's test-only.
What Changed
When an account switch restarts a Claude pane whose tab recorded no start folder, the restart falls back to the workspace folder. It then compares that folder with the folder the session ran in, so a session started in a subfolder resumes with
cd '<subfolder>' && claude --resume …. Two PRs merging together (#33629 and #33659) broke that fallback, and #34202 restored it. Nothing tested it.agent-account-restart-startup.test.ts: the tab has no start folder, the workspace is/repo, and the Claude session ran in/repo/pkg, so the command must start withcd '/repo/pkg'.beforeEachnow also resetstabsByWorktreeandworktreesByRepo, so the store state these tests set up doesn't carry into the next case.Why
A regression test, so the next refactor of this function can't drop the fallback silently. No production code changes.
Linked Issue
N/A (follow-up to #34202; this PR was #34203's original fix, now reduced to its test).
Visual Proof
N/A: test-only.
Testing
All 17 tests in the file pass.
The new case fails if the workspace-folder fallback is removed (the command has no
cd).pnpm tc:web, oxlint, the ast-grep gates and the changed-code gate pass.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
Test-only.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)