Repository navigation
fix(native-chat): settle sidebar agent status while the chat pane is hidden - #18713
brennanb2025 wants to merge 4 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe structured session read owner now tracks pending-turn retentions and exposes retain/release callbacks. The outbox retains turns during dispatch and retry, and releases them after refusal, rejection, or send failure. Retry preparation now handles operation ID rotation and retry state. Tests cover hidden-turn settlement and retention across send and unmount. Merge Risk: 🔵 Low · up to The production fix appears functional, but the regression test does not fully guard its retention behavior. This is bounded test-coverage risk rather than a demonstrated runtime defect. 🚥 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.
✅ No new issues found.
Reviewed changes
- Retain read-owner activation during hidden active turns —
useStructuredAgentSessionReadObservationnow activates the shared session read owner while the projection has a running turn, so the turn-completion tombstone is still observed after the chat pane hides. - Hidden-pane settlement regression test — a new
StructuredAgentSessionStatusBridgetest drives a running turn, hides the pane, delivers a removal batch, and asserts the sidebar flipsworking → doneand the subscription is released only after settlement.
The activation predicate (activeStructuredAgentSessionTurnId) is deliberately scoped to the working state, which settles autonomously; the attention/blocked state settles through pane interaction and correctly needs no hidden-pane observation.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.test.tsx (1)
290-292: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert
retainPendingTurnis captured before you call it.
retainPendingTurn?.('client-1')skips the call silently when the capture at line 141 does not run. The batch at lines 297-331 still settles todoneand still triggers oneunsubscribe, so this regression test passes without exercising retention at all. Test 1 already guards this at lines 238-239. Mirror that assertion here.💚 Proposed fix
act(() => { + expect(retainPendingTurn).not.toBeNull() retainPendingTurn?.('client-1') })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 39e96240-f5a9-4d05-a3a6-c8204c7f283e
📒 Files selected for processing (8)
src/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.test.tsxsrc/renderer/src/components/native-chat/structured-agent-session-outbox-retry.tssrc/renderer/src/components/native-chat/structured-agent-session-pending-turn-retentions.tssrc/renderer/src/components/native-chat/structured-agent-session-read-owner.tssrc/renderer/src/components/native-chat/use-structured-agent-session-outbox.test.tsxsrc/renderer/src/components/native-chat/use-structured-agent-session-outbox.tssrc/renderer/src/components/native-chat/use-structured-agent-session-read.tssrc/renderer/src/components/native-chat/use-structured-agent-session.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/components/native-chat/use-structured-agent-session-read.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.
There was a problem hiding this comment.
Important
The new pending-turn retention heuristic can release a queued send's retention before that send's turn ever starts when two sends land in the same pre-running window, leaving a hidden pane's second turn unobserved (see the inline comment).
Reviewed changes
- Added a pending-turn retention subsystem —
structured-agent-session-pending-turn-retentions.tskeeps the session read owner activated from the moment a send is queued until its turn's lifecycle settles, closing the gap between the send handoff and therunningstatus the prior commit's activation predicate relied on. - Threaded
retainPendingTurn/releasePendingTurnthrough the read path — the read owner, read hook, and session hook now expose retention/release, and the outbox retains on queue/dispatch and releases on refusal, rejection, and failure. - Extracted
prepareStructuredAgentSessionOutboxRetry— the outboxretryoperation-id rotation is factored into a pure, behavior-preserving helper. - Added hidden-pane handoff regression tests —
StructuredAgentSessionStatusBridgetests cover an immediate hidden send before its running event and a batch where running and settled lifecycles arrive together.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Electron visual proof at
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Fenced the completing turn out of the settlement scan — the
!activeTurnIdbranch increateStructuredAgentSessionPendingTurnRetentionsnow seedsclaimedTurnIdswithobservedActiveTurnId, so a turn's completion no longer releases a still-pending send's retention before that send's own turn starts. - Added a concurrent-send regression test —
does not settle a pending hidden send when the previous turn completesretains a second send while a first turn is running, completes the first turn, and asserts the pending retention survives until its own turn settles.
The new test fails against the prior version (empty claimedTurnIds) and passes with the seed in place, and the change leaves the other settlement paths (claim-on-running, release-on-removal, refusal/rejection) untouched.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Retained turn-ownership history —
createStructuredAgentSessionPendingTurnRetentionsnow tracks every observed active turn in a persistentobservedTurnIdsset (seeded on first retain, accumulated per observe, cleared when retentions empty) instead of fencing only the singleobservedActiveTurnId. The!activeTurnIdsettlement scan therefore excludes all prior turns, not just the most recent one, so a stale completion item from an earlier turn can no longer release a still-pending send's retention on a later snapshot. - Extended the regression test to three turns — the test now retains two pending sends (
client-b,client-c) and assertsunsubscribeis still unissued after the first turn settles, then drives the second turn throughrunning → donebefore the subscription releases.
The persistent-set change closes the residual window in the prior commit (where observedActiveTurnId reset to null after the completing observe, re-exposing an earlier turn's completion). The extended test fails against the single-id version and passes here.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Electron visual proof at
|
|
Final review status: clean — recommend landing at
Residual QA gaps: |
|
Superseded by #18776, which moves the status projection to the host (one status stream per client) instead of retaining the renderer's transcript reader. That also covers the unopened-tab and window-reload cases this change could not reach. Closing this one. |





Item 5: "Sometimes the sidebar agent status won't stop 'working' status until I click into the Chat UI view, even it's done working."
Reported by Jinjing in the Chat UI UI/UX feedback thread: https://stablygroup.slack.com/archives/C0BV03ZK1KN/p1788474468997739
ELI5
Every agent chat has a "listener" that watches for the message "I'm finished." That listener was only switched on while the chat was on screen. As soon as you looked at a different workspace, the listener went to sleep, so the sidebar kept showing the last thing it had heard: "working." It only woke up again when you opened the chat, which is why clicking into the Chat UI "fixed" it. Now the listener stays on whenever the agent is mid-reply, even when the chat is off screen, and goes back to sleep once the reply lands.
Before / After (user-facing)
Before
After
Root cause
The structured status bridge subscribed to the session read owner without ever activating it. Hiding the last visible reader stopped transport before the turn-completion tombstone arrived, so the projection kept reporting an active turn until the pane was reopened.
Fix
Retain read-owner activation while the cached projection still has an active turn, so settlement is observed with the pane hidden.
Validation
15/15 targeted tests including a new regression test for hidden-pane settlement;
oxlint;pnpm tc:web. Electron CDP evidence shows the sidebar going Working -> Done in the background without reopening the Chat UI.Reproduced in the real Electron app over CDP before the fix and verified after.