Repository navigation
fix(agent-hooks): revive a retired pane on each provider's own new-turn event - #15344
Conversation
📝 WalkthroughWalkthroughThe server now uses hook sources to classify provider-specific new-turn events when determining retired pane status. Source-less remote events retain the existing Merge Risk: ⚪ Minimal · up to The change restores retired sidebar rows on each provider's recognized new-turn event while preserving legacy source-less relay behavior; no actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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: 1
🧹 Nitpick comments (1)
src/main/agent-hooks/server.ts (1)
1140-1145: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReduce historical comments to brief invariant comments.
src/main/agent-hooks/server.ts#L1140-L1145: Keep one short comment that explains the provider classifier and the source-less compatibility fallback.src/main/agent-hooks/server-retired-pane-new-turn.test.ts#L63-L66: Keep one short comment that explains exhaustive provider coverage.src/main/agent-hooks/server-closed-tab-suppression.test.ts#L518-L523: Keep one short comment that explains why the test uses a non-boundary event.As per coding guidelines, comments must be concise, non-obvious, and brief.
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: fd543f6b-56c4-42d1-9e33-bff65c5edcf9
📒 Files selected for processing (3)
src/main/agent-hooks/server-closed-tab-suppression.test.tssrc/main/agent-hooks/server-retired-pane-new-turn.test.tssrc/main/agent-hooks/server.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a5f8064c-aefe-48e3-bbc1-1b113f939ce4
📒 Files selected for processing (2)
src/main/agent-hooks/server-retired-pane-new-turn.test.tssrc/main/agent-hooks/server.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/agent-hooks/server.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Behavioural validation — real grok hook events through the real hook serverUnit tests already covered all 18 sources. This closes the remaining gap: a real agent CLI's own captured bytes, driven through the real Subject: grok 1.0.5, one The finding that explains the whole bugGrok registers its hooks under PascalCase keys ( The registration name is not the emitted name. That mismatch is a good illustration of why a hand-maintained literal list rots: the name Orca writes into the vendor's config looks correct, and the name the vendor sends back is different. Verbatim captured vocabulary (one turn, in order):
The classifier is correct for grok, and this PR's test-map row ArmsBoth builds ran in one process with
Arm 2 is what makes arm 1 meaningful — it proves the capture genuinely reproduces the defect. Arm 3 is the over-broad check: a non-boundary event must not resurrect a finished agent's row. Honest limits
|
…rn event The un-retirement gate matched two raw event-name literals, UserPromptSubmit and SessionStart. Only 5 of 18 hook sources name their turn boundary that way, so for the rest a reused pane stayed rowless forever: the user starts a new turn and no row ever appears in the sidebar or dashboard. Measured, not estimated — 10 providers fail the new test on main: gemini (BeforeAgent), antigravity (PreInvocation), amp (agent.start), cursor (beforeSubmitPrompt), pi/omp/prime-agent (before_agent_start), grok (user_prompt_submit), copilot (sessionStart, seen raw), hermes (pre_llm_call). The gate was also wrong in the other direction: opencode has no turn boundary at all, yet a literal SessionStart revived its pane. Both directions are covered. The correct per-provider classifier, isNewTurnEvent, was already imported into this file and already used 160 lines below — #14706 added that call specifically so consumers would stop re-deriving boundaries from literals, and left this one. Keeps the literal check when the remote envelope omits source: that field is optional, an older relay does not send it, and requiring it would have left every source-less remote pane retired forever.
Review of the first commit found that `isAgentHookSource(envelope.source) ? envelope.source : undefined` collapses two different wire conditions into one: an older relay that omits `source`, and a NEWER host relaying a provider this build does not know. They need opposite answers. Case two is the normal upgrade order — hosts and clients update independently — and its boundary event will not be UserPromptSubmit/SessionStart, because 13 of the 18 providers we already ship are named something else. So the legacy-literal fallback stranded that provider's panes permanently: the exact defect this branch fixes, silently reintroduced for traffic our own wire doctrine calls normal. Pass the raw wire value so the gate can distinguish them, and fail OPEN on an unrecognized provider. The costs are asymmetric: a stranded pane is invisible, permanent, and has no user-facing recovery, while a spurious revive produces a row that decays after AGENT_STATUS_STALE_AFTER_MS. Also from review: - Cover the source-less branches, which had no coverage at all — including a test pinning what the legacy shim CANNOT do, so nobody later widens the literal list to "fix" it. - Use the source as agentType rather than always 'claude'; 15 of 16 rows were describing a state that cannot occur. - Reword the opencode comment: no plugin in that family emits these literals, so this closes a hole rather than removing behavior. Checked and not changed: the local HTTP path 404s an unresolvable source, so the fallback is unreachable there and masks nothing.
…tic event The negative case asserted that an opencode pane stays retired after a literal SessionStart. That rests on a false premise: origin/main's opencode plugin never emits SessionStart at all — zero occurrences in opencode/hook-service.ts, and the shared family source is what mimo-code uses too. So the assertion pinned an event no plugin sends, and it would have become actively wrong the moment a pending change gives opencode a real SessionStart, silently re-breaking the rowless reused-pane case that change exists to fix. Assert against mimo-code and command-code instead. Both genuinely have no boundary event in any planned state, so the case tests what it claims to.
5898e93 to
2af1226
Compare
Only a non-empty unknown string can identify a future provider. Keep null, blank, numeric, and object source values behind the retired-pane fence instead of treating malformed wire data as a new turn.
|
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. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/agent-hooks/server-retired-pane-new-turn.test.ts (1)
69-72: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShorten the test rationale comments.
These comments contain multi-line implementation history and repeat behavior expressed by the test names and assertions. Keep only the constraint that is necessary to understand an unusual test case.
As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”
Also applies to: 83-84, 90-91, 96-98, 114-117
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1052da41-1952-4345-b80e-ded6ecbb97b3
📒 Files selected for processing (3)
src/main/agent-hooks/server-closed-tab-suppression.test.tssrc/main/agent-hooks/server-retired-pane-new-turn.test.tssrc/main/agent-hooks/server.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/agent-hooks/server.ts
- src/main/agent-hooks/server-closed-tab-suppression.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
| it('revives on a literal boundary when an older relay omits source', () => { | ||
| expect(reviveRetiredPane(undefined, 'UserPromptSubmit')).toBe(true) | ||
| }) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Cover the source-less SessionStart fallback.
Lines 85-87 test only UserPromptSubmit. The parameterized provider cases always set source, so they do not execute the legacy fallback branch. Add a source-less SessionStart assertion. A regression that removes only this fallback literal will otherwise pass.
Proposed test update
- it('revives on a literal boundary when an older relay omits source', () => {
- expect(reviveRetiredPane(undefined, 'UserPromptSubmit')).toBe(true)
- })
+ it.each(['UserPromptSubmit', 'SessionStart'])(
+ 'revives on %s when an older relay omits source',
+ (hookEventName) => {
+ expect(reviveRetiredPane(undefined, hookEventName)).toBe(true)
+ }
+ )📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| it('revives on a literal boundary when an older relay omits source', () => { | |
| expect(reviveRetiredPane(undefined, 'UserPromptSubmit')).toBe(true) | |
| }) | |
| it.each(['UserPromptSubmit', 'SessionStart'])( | |
| 'revives on %s when an older relay omits source', | |
| (hookEventName) => { | |
| expect(reviveRetiredPane(undefined, hookEventName)).toBe(true) | |
| } | |
| ) |
Rendered sidebar proof (visual arm only)Closes the remaining user-visible gap for this PR: a retired pane’s sidebar agent row stays gone until that provider’s own new-turn event, then comes back in the full Orca window. Instance. Dev build of this worktree at Setup. Seeded a live Gemini row via authenticated POST to this instance’s Visible observations (uncropped full window, sidebar on the left):
Live row immediately before retirement, for contrast: Limits. Visual proof only — Gemini is the on-screen representative of a provider whose boundary is not |
|
Confirming this from the OMP side. Orca 1.4.182, OMP 17.3.4. The solid part first. I added a sidecar pi extension that logs every hook and retries the completion post until the server answers 2xx. Three panes have In Now something I cannot pin on this gate, offered only as a possible downstream effect. I have 47 automation runs stuck in One run argues against it being the same bug. Its Separate scope question: does this lift the tab level fence at |
…rn event (stablyai#15344) * fix(agent-hooks): revive a retired pane on each provider's own new-turn event The un-retirement gate matched two raw event-name literals, UserPromptSubmit and SessionStart. Only 5 of 18 hook sources name their turn boundary that way, so for the rest a reused pane stayed rowless forever: the user starts a new turn and no row ever appears in the sidebar or dashboard. Measured, not estimated — 10 providers fail the new test on main: gemini (BeforeAgent), antigravity (PreInvocation), amp (agent.start), cursor (beforeSubmitPrompt), pi/omp/prime-agent (before_agent_start), grok (user_prompt_submit), copilot (sessionStart, seen raw), hermes (pre_llm_call). The gate was also wrong in the other direction: opencode has no turn boundary at all, yet a literal SessionStart revived its pane. Both directions are covered. The correct per-provider classifier, isNewTurnEvent, was already imported into this file and already used 160 lines below — stablyai#14706 added that call specifically so consumers would stop re-deriving boundaries from literals, and left this one. Keeps the literal check when the remote envelope omits source: that field is optional, an older relay does not send it, and requiring it would have left every source-less remote pane retired forever. * fix(agent-hooks): tell an absent source apart from an unrecognized one Review of the first commit found that `isAgentHookSource(envelope.source) ? envelope.source : undefined` collapses two different wire conditions into one: an older relay that omits `source`, and a NEWER host relaying a provider this build does not know. They need opposite answers. Case two is the normal upgrade order — hosts and clients update independently — and its boundary event will not be UserPromptSubmit/SessionStart, because 13 of the 18 providers we already ship are named something else. So the legacy-literal fallback stranded that provider's panes permanently: the exact defect this branch fixes, silently reintroduced for traffic our own wire doctrine calls normal. Pass the raw wire value so the gate can distinguish them, and fail OPEN on an unrecognized provider. The costs are asymmetric: a stranded pane is invisible, permanent, and has no user-facing recovery, while a spurious revive produces a row that decays after AGENT_STATUS_STALE_AFTER_MS. Also from review: - Cover the source-less branches, which had no coverage at all — including a test pinning what the legacy shim CANNOT do, so nobody later widens the literal list to "fix" it. - Use the source as agentType rather than always 'claude'; 15 of 16 rows were describing a state that cannot occur. - Reword the opencode comment: no plugin in that family emits these literals, so this closes a hole rather than removing behavior. Checked and not changed: the local HTTP path 404s an unresolvable source, so the fallback is unreachable there and masks nothing. * test(agent-hooks): stop pinning opencode's fence behavior on a synthetic event The negative case asserted that an opencode pane stays retired after a literal SessionStart. That rests on a false premise: origin/main's opencode plugin never emits SessionStart at all — zero occurrences in opencode/hook-service.ts, and the shared family source is what mimo-code uses too. So the assertion pinned an event no plugin sends, and it would have become actively wrong the moment a pending change gives opencode a real SessionStart, silently re-breaking the rowless reused-pane case that change exists to fix. Assert against mimo-code and command-code instead. Both genuinely have no boundary event in any planned state, so the case tests what it claims to. * fix(agent-hooks): reject malformed relay sources at retired fence Only a non-empty unknown string can identify a future provider. Keep null, blank, numeric, and object source values behind the retired-pane fence instead of treating malformed wire data as a new turn. (cherry picked from commit d1127b9)
…rn event (stablyai#15344) * fix(agent-hooks): revive a retired pane on each provider's own new-turn event The un-retirement gate matched two raw event-name literals, UserPromptSubmit and SessionStart. Only 5 of 18 hook sources name their turn boundary that way, so for the rest a reused pane stayed rowless forever: the user starts a new turn and no row ever appears in the sidebar or dashboard. Measured, not estimated — 10 providers fail the new test on main: gemini (BeforeAgent), antigravity (PreInvocation), amp (agent.start), cursor (beforeSubmitPrompt), pi/omp/prime-agent (before_agent_start), grok (user_prompt_submit), copilot (sessionStart, seen raw), hermes (pre_llm_call). The gate was also wrong in the other direction: opencode has no turn boundary at all, yet a literal SessionStart revived its pane. Both directions are covered. The correct per-provider classifier, isNewTurnEvent, was already imported into this file and already used 160 lines below — stablyai#14706 added that call specifically so consumers would stop re-deriving boundaries from literals, and left this one. Keeps the literal check when the remote envelope omits source: that field is optional, an older relay does not send it, and requiring it would have left every source-less remote pane retired forever. * fix(agent-hooks): tell an absent source apart from an unrecognized one Review of the first commit found that `isAgentHookSource(envelope.source) ? envelope.source : undefined` collapses two different wire conditions into one: an older relay that omits `source`, and a NEWER host relaying a provider this build does not know. They need opposite answers. Case two is the normal upgrade order — hosts and clients update independently — and its boundary event will not be UserPromptSubmit/SessionStart, because 13 of the 18 providers we already ship are named something else. So the legacy-literal fallback stranded that provider's panes permanently: the exact defect this branch fixes, silently reintroduced for traffic our own wire doctrine calls normal. Pass the raw wire value so the gate can distinguish them, and fail OPEN on an unrecognized provider. The costs are asymmetric: a stranded pane is invisible, permanent, and has no user-facing recovery, while a spurious revive produces a row that decays after AGENT_STATUS_STALE_AFTER_MS. Also from review: - Cover the source-less branches, which had no coverage at all — including a test pinning what the legacy shim CANNOT do, so nobody later widens the literal list to "fix" it. - Use the source as agentType rather than always 'claude'; 15 of 16 rows were describing a state that cannot occur. - Reword the opencode comment: no plugin in that family emits these literals, so this closes a hole rather than removing behavior. Checked and not changed: the local HTTP path 404s an unresolvable source, so the fallback is unreachable there and masks nothing. * test(agent-hooks): stop pinning opencode's fence behavior on a synthetic event The negative case asserted that an opencode pane stays retired after a literal SessionStart. That rests on a false premise: origin/main's opencode plugin never emits SessionStart at all — zero occurrences in opencode/hook-service.ts, and the shared family source is what mimo-code uses too. So the assertion pinned an event no plugin sends, and it would have become actively wrong the moment a pending change gives opencode a real SessionStart, silently re-breaking the rowless reused-pane case that change exists to fix. Assert against mimo-code and command-code instead. Both genuinely have no boundary event in any planned state, so the case tests what it claims to. * fix(agent-hooks): reject malformed relay sources at retired fence Only a non-empty unknown string can identify a future provider. Keep null, blank, numeric, and object source values behind the retired-pane fence instead of treating malformed wire data as a new turn.
…rn event (stablyai#15344) * fix(agent-hooks): revive a retired pane on each provider's own new-turn event The un-retirement gate matched two raw event-name literals, UserPromptSubmit and SessionStart. Only 5 of 18 hook sources name their turn boundary that way, so for the rest a reused pane stayed rowless forever: the user starts a new turn and no row ever appears in the sidebar or dashboard. Measured, not estimated — 10 providers fail the new test on main: gemini (BeforeAgent), antigravity (PreInvocation), amp (agent.start), cursor (beforeSubmitPrompt), pi/omp/prime-agent (before_agent_start), grok (user_prompt_submit), copilot (sessionStart, seen raw), hermes (pre_llm_call). The gate was also wrong in the other direction: opencode has no turn boundary at all, yet a literal SessionStart revived its pane. Both directions are covered. The correct per-provider classifier, isNewTurnEvent, was already imported into this file and already used 160 lines below — stablyai#14706 added that call specifically so consumers would stop re-deriving boundaries from literals, and left this one. Keeps the literal check when the remote envelope omits source: that field is optional, an older relay does not send it, and requiring it would have left every source-less remote pane retired forever. * fix(agent-hooks): tell an absent source apart from an unrecognized one Review of the first commit found that `isAgentHookSource(envelope.source) ? envelope.source : undefined` collapses two different wire conditions into one: an older relay that omits `source`, and a NEWER host relaying a provider this build does not know. They need opposite answers. Case two is the normal upgrade order — hosts and clients update independently — and its boundary event will not be UserPromptSubmit/SessionStart, because 13 of the 18 providers we already ship are named something else. So the legacy-literal fallback stranded that provider's panes permanently: the exact defect this branch fixes, silently reintroduced for traffic our own wire doctrine calls normal. Pass the raw wire value so the gate can distinguish them, and fail OPEN on an unrecognized provider. The costs are asymmetric: a stranded pane is invisible, permanent, and has no user-facing recovery, while a spurious revive produces a row that decays after AGENT_STATUS_STALE_AFTER_MS. Also from review: - Cover the source-less branches, which had no coverage at all — including a test pinning what the legacy shim CANNOT do, so nobody later widens the literal list to "fix" it. - Use the source as agentType rather than always 'claude'; 15 of 16 rows were describing a state that cannot occur. - Reword the opencode comment: no plugin in that family emits these literals, so this closes a hole rather than removing behavior. Checked and not changed: the local HTTP path 404s an unresolvable source, so the fallback is unreachable there and masks nothing. * test(agent-hooks): stop pinning opencode's fence behavior on a synthetic event The negative case asserted that an opencode pane stays retired after a literal SessionStart. That rests on a false premise: origin/main's opencode plugin never emits SessionStart at all — zero occurrences in opencode/hook-service.ts, and the shared family source is what mimo-code uses too. So the assertion pinned an event no plugin sends, and it would have become actively wrong the moment a pending change gives opencode a real SessionStart, silently re-breaking the rowless reused-pane case that change exists to fix. Assert against mimo-code and command-code instead. Both genuinely have no boundary event in any planned state, so the case tests what it claims to. * fix(agent-hooks): reject malformed relay sources at retired fence Only a non-empty unknown string can identify a future provider. Keep null, blank, numeric, and object source values behind the retired-pane fence instead of treating malformed wire data as a new turn.




ELI5
When an agent finishes, Orca "retires" its sidebar row but leaves the pane reusable. Starting a new turn is supposed to bring the row back. That check only recognised two event names — and only 5 of our 18 agent integrations use them. For the other 10, the row never came back at all: you start working and the sidebar stays empty.
What Changed
src/main/agent-hooks/server.ts— the un-retirement gate now asks the per-provider classifierisNewTurnEventinstead of comparing against two raw literals.Why
server.ts:1143gated onhookEventName === 'UserPromptSubmit' || hookEventName === 'SessionStart'. Those are Claude-shaped names. Measured against the new test, 10 providers fail on main:BeforeAgentPreInvocationagent.startbeforeSubmitPromptbefore_agent_startuser_prompt_submitsessionStart(the gate sees the raw name)pre_llm_callAnd the gate was wrong in the other direction too.
opencode,mimo-codeandcommand-codehave no turn boundary at all —isNewTurnEventreturnsfalseoutright for them — yet a literalSessionStartrevived their panes. Both directions are now covered by tests.The correct classifier was already imported into this file and already used 160 lines below at
:1305. #14706 added that call specifically so no consumer would re-derive boundaries from raw literals, with a comment saying a second literal list "would strand the providers whose boundary event is named anything else" — and left this one in place. This is that consumer.Linked Issue
Refs #14626, which reported this defect. That PR is still open; this is the one-line form of its fix.
Visual Proof
N/A— the visible effect is a sidebar row appearing where none did. A before/after screenshot would be an empty sidebar next to a populated one, which carries less information than the per-provider test matrix above.Testing
New file
server-retired-pane-new-turn.test.ts— parametrised over every hook source, driving the real ingest path (ingestRemote→ the disposition), asserting the pane revives.Proven red, not assumed. Reverting
server.tsto main and rerunning: 11 failures — the 10 providers above, plus the negative case whereopencodeincorrectly revived. Restoring the fix: 17 pass.Exhaustiveness is enforced by the type, not by a hand-maintained list: the event map is a
Record<AgentHookSource, string | null>, so a new source fails typecheck here rather than silently skipping coverage.Two negative controls, both of which would catch an over-broad gate:
opencode) must stay retired;gemini+AfterAgent) must stay retired.One existing test changed, and the reason matters.
server-closed-tab-suppression.test.tsasserted that a pane whose tab was closed stays fenced after the tab-id LRU evicts. It posted pi'sbefore_agent_startand passed — but only because that event was not recognised. I measured the same scenario on main with a recognised boundary:So the property it protected already did not hold on main for the most common boundary event; it passed for a reason unrelated to its stated intent. I switched it to a non-boundary event so it tests the property it describes, and added a control asserting the same event does produce a row on an unfenced pane — otherwise the empty snapshot could pass vacuously. The original comment now records the measurement so the next reader is not misled.
Whether a genuine new turn should lift the pane fence for a closed tab is a real question, but it is pre-existing behaviour for Claude and Codex today and is not something this PR decides.
Gates, run locally:
pnpm typecheckexit 0;vitestoversrc/main/agent-hooks,src/shared/agent-hook-listener,src/main/runtime— 441 files, 5408 passed, 14 skipped;oxfmt --checkclean on all 3 changed files;oxlintclean.Review
Agent skill upstream boundary
Notes
sourceis optional on the remote envelope, and an older relay does not send it. Requiring it would have left every source-less remote pane retired forever — a silent regression for mixed-version pairs. The gate keeps the literal check on that path, so an old relay behaves exactly as it does today. This was caught by an existing test failing, not by inspection.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author