Repository navigation
Description
Summary
Cold-restoring a sleeping agent can fork a second local claude --resume <sessionId> onto a transcript another live pane is still writing, when the two panes are in different worktrees. The existing dedupe cannot see across that boundary.
workspace-terminal-host-authority.ts already names this failure mode for the SSH case ("resuming a sleeping agent forks a second claude --resume onto a transcript the host is still writing", STA-3500/3498/3374). This is the same shape, purely local — no remote host involved.
Why the guard misses it
activeOrQueuedResumeClaimsProviderSession() in src/renderer/src/lib/resume-sleeping-agent-session.ts checks three sources for a live/queued claim on the same providerSession — agentStatusByPaneKey, pendingStartupByTabId, automaticAgentResumeClaimsByTabId — and every branch is scoped to the record's own worktree:
const worktreeTabIds = new Set((state.tabsByWorktree[record.worktreeId] ?? []).map(t => t.id))
…
worktreeTabIds.has(getAgentStatusTabId(entry) ?? '') && entry.worktreeId === record.worktreeId
worktreeTabIds.has(tabId) && …
worktreeTabIds.has(tabId) && claim.worktreeId === record.worktreeIdA Claude transcript is identified by sessionId and is global to the machine — it is not owned by a worktree. So a pane running that session in worktree A is invisible when a record for worktree B is resumed, and the resume proceeds.
Observed
macOS, Orca 1.4.192, three sessionIds duplicated at once. Two show the cross-worktree pattern plainly — original in the repo's main checkout, duplicate in an Orca workspace worktree:
sessionId 284b624a… pid 29026 cwd …/imbee-automation (main worktree)
pid 45980 cwd ~/orca/workspaces/…/T94 (different worktree)
sessionId 95c4f830… pid 29625 cwd …/imbee-automation (main worktree)
pid 45960 cwd ~/orca/workspaces/…/T126 (different worktree)
Both processes carry the same sessionId in ~/.claude/sessions/<pid>.json and resolve to one transcript. Ancestry confirms Orca spawned the second:
Orca Helper -> login -> zsh -> claude --resume <sessionId>
13 of 21 live sessions on this machine were started with --resume. Killing the extras is not durable — the same sessionIds re-duplicated within hours.
Impact
- Two processes appending to one
.jsonl. No corruption observed — 5,041 lines all parsed cleanly, and the file is not held open by either process — so this is a latent risk, not a realised one. - The measured cost is context: each duplicate re-sends the whole conversation per request. An 8.8 MB transcript loaded twice is the concrete waste.
- The restored copy loads the transcript as of its resume, so subsequent writes from both interleave and the file stops being a faithful record of either.
Suggested direction
Deduping on providerSession for claude probably needs to be worktree-agnostic, since the identity it keys on is machine-global. I have not proposed a patch: the surrounding invariants span hibernation, mobile wake fanout and the SSH host-authority verdicts, and I could not tell from outside which cross-worktree resumes are legitimate.
Not verified
I did not confirm the cross-worktree path for a third duplicated session whose panes shared one cwd — a floating terminal (FLOATING_TERMINAL_WORKTREE_ID) would produce the same symptom by a different route, and I could not distinguish them from outside the app.
Activity
nwparker commentedon Oct 15, 2026
Thanks for the detailed report and for identifying the cross-worktree boundary. This case is fixed on main by #19882 (
e45cf438bc5adc845bc14554c174b480687b6210): a matching session with an exact live pane now prevents another automatic resume across worktrees, including after a completed turn.Verified on main
e2f2277d51272bb36a906c87df68dd145e02b5a5on macOS arm64 by executing the production restore sweep. Both working and done Claude peers in another worktree prevented duplicate launches; the control without a live peer PTY still resumed. All 40 targeted tests passed. This was production store-level verification, not a live two-Claude UI test.Closing as fixed on main. If this recurs on a build containing #19882, please let us know; a live process missing from the status/PTY inventory would need a separate investigation.