← Back to Pull requests

fix(seat): a missing seat's recycled pane never verifies it, and a slow restore isn't reported back at its shell #3843

Closed
unknown closed this pull request without merging on Nov 24, 2026 23:56 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 15:07 UTC
Author

What a person sees today

1. A seat whose tmux session is gone can read running/verified.
- After a tmux server restart, tmux reuses pane ids. A seat whose session never came back can still hold a binding to %22, and %22 may now belong to another seat.
- rig ps then shows the missing seat as running and verified, while sends to it keep failing.
- The sends correctly target the missing session's name, so nothing reaches the wrong seat. But the status misleads, and each identity sweep overwrites the session_missing that a failed send recorded.
2. A single original-session restore can report Claude resume failed: pane returned to shell instead of entering Claude and suggest a fresh launch, while the original conversation then starts in the pane a few seconds later.

Why

1. The live-pid path doesn't check the session. In seat-identity-reconciler.ts computeVerdict, the dead-pane path checks that the pane belongs to the seat's session (#2248), and the null-pid path treats a session missing from the listing as session_missing. The live-pid path checks neither, so any live pane with the bound id verifies the seat, and the neighbour's PID is recorded as the seat's process. #3471 and #3798 keep absence through unreadable samples "until a matching pane is seen", and a recycled live pane is exactly such a match.
2. A shell that hasn't read the launch looks like a shell Claude exited to.
- The launch is typed into a new pane as a staged script. If the pane's shell is still running its startup files, it hasn't read the launch yet, and it holds the terminal with nothing under it.
- That looks the same as a shell Claude exited to, so the two idle-shell samples agree and the resume ends in retry_fresh.
- Reproduced on a throwaway tmux socket (-L) with the real ClaudeCodeAdapter.launchHarness: a pane whose .zshrc takes 6 s gave exactly this message, and the stand-in claude was running in the pane right after.

The fix (in the existing checks; no new refusal, hold or setting)

  • seat-identity-reconciler.ts: when this sweep's readable listing lacks the seat's session, the live-pid path reads that session's panes again, as the dead-pane path does.

  • - The seat's own pane listed: it keeps verifying (the listing was stale).
    - The session listed without that pane: tmux_unavailable (unknown).
    - No session: session_missing.
    - A listed session pays for no extra read, and an unreadable listing still goes down the existing probe path.
  • tmux.ts: sendShellCommand remembers the script it staged per target. stagedLaunchUnread(target) is true only while that script still exists; it removes itself when the shell reads it.

  • claude-code-adapter.ts and claude-resume.ts: a pane whose shell hasn't read the launch isn't "returned to shell". The resume takes the existing longer wait.

  • - If Claude comes up, it's a normal resume.
    - If it doesn't, the existing "launch kept" attention result applies, with the token kept, instead of retry_fresh.

    Tests

  • Reproduction cells, each red with the product files at main:

  • - seat-identity-reconciler.test.ts: four runtime and label cases; a missing session recorded by a failed send survives the next sweep; a session that appears after the listing without the bound pane reads unknown.
    - rig-ps-server-gone.test.ts: rig ps reads the seat stopped with session_missing in its identity, status and activity, sweep after sweep.
    - claude-runtime-adapter.test.ts, claude-resume.test.ts, tmux-shell-command.test.ts: the unread-launch cases.
  • Boundary cells, which pass on main by design:

  • - a stale listing whose pane is still the seat's own keeps verifying;
    - the recycled pane under an unreadable listing stays unknown;
    - a listed session's live pane verifies with no extra read;
    - a shell that read the launch and is back at its prompt still reports the return;
    - an ordinary resume is marked resumed.
  • Results: the 5 touched files pass 419/420 (1 skipped, unchanged); 13 cells fail with main's product files; tsc --noEmit passes.
  • Not covered here

  • Codex's resume has the same returned-to-shell shape (codex-resume.ts, codex-runtime-adapter.ts). It isn't reproduced or changed here.

  • A listed session whose binding names a pane in another session still verifies by pane id. Fixing that needs a membership read on every sweep.
  • 🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    Resume and readiness checks now distinguish reports from earlier launches from reports belonging to the current launch, reducing false failures. Launches that are still starting or have ambiguous reports remain available for attention.
    * Seat status now reflects missing sessions more accurately when pane identifiers are reused, without inheriting another seat’s process information. If tmux status cannot be verified, the seat remains marked as running rather than detached.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mvschwarz Review duration: 1969m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 650 lines diff across 8 files
    0.57
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #3843"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 57% (MEDIUM) · Higher = larger blast radius
    57%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%