Repository navigation
fix(remote): keep the host's last assistant message on client-owned agent rows (#12906) - #14716
Conversation
…gent rows A remote pane has two writers for one agent-status key: this renderer's OSC byte pipeline and the mirrored host session.tabs snapshot. When the client owns the key, buildMirroredAgentStatusPatch keeps the client's entry wholesale and copies only paneKey/worktreeId/tabId/providerSession off the host frame. lastAssistantMessage is hook-only content the byte pipeline can never see, and setAgentStatus writes payload.lastAssistantMessage straight through, so every OSC write also blanks it. The host publishes the text and the client receives it, then discards it on every republication — the remote agent row's message line is permanently empty while identity and status render fine (#12906). Adopt it across the fence the same way providerSession already is, falling back to the mirrored value so a host that stops publishing the field cannot blank a line it already delivered.
|
Warning Review limit reached
Next review available in: 4 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
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 |
|
Agreed this is complementary, not a supersede. #9930 remains the host-side half: |
Review statusState: The review loop located the loss before fixing it. It distinguished publish / transit / render rather than patching the first plausible spot, and concluded the message is published by the host, received by the client, and then discarded by the client's own status-arbitration merge — case (c), not (a) or (b). The supporting evidence is that a remote pane has two writers for one I verified the production change is a single hunk in lastAssistantMessage:
(hostIdentityPredatesCurrentTurn ? undefined : entry.lastAssistantMessage) ??
existing.lastAssistantMessageThe asymmetry with the line above it is real and deliberate: I also confirmed the oracle claim — the field really is what the row renderers read. No wire change, and this is worth stating explicitly. Both changed files are under Validation — what was and was not done. Done: a 5-case suite that replays byte-for-byte what Not done: no live paired remote runtime was exercised. The PR states plainly that reproducing it on screen needs a live paired remote runtime with an agent mid-turn and that this environment has no sanctioned host for it, so there is no visual proof and no end-to-end run against a real This is the client half only — #9930 is the host half, and it is still open#9930 (@innocarpe, @innocarpe commented on this PR on 2026-08-15 and their account agrees with the PR body — there is no divergence to reconcile. Their words: this is "complementary, not a supersede"; #9930 "remains the host-side half: What remains broken without #9930: panes whose host status is demoted under a neutral live shell title publish no message at all, so there is nothing for this client-side fix to adopt. Conversely, #9930 alone would leave this client still discarding the message for any pane it streams. Neither subsumes the other, and #12906 was filed separately from #9914 precisely because it suspected a different cause — which the analysis confirms. No PRs are superseded by this one. Known limits a reviewer should read
Given the branch is 146 commits behind |
|
Thanks for the review-status write-up — still agreed this is complementary, not a supersede. #9930 is rebased onto current Local check after the rebase: the demotion + last-message case and the neighbouring Without this host half, a demoted-under-shell-title pane still publishes no message for this PR to adopt. Without this client half, the host message is still discarded for any pane the laptop streams. Staying out of the client path. |
…gent rows (stablyai#12906) (stablyai#14716) * fix(remote): keep the host's last assistant message on client-owned agent rows A remote pane has two writers for one agent-status key: this renderer's OSC byte pipeline and the mirrored host session.tabs snapshot. When the client owns the key, buildMirroredAgentStatusPatch keeps the client's entry wholesale and copies only paneKey/worktreeId/tabId/providerSession off the host frame. lastAssistantMessage is hook-only content the byte pipeline can never see, and setAgentStatus writes payload.lastAssistantMessage straight through, so every OSC write also blanks it. The host publishes the text and the client receives it, then discards it on every republication — the remote agent row's message line is permanently empty while identity and status render fine (stablyai#12906). Adopt it across the fence the same way providerSession already is, falling back to the mirrored value so a host that stops publishing the field cannot blank a line it already delivered. * refactor: mirror providerSession's coalesce shape and tighten the comment
…gent rows (stablyai#12906) (stablyai#14716) * fix(remote): keep the host's last assistant message on client-owned agent rows A remote pane has two writers for one agent-status key: this renderer's OSC byte pipeline and the mirrored host session.tabs snapshot. When the client owns the key, buildMirroredAgentStatusPatch keeps the client's entry wholesale and copies only paneKey/worktreeId/tabId/providerSession off the host frame. lastAssistantMessage is hook-only content the byte pipeline can never see, and setAgentStatus writes payload.lastAssistantMessage straight through, so every OSC write also blanks it. The host publishes the text and the client receives it, then discards it on every republication — the remote agent row's message line is permanently empty while identity and status render fine (stablyai#12906). Adopt it across the fence the same way providerSession already is, falling back to the mirrored value so a host that stops publishing the field cannot blank a line it already delivered. * refactor: mirror providerSession's coalesce shape and tighten the comment
…gent rows (stablyai#12906) (stablyai#14716) * fix(remote): keep the host's last assistant message on client-owned agent rows A remote pane has two writers for one agent-status key: this renderer's OSC byte pipeline and the mirrored host session.tabs snapshot. When the client owns the key, buildMirroredAgentStatusPatch keeps the client's entry wholesale and copies only paneKey/worktreeId/tabId/providerSession off the host frame. lastAssistantMessage is hook-only content the byte pipeline can never see, and setAgentStatus writes payload.lastAssistantMessage straight through, so every OSC write also blanks it. The host publishes the text and the client receives it, then discards it on every republication — the remote agent row's message line is permanently empty while identity and status render fine (stablyai#12906). Adopt it across the fence the same way providerSession already is, falling back to the mirrored value so a host that stops publishing the field cannot blank a line it already delivered. * refactor: mirror providerSession's coalesce shape and tighten the comment
ELI5
When your laptop is paired to a remote Orca runtime, every agent pane has two things writing its status into one slot: the remote host (which reads the real agent hooks and knows what the agent last said) and your own laptop (which watches the terminal bytes and can only tell "spinner on / spinner off").
To stop the two from fighting, we let the laptop win for panes it is actively streaming. But the "laptop wins" rule threw away the whole host row — including the one thing the laptop can never know: the agent's last message. So the remote agent row showed the agent's name and its status, and the message line underneath stayed blank forever.
This keeps that one field from the host, exactly the way we already keep the host's session id.
What Changed
buildMirroredAgentStatusPatch(src/renderer/src/runtime/web-session-tabs-sync.ts) now carrieslastAssistantMessagefrom the host frame onto a client-owned entry, alongside theproviderSessionit already carried:hostIdentityPredatesCurrentTurnis the predicate this line already computes forproviderSession; reusing it keeps local parity (a pane that has started a new turn shows no completion text, becausesetAgentStatuswritespayload.lastAssistantMessagestraight through and aworkingpayload carries none).?? existingfallback means a host that stops publishing the field cannot blank a line it already delivered. Host-first, unlike theproviderSessionline above it, because only the host can ever mint one.Receive-side only. No wire change, no new field, no new opcode, no capability, nothing new published. 6 added lines in one file, plus a new test file.
Why
Where the message is lost: (c), not (a) or (b)
The message is published by the host, received by the client, and then discarded by the client's own status-arbitration merge.
A remote pane has two writers for one
agentStatusByPaneKeykey:lastAssistantMessage?session.tabssnapshot →remapHostAgentStatuspty-connection.tsOSC pipeline (shouldOwnAgentStatusInRenderer = runtimeEnvironmentId !== null, i.e. every remote pane)Stopeventrenderer-owned-agent-status-registry.tsfences the host out of a pane the client both claimed and wrote, so the mirror keeps the client entry wholesale and copies onlypaneKey/worktreeId/tabId/providerSessionoff the host frame. Two things then compound:setAgentStatuswriteslastAssistantMessage: payload.lastAssistantMessagewith no merge, so every byte-derived OSC write blanks whatever the host had delivered.Net: on a remote pane, the field is destroyed and can never be restored.
terminalTitle/agentType/statesurvive because the client does produce those — which is exactly the reported shape: identity and status render, the message line never does.Both row renderers read that field and nothing else —
DashboardAgentRowMessagerenders its blank spacer whenlastAssistantMessageis falsy, andgetCompactAgentSecondaryfalls through to the agent-type label.That also explains why the reporter's
orca worktree ps --jsonon the node shows a populatedagents[].lastAssistantMessage:worktree psis a different projection that never passes through this merge.The #14621 pattern, again: a surface claiming authority it does not have
isClientAuthoritativeAgentStatusPanegrants the client authority over the whole statusrow on the strength of "claimed at transport creation and wrote once" — regardless of whether
the client can produce the field being arbitrated. That is the same shape as #14621's hook
diagnostic reporting
installedfor a host where nothing was: an authority claim wider thanthe evidence behind it.
providerSessionwas already recognised as an exception; every otherhost-only field was silently swept up with it.
The narrow fix is to carve out the field the ticket names. The general shape — the fence still
discards
interrupted,toolName/toolInput,model,subagents,orchestrationfor thesame reason — is left for whoever has a ticket that needs one of those, rather than widened
speculatively here.
Checked for the #14649 shape too (one bad element voiding a whole aggregate): the mirror loops
per surface and per pane key with no
Promise.alland no all-or-nothing collection, so a singlepane cannot void the batch.
Why the fix is on the client
The hard rule is don't make the client infer content it was not sent. This does the opposite — the client was sent the text and is throwing it away. Nothing is inferred, synthesized, or reconstructed: if the host frame carries no message and none was ever mirrored, the line stays blank (covered by a test).
Relationship to #9930 — complementary, NOT superseded
No PRs are superseded by this one.
#9930 (@innocarpe) fixes a host-side drop:
listMobileSessionTabsdemotes a staleworkingstatus under a neutral live title and omitslastAssistantMessagefrom the demoted projection. That is a real, separate loss on the publication side and it should still land.This PR fixes the client-side drop that happens after a host frame carrying the message arrives. #12906 filed separately from #9914 precisely because it suspected a different cause — it is. Neither fix subsumes the other:
Remote wire compatibility
Assessed against all three rules in
docs/reference/remote-wire-compatibility.md:lastAssistantMessagehas always been onAgentStatusEntryand has always been published on the terminal surface; this only stops the receiver discarding it.Both skew directions are covered by tests anyway:
control:test (a pane the client never wrote status for takes the host entry verbatim, exactly as before).tests/e2e/cross-version-wire/cross-version-terminal-wire.unit.test.tsruns green.On STA-3455 (agent status has no explicit owner)
This adds no new cross-machine clock comparison. The two that exist on this line (
existing.updatedAt > entry.updatedAt, andhostIdentityPredatesCurrentTurn'sstateStartedAtcompare) are untouched; the new field reuses the second one's already-computed result rather than introducing a third.Linked Issue
Fixes #12906
Related (not fixed here): #9914 — the host-side half, addressed by #9930.
Visual Proof
The change is data plumbing with no layout, styling, or component change; the rendered difference is the existing
DashboardAgentRowMessageslot going from its blank spacer to the agent's text. Reproducing it on screen needs a live paired remote runtime with an agent mid-turn, which this environment has no sanctioned host for.Behavioural before/after is pinned instead by a test that runs the real seams end to end — the real
applyFreshWebSessionTabsSnapshotmirror, the real store, the realbuildWorktreeAgentRows— and asserts on the exact field both row renderers read:Before (working tree at
ab9d1a29a9, new test file only):After:
The 3 tests that pass in both directions are the non-regression half: the host-authoritative control path and the two "never fabricate a message" invariants are unchanged by the fix.
The render half of the chain —
entry.lastAssistantMessage⇒ the visible secondary line — is already pinned by the repo's own suite and needs no new coverage:So this PR restores the field, and that test proves the field is the line.
Testing
New:
src/renderer/src/runtime/remote-agent-row-last-assistant-message.test.ts(5 cases). It replays byte-for-byte whatpty-connectiondoes for a remote pane — claim the key at transport creation, prove the claim with a byte-derived write — then drives real host snapshots through the real mirror.Every case guards against a vacuous pass — the blank-line assertions also assert the row exists.
Platforms: the changed code is renderer-side TypeScript with no OS-dependent branch. The path it fixes is by definition the remote/paired one (macOS client ↔ Linux
orca servein the report); local panes never reach this merge.Review
AGENT_STATUS_ASSISTANT_MESSAGE_MAX_LENGTH(8 KB) upstream.agentStatusEntryEqualalready compareslastAssistantMessage, so no extra republication churn; a message-only change is deliberately not sort- or aggregate-relevant, so it does not bumpagentStatusEpoch.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)pnpm typecheckdeliberately not run locally (OOM risk in this environment); the changed-code type-aware gate is green over both changed files and CI covers the rest.Out of scope
The host-side half — leaving
lastAssistantMessageon the demoted projection inlistMobileSessionTabsis fix(runtime): retain completion subtitles for paired workspaces #9930's change, not duplicated here.STA-3521 (remote agent rows cannot open their tabs when several remote agents share a project). Not the same root cause — that is activation, not content — so it is deliberately not bundled. Handing over the lead this investigation turned up, unreproduced but code-verified:
Activating a remote terminal tab requires two things, and the reference implementation is the workspace tab palette (
workspace-tab-palette-activation.ts:105-113):The RPC is what records the focus intent (
recordWebSessionFocusIntent) and sendsintent: 'user'— commented inweb-runtime-session.ts:1157as "the gesture that is supposed to wake a slept pane".activateTabAndFocusPane— the sidebar agent row's path — does only the local half.setActiveTab→activateTab(store/slices/tabs.ts:1037) never reachesweb-runtime-session, so the host is never told and no focus intent is recorded. The other three activation entry points (Terminal.tsx,useTabGroupWorkspaceModel.ts,tab-number-shortcuts.ts) all do call the RPC;activateTabAndFocusPane's five callers — sidebar agent rows, Manage Sessions, the Activity page, terminal-handle links, and the dashboard popout bridge — do not.That asymmetry fits the report's shape, including why multiplicity matters: with one agent the host's active tab already is the target, so a local-only flip is indistinguishable from a correct activation; with several it is not, and the target pane is never asked to wake.
Ruled out along the way, so nobody re-walks it: the paired mirror subscribes via
session.tabs.subscribeAll, so non-active worktrees do get their tabs mirrored — a missing-tab theory is not the gap. The one other silent no-op ishandleActivateAgentTab(WorktreeCardAgents.tsx:176-181), reachable only by rows frombuildWorktreeAgentRows' worktree-attributed fallback (worktree-agent-rows.ts:271-296); worth instrumenting second.Wiring consumers to feat(agent-status): step 1 — stamp observation provenance and ordering at every status ingress (STA-4293) #14706's
observationprovenance facet.Author