Skip to content

fix: propagate hook-only agent status to Remote Orca Server clients (#7970) - #7998

Merged
Jinwoo-H merged 2 commits into
mainfrom
Jinwoo-H/remote-issue-2
Jul 10, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
Jinwoo-H/remote-issue-2

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

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 (shouldTouchPtyBackedSessionTabs in handlePtyData). Paired clients therefore keep a stale agent state (e.g. opencode working/idle) indefinitely. On top of that, buildPtyMobileAgentStatus derived 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 like waiting never 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, emit ESC ]9999;{"state":"waiting",...} BEL with 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/reposChanged client events propagate CLI-created worktrees (incl. --parent-worktree lineage) 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

  • retainAgentRowSnapshot now reports whether the payload changed the retained row in a client-visible way (state, prompt, agentType, toolName, interactivePrompt, interrupted); handlePtyData republishes 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).
  • buildPtyMobileAgentStatus prefers 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 notifyMobileSessionTabsChanged has no debounce), forces keepFullAgentStatus for any hook row < 15 min old even when the title says the shell owns the pane (reintroducing the #1437 stuck-spinner class), and its accounts.list change 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

  • Unit: 590/590 in 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:node clean; oxlint clean.
  • Live e2e on a paired rig (headless orca serve + desktop client via pairing code, CDP-inspected client store):
    • before fix: hook-only waiting never arrived (stale >48s, then indefinitely)
    • after fix: hook-only working arrives with prompt/agentType, waiting transition arrives, shell-title reclaim clears the row (no stuck spinner)
    • regression sweep on the same rig: server-side worktree create (CLI + --parent-worktree lineage), 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/reposChanged emitted 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.

Jinwoo-H and others added 2 commits July 9, 2026 21:51
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]>
@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 869f9045-b038-451a-bbf6-a73531217e57

📥 Commits

Reviewing files that changed from the base of the PR and between 06f4d68 and deec224.

📒 Files selected for processing (1)
  • src/renderer/src/hooks/useIpcEvents.ts

📝 Walkthrough

Walkthrough

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

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change well, but it omits required template sections like Screenshots, Testing checkboxes, AI Review Report, Security Audit, and Notes. Add the missing template sections and include the testing checklist, AI review summary, security audit, screenshots/no visual change note, and platform-specific notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: propagating hook-only agent status to Remote Orca Server clients.
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.
✨ Finishing Touches
📝 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.

🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)

5677-5708: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Accumulator ordering is load-bearing — keep the call on the left.

this.retainAgentRowSnapshot(...) || retainedChanged correctly 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 once retainedChanged is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4baaca6 and 06f4d68.

📒 Files selected for processing (2)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts

@Jinwoo-H
Jinwoo-H merged commit e8c84bb into main Jul 10, 2026
2 checks passed
@AmethystLiang AmethystLiang added the orca-remote-server Remote Orca Server / orca serve / paired remote runtime label Jul 22, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

orca-remote-server Remote Orca Server / orca serve / paired remote runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants