Repository navigation
fix(agent-status): clear the pane when a Claude compact finishes (STA-2915, STA-4613) - #15202
Conversation
|
Warning Review limit reachedNext included review available in 9 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (10)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 0 remain after this review. 📝 WalkthroughWalkthroughClaude compact handling now registers only 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/main/claude/compact-status-registration.test.ts (1)
158-174: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd coverage for an auto compact followed by a manual compact in the same turn.
This test asserts only that the auto
PostCompactreturnsnull. It does not observe the consumed-prompt-id side effect that the auto event records inclaudeConsumedCompactPromptIdByPaneKey. A sequence of autoPostCompactthen manualPostCompactwith the sameprompt_idwould leave the paneworking, and no test here would fail. See the related comment onsrc/shared/agent-hook-listener.tsLines 4396-4417.💚 Suggested additional test
it('still clears the pane when a manual compact follows an auto compact in the same turn', () => { const state = createHookListenerState() startTurn(state) expect( deliverIfRegistered(state, hook('PostCompact', COMPACT_PROMPT_ID, { trigger: 'auto' })) ).toBeNull() const manual = deliverIfRegistered( state, hook('PostCompact', COMPACT_PROMPT_ID, { trigger: 'manual' }) ) expect(manual?.payload.state).toBe('done') expect(manual?.payload.sessionBoundary).toBe(true) })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cbc12ebe-e759-4d7c-a7b0-815969fd8943
📥 Commits
Reviewing files that changed from the base of the PR and between 6ee265e and 3b933cbf3d010387a3ba44ac8da039a9dc933832.
📒 Files selected for processing (10)
src/main/agent-hooks/manual-compact-hook-stream.test.tssrc/main/agent-hooks/server.tssrc/main/claude/compact-status-registration.test.tssrc/main/claude/hook-settings.tssrc/main/ssh/ssh-relay-session-agent-hooks.integration.test.tssrc/relay/agent-hook-server.tssrc/shared/agent-hook-listener-claude-turn-state.test.tssrc/shared/agent-hook-listener.tssrc/shared/claude-compact-completion.tssrc/shared/manual-compact-prompt-identity.test.ts
💤 Files with no reviewable changes (1)
- src/shared/manual-compact-prompt-identity.test.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 6 remain after this review.
…-2915, STA-4613) A manual /compact ends at an idle prompt without emitting Stop, so nothing in the compact window could ever clear the pane. A worktree that entered the compact `working` stayed `working` until the 30-minute stale sweep -- and the summarizer's start-less SubagentStop kept republishing the row, resetting that clock each time. The correlation added by #12332 was supposed to own this, but it could never run: PreCompact and PostCompact were never added to CLAUDE_EVENTS, so they were never registered with Claude. compactTrigger was always undefined, and the transition guard, the ownership cache, the relay wire field and the ingest branch were all unreachable. Five test files exercised the logic by injecting events past the registration boundary, so the suite stayed green over code that could not execute. Register PostCompact -- and deliberately NOT PreCompact. Measured on Claude Code 2.1.227, a successful manual compact emits PreCompact, a start-less SubagentStop, SessionStart(source=compact), then PostCompact; an ABORTED compact ("Not enough messages to compact") emits PreCompact ALONE. Mapping PreCompact to `working` would strand the pane on every aborted compact, which is the bug being fixed, so the abort guard is structural: Orca never subscribes to the pre-validation event. PostCompact carries its own trigger, so no anchor is needed to tell manual from auto and the correlation machinery is deleted rather than repaired. Manual becomes a `done` with sessionBoundary set -- a finished compact is a session-shaped boundary, not a completed turn, so completion notifications, unread counts and automation-run evidence stay out of it. Auto claims nothing: it runs inside a turn that resumes and emits its own Stop. The source-blind early return that dropped compact events for EVERY provider before its normalizer ran is narrowed to Claude, so it keeps failing closed on a malformed payload without pre-empting other providers. Ownership is kept where the deleted guard had it: a valid provider prompt id is required, a completion clears a row but never creates one (a retired pane must not be resurrected), and a hydrated row is matched on provider session only -- it carries the previous session's connectionId, and older rows carry no session at all, so a strict check would reject the restart case this fixes. A consumed prompt id keeps relay duplicates from refreshing the row. Mixed versions: no new wire field and no new opcode. An older relay normalizes with its own shipped mapping and forwards the event, so ingest drops `auto` envelopes and stamps the boundary on `manual` ones; its replay strips the trigger entirely, so payload state stands in for it while ownership is still enforced. The relay now caches a completion with its compact identity removed, so a client that was offline during the compact still receives the clearing row on reconnect. Tests go red before this change and green after: 6 of 12 in the new registration-gated suite and 5 of 8 in the relay/ingest suite. The harness delivers only events present in CLAUDE_EVENTS, so a fix that is never registered cannot pass -- the failure mode that let the original correlation ship unreachable.
3b933cb to
3667dc8
Compare
…ew invariant The gate pinned a test file this change deletes, so the manifest check failed. Repointing the path alone would have left the gate describing an invariant that no longer exists: it required a manual PostCompact to match its exact PreCompact generation, and PreCompact is no longer consumed at all. Restate it. The invariant is now that PreCompact never moves a pane, that only a manual PostCompact marks done and does so as a session boundary, that a completion clears an existing row but never creates one, and that a relay predating the contract has its automatic envelopes dropped and its trigger- stripped replays classified by payload state under the same ownership checks. Evidence runs are the real ones: the 105-test suite from this branch, and the Claude Code 2.1.227 PTY capture that measured PreCompact arriving alone on an aborted compact.
…o clear Review found the completion did not clear the pane STA-2915 actually reports, and that republishing it was a strict regression. - A manual completion now retires a subagent that exists only as a disk snapshot: a /compact only completes at an idle prompt, so a restored child is proof of nothing. Live evidence -- a child observed in this runtime, an unclassifiable running background task, a registered session cron -- still holds the pane. - A completion that cannot clear now publishes nothing instead of restating the row, which was stripping restoredUnconfirmed off a hydrated row and restarting the staleness clock for work the compact never observed. - The relay defers compact ownership to the client that owns pane identity, so a cold relay cache can no longer swallow the one event that clears a remote pane. - claudeConsumedCompactPromptIdByPaneKey joins all three pane-scoped teardown routes, and an auto compact no longer spends the pane's consumed-compact slot. - The promptless completion keeps the summarized turn's label with or without a trigger on the envelope. Tests: the two restart cases now deliver the completion while the hydrated row is still cached, so they exercise the restored-row branch instead of passing through the strict one; the triggerless working replay is asserted from a FINISHED pane so it can fail. Reverting the four source files turns 12 of 21 registration-gated and 8 of 12 relay/ingest tests red, and 18 of 18 targeted mutations are caught.
Revision after review — live evidenceReview returned REVISE on five findings plus four nits. All nine are addressed in Arm 1 — the pane STA-2915 actually reports now clearsGenuine repro, not a fixture: a real Claude pane ran a Before — the stuck card, spinner on the pane and its restored child, both aged 2m: One accepted write, straight to The reap is recoverable, not destructive: the Arm 2 — an aborted compact still leaves the row byte-identicalNot just "still done" — Arm 3 — a genuinely live subagent still holds
|
| Check | Result |
|---|---|
| Revert the four source files to the merge base, tests untouched | 20 of 33 red (12/21 registration-gated, 8/12 relay/ingest) |
| Targeted mutations | 18 of 18 caught (was 15 of 18 — resolveLegacyCompactTrigger, and the restored-row branch twice, previously survived) |
| Agent-hook + agent-status suites, combined tree | 119 files / 1232 passed |
| Renderer agent-status suites, combined tree | 334 files / 3041 passed |
pnpm typecheck, combined tree |
clean |
pnpm run check:reliability-gates |
85 gates pass |
The reliability-gate manifest was claiming restored-row coverage the suite did not have; the
invariant, oracle, assertion refs and evidence numbers are all restated to what the suite now
actually proves.
…tion removal The conflict is main's per-write `observation` facet landing on the same line as this branch's removal of `resolveCachedClaudeCompactOwnership`. Taking either side whole would lose real work: the branch's side drops main's observation stamping, main's side reinstates a call this branch deliberately deleted as unreachable. Kept both intents — observation is stamped from `boundaryAwarePayload`, which is what `cachedPayload` reduced to once the correlation cache was removed.
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
The 2 red e2e jobs are a CI relay-build problem, not this PREvery failure across both jobs is the same line, thrown at The job log says why, earlier in the same run: The relay build was skipped because a bundle was already present, but that bundle carries no Attribution: this branch changes no e2e spec, and its only Filed separately as a CI issue. Not patching it from a status-semantics branch. |
Both conflicts are independent map fields added to the same listener state — this branch's `claudeConsumedCompactPromptIdByPaneKey` and #15212's `claudeSessionOwnerByPaneKey`. Taking either side whole would drop the other's work, so both are kept in the type and the initializer.
End-to-end SSH validation (PR worktree, no production edits)Verdict: land Isolated Electron launch of Measured compact stream over the remote relay hook path:
Remote backing: ScreenshotsIsolated profile: SSH demo-project connected: Working before compact: Cleared after PostCompact: Gaps (not blockers)
Full write-up: |
Replacement screenshots — post-merge HEAD
|
| Event | Visible | Store |
|---|---|---|
UserPromptSubmit |
yellow Working on SSH worktree card, Claude agent row, and tab | state=working, agentType=claude, connectionId=ssh-…, acceptedStatusSeq=1 |
PreCompact trigger=manual |
still Working | no new write (acceptedStatusSeq/updatedAt unchanged) |
PostCompact trigger=manual |
green Done | state=done, sessionBoundary=true, acceptedStatusSeq=2 |
duplicate PostCompact |
unchanged | acceptedStatusSeq and updatedAt unchanged |
Remote backing: git -C /work/demo-project status --short --branch → ## main / 67c9b95. Playwright console: 0 errors. Compact ingest had no relay/app errors (first connect failed until Node 18 was installed on the throwaway image; reconnect deployed the relay).
Screenshots
Isolated profile:
SSH demo-project connected:
Working before compact:
Cleared after PostCompact:
Gaps (not blockers)
- Did not drive a live Claude TUI
/compact; injected the measured Claude 2.1.227 hook stream into the production remote hook HTTP path. - Restart-hydration stuck pane and live-child-holds-working were not re-exercised in this Electron session (covered by the PR test suites).
Full write-up: /tmp/orca-ssh-test-1787596409/evidence/PR15202-ssh-validation.md (session artifact, not committed).
Review complete — land
Residual gap: this run injected the measured Claude 2.1.227 hook stream through the production remote hook path rather than driving a live Claude TUI Verdict: land. |
|
Manual validation update:
This manually covers the Claude TUI |
Two conflicts, both from siblings that have since merged: - agent-hook-listener.ts: #15202 added the manual-compact restored-roster reap immediately before the resolver call this branch replaced. Kept both — main's block runs, then resolveClaudePaneStatus — and bridged `effectiveState` off `resolvedStatus.stateName` so #15202's downstream guard reads the same value instead of resolving twice. - agent-status-types.ts: a SEMANTIC conflict, not a textual one. #15212 replaced the entry's `WithAgentStatusObservation` intersection with `AgentStatusRowFacets`, and the payload type that used the old name moved into the extracted ipc-payload module — so the import went dead and CI failed TS6196. Dropped it.
…-2915, STA-4613) (stablyai#15202) * fix(agent-status): clear the pane when a Claude compact finishes (STA-2915, STA-4613) A manual /compact ends at an idle prompt without emitting Stop, so nothing in the compact window could ever clear the pane. A worktree that entered the compact `working` stayed `working` until the 30-minute stale sweep -- and the summarizer's start-less SubagentStop kept republishing the row, resetting that clock each time. The correlation added by stablyai#12332 was supposed to own this, but it could never run: PreCompact and PostCompact were never added to CLAUDE_EVENTS, so they were never registered with Claude. compactTrigger was always undefined, and the transition guard, the ownership cache, the relay wire field and the ingest branch were all unreachable. Five test files exercised the logic by injecting events past the registration boundary, so the suite stayed green over code that could not execute. Register PostCompact -- and deliberately NOT PreCompact. Measured on Claude Code 2.1.227, a successful manual compact emits PreCompact, a start-less SubagentStop, SessionStart(source=compact), then PostCompact; an ABORTED compact ("Not enough messages to compact") emits PreCompact ALONE. Mapping PreCompact to `working` would strand the pane on every aborted compact, which is the bug being fixed, so the abort guard is structural: Orca never subscribes to the pre-validation event. PostCompact carries its own trigger, so no anchor is needed to tell manual from auto and the correlation machinery is deleted rather than repaired. Manual becomes a `done` with sessionBoundary set -- a finished compact is a session-shaped boundary, not a completed turn, so completion notifications, unread counts and automation-run evidence stay out of it. Auto claims nothing: it runs inside a turn that resumes and emits its own Stop. The source-blind early return that dropped compact events for EVERY provider before its normalizer ran is narrowed to Claude, so it keeps failing closed on a malformed payload without pre-empting other providers. Ownership is kept where the deleted guard had it: a valid provider prompt id is required, a completion clears a row but never creates one (a retired pane must not be resurrected), and a hydrated row is matched on provider session only -- it carries the previous session's connectionId, and older rows carry no session at all, so a strict check would reject the restart case this fixes. A consumed prompt id keeps relay duplicates from refreshing the row. Mixed versions: no new wire field and no new opcode. An older relay normalizes with its own shipped mapping and forwards the event, so ingest drops `auto` envelopes and stamps the boundary on `manual` ones; its replay strips the trigger entirely, so payload state stands in for it while ownership is still enforced. The relay now caches a completion with its compact identity removed, so a client that was offline during the compact still receives the clearing row on reconnect. Tests go red before this change and green after: 6 of 12 in the new registration-gated suite and 5 of 8 in the relay/ingest suite. The harness delivers only events present in CLAUDE_EVENTS, so a fix that is never registered cannot pass -- the failure mode that let the original correlation ship unreachable. * test(agent-status): restate the compact reliability gate around the new invariant The gate pinned a test file this change deletes, so the manifest check failed. Repointing the path alone would have left the gate describing an invariant that no longer exists: it required a manual PostCompact to match its exact PreCompact generation, and PreCompact is no longer consumed at all. Restate it. The invariant is now that PreCompact never moves a pane, that only a manual PostCompact marks done and does so as a session boundary, that a completion clears an existing row but never creates one, and that a relay predating the contract has its automatic envelopes dropped and its trigger- stripped replays classified by payload state under the same ownership checks. Evidence runs are the real ones: the 105-test suite from this branch, and the Claude Code 2.1.227 PTY capture that measured PreCompact arriving alone on an aborted compact. * fix(agent-status): clear the restart-stuck pane a compact was meant to clear Review found the completion did not clear the pane STA-2915 actually reports, and that republishing it was a strict regression. - A manual completion now retires a subagent that exists only as a disk snapshot: a /compact only completes at an idle prompt, so a restored child is proof of nothing. Live evidence -- a child observed in this runtime, an unclassifiable running background task, a registered session cron -- still holds the pane. - A completion that cannot clear now publishes nothing instead of restating the row, which was stripping restoredUnconfirmed off a hydrated row and restarting the staleness clock for work the compact never observed. - The relay defers compact ownership to the client that owns pane identity, so a cold relay cache can no longer swallow the one event that clears a remote pane. - claudeConsumedCompactPromptIdByPaneKey joins all three pane-scoped teardown routes, and an auto compact no longer spends the pane's consumed-compact slot. - The promptless completion keeps the summarized turn's label with or without a trigger on the envelope. Tests: the two restart cases now deliver the completion while the hydrated row is still cached, so they exercise the restored-row branch instead of passing through the strict one; the triggerless working replay is asserted from a FINISHED pane so it can fail. Reverting the four source files turns 12 of 21 registration-gated and 8 of 12 relay/ingest tests red, and 18 of 18 targeted mutations are caught. * fix(agent-hooks): preserve compact identity across relay replay * docs(reliability): describe compact replay ownership (cherry picked from commit 1921ba2)
…-2915, STA-4613) (stablyai#15202) * fix(agent-status): clear the pane when a Claude compact finishes (STA-2915, STA-4613) A manual /compact ends at an idle prompt without emitting Stop, so nothing in the compact window could ever clear the pane. A worktree that entered the compact `working` stayed `working` until the 30-minute stale sweep -- and the summarizer's start-less SubagentStop kept republishing the row, resetting that clock each time. The correlation added by stablyai#12332 was supposed to own this, but it could never run: PreCompact and PostCompact were never added to CLAUDE_EVENTS, so they were never registered with Claude. compactTrigger was always undefined, and the transition guard, the ownership cache, the relay wire field and the ingest branch were all unreachable. Five test files exercised the logic by injecting events past the registration boundary, so the suite stayed green over code that could not execute. Register PostCompact -- and deliberately NOT PreCompact. Measured on Claude Code 2.1.227, a successful manual compact emits PreCompact, a start-less SubagentStop, SessionStart(source=compact), then PostCompact; an ABORTED compact ("Not enough messages to compact") emits PreCompact ALONE. Mapping PreCompact to `working` would strand the pane on every aborted compact, which is the bug being fixed, so the abort guard is structural: Orca never subscribes to the pre-validation event. PostCompact carries its own trigger, so no anchor is needed to tell manual from auto and the correlation machinery is deleted rather than repaired. Manual becomes a `done` with sessionBoundary set -- a finished compact is a session-shaped boundary, not a completed turn, so completion notifications, unread counts and automation-run evidence stay out of it. Auto claims nothing: it runs inside a turn that resumes and emits its own Stop. The source-blind early return that dropped compact events for EVERY provider before its normalizer ran is narrowed to Claude, so it keeps failing closed on a malformed payload without pre-empting other providers. Ownership is kept where the deleted guard had it: a valid provider prompt id is required, a completion clears a row but never creates one (a retired pane must not be resurrected), and a hydrated row is matched on provider session only -- it carries the previous session's connectionId, and older rows carry no session at all, so a strict check would reject the restart case this fixes. A consumed prompt id keeps relay duplicates from refreshing the row. Mixed versions: no new wire field and no new opcode. An older relay normalizes with its own shipped mapping and forwards the event, so ingest drops `auto` envelopes and stamps the boundary on `manual` ones; its replay strips the trigger entirely, so payload state stands in for it while ownership is still enforced. The relay now caches a completion with its compact identity removed, so a client that was offline during the compact still receives the clearing row on reconnect. Tests go red before this change and green after: 6 of 12 in the new registration-gated suite and 5 of 8 in the relay/ingest suite. The harness delivers only events present in CLAUDE_EVENTS, so a fix that is never registered cannot pass -- the failure mode that let the original correlation ship unreachable. * test(agent-status): restate the compact reliability gate around the new invariant The gate pinned a test file this change deletes, so the manifest check failed. Repointing the path alone would have left the gate describing an invariant that no longer exists: it required a manual PostCompact to match its exact PreCompact generation, and PreCompact is no longer consumed at all. Restate it. The invariant is now that PreCompact never moves a pane, that only a manual PostCompact marks done and does so as a session boundary, that a completion clears an existing row but never creates one, and that a relay predating the contract has its automatic envelopes dropped and its trigger- stripped replays classified by payload state under the same ownership checks. Evidence runs are the real ones: the 105-test suite from this branch, and the Claude Code 2.1.227 PTY capture that measured PreCompact arriving alone on an aborted compact. * fix(agent-status): clear the restart-stuck pane a compact was meant to clear Review found the completion did not clear the pane STA-2915 actually reports, and that republishing it was a strict regression. - A manual completion now retires a subagent that exists only as a disk snapshot: a /compact only completes at an idle prompt, so a restored child is proof of nothing. Live evidence -- a child observed in this runtime, an unclassifiable running background task, a registered session cron -- still holds the pane. - A completion that cannot clear now publishes nothing instead of restating the row, which was stripping restoredUnconfirmed off a hydrated row and restarting the staleness clock for work the compact never observed. - The relay defers compact ownership to the client that owns pane identity, so a cold relay cache can no longer swallow the one event that clears a remote pane. - claudeConsumedCompactPromptIdByPaneKey joins all three pane-scoped teardown routes, and an auto compact no longer spends the pane's consumed-compact slot. - The promptless completion keeps the summarized turn's label with or without a trigger on the envelope. Tests: the two restart cases now deliver the completion while the hydrated row is still cached, so they exercise the restored-row branch instead of passing through the strict one; the triggerless working replay is asserted from a FINISHED pane so it can fail. Reverting the four source files turns 12 of 21 registration-gated and 8 of 12 relay/ingest tests red, and 18 of 18 targeted mutations are caught. * fix(agent-hooks): preserve compact identity across relay replay * docs(reliability): describe compact replay ownership
…-2915, STA-4613) (stablyai#15202) * fix(agent-status): clear the pane when a Claude compact finishes (STA-2915, STA-4613) A manual /compact ends at an idle prompt without emitting Stop, so nothing in the compact window could ever clear the pane. A worktree that entered the compact `working` stayed `working` until the 30-minute stale sweep -- and the summarizer's start-less SubagentStop kept republishing the row, resetting that clock each time. The correlation added by stablyai#12332 was supposed to own this, but it could never run: PreCompact and PostCompact were never added to CLAUDE_EVENTS, so they were never registered with Claude. compactTrigger was always undefined, and the transition guard, the ownership cache, the relay wire field and the ingest branch were all unreachable. Five test files exercised the logic by injecting events past the registration boundary, so the suite stayed green over code that could not execute. Register PostCompact -- and deliberately NOT PreCompact. Measured on Claude Code 2.1.227, a successful manual compact emits PreCompact, a start-less SubagentStop, SessionStart(source=compact), then PostCompact; an ABORTED compact ("Not enough messages to compact") emits PreCompact ALONE. Mapping PreCompact to `working` would strand the pane on every aborted compact, which is the bug being fixed, so the abort guard is structural: Orca never subscribes to the pre-validation event. PostCompact carries its own trigger, so no anchor is needed to tell manual from auto and the correlation machinery is deleted rather than repaired. Manual becomes a `done` with sessionBoundary set -- a finished compact is a session-shaped boundary, not a completed turn, so completion notifications, unread counts and automation-run evidence stay out of it. Auto claims nothing: it runs inside a turn that resumes and emits its own Stop. The source-blind early return that dropped compact events for EVERY provider before its normalizer ran is narrowed to Claude, so it keeps failing closed on a malformed payload without pre-empting other providers. Ownership is kept where the deleted guard had it: a valid provider prompt id is required, a completion clears a row but never creates one (a retired pane must not be resurrected), and a hydrated row is matched on provider session only -- it carries the previous session's connectionId, and older rows carry no session at all, so a strict check would reject the restart case this fixes. A consumed prompt id keeps relay duplicates from refreshing the row. Mixed versions: no new wire field and no new opcode. An older relay normalizes with its own shipped mapping and forwards the event, so ingest drops `auto` envelopes and stamps the boundary on `manual` ones; its replay strips the trigger entirely, so payload state stands in for it while ownership is still enforced. The relay now caches a completion with its compact identity removed, so a client that was offline during the compact still receives the clearing row on reconnect. Tests go red before this change and green after: 6 of 12 in the new registration-gated suite and 5 of 8 in the relay/ingest suite. The harness delivers only events present in CLAUDE_EVENTS, so a fix that is never registered cannot pass -- the failure mode that let the original correlation ship unreachable. * test(agent-status): restate the compact reliability gate around the new invariant The gate pinned a test file this change deletes, so the manifest check failed. Repointing the path alone would have left the gate describing an invariant that no longer exists: it required a manual PostCompact to match its exact PreCompact generation, and PreCompact is no longer consumed at all. Restate it. The invariant is now that PreCompact never moves a pane, that only a manual PostCompact marks done and does so as a session boundary, that a completion clears an existing row but never creates one, and that a relay predating the contract has its automatic envelopes dropped and its trigger- stripped replays classified by payload state under the same ownership checks. Evidence runs are the real ones: the 105-test suite from this branch, and the Claude Code 2.1.227 PTY capture that measured PreCompact arriving alone on an aborted compact. * fix(agent-status): clear the restart-stuck pane a compact was meant to clear Review found the completion did not clear the pane STA-2915 actually reports, and that republishing it was a strict regression. - A manual completion now retires a subagent that exists only as a disk snapshot: a /compact only completes at an idle prompt, so a restored child is proof of nothing. Live evidence -- a child observed in this runtime, an unclassifiable running background task, a registered session cron -- still holds the pane. - A completion that cannot clear now publishes nothing instead of restating the row, which was stripping restoredUnconfirmed off a hydrated row and restarting the staleness clock for work the compact never observed. - The relay defers compact ownership to the client that owns pane identity, so a cold relay cache can no longer swallow the one event that clears a remote pane. - claudeConsumedCompactPromptIdByPaneKey joins all three pane-scoped teardown routes, and an auto compact no longer spends the pane's consumed-compact slot. - The promptless completion keeps the summarized turn's label with or without a trigger on the envelope. Tests: the two restart cases now deliver the completion while the hydrated row is still cached, so they exercise the restored-row branch instead of passing through the strict one; the triggerless working replay is asserted from a FINISHED pane so it can fail. Reverting the four source files turns 12 of 21 registration-gated and 8 of 12 relay/ingest tests red, and 18 of 18 targeted mutations are caught. * fix(agent-hooks): preserve compact identity across relay replay * docs(reliability): describe compact replay ownership











Fixes STA-2915 and STA-4613. They are one piece of work: STA-2915 is the symptom, STA-4613 is the mechanism.
The bug
After a Claude
/compact, a worktree card could stay stuck on "Working…" while the TUI sat idle — most visibly after an Orca update, when several worktrees all look busy and nothing is happening.A manual
/compactends at an idle prompt and emits noStop. Nothing in the compact window could clear the pane, so a worktree that entered the compactworkingstayedworkinguntil the 30-minute stale sweep. Worse, the compact's summarizer fires a start-lessSubagentStopthat re-publishes the row, resetting that staleness clock each time.Why the existing fix never ran
The manual-compact correlation merged in #12332 cannot execute in production.
PreCompactandPostCompactwere never added toCLAUDE_EVENTS, so they were never registered with Claude —git log -S PreCompact -- src/main/claude/returns zero commits.compactTriggeris therefore alwaysundefined, and the transition guard, the ownership cache, the relay wire field and the ingest branch are all unreachable.Five test files exercised that logic by injecting events past the registration boundary, so the suite was green over code that could not run.
What Claude actually emits
Measured on Claude Code 2.1.227, from a PTY-driven interactive session (the TUI is what Orca runs, and it differs from
-pmode):Successful manual compact
Aborted compact ("Not enough messages to compact")
Also measured:
/compactfires noUserPromptSubmitat all, andsession_idis stable across the whole window.The decision
Register
PostCompactonly — and deliberately notPreCompact.PreCompactfires before the compact is validated, and an aborted compact emits it alone. Naively mapping it toworkingwould strand the pane on every "Not enough messages to compact" — i.e. it would create STA-2915. The abort guard is therefore structural: Orca never subscribes to the pre-validation event, so there is nothing to bound.PostCompactcarries its owntrigger, so no anchor is needed to tell manual from auto. That is what makes the correlation machinery deletable rather than repairable — its whole purpose was carrying ownership fromPreCompactforward.PostCompactmanualdone, withsessionBoundary: truePostCompactautoPreCompactsessionBoundaryis mandatory, not decoration: a plaindoneis read as a turn completed by automation-run completion evidence, activity unread counts, the completion coordinator and dashboard finished timestamps. A finished compact is a session-shaped boundary — the stuck→cleared transition must be silent.autoclaims nothing because it runs inside a turn that resumes and emits its ownStop.Which gates a completion may clear
Mapping
PostCompacttodoneis not enough on its own:resolveClaudePaneStatecan still gate thelead's
doneback up toworking. Review found that this is what actually holds the pane STA-2915reports, so the completion needs an explicit rule about which gates it may retire.
The discriminator is proven-live vs merely-restored, not "is a gate set":
SubagentStarton this listenerworkingbackground_tasksinventoryworkingsession_cronsinventoryworkingA manual
/compactonly ever completes at an idle prompt, so a child that exists only as a snapshothas nothing live behind it. Everything else is a live report, and real agent work in flight must keep
the pane spinning. Hydration seeds only the roster, so the restored class is exactly the roster class.
And the completion either clears the row or publishes nothing at all. When live evidence still
holds the pane, restating the row would strip
restoredUnconfirmedoff a hydrated row and restart the30-minute staleness clock for work the compact never observed — strictly worse than the silence this
event replaced. The lead record is still updated, so whichever event retires that evidence clears the
pane normally.
Also fixed: the source-blind guard
The early return that dropped compact events pre-empted every provider's normalizer before it ran, not just Claude's. It is narrowed to Claude so it still fails closed on a malformed payload without silently killing any other provider's mapping.
Guards kept from the deleted code
connectionId, and older rows carry no session at all, so a strict check would reject the very restart case this fixes.Mixed versions
No new wire field and no new stream opcode, so no capability negotiation.
compactTriggeralready existed on the envelope and on both ingest paths.autoenvelopes and stamps the boundary onmanualones (the old relay built them before the flag existed, so they arrive as a plaindone).compactTriggerbefore caching, so the replay has no discriminator; payload state stands in for it, with the full ownership guard still enforced. That replay keeps the summarized turn's label too: the carry-forward is keyed on "did ingest accept a completion", not on the trigger surviving the wire.donerow and resurrecting a retired pane.Ownership is enforced once, on the client. The relay forwards and defers. Pane retirement, tab
closure and hydrated rows all live on the client, which re-runs the same guard on ingest — so running
it on the relay as well bought nothing and added a way to lose the event: the relay's cache is
per-process and capped at 256 panes, so a relay restart (hooks resolve the endpoint file per
invocation, so they reconnect and keep firing) or an eviction would silently drop the one signal that
can clear a remote pane. There is no remote gap: a cold relay cache forwards, and the client still
refuses to mint a row it never had.
Tests
Red before, green after — 12 of 21 in the registration-gated suite and 8 of 12 in the relay/ingest suite, verified by reverting the four source files to the merge base and re-running with the tests untouched.
Every assertion is mutation-tested: 18 of 18 targeted mutations are caught, including reaping
runtime children as well as snapshot ones, restating a pane that live evidence still holds,
re-enforcing compact ownership on the relay, keying the label carry-forward on the trigger again, and
dropping the consumed-compact map from any single teardown route.
The anti-vacuity measure is the point: the harness delivers only events that are actually present in
CLAUDE_EVENTS, so a fix that is never registered cannot pass. That is exactly the failure mode that let #12332 ship unreachable. Tests that were already green on baseline are labelled regression cover rather than claimed as fixes.Covered: successful compact, aborted compact (both from idle and from a working pane), auto no-op,
sessionBoundarysuppression, the three restart shapes (no cached row, staleconnectionId, missing provider session), the restart-stuck pane driven end to end over loopback HTTP from a hydrated row, a runtime child holding the pane through a completion with no write at all, retired-pane non-resurrection, duplicate suppression, a cold relay cache and replay, the consumed-compact map across all three pane-teardown routes, old-relaymanual/auto/triggerless-replay ingest, and reconnect replay.The restored-row cases now deliver the completion while the hydrated row is still the cached owner and
assert the summarizer published nothing, so they exercise the restored-row branch rather than passing
through the strict one. The triggerless
workingreplay is asserted from a finished pane, so itcan fail.
Landing alongside #15189 and #15212
All three touch
src/shared/agent-hook-listener.ts. Merged fresh ontomainin the order#15189 → #15202 → #15212:
resolved by keeping both sides — two are fix(agent-status): clear the pane when a Claude compact finishes (STA-2915, STA-4613) #15202 vs fix(agent-status): retire panes whose agent process is gone (STA-4612) #15212 (the new
HookListenerStatemap and itsinitialiser), three are fix(agent-status): leftover Claude shells must not hold a finished lead at working (STA-4119) #15189 vs fix(agent-status): retire panes whose agent process is gone (STA-4612) #15212 (
updateClaudeRunningNonAgentTask's signature,providerBackgroundWorkActivevsacceptedStatusSeqon the status type, and the matching storewrite). No semantic choice is required.
334 files / 3041 tests on the renderer agent-status suites,
pnpm typecheckclean.Worth knowing for whoever lands last: #15189 removes the recognised-background-shell gate from
resolveClaudePaneState, so on the merged tree the gates a completion can meet are the subagentroster and the session cron. This PR's discriminator is scoped to the roster's restored entries and
does not touch #15189's predicate.
Process
Planned first, then reviewed. Five review rounds surfaced 22 defects against the plan before any code was written — including that the first draft's flagship test was green today, that a blanket replay-reject would have re-created the bug on the SSH reconnect path, and that an old relay does not drop the event as the plan originally claimed. The decision itself was upheld in every round. Implementation then found one more: a pre-existing cleanup test proved that "accept when there is no cached row" would let a compact resurrect a deliberately retired pane, which is why a completion now only ever clears.
Supersedes #11961
#11961 is
CONFLICTING/DIRTYand untouched since 2026-08-01, so its CI has been silently stopped for over two weeks. Its title duplicates already-merged #14375, and its diff is entirely child-lifecycle work — not about/compactat all; it is attached to the wrong ticket. Its central idea shipped in #14375 in a more refined form (evidence-based rather than coarse flags), and main already took its tool-cache reset.Recommend closing it as superseded. Three small residuals are worth a separate follow-up:
isValidClaudeSubagentIdas a pre-check before allocating a roster, trimming lifecycle/inventory agent ids so a padded id matches its own roster key, and dropping awaitinglead record with nostateBeforeWaitinstead of fabricatingworking. None relate to compact.PR author: @BrennanKB5