Skip to content

Preserve WSL Codex question and child completion status - #34724

Merged
nwparker merged 3 commits into
mainfrom
nwparker/remote-agent-status
Oct 28, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/remote-agent-status

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​440 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​440
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​183 $\color{#cf222e}{\Huge{\mathbf{−}}}$​62 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​121

ELI5

A Codex question in a WSL terminal could show Working while it waited for an answer. A child that finished without its stop hook could also keep the pane Working after the guest reported completion. The receiver now preserves those guest status facts.

What Changed

Reuse the existing question-tool classification when reconciling relayed Codex events. Reconcile complete transcript rosters so finished children disappear, while retaining ambiguous rosters shed to fit a transport frame.

Why

The main process re-derived every PreToolUse event as working and only merged child additions. It could overwrite a guest question and retain a completed child indefinitely. Current production scope is the WSL hook relay; paired-host and SSH snapshot mirroring use a separate path.

Linked Issue

Separately discovered WSL parity defects while investigating the supplied remote-terminal status report.

Visual Proof

Question, before:

(screenshot removed: contained real product data)

Question, after:

(screenshot removed: contained real product data)

Completed child, before:

(screenshot removed: contained real product data)

Completed child, after:

(screenshot removed: contained real product data)

These are actual baseline/target normalization, relay-cache, envelope, and ingestion results delivered unchanged through the normal main-to-renderer IPC seam in hidden macOS Electron. They verify receiver behavior and presentation; they do not exercise native Windows/WSL transport.

Testing

  • Independent review passed 62 tests across 10 focused suites.
  • Red/green ingestion tests cover current/older payloads, approval and answer transitions, two children completing separately, relay restart, and a shed-roster safety control.
  • Separate reviewer exercised the rendered IPC path: one Electron test passed, all four screenshots visually inspected. Working becomes Waiting for input; completed child Working becomes Done.
  • Final-head CI: all 42 reported checks settled successfully, including Ubuntu, Debian, and Fedora WSL.
  • Required local ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2: all 23 selected checks passed at the final commit.

Review

One bounded pass over the affected roster; no new timers, I/O, subprocesses, wire fields, or platform assumptions. Incomplete wire data cannot falsely end live work. Folder workspace identity is preserved. Desktop and mobile consumers receive the same existing status fields.

Agent skill upstream boundary

  • No upstream skill-installer source was copied.

Notes

Native Windows/WSL transport and physical mobile execution were not performed locally. Targets main after #34721 was merged. The original parent commit includes that already-merged one-line test-import repair.

Checklist

  • Focused receiver fix with independent review and rendered evidence.
  • Compatibility, failure handling, 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 9 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: f1113f31-f85a-44e4-b28c-d3f0f5c6eb59
Commits

Reviewing files that changed from the base of the PR and between cce6189 and ba925fe.

Files selected for processing: 13
  • src/main/agent-hooks/server-ingest-remote-codex-question.test.ts
  • src/main/agent-hooks/server-ingest-remote-codex-transcript.test.ts
  • src/main/agent-hooks/server/server-ingest-remote.ts
  • src/main/agent-hooks/server/server-relay-sessions.ts
  • src/main/agent-hooks/server/server-status-update.ts
  • src/main/agent-hooks/server/server-types.ts
  • src/main/agent-hooks/wsl-hook-relay-deps.ts
  • src/main/agent-hooks/wsl-hook-relay-link.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.ts
  • src/shared/agent-hook-listener/providers/codex-events.ts
  • src/shared/agent-hook-listener/providers/codex-state.ts
  • src/shared/agent-hook-relay.ts
  • src/shared/codex-subagent-roster.ts
Walkthrough

Codex hook state inference now uses the tool name to identify ask-user-question events. Child roster reconciliation handles explicit rosters, done polls without a roster, and working polls with shed-subagents data. New tests cover remote question handling, child completion, and truncated snapshots. A Claude rewind transcript test import path also changed.

Priority: Normal

Merge Risk: Low · previous review cce61

Some WSL Codex sessions may briefly show the wrong question or child status. These are bounded display-state issues, but the roster case affects a behavior this change aims to fix.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description follows the template well. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Review, Agent skill upstream boundary, Notes, and Checklist sections. The Linked Issue s… Add a real linked issue in the "Fixes #" line, or confirm the author is a stablyai maintainer who should attach a pre-existing issue. Fill in the AI Disclosure section or state that it does not apply. Confirm the Testing checkbox for manual…
Docstring Coverage Warning Docstring coverage is 50.00% 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 "Preserve WSL Codex question and child completion status" matches the main change. The diff makes the receiver keep Codex questions in a waiting state and clears completed child agents from …
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: Title check

Explanation

The title "Preserve WSL Codex question and child completion status" matches the main change. The diff makes the receiver keep Codex questions in a waiting state and clears completed child agents from the roster for WSL relayed Codex events. The title is specific and concise, and a teammate scanning history would understand the primary change.

Full details: Description check

Explanation

The description follows the template well. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Review, Agent skill upstream boundary, Notes, and Checklist sections. The Linked Issue section lacks an actual issue reference ("Fixes #" is empty), and it says the work relates to separately discovered defects, not a linked issue. The AI Disclosure section is absent. The Testing section has detailed validation. The Checklist is filled in. The Visual Proof section has before/after images for the UI behavior change. The main gap is the missing issue link, which the template says must always exist for outside contributors.

Resolution

Add a real linked issue in the "Fixes #" line, or confirm the author is a stablyai maintainer who should attach a pre-existing issue. Fill in the AI Disclosure section or state that it does not apply. Confirm the Testing checkbox for manual local testing against the platforms actually tested (macOS was used; native Windows/WSL transport was not exercised).

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% 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 2 functions across 4 files.

Resolution

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

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • 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: 2


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: b5a83c9f-23ec-4ad4-8780-608b99079a22
Commits

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

Files selected for processing: 4
  • src/main/agent-hooks/server-ingest-remote-codex-question.test.ts
  • src/main/agent-hooks/server-ingest-remote-codex-transcript.test.ts
  • src/main/claude/claude-rewind-transcript.test.ts
  • src/shared/agent-hook-listener/providers/codex-state.ts

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

Comment on lines +209 to +221
if (
!eventName &&
payload.mainAgent &&
(payload.subagents !== undefined || payload.state === 'done')
) {
// A working poll can shed its roster in transit; only explicit children or done prove removals.
const liveIds = new Set(payload.subagents?.map((child) => child.id))
for (const id of roster.keys()) {
if (!liveIds.has(id)) {
roster.delete(id)
}
}
}

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 · Data Integrity & Integration · Quick win

Supported by static analysis

Script executed:

rg -n 'codexRosterToSnapshots|shed.subagents|shedSubagents|subagents.*undefined' src/shared src/relay src/main/agent-hooks | head -100
sed -n '195,235p' src/shared/agent-hook-listener/providers/codex-state.ts

Repository: stablyai/orca

Length of output: 5285


Script executed:

set -o pipefail
printf '%s\n' '--- roster converter ---'
sed -n '1,180p' src/shared/codex-subagent-roster.ts
printf '%s\n' '--- codex event producer ---'
sed -n '1,150p' src/shared/agent-hook-listener/providers/codex-events.ts
printf '%s\n' '--- relay normalization ---'
sed -n '1,240p' src/shared/agent-hook-relay.ts
printf '%s\n' '--- receiver reconciliation ---'
sed -n '1,330p' src/shared/agent-hook-listener/providers/codex-state.ts
printf '%s\n' '--- focused references and tests ---'
rg -n -F --glob '*.ts' -e 'reconcileRemoteCodexState' -e 'codexRosterToSnapshots' -e 'subagents: undefined' -e 'mainAgent:' src/shared src/main | head -240

Repository: stablyai/orca

Length of output: 42538


Script executed:

set -o pipefail
printf '%s\n' '--- remaining codex producer ---'
sed -n '140,520p' src/shared/agent-hook-listener/providers/codex-events.ts
printf '%s\n' '--- relay all shed-field uses ---'
rg -n -F --glob '*.ts' -e 'AGENT_HOOK_SHED_FIELDS_KEY' -e 'createShedSubagentsField' -e 'restoreShedStatusFields' -e 'shedFields' src/shared src/main
printf '%s\n' '--- status normalization and payload serialization ---'
rg -n -F --glob '*.ts' -e 'function normalizeAgentStatusPayload' -e 'normalizeAgentStatusPayload(' -e 'JSON.stringify' src/shared/agent-status-types.ts src/shared/agent-hook-relay.ts src/main/agent-hooks | head -160
sed -n '300,370p' src/shared/agent-status-types.ts
printf '%s\n' '--- focused reconciliation tests ---'
sed -n '1,180p' src/shared/agent-hook-listener-codex-main-agent.test.ts
printf '%s\n' '--- producer/reconciliation call sites ---'
rg -n -F --glob '*.ts' -e 'buildCodexStatusPayload(' -e 'normalizeCodexSubagentLifecycleEvent(' -e 'reconcileRemoteCodexState(' src/shared src/main

Repository: stablyai/orca

Length of output: 36638


Script executed:

set -o pipefail
printf '%s\n' '--- transcript child reconciliation ---'
rg -n -F --glob '*.ts' -e 'reconcileCodexSubagentTranscript' -e 'finishCodexSubagent' -e 'subagents.delete' src/shared/codex-subagent-transcript.ts src/shared src/main | head -180
sed -n '1,360p' src/shared/codex-subagent-transcript.ts
printf '%s\n' '--- remote status update ---'
sed -n '120,225p' src/main/agent-hooks/server/server-status-update.ts
printf '%s\n' '--- remote ingest normalization ---'
sed -n '110,180p' src/main/agent-hooks/server-ingest-remote.ts
sed -n '1,100p' src/main/agent-hooks/server/server-remote-envelope-normalization.ts
printf '%s\n' '--- WSL relay producer/transport references ---'
rg -n -F --glob '*.ts' -e 'buildCodexStatusPayload' -e 'normalizeCodexEvent' -e 'hookEventName' -e 'shedFields' src/main/agent-hooks src/shared | head -240

Repository: stablyai/orca

Length of output: 41736


Script executed:

set -o pipefail
printf '%s\n' '--- WSL relay files ---'
rg --files src | rg -i 'wsl|relay|remote.*hook|hook.*remote'
printf '%s\n' '--- WSL relay symbols ---'
rg -n -F --glob '*.ts' -e 'wsl-hook-relay' -e 'agent.hook' -e 'createShedSubagentsField' -e 'AGENT_HOOK_SHED_FIELDS_KEY' -e 'hookEventName: undefined' src | head -260
printf '%s\n' '--- exact remote ingest ---'
sed -n '80,180p' src/main/agent-hooks/server/server-ingest-remote.ts
printf '%s\n' '--- exact relay envelope construction candidates ---'
rg -n -F --glob '*.ts' -e 'payload: ' -e 'shedFields' -e 'connectionId: null' src/main src/shared | rg -i 'relay|hook|wsl|envelope|shed|payload' | head -240

Repository: stablyai/orca

Length of output: 41612


Script executed:

set -o pipefail
printf '%s\n' '--- envelope build ---'
sed -n '1,280p' src/wsl-guest/agent-hook-envelope-build.ts
printf '%s\n' '--- envelope publication ---'
sed -n '1,340p' src/wsl-guest/agent-hook-envelope-publication.ts
printf '%s\n' '--- WSL hook server path ---'
sed -n '1,280p' src/wsl-guest/agent-hook-server.ts
printf '%s\n' '--- canonical status and cached status ---'
sed -n '1,240p' src/wsl-guest/agent-hook-canonical-status.ts
sed -n '1,240p' src/wsl-guest/agent-hook-cached-pane-status.ts

Repository: stablyai/orca

Length of output: 30246


Script executed:

set -o pipefail
printf '%s\n' '--- canonical status event ---'
rg -n -F --glob '*.ts' -e 'tmuxCanonicalStatusEvent' -e 'AgentHookEventPayload' src/shared/tmux-selected-status.ts src/shared src/wsl-guest | head -160
sed -n '1,280p' src/shared/tmux-selected-status.ts
printf '%s\n' '--- canonical status store and event mutation ---'
rg -n -F --glob '*.ts' -e 'createAgentStatusStore' -e 'hookEventName' src/shared/tmux-agent-hook-owner.ts src/shared/agent-status-store.ts src/shared/tmux-selected-status.ts | head -200
sed -n '1,280p' src/shared/tmux-agent-hook-owner.ts

Repository: stablyai/orca

Length of output: 32393


Preserve an authoritative empty Codex roster.

Transcript reconciliation can remove the last child while the root remains working. codexRosterToSnapshots then omits subagents. The relay forwards that omission without a shed marker. The receiver does not prune the cached child for named root events, so the stale child can keep the row working until a later clearing event.

Use an explicit empty roster for an existing host roster. Reconcile explicit rosters for named events. Preserve the empty-roster digest when transport shedding occurs.

Suggested fix
--- a/src/shared/agent-hook-listener/providers/codex-events.ts
+++ b/src/shared/agent-hook-listener/providers/codex-events.ts
@@
 ): ParsedAgentStatusPayload | null {
+  const roster = state.codexSubagentRosterByPaneKey.get(paneKey)
   const snapshot = options.updateLead
@@
-    subagents: codexRosterToSnapshots(state.codexSubagentRosterByPaneKey.get(paneKey)),
+    subagents: roster ? (codexRosterToSnapshots(roster) ?? []) : undefined,
--- a/src/shared/agent-hook-listener/providers/codex-state.ts
+++ b/src/shared/agent-hook-listener/providers/codex-state.ts
@@
   if (
-    !eventName &&
     payload.mainAgent &&
-    (payload.subagents !== undefined || payload.state === 'done')
+    (payload.subagents !== undefined || (!eventName && payload.state === 'done'))
   ) {
-    // A working poll can shed its roster in transit; only explicit children or done prove removals.
+    // Explicit rosters are authoritative; an unlabelled done payload also proves removals.
--- a/src/shared/agent-hook-relay.ts
+++ b/src/shared/agent-hook-relay.ts
@@
 function hasMatchingShedSubagentsField(
@@
 }
 
+function hasEmptyShedSubagentsField(shedFields: readonly unknown[]): boolean {
+  return shedFields.some((field) => field === createShedSubagentsField([]))
+}
+
@@
   const subagents =
     payload.subagents === undefined &&
-    hasMatchingTurnIdentity(payload, previous) &&
-    hasMatchingShedSubagentsField(shedFields, previous)
-      ? previous.subagents
+    hasMatchingTurnIdentity(payload, previous)
+      ? hasMatchingShedSubagentsField(shedFields, previous)
+        ? previous.subagents
+        : hasEmptyShedSubagentsField(shedFields)
+          ? []
+          : undefined
       : undefined

}
} else {
const leadState = codexLeadStateForHookEvent(eventName, payload.state)
const leadState = codexLeadStateForHookEvent(eventName, payload.state, payload.toolName)

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

Do not classify a cached tool name as the current question.

If an unnamed PreToolUse follows a request_user_input response, resolveToolState can retain request_user_input as payload.toolName. The host classifies the new event as working, but this call changes the receiver’s lead state to waiting. Preserve the current event’s tool identity separately, or clear the cached name for an unnamed PreToolUse. (raw.githubusercontent.com)

…g relay session

- Unlabelled relayed polls retire only children the current relay link listed;
  each WSL link starts a new session, so a restarted guest's partial roster
  cannot delete children an earlier guest reported.
- One removal rule: an explicit list, a done aggregate, or an unshed absent
  roster proves removals; a shed roster with live work keeps the children.
  Drops the old done-main-agent clear that wiped shed rosters.
- An unshed poll with no roster now retires the last child while the root works.
- Share the Codex hook event-to-state rule between local and relayed paths.
@nwparker
nwparker force-pushed the nwparker/remote-agent-status branch from cce6189 to ba925fe Compare October 28, 2026 07:17
@nwparker
nwparker merged commit c017ef9 into main Oct 28, 2026
54 checks passed
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