Repository navigation
fix: propagate hook-only agent status to Remote Orca Server clients (#7970) - #7998
Conversation
On a headless Remote Orca Server, agent-status hooks (OSC 9999) updated the retained row map but never republished PTY-backed session snapshots — only terminal *title* changes did. Paired desktop/web/mobile clients therefore kept a stale agent state (e.g. opencode working/idle) until relaunch, and even title-driven updates carried an empty prompt and no agent identity because the snapshot builder only used the title heuristic (#7970). - retainAgentRowSnapshot reports client-visible changes (state, prompt, agent type, tool, interactive prompt, interrupted) so handlePtyData can republish snapshots on hook-only transitions without fanning out a rebuild per repeated same-state hook ping. - buildPtyMobileAgentStatus prefers the fresh retained hook payload over the title-only fallback, so clients see the real state/prompt/agentType and interactive prompts. The non-agent-title suppression (#1437 stuck spinners) still wins unless the hook shows a live tool/question signal, and it now also covers leaf-backed panes with no PTY record. Co-authored-by: Orca <[email protected]>
worktreesChanged/reposChanged emitted during a transport gap are lost, not queued. A quick drop can replay without flipping the environment unreachable, so the reachability-transition refetch never runs and a server-created worktree stays invisible until relaunch (#7970). Request a debounced project refresh on the replay tag, mirroring the SSH-state refetch that already rides it. Co-authored-by: Orca <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated runtime agent-status retention to detect client-visible snapshot changes and republish PTY-backed mobile session tabs accordingly. Mobile agent-status generation now resolves fresh retained snapshots, preserves live hook signals when title evidence is absent, normalizes retained status fields, and falls back to PTY status when needed. Added headless-mode tests for hook-only republishing, duplicate OSC 9999 suppression, and clearing retained working status after shell title recovery. Runtime client transport gaps now also schedule a debounced project refresh. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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.
🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)
5677-5708: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAccumulator ordering is load-bearing — keep the call on the left.
this.retainAgentRowSnapshot(...) || retainedChangedcorrectly evaluates the call first, so its snapshot-retention side effect runs for every payload/target regardless of the accumulated value. Reversing the operands would short-circuit and skip retention onceretainedChangedis true. Worth a brief inline note so a future refactor doesn't flip it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c612fa67-387a-4503-a82c-35a483da880f
📒 Files selected for processing (2)
src/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.ts
…tablyai#7970) (stablyai#7998) * fix: propagate hook-only agent status to Remote Orca Server clients On a headless Remote Orca Server, agent-status hooks (OSC 9999) updated the retained row map but never republished PTY-backed session snapshots — only terminal *title* changes did. Paired desktop/web/mobile clients therefore kept a stale agent state (e.g. opencode working/idle) until relaunch, and even title-driven updates carried an empty prompt and no agent identity because the snapshot builder only used the title heuristic (stablyai#7970). - retainAgentRowSnapshot reports client-visible changes (state, prompt, agent type, tool, interactive prompt, interrupted) so handlePtyData can republish snapshots on hook-only transitions without fanning out a rebuild per repeated same-state hook ping. - buildPtyMobileAgentStatus prefers the fresh retained hook payload over the title-only fallback, so clients see the real state/prompt/agentType and interactive prompts. The non-agent-title suppression (stablyai#1437 stuck spinners) still wins unless the hook shows a live tool/question signal, and it now also covers leaf-backed panes with no PTY record. Co-authored-by: Orca <[email protected]> * fix: refetch remote projects when the client-events stream replays worktreesChanged/reposChanged emitted during a transport gap are lost, not queued. A quick drop can replay without flipping the environment unreachable, so the reachability-transition refetch never runs and a server-created worktree stays invisible until relaunch (stablyai#7970). Request a debounced project refresh on the replay tag, mirroring the SSH-state refetch that already rides it. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Orca <[email protected]>
Problem — the reproducible half of #7970 (STA-1557)
On a headless Remote Orca Server (
orca serve), agent-status hooks (OSC 9999) update the server's retained agent-row map but never republish the PTY-backed session snapshots — only terminal title changes do (shouldTouchPtyBackedSessionTabsinhandlePtyData). Paired clients therefore keep a stale agent state (e.g. opencode working/idle) indefinitely. On top of that,buildPtyMobileAgentStatusderived status only from the title heuristic, so even title-driven updates reached clients with an empty prompt and no agent identity, and hook-only states likewaitingnever surfaced at all.Repro (verified live on main before the fix): pair a desktop client with
orca serve, create a terminal in a server worktree, emitESC ]9999;{"state":"waiting",...} BELwith no title change → client stays on the previous state forever.The other half of #7970 — already fixed in v1.4.131
The report's worktree-sync symptom ("child worktrees created via the orchestration skill don't show up until relaunch") did not reproduce on main:
worktreesChanged/reposChangedclient events propagate CLI-created worktrees (incl.--parent-worktreelineage) to paired clients within seconds, and after a 2-minute wedged transport (SIGSTOP'd server) the client detects the dead link, reconnects, and catches up on worktrees created during the gap — no relaunch. That recovery is #7827 + #7831, which shipped in v1.4.131, released ~2.5h after this issue was filed (issue: 2026-07-09 20:42Z; release: 23:07Z). The reporter was necessarily on ≤ v1.4.130, which has the exact "state frozen until relaunch" zombie-transport bug (#7718 family). Reporter should update to ≥ v1.4.131 for that half.Fix
retainAgentRowSnapshotnow reports whether the payload changed the retained row in a client-visible way (state, prompt, agentType, toolName, interactivePrompt, interrupted);handlePtyDatarepublishes PTY-backed session snapshots when it did. Change-gated, so chatty same-state hook pings do not fan a snapshot rebuild out to every paired client (verified by test).buildPtyMobileAgentStatusprefers the fresh retained hook payload (≤AGENT_STATUS_STALE_AFTER_MS) over the title-only fallback, so paired clients get the real state/prompt/agent identity and interactive prompts. The non-agent-title suppression (the [Mobile-Beta-Feedback]: terminal icon aways loading #1437 stuck-spinner guard) still wins unless the hook carries a live tool/question signal — mirroring the renderer-synced branch — and now also covers leaf-backed panes with no PTY record.Relationship to PR #7976
#7976 bundles a similar server-side idea (its 5th commit) with unrelated accounts/activity/native-chat/icon changes and has correctness/perf concerns: it republishes on every OSC 9999 chunk (no change gating, and
notifyMobileSessionTabsChangedhas no debounce), forceskeepFullAgentStatusfor any hook row < 15 min old even when the title says the shell owns the pane (reintroducing the #1437 stuck-spinner class), and itsaccounts.listchange regresses the mobile await-refresh contract. This PR fixes the #7970 slice narrowly; the accounts work (#7973) should be evaluated as its own PR.Validation
orca-runtime.test.ts(4 new: hook-only republish with payload richness, waiting transition, identical-payload no-churn, shell-title suppression over a fresh hook row).pnpm typecheck:nodeclean; oxlint clean.orca serve+ desktop client via pairing code, CDP-inspected client store):waitingnever arrived (stale >48s, then indefinitely)workingarrives withprompt/agentType,waitingtransition arrives, shell-title reclaim clears the row (no stuck spinner)--parent-worktreelineage), repo add, and 2-min transport-wedge catch-up all still sync live.Fixes the remaining live-sync gap of #7970.
Made with Orca 🐋
Addendum — replay-gap hardening (second commit)
worktreesChanged/reposChangedemitted during a transport gap are lost, not queued. A quick drop can replay the client-events stream without ever flipping the environment unreachable, so the reachability-transition refetch never runs and a server-created worktree stays invisible until relaunch. The replay tag on the first post-reconnect response now also requests a debounced project refresh (repos + worktrees + lineage), mirroring the SSH-state refetch that already rides it (#7831). This closes the remaining lost-event corner of the worktree-sync half of #7970 for both desktop and paired web clients.