Skip to content

Keep remote agent status in sync after completion and approvals - #34729

Merged
nwparker merged 5 commits into
mainfrom
nwparker/paired-stale-agent-status
Oct 28, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/paired-stale-agent-status

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​755 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​751
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​220 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​208

ELI5

A remote agent could keep showing Working after it finished, or keep showing an approval after it resumed. Reconcile the host's current status and saved pane titles while preserving newer activity from the terminal itself.

What Changed

Refresh mirrored pane titles during accepted host snapshots, including inactive workspaces. Remove only proven absent durable leaf identities; preserve unknown numeric slots and use mounted pane or PTY bindings before layout replay order, so closed or moved split panes keep the correct titles.

Allow expired client state to converge even when the host clock is behind. Keep host approval/question facts authoritative across clock skew, and release the client byte fence when the displayed row was adopted from the host. A new real terminal status can reacquire ownership afterward, including when its timestamp is below the previously mirrored host value.

Why

Saved spinner titles and cross-machine timestamp comparisons could outlive completed work. A separate ownership mismatch let a previously earned byte-writer claim fence the host's own adopted approval row, preventing its completion update from appearing.

Linked Issue

Supplied remote-terminal status report. Builds on #25205, preserving sparse and moved runtime pane identities and correcting approval handback. Original contribution is credited in the commit history.

Visual Proof

Stale completion, before:

Before stale remote spinner

Stale completion, after:

After stale remote spinner

Approval continuation, before:

Before remote approval handback

Approval continuation, after:

After remote approval handback

Testing

  • Red/green tests cover stale numeric titles, expired skewed client state, removed durable leaves, sparse and reordered panes, inactive workspace completion, and live byte ownership. Old production code failed 10 of 14 initial new cases.
  • Independent final review passed 50 checks: 41 focused repository cases, six actual connection-callback provenance controls, the behind-host clock-skew regression, and two mounted-pane identity controls. Old callback code fails exactly the two mirrored-row controls. Earlier review defects were corrected before publication.
  • Exact final commit: two hidden Electron specs passed through real paired transport. The completion case deliberately seeds controlled saved stale state, then uses actual Stop snapshots, repeated refreshes, and reopen. The approval case uses a persistent terminal fixture, genuine OSC status writes, and real authenticated PreToolUse → PermissionRequest → PostToolUse hook events; no fabricated store or clock state in that case.
  • A subsequent real OSC update reacquires the byte fence and stays Working against a lagging host Done snapshot.
  • Final-head CI: all 55 reported checks settled successfully, including Ubuntu, Debian, and Fedora WSL.
  • Required local ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2: all 27 selected checks passed at the final commit.

Review

No new polling, I/O, subprocesses, protocol fields, or resource owners. Accepted snapshot reconciliation preserves record identity when unchanged. Existing fresh-byte protections remain; host-only interactive state is not decided by cross-machine wall clocks. Folder workspace behavior was rendered; git workspace and mobile mirror consumers use the same path.

Agent skill upstream boundary

  • No upstream skill-installer source was copied.

Notes

Runtime proof used macOS loopback paired transport and an instrumented terminal fixture, rather than a full agent inference turn. Native Windows/Linux/WSL and physical mobile were not run locally. Targets main after #34721 was merged. The original parent commit includes that already-merged one-line test-import repair.

Checklist

  • Focused remote status fix with independent review and before/after evidence.
  • Compatibility, ownership, sparse/moved panes, cleanup, and performance reviewed.
  • Required local affected checks and final-head CI complete.

@nwparker nwparker mentioned this pull request Oct 28, 2026
10 tasks done
@nwparker
nwparker changed the base branch from nwparker/remote-validation-test-import to main October 28, 2026 05:26
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e50a1a55-fc10-4109-8b5d-4ca306c4bd8b
Commits

Reviewing files that changed from the base of the PR and between e73f1ed and 9b30416.

Files selected for processing: 3
  • src/renderer/src/lib/worktree-status-sparse-pane.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync-stale-spinner.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync/agent-status-primitives.ts
Walkthrough

The changes refine host and client agent-status reconciliation, classify orphan runtime pane titles, and add host-derived runtime pane title updates to final patches outside local PTY mode. The patch resolves pane slots against layouts and host surfaces, preserves titles under fresh client status authority, and updates or removes saved titles. New tests cover status transitions, split-pane mapping, orphan titles, sparse pane slots, and remote completion after a hidden window is revealed.

Priority: Normal

Merge Risk: Moderate · previous review e73f1

Typecheck failures in the status-sync code and its tests will fail the type-checking CI step until they are fixed. The behavior change looks sound, but fix the predicate signature and the two test literals before merging.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description is detailed and covers the change, rationale, visual proof, testing, review, compatibility, and checklist. The Linked Issue section does not provide a completed Fixes # reference or … Add the actual issue reference in the Fixes # section. Keep or clarify the existing #25205 reference if it is the issue addressed by this pull request.
Docstring Coverage Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: synchronizing remote agent status after completion and approval handoff.
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.
Full details: Description check

Explanation

The description is detailed and covers the change, rationale, visual proof, testing, review, compatibility, and checklist. The Linked Issue section does not provide a completed Fixes # reference or a clear issue link.

Resolution

Add the actual issue reference in the Fixes # section. Keep or clarify the existing #25205 reference if it is the issue addressed by this pull request.

Full details: Docstring Coverage

Explanation

Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 13 functions across 14 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ace1e451-25bf-486c-b61e-6229bfbb368a
Commits

Reviewing files that changed from the base of the PR and between 66e2d39 and e82433f.

Files selected for processing: 14
  • src/main/claude/claude-rewind-transcript.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pane-host-capability-flags.ts
  • src/renderer/src/lib/worktree-status-sparse-pane.test.ts
  • src/renderer/src/lib/worktree-status.ts
  • src/renderer/src/runtime/web-session-tabs-sync-completion-on-reveal.test.tsx
  • src/renderer/src/runtime/web-session-tabs-sync-remote-status-title-flap.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync-stale-spinner.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync/agent-status-patch.ts
  • src/renderer/src/runtime/web-session-tabs-sync/agent-status-primitives.ts
  • src/renderer/src/runtime/web-session-tabs-sync/apply-final-patch.ts
  • src/renderer/src/runtime/web-session-tabs-sync/runtime-pane-title-patch.ts
  • src/renderer/src/runtime/web-session-tabs-sync/state.ts
  • src/shared/runtime-pane-title-leaf-id.test.ts
  • src/shared/runtime-pane-title-leaf-id.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Comment on lines +113 to +115
if (leafId === null && !isRuntimePaneTitleOrphan(layout.root, runtimePaneId, leaves)) {
continue
}

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.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

#!/bin/bash
rg -n -C4 'getLeafId' src/renderer/src/runtime/mounted-terminal-tab-registry.ts src/renderer/src/components/terminal-pane
rg -n -C3 'runtimePaneTitlesByTabId' src/renderer/src/runtime/web-session-tabs-sync-stale-spinner.test.ts

Repository: stablyai/orca

Length of output: 41396


Script executed:

#!/bin/bash
set -o pipefail
printf '%s\n' '--- target diff ---'
git diff --unified=30 b4131707fd9f1223d779d34134394587ab691881 e82433f37d8fd21795ed594b773177c7a940b882 -- src/renderer/src/runtime/web-session-tabs-sync/runtime-pane-title-patch.ts
printf '%s\n' '--- target file ---'
nl -ba src/renderer/src/runtime/web-session-tabs-sync/runtime-pane-title-patch.ts
printf '%s\n' '--- orphan definitions and callers ---'
rg -n -C8 -F -- 'isRuntimePaneTitleOrphan' src/renderer/src/runtime src/renderer/src/runtime/web-session-tabs-sync
printf '%s\n' '--- directly bound tests ---'
nl -ba src/renderer/src/runtime/web-session-tabs-sync-stale-spinner.test.ts | sed -n '1,410p'

Repository: stablyai/orca

Length of output: 35127


Script executed:

#!/bin/bash
set -o pipefail
printf '%s\n' '--- shared helper ---'
nl -ba src/shared/runtime-pane-title-leaf-id.ts
printf '%s\n' '--- sync harness and manager registration ---'
rg -n -C10 -F -- 'registerMountedTerminalTab' src/renderer/src/runtime src/renderer/src/runtime/web-session-tabs-sync src/renderer/src/runtime/web-session-tabs-sync-test-harness.ts
printf '%s\n' '--- layouts and pane bindings used by the stale-spinner tests ---'
rg -n -C8 -F -- 'ptyIdsByTabId' src/renderer/src/runtime/web-session-tabs-sync-test-harness.ts src/renderer/src/runtime/web-session-tabs-sync-stale-spinner.test.ts

Repository: stablyai/orca

Length of output: 14290


Limit title deletion to confirmed-absent durable IDs.

A numeric slot can resolve to a non-null leaf while its host surface is missing. hostTitle then remains undefined, and the current guard skips isRuntimePaneTitleOrphan before deleting the saved title. Apply the orphan check to every deletion path.

Suggested fix
--- "a/src/renderer/src/runtime/web-session-tabs-sync/runtime-pane-title-patch.ts"
+++ "b/src/renderer/src/runtime/web-session-tabs-sync/runtime-pane-title-patch.ts"
@@ -110,9 +110,12 @@
         }
       }
       // Why: a slot the layout cannot place is not proof the pane was removed.
-      if (leafId === null && !isRuntimePaneTitleOrphan(layout.root, runtimePaneId, leaves)) {
+      if (
+        hostTitle === undefined &&
+        !isRuntimePaneTitleOrphan(layout.root, runtimePaneId, leaves)
+      ) {
         continue
       }
       if (nextPaneTitles === paneTitles) {
         nextPaneTitles = { ...paneTitles }
       }
Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (leafId === null && !isRuntimePaneTitleOrphan(layout.root, runtimePaneId, leaves)) {
continue
}
if (
hostTitle === undefined &&
!isRuntimePaneTitleOrphan(layout.root, runtimePaneId, leaves)
) {
continue
}

nwparker and others added 4 commits October 27, 2026 23:56
Adapt the remote completion repair from #25205 while preserving sparse runtime pane slots through existing PTY bindings.

Co-authored-by: Manan Chataut <[email protected]>
Use mounted manager identities and retained PTY bindings ahead of replay order; keep fresh byte-stream ownership on the correct moved pane.
- Share the byte-write timing decision (resolveRendererOwnedAgentStatusTiming) between pty-connection and the flap test so reverting it fails a test.
- Only delete a saved pane title when its durable leaf is absent from both the host layout and local panes; unresolved or surface-less slots are kept.
- Share the client-fence predicate (clientAgentStatusFencesHost) between status and title reconciliation.
- Cover removed-leaf spinner fallback in worktree status and a client split absent from a pre-split host snapshot.
@nwparker
nwparker force-pushed the nwparker/paired-stale-agent-status branch from e82433f to e73f1ed Compare October 28, 2026 07:12

@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.

Actionable comments posted: 3


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bc483529-531f-45fe-a4f1-29b4aa12f1e0
Commits

Reviewing files that changed from the base of the PR and between e82433f and e73f1ed.

Files selected for processing: 11
  • src/renderer/src/components/terminal-pane/pty-connection/pane-host-capability-flags.ts
  • src/renderer/src/components/terminal-pane/renderer-owned-agent-status-registry.ts
  • src/renderer/src/lib/worktree-status-sparse-pane.test.ts
  • src/renderer/src/lib/worktree-status.ts
  • src/renderer/src/runtime/web-session-tabs-sync-remote-status-title-flap.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync-stale-spinner.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync/agent-status-patch.ts
  • src/renderer/src/runtime/web-session-tabs-sync/agent-status-primitives.ts
  • src/renderer/src/runtime/web-session-tabs-sync/runtime-pane-title-patch.ts
  • src/shared/runtime-pane-title-leaf-id.test.ts
  • src/shared/runtime-pane-title-leaf-id.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

[{ id: 'tab', title: 'zsh', launchAgent: 'codex' }],
[],
{ tab: ['pty-a'] },
{ tab: { [LEAF_C]: '⠋ Codex' } },

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.

Major · Functional Correctness · Quick win

Fix the TS2353 typecheck error in the orphan-title test.

getWorktreeStatus types runtimePaneTitlesByTabId as Record<string, Record<number, string>>. The fresh object literal { [LEAF_C]: '⠋ Codex' } has a string key that is not numeric. TypeScript rejects it with TS2353. The CI log reports this exact error at Line 37, so typecheck:ci fails.

The CI log names an earlier commit (0d3eb96) than the reviewed revision. The line content is unchanged, so the error likely remains. Confirm with the typecheck.

Build the titles as a non-literal Record<string, string> and pass the variable. This assignment is valid because a string index signature satisfies the numeric index signature.

🐛 Proposed fix
--- "a/src/renderer/src/lib/worktree-status-sparse-pane.test.ts"
+++ "b/src/renderer/src/lib/worktree-status-sparse-pane.test.ts"
@@ -34,7 +34,7 @@
         [{ id: 'tab', title: 'zsh', launchAgent: 'codex' }],
         [],
         { tab: ['pty-a'] },
-        { tab: { [LEAF_C]: '⠋ Codex' } },
+        { tab: durableLeafTitles },
         { terminalLayoutRootsByTabId: { tab: { type: 'leaf', leafId: LEAF_A } } }
       )
     ).not.toBe('working')

Add this declaration inside the it callback, before the expect call:

const durableLeafTitles: Record<string, string> = { [LEAF_C]: '⠋ Codex' }
Tools
GitHub Actions: PR 34729 | source 0d3eb96 | workflow 0d3eb96 | unit full / 15_static analysis and typecheck.txt

[error] 37-37: TypeScript error in bun config/tsconfig.tc.web.json: Object literal specifies [LEAF_C], which is not a known property of Record<number, string> (TS2353).

GitHub Actions: PR 34729 | source 0d3eb96 | workflow 0d3eb96 | unit full / static analysis and typecheck

[error] 37-37: TypeScript error TS2353: Object literal property '[LEAF_C]' does not exist in type 'Record<number, string>'. The pnpm run typecheck:ci --bun-concurrency=2 --bun-threads=2 check failed.

Source: Pipeline failures

Comment on lines +100 to +102
hostEntry: AgentStatusEntry | undefined,
now: number
): existing is AgentStatusEntry {

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.

Major · Functional Correctness · Quick win

Supported by static analysis

Script executed:

#!/bin/bash
# Confirm agentStatus allows null on the terminal surface type.
rg -nP -C2 'agentStatus\??:' src/shared/runtime-types.ts
# List all callers of clientAgentStatusFencesHost.
rg -nP -C3 '\bclientAgentStatusFencesHost\s*\(' src

Repository: stablyai/orca

Length of output: 2724


Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- helper ---'
nl -ba src/renderer/src/runtime/web-session-tabs-sync/agent-status-primitives.ts | sed -n '1,135p'
printf '%s\n' '--- agent-status patch ---'
nl -ba src/renderer/src/runtime/web-session-tabs-sync/agent-status-patch.ts | sed -n '70,125p'
printf '%s\n' '--- runtime pane title patch ---'
nl -ba src/renderer/src/runtime/web-session-tabs-sync/runtime-pane-title-patch.ts | sed -n '70,115p'
printf '%s\n' '--- AgentStatusEntry declarations and agentStatus fields ---'
rg -n -F --glob '*.{ts,tsx}' -e 'interface AgentStatusEntry' -e 'type AgentStatusEntry' -e 'agentStatus:' -e 'agentStatus?:' -e 'agentStatus | null' src/renderer src/shared

Repository: stablyai/orca

Length of output: 31050


Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- TerminalSurface and state declarations ---'
rg -n -F --glob '*.ts' -e 'export type TerminalSurface' -e 'export interface TerminalSurface' -e 'type TerminalSurface' -e 'interface TerminalSurface' src/renderer/src/runtime/web-session-tabs-sync src/shared
printf '%s\n' '--- state imports and surface declaration context ---'
rg -n -F -C4 --glob '*.ts' 'TerminalSurface' src/renderer/src/runtime/web-session-tabs-sync/state.ts src/renderer/src/runtime/web-session-tabs-sync
printf '%s\n' '--- nullable runtime surface contracts ---'
nl -ba src/shared/runtime-mobile-session-tab-contracts.ts | sed -n '1,45p'

Repository: stablyai/orca

Length of output: 41987


Fix the clientAgentStatusFencesHost signature.

The type predicate is incorrect for the current caller. After existing &&, the false branch of the aliased predicate can narrow existing to never, making existing.updatedAt invalid in agent-status-patch.ts.

hostSurface.agentStatus also allows null, but the parameter excludes null. Return boolean and accept null.

🐛 Suggested fix
--- "a/src/renderer/src/runtime/web-session-tabs-sync/agent-status-primitives.ts"
+++ "b/src/renderer/src/runtime/web-session-tabs-sync/agent-status-primitives.ts"
@@ -97,9 +97,9 @@
 export function clientAgentStatusFencesHost(
   paneKey: string,
   existing: AgentStatusEntry | undefined,
-  hostEntry: AgentStatusEntry | undefined,
+  hostEntry: AgentStatusEntry | null | undefined,
   now: number
-): existing is AgentStatusEntry {
+): boolean {
   return (
     isFencedClientAgentStatus(paneKey, existing, now) &&
     !(hostEntry && hostAgentStatusPiercesClientAuthority(hostEntry))
Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
hostEntry: AgentStatusEntry | undefined,
now: number
): existing is AgentStatusEntry {
hostEntry: AgentStatusEntry | null | undefined,
now: number
): boolean {

Source: Pipeline failures

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.

1 participant