fix(session): take-over sets status='running' so file attach works (v0.138.2)#236
Merged
Conversation
…0.138.2) Taking over an unattended run (claimSession / POST /interactive) flipped headless→0, set claimed_by, and cleared the resume sentinel — but never set status='running' the way the resume path (markResumed) does. A take-over can race the Stop-hook turn-end teardown that already moved the run to 'done', so the claimed-and-attached session kept a terminal status and everything gated on status==='running' (notably attachFile) rejected it with "session is not live". Take-over now forces status='running' (pane resurrects on re-open via the already-cleared sentinel). The console's attach/drag/paste gate also keys off the pane being attached/live (isLive + the just-took-over override) instead of raw status, so it no longer lags a poll behind a take-over; the server stays the hard authority. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The bug
Taking over an unattended (headless/automation/task/chat) session and then attaching a file failed with "session is not live" — even though you were attached and steering the run.
Root cause
The resume path (
markResumed) setsstatus = 'running'. The take-over path (claimSession/POST /api/sessions/:id/interactive) did not — it only flippedheadless→0, setclaimed_by, and cleared the resume sentinel.A take-over can race the Stop-hook turn-end teardown (
markTurnIdle→teardownUnattended→markEnded), which may have already moved the run tostatus = 'done'. The claimed-and-attached run then kept that terminal status, so everything gated onstatus === 'running'— notablyattachFile'sif (row.status !== 'running') return "session is not live"— rejected the now-live session. The green dot lied because the console'sisLiveisalive || status === 'running', looser than the attach gate.Fix
claimSessionnow setsstatus = 'running'in the same UPDATE (the pane resurrects on re-open via the already-cleared sentinel) — the one flag resume set that claim was missing.isLive(session) || overrideAttach) instead of rawstatus, so it no longer lags a poll behind a take-over and matches the green dot. The server (attachFile) stays the hard authority.Testing
npm run typecheck✓cd web && npm run build✓npm run test:governance→ 68/68 ✓Diagnosed against the live instapods DB (interactive/headless sessions finishing into
done/stoppedwhile the console still paints them "live").🤖 Generated with Claude Code