fix(agent-status): stop a session-boundary row clearing a sleeping record

Resolving the merge with main, this branch's turn-complete predicate replaced
main's plain done check in the worktree-scoped arm of the resume claim. That was
the wrong half to keep. A launch-membership row carries no provider session, and
the equality guard above the arm returns false whenever either side is
undefined, so a membership row can never reach it; the substitution had no
effect on membership at all.

What it did reach were the rows that do carry a provider session and a session
boundary -- SessionStart, Grok and remote compact completion, all of which
predate this branch. Claiming there runs clearSleepingAgentSession, so a pending
auto-resume was deleted rather than deferred, with nothing left to retry from.

main's live-PTY ownership arm is untouched.
This commit is contained in:
Brennan Benson
2026-09-17 01:22:23 -07:00
parent 3e8547954d
commit 6ce2e34e3e
@@ -23,7 +23,6 @@ import {
import { parkUntilHostMirrorHandleLands } from './host-mirror-handle-gap-wait'
import { resolveWorkspaceTerminalHostAuthority } from './workspace-terminal-host-authority'
import { parkUntilHostSessionMirrorHydrates } from '@/runtime/host-session-mirror-hydration'
import { isAgentStatusTurnComplete } from '../../../shared/agent-completion-time'
export type { ResumeSleepingAgentSessionsOptions } from './sleeping-agent-session-launch'
@@ -137,10 +136,12 @@ function activeOrQueuedResumeClaimsProviderSession(
) {
return true
}
// A launch-membership boundary row is a `done` that never carried a turn, so it must keep
// claiming the provider session rather than read as a finished one and release the record.
// Deliberately `state`, not the turn-complete predicate: a launch-membership row carries no
// provider session, so the equality guard above already excludes it and widening this arm to
// boundary rows would only reach SessionStart/compact rows — whose records this claim then
// clears, turning a pending auto-resume into a deleted one.
if (
!isAgentStatusTurnComplete(entry) &&
entry.state !== 'done' &&
worktreeTabIds.has(tabId ?? '') &&
entry.worktreeId === record.worktreeId
) {