Skip to content

fix(session): take-over sets status='running' so file attach works (v0.138.2)#236

Merged
vikasprogrammer merged 1 commit into
mainfrom
feat/takeover-attach-fix
Jul 13, 2026
Merged

fix(session): take-over sets status='running' so file attach works (v0.138.2)#236
vikasprogrammer merged 1 commit into
mainfrom
feat/takeover-attach-fix

Conversation

@vikasprogrammer

Copy link
Copy Markdown
Owner

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) sets status = 'running'. The take-over path (claimSession / POST /api/sessions/:id/interactive) did not — it only flipped headless→0, set claimed_by, and cleared the resume sentinel.

A take-over can race the Stop-hook turn-end teardown (markTurnIdleteardownUnattendedmarkEnded), which may have already moved the run to status = 'done'. The claimed-and-attached run then kept that terminal status, so everything gated on status === 'running' — notably attachFile's if (row.status !== 'running') return "session is not live" — rejected the now-live session. The green dot lied because the console's isLive is alive || status === 'running', looser than the attach gate.

Fix

  • claimSession now sets status = '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.
  • The console's 📎 attach / drag / paste gate keys off the pane being attached/live (isLive(session) || overrideAttach) instead of raw status, 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/stopped while the console still paints them "live").

🤖 Generated with Claude Code

…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>
@vikasprogrammer vikasprogrammer merged commit 7dd8943 into main Jul 13, 2026
1 check passed
@vikasprogrammer vikasprogrammer deleted the feat/takeover-attach-fix branch July 13, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant