Skip to content

fix(agent-status): clear the pane when a Claude compact finishes (STA-2915, STA-4613) - #15202

Merged
brennanb2025 merged 7 commits into
mainfrom
brennanb2025/sta-2915-4613-compact
Aug 24, 2026
Merged

brennanb2025 merged 7 commits into
mainfrom
brennanb2025/sta-2915-4613-compact

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​774 $\color{#cf222e}{\Huge{\mathbf{−}}}$​487 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​287
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​283 $\color{#cf222e}{\Huge{\mathbf{−}}}$​169 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​114

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 /compact ends at an idle prompt and emits no Stop. Nothing in the compact window could clear the pane, so a worktree that entered the compact working stayed working until the 30-minute stale sweep. Worse, the compact's summarizer fires a start-less SubagentStop that 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. PreCompact and PostCompact were never added to CLAUDE_EVENTS, so they were never registered with Claude — git log -S PreCompact -- src/main/claude/ returns zero commits. compactTrigger is therefore always undefined, 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 -p mode):

Successful manual compact

PreCompact    trigger=manual  prompt_id=04b43d44
SubagentStop  agent_id=a75b…  prompt_id=04b43d44   <- start-less summarizer
SessionStart  source=compact  prompt_id=04b43d44
PostCompact   trigger=manual  prompt_id=04b43d44
Notification  notification_type=idle_prompt

Aborted compact ("Not enough messages to compact")

PreCompact    trigger=manual  prompt_id=991e0fa7
(nothing else)

Also measured: /compact fires no UserPromptSubmit at all, and session_id is stable across the whole window.

The decision

Register PostCompact only — and deliberately not PreCompact.

PreCompact fires before the compact is validated, and an aborted compact emits it alone. Naively mapping it to working would 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.

PostCompact carries its own trigger, 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 from PreCompact forward.

Event Mapping
PostCompact manual done, with sessionBoundary: true
PostCompact auto no state change
PreCompact not registered, not mapped

sessionBoundary is mandatory, not decoration: a plain done is 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.

auto claims nothing because it runs inside a turn that resumes and emits its own Stop.

Which gates a completion may clear

Mapping PostCompact to done is not enough on its own: resolveClaudePaneState can still gate the
lead's done back up to working. Review found that this is what actually holds the pane STA-2915
reports, 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":

Gate Evidence behind it A manual completion
A subagent restored from a disk snapshot none — hydration reseeded it, nothing has reported since retires it
A subagent observed in this runtime a real SubagentStart on this listener leaves it holding working
An unclassifiable running background task a live background_tasks inventory leaves it holding working
A registered session cron a live session_crons inventory leaves it holding working

A manual /compact only ever completes at an idle prompt, so a child that exists only as a snapshot
has 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 restoredUnconfirmed off a hydrated row and restart the
30-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

  • A valid provider prompt id is required (the deleted guard required one; duplicate suppression also needs it to key on).
  • A completion clears a row but never creates one, so a retired pane cannot be resurrected.
  • 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 very restart case this fixes.
  • A consumed prompt id stops relay duplicates from refreshing the row.

Mixed versions

No new wire field and no new stream opcode, so no capability negotiation. compactTrigger already existed on the envelope and on both ingest paths.

  • Old client + new host — the envelope is dropped for want of an anchor. Status quo.
  • New client + old relay — the old relay normalizes with its own shipped mapping and forwards, so ingest drops auto envelopes and stamps the boundary on manual ones (the old relay built them before the flag existed, so they arrive as a plain done).
  • Old relay replay — it strips compactTrigger before 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.
  • The relay preserves compact identity in its replay cache, so a reconnecting client re-runs pane ownership before applying the clearing row. This prevents a cold relay from replaying an unowned completion as an ordinary done row 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, sessionBoundary suppression, the three restart shapes (no cached row, stale connectionId, 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-relay manual/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 working replay is asserted from a finished pane, so it
can fail.

Landing alongside #15189 and #15212

All three touch src/shared/agent-hook-listener.ts. Merged fresh onto main in the order
#15189 → #15202 → #15212:

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 subagent
roster 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/DIRTY and 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 /compact at 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: isValidClaudeSubagentId as a pre-check before allocating a roster, trimming lifecycle/inventory agent ids so a padded id matches its own roster key, and dropping a waiting lead record with no stateBeforeWait instead of fabricating working. None relate to compact.


PR author: @BrennanKB5

@coderabbitai

coderabbitai Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

Next included review available in 9 minutes.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 014941c6-8ffd-4ea7-b187-63b0362a5d46

📥 Commits

Reviewing files that changed from the base of the PR and between 94f2317 and 30f99ac.

📒 Files selected for processing (11)
  • config/reliability-gates.jsonc
  • src/main/agent-hooks/manual-compact-hook-stream.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/claude/compact-status-registration.test.ts
  • src/main/claude/hook-settings.ts
  • src/main/ssh/ssh-relay-session-agent-hooks.integration.test.ts
  • src/relay/agent-hook-server.ts
  • src/shared/agent-hook-listener-claude-turn-state.test.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/claude-compact-completion.ts
  • src/shared/manual-compact-prompt-identity.test.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5bc35afe-6c86-4785-a282-b585bebb260e

📥 Commits

Reviewing files that changed from the base of the PR and between 6efd406 and 1f73fca.

📒 Files selected for processing (11)
  • config/reliability-gates.jsonc
  • src/main/agent-hooks/manual-compact-hook-stream.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/claude/compact-status-registration.test.ts
  • src/main/claude/hook-settings.ts
  • src/main/ssh/ssh-relay-session-agent-hooks.integration.test.ts
  • src/relay/agent-hook-server.ts
  • src/shared/agent-hook-listener-claude-turn-state.test.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/claude-compact-completion.ts
  • src/shared/manual-compact-prompt-identity.test.ts
💤 Files with no reviewable changes (1)
  • src/shared/manual-compact-prompt-identity.test.ts
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/main/agent-hooks/server.ts
  • src/relay/agent-hook-server.ts
  • src/main/claude/hook-settings.ts
  • src/main/ssh/ssh-relay-session-agent-hooks.integration.test.ts
  • src/shared/agent-hook-listener-claude-turn-state.test.ts
  • src/main/claude/compact-status-registration.test.ts
  • src/shared/agent-hook-listener.ts
  • config/reliability-gates.jsonc
  • src/main/agent-hooks/manual-compact-hook-stream.test.ts
  • src/shared/claude-compact-completion.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Claude compact handling now registers only PostCompact. The listener validates Claude completion ownership, rejects PreCompact, deduplicates provider prompt IDs, preserves cached prompts, and marks accepted manual completions as session boundaries. Relay handling supports legacy trigger recovery and identity-neutralized replay caching. Tests cover local hooks, remote relays, ownership validation, duplicate suppression, automatic and aborted compaction, prompt retention, and SSH event propagation.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.91% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary change: clearing panes when Claude compact completes.
Description check ✅ Passed The description thoroughly explains the bug, implementation, linked issues, compatibility behavior, and extensive testing, but omits the template headings and required visual-proof statement.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/main/claude/compact-status-registration.test.ts (1)

158-174: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add coverage for an auto compact followed by a manual compact in the same turn.

This test asserts only that the auto PostCompact returns null. It does not observe the consumed-prompt-id side effect that the auto event records in claudeConsumedCompactPromptIdByPaneKey. A sequence of auto PostCompact then manual PostCompact with the same prompt_id would leave the pane working, and no test here would fail. See the related comment on src/shared/agent-hook-listener.ts Lines 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.ts
  • src/main/agent-hooks/server.ts
  • src/main/claude/compact-status-registration.test.ts
  • src/main/claude/hook-settings.ts
  • src/main/ssh/ssh-relay-session-agent-hooks.integration.test.ts
  • src/relay/agent-hook-server.ts
  • src/shared/agent-hook-listener-claude-turn-state.test.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/claude-compact-completion.ts
  • src/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.

Comment thread src/shared/agent-hook-listener.ts Resolved
Comment thread src/shared/agent-hook-listener.ts Resolved
…-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.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-2915-4613-compact branch from 3b933cb to 3667dc8 Compare August 18, 2026 01:44
…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.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Revision after review — live evidence

Review returned REVISE on five findings plus four nits. All nine are addressed in 15853b8 and
verified live on the combined tree (main + #15189 + #15202 + #15212), on an isolated dev
instance driven through CDP only: temp HOME, ORCA_DEV_USER_DATA_PATH, throwaway git init repo,
and the target's worktree path asserted before every step.

Arm 1 — the pane STA-2915 actually reports now clears

Genuine repro, not a fixture: a real Claude pane ran a Task subagent, and the app was SIGKILLed
the instant last-status.json showed state: working with a working child. The PTY daemon was
spared, so Claude survived; the app was relaunched onto the same profile and hydrated the row.

Before — the stuck card, spinner on the pane and its restored child, both aged 2m:

before

BEFORE  state=working  subs=["working"]  updatedAt=1787024126541  acceptedStatusSeq=5
/compact
t=1     state=done     subs=[]           updatedAt=1787024297060  acceptedStatusSeq=7

One accepted write, straight to done, roster empty. After:

after

The reap is recoverable, not destructive: the sleep child was still genuinely alive, and when it
finished it re-registered as a runtime child and the pane re-resolved through the normal path
(working at t=10, back to done at t=11).

Arm 2 — an aborted compact still leaves the row byte-identical

before  state=done  updatedAt=1787023532645  acceptedStatusSeq=1
/compact  ->  "Not enough messages to compact."
after   state=done  updatedAt=1787023532645  acceptedStatusSeq=1

Not just "still done" — acceptedStatusSeq (from #15212, on the combined tree) proves the row took
no accepted write at all.

Arm 3 — a genuinely live subagent still holds working

This is the arm that protects the decision that real agent work in flight keeps the pane spinning. A
runtime SubagentStart was delivered through the running app's own loopback hook endpoint, then a
real /compact was typed into the real TUI and ran to completion (Compacted (ctrl+o to see full summary), 2m10s):

BEFORE  state=working  subs=["live-child-arm3c:working"]  acceptedStatusSeq=45
/compact ... Compacted
FINAL   state=working  subs=["live-child-arm3c:working"]  acceptedStatusSeq=46

live child

The single write (45 → 46) is the compact summarizer's SubagentStop republishing the cached lead
state, which is pre-existing behaviour. The completion itself published nothing.

Determinism behind the live arms

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.
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

The 2 red e2e jobs are a CI relay-build problem, not this PR

Every failure across both jobs is the same line, thrown at ssh:connect before any test logic runs:

Error invoking remote method 'ssh:connect': Error: Orca's local relay build is missing its
version marker at /home/runner/work/orca/orca/out/relay/linux-x64/.version. This usually
indicates a packaging or build problem; reinstall Orca.

The job log says why, earlier in the same run:

[e2e] SKIP_BUILD set and SSH relay bundle exists — skipping relay build

The relay build was skipped because a bundle was already present, but that bundle carries no .version marker — so every SSH connection is refused and the specs fail before touching anything they test. It reproduces on rerun because the cached state is identical, which is why it looks deterministic rather than flaky.

Attribution: this branch changes no e2e spec, and its only src/relay/ edits are to the agent-hook envelope/server files — code that is never reached, because ssh:connect fails first. The same two jobs fail identically on the sibling PR in this batch, whose diff is confined to compact hook registration and shares almost nothing with this one. Sibling #15212 shows fully green (48/48) only because its merge base leaves those specs unchanged, so they never run there.

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.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

End-to-end SSH validation (PR worktree, no production edits)

Verdict: land

Isolated Electron launch of brennanb2025/sta-2915-4613-compact (window.api.app.getIdentity() → devWorktreeName=sta-2915-4613-compact, devRepoRoot=/Users/brennanbenson/orca/workspaces/orca/sta-2915-4613-compact). Relay built first (pnpm build:relay). Throwaway Linux Docker SSH target (not localhost) with real demo-project at /work/demo-project (GitHub clone blocked; local bundle fallback, 67c9b95 on main). Target ssh-1787595546024-gu7eeo connected; relay deployed and hook server accepted in-container POSTs.

Measured compact stream over the remote relay hook path:

Event Visible Store
UserPromptSubmit yellow Working on SSH worktree card, agent row, and tab state=working, agentType=claude, connectionId=ssh-…
PreCompact trigger=manual still Working no new write
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...origin/main / 67c9b95. Electron/relay logs had no compact ingest errors (empty-body 204 fail-open during a first file-write miss was re-run with verified JSON).

Screenshots

Isolated profile:

01-fresh-isolated-profile.png

SSH demo-project connected:

02-ssh-demo-project-connected.png

Working before compact:

03-ssh-working-before-compact.png

Cleared after PostCompact:

04-ssh-cleared-after-postcompact.png

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.
  • pty.writeAccepted returned false, so hooks were POSTed with in-container curl to the relay hook server rather than through the PTY.
  • 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-1787595199/evidence/PR15202-ssh-validation.md (session artifact, not committed).

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Replacement screenshots — post-merge HEAD 30f99acfd2 SSH Electron validation

Verdict: land

Isolated Electron launch of brennanb2025/sta-2915-4613-compact at exact SHA 30f99acfd2d543223b038ae53b6b03bd69f635ac (window.api.app.getIdentity() → devWorktreeName=sta-2915-4613-compact, devRepoRoot=/Users/brennanbenson/orca/workspaces/orca/sta-2915-4613-compact). Local tree clean; no code edits. Relay built first (pnpm build:relay). Throwaway Linux Docker SSH target (ubuntu:24.04, not localhost) with real demo-project at /work/demo-project (GitHub clone blocked; local bundle fallback, 67c9b95 on main). Target ssh-1787596642148-demo connected; linux-arm64 relay started; hook server accepted in-container POSTs.

Measured compact stream over the remote relay hook path:

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:

01-fresh-isolated-profile.png

SSH demo-project connected:

02-ssh-demo-project-connected.png

Working before compact:

03-ssh-working-before-compact.png

Cleared after PostCompact:

04-ssh-cleared-after-postcompact.png

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).

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review complete — land

  • Found and fixed one substantive regression: a cold relay replay stripped PostCompact identity, which could replay an unowned completion as an ordinary done row and resurrect a retired pane. The replay cache now preserves compact identity so the client re-runs ownership; regression coverage was added (148726f90d, gate wording in 705412874e).
  • Resolved the current origin/main conflict in src/shared/agent-hook-listener.ts by preserving both independent per-pane maps and their initializers. Merge commit: 30f99acfd2.
  • Same-model review and final readiness/performance passes are clean. Focused compact/relay suite: 117/117. Post-merge interaction suite: 73/73. Typecheck, Oxlint, 93 reliability gates, and diff checks pass.
  • Full PR CI is green, including Node 24/26 shards, static analysis, cross-version wire compatibility, Git compatibility, Windows packaging, changed e2e, and SSH Docker isolation.
  • Exact post-merge Electron/SSH validation at 30f99acfd2 passed against a throwaway Linux SSH target with a real demo-project: visible Working → PreCompact no-op → visible Done after PostCompact with sessionBoundary=true; duplicate completion did not refresh state. Logs were clean and test resources were removed.
  • Replacement screenshots and detailed evidence: fix(agent-status): clear the pane when a Claude compact finishes (STA-2915, STA-4613) #15202 (comment)

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 /compact; restart-hydration and live-child gating are covered by the focused automated suites. This is not a landing blocker.

Verdict: land.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Manual validation update:

  • Ran one real Claude Code TUI session (2.1.237, Opus 5) from this branch with Orca’s registered production hook environment.
  • Built conversation context, then invoked /compact exactly once.
  • Compaction completed successfully and the PostCompact hook reported successful completion with {}.
  • Exited the TUI cleanly; the worktree remained clean.

This manually covers the Claude TUI /compact flow for this PR.

@brennanb2025
brennanb2025 merged commit 1921ba2 into main Aug 24, 2026
50 checks passed
brennanb2025 added a commit that referenced this pull request Aug 24, 2026
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.
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 25, 2026
…-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)
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…-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
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…-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
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