Skip to content

fix(agent-status): preserve host transition order on paired clients - #34129

Closed
Fede654 wants to merge 2 commits into
stablyai:mainfrom
Fede654:fix/mirrored-agent-status-order-by-state-start
Closed

Fede654 wants to merge 2 commits into
stablyai:mainfrom
Fede654:fix/mirrored-agent-status-order-by-state-start

Conversation

@Fede654

@Fede654 Fede654 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

A paired client can keep showing an agent as working after the host reports that it has finished. This small change lets the client follow the host's newer state even when that state's last-update timestamp is older, and prevents a repeated earlier state from bringing the spinner back.

What Changed

Extend the existing host snapshot arbitration in buildMirroredAgentStatusPatch. When two mirrored rows have different states and different state-start times, compare their state-start times in both directions. Keep the existing last-update comparison for ties and same-state updates, and preserve the existing client-ownership fence.

The regression tests cover completion with an older last-update timestamp, replay of the preceding working state, acceptance of the next turn, rejection of an older completion with either an older or newer last-update timestamp, and preservation of client-owned working state.

Why

The existing separation between host snapshots and client-owned status provides the foundation for this fix. A host completion can retain an old updatedAt, so that timestamp alone cannot order these transitions. Using the state-start times already present in the host rows keeps this adjustment local to the existing arbitration, without changing the host's published data or the client-ownership policy. Comparing in both directions also prevents an older working row from undoing an accepted completion.

Linked Issue

Addresses #25136 for the case where the host's completion reaches the client but loses the timestamp comparison. This PR does not claim to resolve the separate orphaned-title or hidden-window synchronization cases described in that report, and deliberately does not close the entire issue.

Visual Proof

Pending before/after capture of the rendered client. This is a behavior change, so visual proof is not marked N/A. Opening as a draft until that requirement is satisfied.

The deterministic regression reproduces working → done → replayed earlier working: before the correction the final state is working; after it the final state stays done, with no sort-epoch change. A subsequent new turn is accepted. These assertions supplement, rather than replace, the required visual evidence.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Validated locally on Linux, with ORCA_BACKGROUND_LAUNCH=1:

  • Five focused suites: 30 tests passed. Includes remote status/title arbitration, agent status mirroring, main-agent verdicts, unverifiable hosts, and agent handoff.
  • pnpm tc:web passed.
  • pnpm run check:code-quality:changed passed.
  • Formatting, commit hooks, and git diff --check passed.
  • The expanded completion/replay regression failed before the correction and passed afterward.

Reproduce the focused test run:

ORCA_BACKGROUND_LAUNCH=1 pnpm test src/renderer/src/runtime/web-session-tabs-sync-remote-status-title-flap.test.ts src/renderer/src/runtime/web-session-tabs-sync-agent-status.test.ts src/renderer/src/runtime/web-session-tabs-sync-remote-main-agent-verdict.test.ts src/renderer/src/runtime/web-session-tabs-sync-unverifiable-host.test.tsx src/renderer/src/runtime/web-session-tabs-sync-agent-handoff.test.ts

No manual macOS, Windows, live SSH, or rendered Electron verification was performed for this revision. Full lint, all typecheck projects, the full test suite, and build are left to CI; they are not claimed as local passes.

AI Disclosure

Prepared with OpenAI Codex (GPT-6), including code review, implementation, regression tests, and this PR description.

Review

AI-assisted self-review: this extends the existing arbitration rather than adding a second status store. The host remains the source of mirrored status; live client ownership keeps its existing precedence. There are no new IPC fields or protocol changes, so older peers continue to use the existing row shape. The change is provider-neutral and introduces no OS calls, path assumptions, git-provider logic, or worktree-only dependencies; folder workspaces use the same path. Remote/SSH behavior is covered by simulated host snapshots, not a live connection test. Mobile and other status readers are unchanged and have not been manually verified. The per-row comparison remains constant-time. No new data access, network exposure, or credentials are introduced. Visual correctness still needs the before/after verification noted above.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Rebased onto origin/main at dc735050b3c6. The scope is limited to host-mirrored transitions with distinct state-start times; same-state updates and equal timestamps retain the existing behavior.

Related work and remaining evidence

Thank you to the authors of the existing reports and fixes in this area. This draft should be evaluated alongside:

Our controlled tests establish the client behavior when state-start ordering and last-update ordering disagree. They do not establish that a current host still produces those rows after #29538, or that this is the cause of every report in #25136. A captured current-host/client reproduction (or a concrete older-peer compatibility case), plus the required visual evidence, remains necessary before presenting this draft as ready. If the host-side correction already covers the observed case, this additional client change may be unnecessary. No implementation from these PRs has been copied into this branch.

Author

GitHub: @Fede654. X/Twitter: @FedeB6209.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Fede654 and others added 2 commits October 27, 2026 15:54
…when they began, not by a stamp the host may leave stale

A host `done` can arrive with an `updatedAt` hours older than the mirrored
`working` it ends while carrying the current turn's `stateStartedAt`. The
mirror kept whichever row had the newer `updatedAt`, so the client showed
`working` until the next turn. Between two rows from the same host, a state
change with a newer `stateStartedAt` now wins; a client-owned pane still
keeps its fence.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@Fede654
Fede654 force-pushed the fix/mirrored-agent-status-order-by-state-start branch from e1fe34a to 3cfe6b6 Compare October 27, 2026 15:57
@Fede654

Fede654 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Withdrawing this draft after comparing it against the existing host-side fix in #29538 and the related proposals #25205 and #20692.

The decisive regression is in this PR: the current host's trailing-Muse-spinner scenario publishes a valid done with a newer updatedAt but an older stateStartedAt than the preceding title-derived working. This PR's state-start comparator rejects that completion and restores the stuck-working symptom that #29538 fixed.

I ran the existing host regression fixture, then replayed its projected timestamps through the renderer's real snapshot/store test harness. Current main and the merge conditions proposed in #25205 and #20692 pass that case; this branch fails it. This is automated fixture evidence, not a live paired-app capture, and does not claim either complete PR has been validated.

The reproducible rows, comparison results, and a regression test are contributed directly to #25205 here: #25205 (comment)

Thank you to the authors of the existing reports and fixes. Keeping a competing implementation with this regression would add review work without a demonstrated benefit. The earlier passing tests in this PR did not cover this valid host projection, so they were insufficient evidence for its ordering assumption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: A paired client keeps a remote Muse pane on working after its turn ends

1 participant