Skip to content

feat(native-chat): show Codex subagent activity instead of opcode rows - #18773

Merged
brennanb2025 merged 36 commits into
mainfrom
brennanb2025/codex-subagent-worklog
Sep 7, 2026
Merged

brennanb2025 merged 36 commits into
mainfrom
brennanb2025/codex-subagent-worklog

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2406 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2399
Prod 21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1652 $\color{#cf222e}{\Huge{\mathbf{−}}}$​151 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1501

What

Codex spawns subagents and reports their full lifecycle. Orca rendered gray codex · item:subAgentActivity opcode rows and nothing else. This adds the real display: one summary row per spawn group, with a live working count, per-state settling, and token usage.

Built against live protocol capture, not the schema alone

I drove codex app-server 0.152.1 directly and captured a real subagent spawn (137 frames, 2 threads). Three things the schema does not tell you, each of which would have produced a broken implementation:

  1. agentsStates arrives empty ({}) even in a real subagent run. The obvious design — read the state map — yields a permanently empty roster. All state here is accumulated from subAgentActivity.kind.
  2. Every activity item is delivered twice — once via item/started, once via item/completed. Every transition is idempotent; 4 wire deliveries produce exactly 1 journal row, and that is asserted.
  3. Children never receive thread/started — it fires once, for the root. There is no agent_nickname, agent_role, or depth to read. The row labels from the trailing segment of agentPath (/root/list_directory → list_directory).

Token totals are summed as latest snapshot per child thread, not accumulated updates — each thread emits a running total repeatedly. Probe showed parent 26099 vs child 40661, i.e. parent < child, so the counters are disjoint and summing children does not double-count.

Two sweeps, so a row can never claim work forever

  • Turn end — when the parent turn terminates, still-running children settle. Without this, one lost completed frame leaves "1 working" on screen indefinitely.
  • Session start — a roster restored from the journal is marked unverifiable, never "exited". Codex resume replays no non-message items, so no event can ever arrive to settle a pre-restart child. Loss of contact is not evidence of exit.

Carrier: a block variant, not a journal item kind

AgentJournalItemBodySchema is a closed z.discriminatedUnion('kind', …) enforced on every row. An unknown kind parses as MALFORMED — the corrupt-journal class that can hide the chat tab entirely. So the roster rides a new NativeChatBlock variant instead: block types are explicitly admissible when unknown by design ("Renderers select blocks by type equality and skip what they cannot draw").

The block is paired with a plain-text twin (Kicked off 2 subagents). A client that knows the block drops the twin; one that doesn't renders the sentence. Verified: mobile matches on block.type === 'tool-call' with silent fallthrough and no exhaustive switch, so it degrades to the sentence rather than breaking.

The twin deliberately carries no live count. The journal row is durable and replayed on every reconnect. The desktop renderer reconciles the block's working to unverifiable outside the live turn and drops the twin entirely — but a text-only client does neither, so a sentence saying 2 working would keep asserting two running children after the writing process died, with nothing left that could re-check them. That is the collapse docs/reference/ssh-execution-boundary.md forbids: loss of contact reported as live state. The durable sentence therefore states only what outlives its process — that the group was spawned, plus whatever outcome had latched (Ran 3 subagents (1 failed)). Liveness lives in the structured block, where a client that can reconcile it also renders it.

agents[].state is deliberately an open string in the schema, matching the file's stated doctrine for tool/dispatch states, so a state a newer build writes cannot turn an older build's row malformed.

Also

  • subAgentActivity/collabAgentToolCall are reclassified now that they render properly — feat(native-chat): model Codex MCP and web-search items instead of leaking opcodes #18763 deliberately kept them as gray rows so subagent work stayed visible until this landed.
  • MessageRow moves out of NativeChatMessageList into its own file to keep both under the max-lines budget without a disable.
  • Live elapsed uses the existing shared useNow(1000) in a leaf component rather than hand-rolled DOM ticking.

Known cost

Mobile loses the mid-flight working count. Mobile drops the structured block and renders the twin, so with the live count gone from that sentence it now reads Kicked off 3 subagents while the fan-out runs, rather than 3 working. This is the accepted price of not lying: mobile has no reconciliation, so any liveness it displayed could not be withdrawn when contact was lost. It does not lose the terminal picture — the turn-end sweep rewrites the row to Ran 3 subagents (2 unverifiable), and the case this protects is exactly the one where that sweep never runs.

Mobile has not been exercised on a device. It consumes the new block variant and the shared tool-fold change is visible there. Degradation was verified statically, not on hardware.

The roster is not seeded from the journal. After in-process group eviction (cap 32) or a restart reusing the outside-turn bucket, an N-child row can be rewritten down to one child. A correct fix needs journal-seeded roster restore; documented in the roster file header.

Tests

  • 34 in the four new test files
  • 1039 across 105 files in the regression sweep over every touched area (shared types, journal schemas, projection, tool-fold, frame disposition, the whole native-chat renderer)
  • 1579 across 152 files in src/main/codex

Lint and format clean on all 19 files. Verified against e2b70a5eba6.

🤖 Generated with Claude Code

Codex spawns subagents and reports their lifecycle, but Orca rendered only
gray `codex · item:subAgentActivity` opcode rows. Build the real display: one
summary row per spawn group with a live working count and token usage.

State is accumulated from `subAgentActivity.kind` alone. A live probe against
app-server 0.152.1 showed `agentsStates` arrives empty even in a real subagent
run, and that every activity item is delivered twice (item/started and
item/completed), so every transition is idempotent and terminal states latch.

Children never receive `thread/started`, so there is no nickname, role, or
depth to read; the row labels from the trailing segment of `agentPath`.

Two sweeps keep a row from claiming work forever: the parent turn's terminal
event settles still-running children, and session start marks a pre-restart
roster unverifiable rather than exited, since Codex resume replays no
non-message items and no event can ever settle them.

The roster rides a new NativeChatBlock variant paired with a plain-text twin.
A journal item kind could not be used: that union is closed, and an unknown
kind parses as malformed, which is the corrupt-journal class that can hide the
chat tab. Block types are explicitly admissible when unknown, so an older
client drops the block and renders the sentence.

MessageRow moves out of NativeChatMessageList to keep both files under the
max-lines budget without a disable.

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

Important

This PR adds 16 string-literal translate('components.native-chat.subagents.*') keys in NativeChatSubagentRun.tsx but never registers them in src/renderer/src/i18n/locales/en.json. pnpm run verify:localization-catalog (a step in .github/workflows/pr.yml) fails on every one, so CI blocks the PR until they are added.

Reviewed changes

  • Codex subagent roster — accumulates subAgentActivity items (each delivered twice, via item/started + item/completed) into one revised-in-place journal row per spawn group, carried as a new subagent-group block with a plain-text twin for clients that lack the block type.
  • Turn/session sweeps — a child still working at turn end becomes unverifiable (loss of contact ≠ exit); the renderer reconciles a restored roster the same way.
  • Renderers — NativeChatMessageRow/NativeChatSubagentRun render the roster (live working count, worst-settled verdict, summed token totals); MessageRow moves out of NativeChatMessageList to stay under max-lines without a disable.

⚠️ components.native-chat.subagents.* keys are not registered in en.json

NativeChatSubagentRun.tsx introduces 16 string-literal translate('components.native-chat.subagents.*') keys, but the diff does not touch src/renderer/src/i18n/locales/en.json. The catalog verifier extracts these keys and fails on each missing one — it runs as part of pnpm lint and as its own step in .github/workflows/pr.yml, so the localization gate blocks this PR.

Technical details
# Missing localization catalog entries

## Affected sites
- src/renderer/src/components/native-chat/NativeChatSubagentRun.tsx:57-213 — 16 `translate()` keys under `components.native-chat.subagents.*` with no `en.json` entry

## Required outcome
- Register every key in `src/renderer/src/i18n/locales/en.json` so `pnpm run verify:localization-catalog` passes.

## Suggested approach
- Run `pnpm run sync:localization-catalog` (the `--fix` form) to add the 16 keys with their string fallbacks.

ℹ️ Nitpicks

  • CodexSubagentRoster in src/main/codex/codex-subagent-roster.ts collides with the existing CodexSubagentRoster type in src/shared/codex-subagent-roster.ts (the agent-hook-listener's per-pane subagent map). Two unrelated concepts now share one name; a distinct name for the new class would avoid confusion.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 74bcf1a2-7ccc-467e-ba84-894510b5e05e

📥 Commits

Reviewing files that changed from the base of the PR and between fd2d2b7 and 1333d95.

📒 Files selected for processing (2)
  • src/renderer/src/components/native-chat/NativeChatSubagentRun.test.tsx
  • src/renderer/src/components/native-chat/NativeChatToolRun.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

Adds Codex subagent activity parsing, token tracking, bounded roster persistence, and settlement handling. Adds shared journal and native chat schemas for subagent groups. Adds fallback text, transcript metadata clipping, provider-frame classification, and tool-folding support. Adds native chat rendering with expandable subagent rosters, status summaries, elapsed time, and token counts. Adds coverage for translation, roster behavior, rendering, schemas, and frame disposition.

Merge Risk: 🟡 Moderate · up to 1333d

Native chat now presents subagent activity as roster rows, but an evicted live roster group can lose previously recorded child activity when revised later. This can make subagent status history incomplete and should be resolved or explicitly accepted before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 52 functions across 22 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description gives a detailed explanation of the change, rationale, implementation, known limitations, and tests. However, it omits the required linked issue, visual proof section, review section, … Add the required template sections and complete them. Include a valid issue reference under Linked Issue, attach before/after visual proof or state N/A with a reason, confirm manual testing and tested platforms, complete the Agent skill ups…
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly describes the primary change: native chat now displays Codex subagent activity instead of opcode rows.
Full details: Description check

Explanation

The description gives a detailed explanation of the change, rationale, implementation, known limitations, and tests. However, it omits the required linked issue, visual proof section, review section, agent-skill boundary checklist, notes, and checklist items. The testing section also does not confirm manual testing or supported platforms.

Resolution

Add the required template sections and complete them. Include a valid issue reference under Linked Issue, attach before/after visual proof or state N/A with a reason, confirm manual testing and tested platforms, complete the Agent skill upstream boundary, Notes, and Checklist sections, and document review status.

✨ Finishing Touches 💡 1
📝 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 989a23c4-c86c-466a-b232-b19338b267c3

📥 Commits

Reviewing files that changed from the base of the PR and between e2b70a5 and fccb28c.

📒 Files selected for processing (19)
  • src/main/codex/codex-structured-journal-limits.ts
  • src/main/codex/codex-structured-journal-translation-subagents.test.ts
  • src/main/codex/codex-structured-journal-translation.ts
  • src/main/codex/codex-subagent-activity.ts
  • src/main/codex/codex-subagent-roster.test.ts
  • src/main/codex/codex-subagent-roster.ts
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.test.ts
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.ts
  • src/renderer/src/components/native-chat/NativeChatMessageList.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
  • src/renderer/src/components/native-chat/NativeChatSubagentRun.test.tsx
  • src/renderer/src/components/native-chat/NativeChatSubagentRun.tsx
  • src/renderer/src/components/native-chat/NativeChatToolRun.tsx
  • src/renderer/src/components/native-chat/native-chat-tool-fold.test.ts
  • src/shared/agent-session-journal-schemas.ts
  • src/shared/native-chat-subagent-summary.test.ts
  • src/shared/native-chat-subagent-summary.ts
  • src/shared/native-chat-tool-fold.ts
  • src/shared/native-chat-types.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

if (typeof oldest !== 'string' || oldest === groupId) {
break
}
this.groups.delete(oldest)

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.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Do not evict active group state without preserving it.

If more than 32 groups exist, Line 222 drops the oldest group state. If that group later receives an activity event, groupFor recreates it with an empty entries map and writes the same durable identity. That revision removes previously recorded children from the roster row. If no later event arrives, its working children also cannot be settled during settleSession().

Keep active groups until they settle, or persist enough evicted state to continue revisions and settlement. Add a regression test with 33 groups and a later event for the first group.

The row led with a glyph that swapped on state — a check once every child
completed, a group icon otherwise — so a group appeared to change identity
the moment it settled. Per the approved mock, the glyph names the category
and never moves: state is carried by the status dot and the tone of the
words beside it.

Use lucide `bot`, the same glyph the individual `subAgentActivity` rows take
in the eight-category vocabulary, so the summary reads as their parent. Slot
and glyph are the mock's 16px/14px, muted by default, and the svg is
`aria-hidden` — the headline is what a screen reader announces, so the icon
never stands alone.

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

Important

The glyph change is clean, but the localization-catalog failure from the prior review is still present — the components.native-chat.subagents.* keys remain unregistered in src/renderer/src/i18n/locales/en.json, so verify:localization-catalog still blocks CI.

Reviewed changes

  • Stable bot glyph — the subagent summary row now leads with a fixed Bot glyph (SubagentGlyph, aria-hidden) instead of state-dependent Check/Users icons, so a settling row never appears to change identity. Added tests assert the glyph persists across all six states and that the word (not the icon) carries the accessible name.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Merge Sim added 2 commits September 5, 2026 01:27
…bagent-worklog

# Conflicts:
#	src/renderer/src/components/native-chat/NativeChatMessageList.tsx
#	src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
…write, and failure reporting

* Restore the exhaustive block handling that adding `subagent-group` to
  `NativeChatBlock` broke. `formatWorkerTranscriptMessage` and `boundBlock`
  both fell through to `image-ref` field access, so `tsc -p` failed for the
  CLI and node projects and `build:cli` could not emit. Both now guard on
  `image-ref` explicitly and give the roster block its own branch.

* Stop the roster's publish from evicting its own append. The sink queue
  coalesces by `coalescingKey` alone with no op-kind check, so passing the
  append's key to `tryPublish` spliced the queued append out and the row
  never reached the journal — permanently, since `lastSerialized` was
  already set. `tryPublish()` now takes no argument, matching every other
  call site. The regression test's fake sink honours the key, which the
  previous fake did not.

* Keep `collabAgentToolCall` substantive. Only the MultiAgentV2 path emits
  `subAgentActivity`, so a V1 turn has no roster row; suppressing its collab
  tool calls too would have left a V1 fan-out showing nothing at all.

* Surface a settled failure while siblings still work. The summary now
  reports the worst adverse outcome independently of the group verdict, so
  the row shows `3 working +1 failed` with a failed-coloured dot instead of
  a neutral pulsing dot. The plain-text twin names it too.

* Treat `/morpheus` as a child. Only `/root` is the turn itself; the old
  segment-count test silently dropped a valid single-segment agent.

* Refresh token-usage recency on update so an active thread is not evicted
  as the oldest entry, and scope the `agentsStates` comment to the V2 path.

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

Important

The delta's fixes are correct and well-tested, but the PR is still not mergeable: the localization-catalog gate is red. The 16 components.native-chat.subagents.* keys in NativeChatSubagentRun.tsx remain unregistered in src/renderer/src/i18n/locales/en.json, and pnpm run verify:localization-catalog (a .github/workflows/pr.yml step) still fails on each one. pnpm run sync:localization-catalog clears it with the string fallbacks.

Reviewed changes

  • Root-node detection — corrected isCodexRootAgentActivity to a literal agentPath === '/root' match, so single-segment child paths like /morpheus are counted as children instead of being dropped as the parent turn.
  • Token-usage recency — re-inserted the thread key (delete then set) in handleTokenUsage so the LRU eviction scan sees recency; a plain set kept the original insertion position and would age out an active thread.
  • Journal write — stopped the roster write() from reusing the append's coalescingKey on tryPublish(); the queue coalesces by key alone with no op-kind check, so the publish was splicing the still-queued append out and the row never reached the journal.
  • V1 collab tool calls — reverted collabAgentToolCall from status-chrome back to substantive, because only the MultiAgentV2 path emits subAgentActivity; suppressing collab tool calls rendered a V1 fan-out blank.
  • Adverse outcomes — added adverseState/adverseCount (failed/stopped/unverifiable) to summarizeSubagentGroup, surfaced immediately on the row (+1 failed) while siblings still work, and carried the count into the plain-text fallback twin.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…every second

The roster row is an `aria-live="polite"` region and it contains the elapsed
clock, which reticks once a second for as long as the fan-out runs. A screen
reader therefore reads out a fresh duration every second, burying the state
changes the live region exists to report — the headline, the verdict, and the
`+1 failed` alert.

No other live region in the transcript does this. `NativeChatToolRun`'s live
button holds only the active tool label, and in `NativeChatWorkingStatus` the
variant that shows a duration is precisely the one with no `aria-live`.

Hide the clock from the accessibility tree only while it is moving. Once the
group settles the duration is fixed, so it stays readable and costs no
announcements.
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

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

Important

The clock-suppression fix is correct and well-tested — no new issues in this delta. The PR is still blocked, however, by the unaddressed localization-catalog gate: the 16 components.native-chat.subagents.* keys in NativeChatSubagentRun.tsx remain unregistered in src/renderer/src/i18n/locales/en.json, so pnpm run verify:localization-catalog (a .github/workflows/pr.yml step) still fails. pnpm run sync:localization-catalog clears it.

Reviewed changes

  • Live-region clock suppression — while children are still working, the once-per-second elapsed clock is now wrapped in aria-hidden, so the aria-live="polite" row stops announcing a fresh duration every second (which was burying the state changes the live region exists to report). Once the group settles, the clock stops ticking and its now-fixed duration becomes readable again; two new tests assert the wrapper in each state.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@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

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 55136d07-98ee-49ad-b18b-d365e9067f8e

📥 Commits

Reviewing files that changed from the base of the PR and between e95d247 and 3f880d4.

📒 Files selected for processing (21)
  • package.json
  • src/cli/handlers/orchestration/worker-output.ts
  • src/main/codex/codex-structured-journal-limits.ts
  • src/main/codex/codex-structured-journal-translation-subagents.test.ts
  • src/main/codex/codex-structured-journal-translation.ts
  • src/main/codex/codex-subagent-activity.ts
  • src/main/codex/codex-subagent-roster.test.ts
  • src/main/codex/codex-subagent-roster.ts
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.test.ts
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.ts
  • src/main/runtime/orchestration/worker-transcript-payload.ts
  • src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
  • src/renderer/src/components/native-chat/NativeChatSubagentRun.test.tsx
  • src/renderer/src/components/native-chat/NativeChatSubagentRun.tsx
  • src/renderer/src/components/native-chat/NativeChatToolRun.tsx
  • src/renderer/src/components/native-chat/native-chat-tool-fold.test.ts
  • src/shared/agent-session-journal-schemas.ts
  • src/shared/native-chat-subagent-summary.test.ts
  • src/shared/native-chat-subagent-summary.ts
  • src/shared/native-chat-tool-fold.ts
  • src/shared/native-chat-types.ts
💤 Files with no reviewable changes (1)
  • package.json
🚧 Files skipped from review as they are similar to previous changes (12)
  • src/renderer/src/components/native-chat/native-chat-tool-fold.test.ts
  • src/renderer/src/components/native-chat/NativeChatToolRun.tsx
  • src/shared/native-chat-tool-fold.ts
  • src/main/codex/codex-structured-journal-limits.ts
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.test.ts
  • src/main/codex/codex-structured-journal-translation-subagents.test.ts
  • src/main/codex/codex-subagent-roster.ts
  • src/main/codex/codex-structured-journal-translation.ts
  • src/main/codex/codex-subagent-activity.ts
  • src/renderer/src/components/native-chat/NativeChatSubagentRun.tsx
  • src/shared/agent-session-journal-schemas.ts
  • src/shared/native-chat-types.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.

@brennanb2025

brennanb2025 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Visual proof of the Codex subagent spawn-group roster in native chat.

These states were synthetically seeded into the agent-session journal (not captured from a live Codex subagent run). Screenshots are of the real rendered Orca UI.

DOM reads (button [aria-expanded][aria-live="polite"]):

  1. Mixed in-flight (highest-value) — Kicked off 4 subagents / 3 working +1 failed · elapsed · 23.6k tokens. Status dot bg-destructive animate-pulse (failure color while the group still pulses).
  2. Expanded — per-child rows: explore/review/test working (pulsing dots) and lint failed (red, not pulsing).
  3. Fully settled completed — Ran 2 subagents / completed · 37s · 20.7k tokens. Dot bg-muted-foreground/60, no pulse.
  4. Expanded settled — explore completed · 12.4k, review completed · 8.3k.

No item:subAgentActivity opcode rows in the transcript. The Bot glyph is the same in every state (status is the dot, not the icon).

A no-failure-only in-flight row (N working with no +alert) was not captured separately; shot 1 is the in-flight proof. A settled roster on a collapsed completed user-turn is hidden behind turn-status disclosure (existing render gate); shot 3 used a settled roster without that wrapper so the completed verdict stays visible.

Mixed in-flight: 3 working +1 failed, pulsing red dot

Expanded mixed roster with per-child states

Settled completed: Ran 2 subagents

Expanded settled completed children

Captured against revision 3f880d493c4 (branch head at capture time).

…readings

Four defects from a third review pass over the Codex subagent roster.

`write()` set `lastSerialized` before the append and rolled it back only when
the APPEND was refused. A refused PUBLISH left it set, so an identical replay
short-circuited and the revision was never published again. The repo's own
pattern is the opposite: `codex-structured-item-streams.ts` advances
`checkpointLengths` only once the append AND the publish are both accepted.
Roll back on either half.

That alone did not cover the sweep, which is the LAST event a group ever gets:
its `changed` guard skips the write on a retry because every child has already
latched, stranding the settled roster's final revision. Write when the previous
attempt was refused part-way, too.

`formatWorkerTranscriptMessage` read `block.agents` as its exhaustive fallback.
The journal schema deliberately admits block types this build does not know and
`client.call` casts the RPC result instead of validating it, so a newer remote
host's block reached that line and threw `agents is not iterable`, taking down
the whole `worker read`. It printed a harmless `[image omitted]` before. Match
`subagent-group` explicitly and degrade the unknown case.

The elapsed clock measured to `now` whenever no child carried a terminal
timestamp. That is exactly the roster restored from the journal after the host
died: the reconciler latches `unverifiable` without a `settledAt`, so a child
that ran four seconds reported the time since the crash as its run length, on a
row that is not even counting. Show no duration when none is known.

Also restores package.json to origin/main: the merge had deleted one of main's
two duplicate `bench:terminal-partial-escape-tail` keys. Behaviour-preserving
(JSON is last-wins and the deleted line was the dead one), but unrelated to this
PR and better left to its own change. No gate rejects duplicate JSON keys.

The new refusal tests also cover the append-side rollback, which had none.

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

Important

The three correctness fixes in this delta are sound and well-tested, but the PR is still not mergeable. The 16 components.native-chat.subagents.* keys in NativeChatSubagentRun.tsx remain unregistered in src/renderer/src/i18n/locales/en.json, and pnpm run verify:localization-catalog (a .github/workflows/pr.yml step) still fails on every one. pnpm run sync:localization-catalog clears it. This was flagged in prior reviews and is unchanged by this delta — I'm carrying it forward because it blocks CI.

Reviewed changes — one new commit since the prior pullfrog review.

  • Refused-publish retry — CodexSubagentRoster.write() now resets lastSerialized to null when the append or the publish is refused, so an identical redelivery isn't suppressed and a settled roster's final revision can't strand; sweep() re-writes whenever lastSerialized is null.
  • Unknown-block degradation — formatWorkerRead now matches block.type === 'subagent-group' explicitly and falls back to [unsupported block] for any block type this build doesn't know, instead of reading .agents off a shape that has none (a newer host's block previously threw and took down the whole worker read).
  • No phantom duration — the subagent row's elapsed clock now renders only when working or a terminal settledAt exists, so a roster restored after a host crash stops reporting "time since the crash" as the child's run length.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…ed turn

`NativeChatToolRun` bailed out for a completed turn whose activity disclosure
is collapsed before it reached the branch that draws a roster-only run. That
guard exists to push TOOL activity behind the turn-status disclosure, and it
fires on exactly the shape a spawn group has: a roster message carries no tool
blocks, so `selectActiveToolCall` returns null and `isSettled` is true, while
the list passes `expandOverride={expandedTurnIds.has(turnKey)}` — false until
the reader opens that turn — and `activeTurnIsWorking={false}`.

That is the default state of every finished turn in the transcript, so the one
compact row this feature exists to leave behind ("Ran 3 subagents") disappeared
the moment its turn ended. Worse, `MessageRow` counts a spawn group as
renderable specifically so the row survives, then rendered a wrapper around a
component that returned null — the empty ghost bubble its own guard is written
to prevent.

Order the roster branch before the disclosure guard. A roster has no tool
activity to hide, and the guard's reasoning ("a failed child command looked
like the whole response was still running") does not reach it. Runs that do
carry tool blocks still fall through to the guard unchanged, and in practice a
roster never shares a message with them: it is its own `role: 'system'` journal
row and `isToolOnlyMessage` is false for it, so `foldToolMessages` never merges
tool blocks into it.

Also drop childless groups when building the rows, so `subagentRows.length`
stays an honest test of "something will draw" — the roster-only branch returns
a margin-bearing wrapper on the strength of it, and a group with no children
renders null.

Both tests fail with their fix reverted; the existing NativeChatToolRun suite
still passes, so the completed-turn disclosure behaviour is unchanged.

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

✅ No new issues found.

Reviewed changes

  • Roster survives settled turns — NativeChatToolRun now orders the roster-only branch (blocks.length === 0) before the completed-turn disclosure guard, so a roster message keeps drawing its "Ran N subagents" row after its turn finishes instead of falling through the guard and rendering a ghost bubble.
  • Childless groups dropped — childless spawn groups are filtered before building subagentRows, so subagentRows.length stays an honest test of "something will draw" and a group with no children renders nothing (NativeChatSubagentRun returns null on summary.total === 0).
  • Two regression tests — both new cases (roster visibility on a collapsed completed turn, and a no-op for an empty group) fail with the fix reverted; the existing NativeChatToolRun suite still passes, confirming the disclosure behaviour for tool-carrying runs is unchanged.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Visual proof re-captured at 1333d9528080dc3b3528dbaa0bf8d9ff6359d529

Supersedes the settled-state shot in comment 5550848405: that shot was taken at 3f880d493c4, where a settled roster on a collapsed completed turn could not be rendered at all, so it used a roster placed outside the turn wrapper. That was not an expected render gate — it was the defect 1333d952808 fixes, and the shot below is the same state in its real arrangement.

The data in these screenshots was synthetically seeded into the structured Codex agent-session journal (journal.db, subagent-group blocks written with their plain-text twin). No live Codex subagent run was involved. Everything shown is the real rendered Orca UI on the PR branch — real decoder, real NativeChatMessageList / NativeChatToolRun / NativeChatSubagentRun, real pane. Nothing is a component harness or a mockup.

1. Settled roster in situ on a collapsed completed turn — the shot the previous run could not take

settled in situ plus mixed in-flight

Ran 3 subagents · completed · 37s · 25.8k tokens sits directly under its own user prompt ("Summarize the last change."), above that turn's assistant reply, with a later user turn below it. That is the ordinary resting state of every finished turn, and it is exactly the shape that hit the old bail-out — all four guard conditions hold at once:

  • structuredActivityUi — true (the turn-status row, "Thinking", renders below)
  • expandOverride === false — turnKey is orca:user-A, present in expandedTurnIds? no → false, not undefined
  • isSettled — a roster message carries no tool blocks, so selectActiveToolCall is null
  • activeTurnIsWorking === false — turn A is not the current turn

Before 1333d952808 this returned null and the row vanished. It now renders. Status dot is bg-muted-foreground/60, no pulse.

The second roster in the same shot is the mixed in-flight re-confirmation: Kicked off 4 subagents · 3 working +1 failed, dot bg-destructive animate-pulse (failure colour while the group still pulses).

2. The same settled turn, expanded

settled roster expanded

Per-child breakdown in place, the turn still collapsed at the turn level: explore completed · 12.4k, review completed · 8.3k, test completed · 5.1k.

3. Mixed in-flight expanded — failure still reads correctly after the fix

both rosters expanded

explore/review/test working with pulsing dots, lint failed · 800 in the destructive colour and not pulsing.

4. No ghost bubble

Measured on the transcript container (flex flex-col gap-5) in every state above: no message row renders empty, and no empty mt-3 tool-run wrapper exists anywhere. In states 1–3 every child of the list has non-zero height and non-zero text.

Pushing the other half deliberately — a spawn group seeded with zero children:

childless group draws no bubble

No bubble, no chrome, no visible artifact where the roster would be. One honest note: MessageRow still keeps that row alive (subagentGroups.length > 0 is true for a childless group, since subagentGroupBlocks does not filter on agents.length), so it emits a zero-height div, which costs one 20px gap-5 slot — measured 40px between the neighbouring rows instead of 20px. It draws nothing and is invisible in the screenshot, and I could not reach it from the writer: all three write() call sites in codex-subagent-roster.ts require at least one entry, so a childless group appears to be unproducible by the Codex roster writer and I had to hand-write it into the journal. Flagging it only for completeness, not as a blocker.

Notes

  • One fixed lucide Bot glyph in every state is by design — state is carried by the status dot and the wording, not the icon.
  • Captured on a dedicated dev instance (isolated ORCA_DEV_USER_DATA_PATH, private vite cache) attached over CDP, devRepoRoot verified as this PR's worktree.

Every defect this feature has shipped so far lived in the assembly between
rows, and the row-level suites kept passing through all of them. Loop 4's
regression — a settled roster swallowed by the completed-turn disclosure —
was found by reading the code, not by a test, and an independent visual-proof
run observed the same symptom in the real UI and routed around it rather than
reporting it. `NativeChatToolRun` rendered alone is handed `expandOverride`
and `activeTurnIsWorking` by the test author, so it agrees with whatever the
caller was assumed to pass.

Drive the real component instead. The roster is its own `role: 'system'`
journal row carrying the producer's two blocks (structured + plain-text twin),
so what reaches the DOM depends on `foldToolMessages`, the turn-key mapping
and the disclosure state `NativeChatMessageList` owns — none of which a row
test exercises.

Three cases, on one assembled transcript that holds tool calls AND a roster:
  - a settled turn with activity collapsed, the resting state of the whole
    transcript, still shows the row (fails with loop 4's reorder reverted);
  - tool activity stays behind that disclosure and appears only on expand,
    and expanding draws no second roster (fails with the guard removed);
  - a working turn reads as a live spawn.

The first also pins that the plain-text twin is dropped rather than printed
beside the row it stands in for.

Timestamps are explicit and ascending: the list re-sorts by (timestamp, id),
so rows sharing a millisecond tie-break alphabetically and the user turn can
sort last, stranding the roster outside its own turn and reconciling live
children to `unverifiable`.

No production code changed.

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

Important

The new message-list coverage is clean and passing (12/12), but the PR is still not mergeable: the localization-catalog gate is red. The 16 components.native-chat.subagents.* keys in NativeChatSubagentRun.tsx remain absent from src/renderer/src/i18n/locales/en.json, and pnpm run verify:localization-catalog still fails on each one (re-verified this run). This predates the current commit and is unchanged by it — pnpm run sync:localization-catalog clears it.

Reviewed changes

  • Message-list-level roster tests — added a NativeChatMessageList spawn-group roster suite that drives the real list over an assembled transcript (tool calls + roster row), pinning that a settled turn with collapsed activity still shows the "Ran 2 subagents" row, tool activity stays behind the disclosure (expanding draws no second roster), and a working turn reads as a live spawn — plus that the plain-text twin is dropped rather than printed beside the block it stands in for.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…ree for a spawn group

`MessageRow` counts any `subagent-group` block as renderable, but
`NativeChatSubagentRun` renders null for a childless roster. A group with
`agents: []` therefore mounted a row that drew nothing — an empty div that still
costs the transcript one `gap-5` slot. The Codex producer never writes one (every
`write()` call site operates on a group that already holds an entry), but the
block schema admits `agents: []` with no `.min(1)`, and the wire is where such a
shape would arrive.

Narrow `subagentGroupBlocks` — whose only production caller IS that renderable
check — to the groups that will draw, behind a named `isRenderableSubagentGroup`
that `NativeChatToolRun` now shares in place of its own copy of the predicate, so
the two guards cannot drift apart again. A childless group carrying its
plain-text twin now prints the twin, which is what the twin is for; a bare one
skips the row entirely.

Also correct four comments that had stopped describing the code:
  - the roster header called `agentsStates` "always empty", contradicting the
    probe note in `codex-subagent-activity.ts` — it is empty on the MultiAgentV2
    path that emits these items, and the V1 path does populate it;
  - `tokensByThread` was documented "retained UNCONDITIONALLY" while
    `handleTokenUsage` LRU-caps it 65 lines below;
  - the sweep is not "the LAST event a group ever gets": neither `settleTurn` nor
    `settleSession` removes the group, so a later `thread/tokenUsage/updated`
    naming a swept child still writes it. The retry condition is right; only its
    stated reason was wrong;
  - the `subAgentActivity` classification is not reached "for every event — and
    every one of them arrives twice". `handleSubagentItem` intercepts those items
    before `items.handle`, so the live path never consults the catalog;
    `restoreThread` replays them straight through, and is the real consumer.

Comment-only apart from the childless-group guard.

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

Important

The delta itself is clean — the "counts as renderable" / "actually draws" reconciliation is correct and well-tested — but the PR is still not mergeable. The 16 components.native-chat.subagents.* keys in NativeChatSubagentRun.tsx remain absent from src/renderer/src/i18n/locales/en.json, so pnpm run verify:localization-catalog (a .github/workflows/pr.yml step) still fails on each one (re-verified this run). This predates the current commit and is unchanged by it; pnpm run sync:localization-catalog clears it.

Reviewed changes — one new commit since the prior pullfrog review.

  • Renderable predicate reconciled — extracted isRenderableSubagentGroup into src/shared/native-chat-subagent-summary.ts and applied it in both subagentGroupBlocks (which NativeChatMessageRow uses to decide whether to mount the roster row and drop its plain-text twin) and NativeChatToolRun's roster filter, so a childless subagent-group block no longer mounts an invisible gap-5 slot.
  • Two regression tests — a childless spawn group describe block asserts a bare childless group mounts no row and that a childless group with a text twin falls back to the twin instead of suppressing it; both fail with the predicate split reverted.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

The producer ALWAYS writes a roster block beside a plain-text twin carrying the
same sentence, for clients that cannot draw the block. The renderer honours that
contract from one side — it draws the block and drops the twin. The CLI honoured
neither side: it printed the twin as prose AND rendered the block as
`[subagents] <same sentence>`, so a real roster message read

    [system] Ran 2 subagents (1 failed)
    [subagents] Ran 2 subagents (1 failed)

Take the mirror of the renderer's rule, which is the cleaner half for a text
client: the twin IS the sentence, so print it and drop the block it stands in
for. A block that arrives WITHOUT its twin — a shape the wire admits and no
producer writes — still stands in for itself, because dropping it
unconditionally would lose the roster entirely. Either way the sentence prints
exactly once, off the same `subagentGroupFallbackText` helper both sides use.

Unreachable through `readWorkerTranscript` today, whose provider rollout decoder
never emits a `subagent-group` block — but the formatter is the CLI's contract
for any transcript source, and the shape is already producible.

The test pinned a TWIN-LESS group, a body `codexSubagentGroupBody` never writes:
it asserted the exact double-print this fixes was correct output, and would have
blessed either behaviour. Rebuild the fixture as the producer's real two-block
row, with the sentence taken from the shared helper rather than hardcoded so it
cannot drift, and assert the sentence appears exactly once. The twin-less shape
keeps a test of its own, labelled as the wire-only fallback it is.

Also record why `settleTurn` keys on the RAW `turnId` while `groupFor` remaps
off-primary activity onto the primary's active turn. The asymmetry is
load-bearing, not an oversight: were `settleTurn` to remap, a child thread
ending its own turn would sweep the parent group and settle every still-working
sibling to `unverifiable`. The lookup missing is the intended no-op.
@pullfrog

pullfrog Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

the model provider had a temporary upstream failure.

The provider refused or dropped the request mid-run — nothing in your repo or your credentials is at fault. Re-trigger Pullfrog; if it keeps happening, check the provider's status page.

provider error: {"code":504,"message":"Upstream idle timeout exceeded","metadata":{"error_type":"timeout"}}

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Merge Sim added 2 commits September 5, 2026 04:35
…row its twin filters

The roster row called 16 `components.native-chat.subagents.*` keys that were
never added to the catalog, failing the localization gate. Synced en.json; the
English strings are the component's own inline fallbacks, so nothing renders
differently.

Also tightens the twin/block handoff on both readers. The renderer dropped
every text block once a roster was present, which is safe only because Codex
writes a roster as its own message — the block is provider-agnostic, so a lane
folding prose in beside one would have lost it on desktop while mobile kept it.
And both readers decided "the twin is already printing" by recomputing the
sentence and comparing bytes, which a roster from a newer build never matches:
its unknown state normalizes to `unverifiable` here, so the CLI printed the
roster twice with two different verdicts. Both now recognize a twin by shape.
Both readers use it to decide the twin is already printing, so a false positive
eats a message's real prose and a false negative prints the roster twice.

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

✅ No new issues found.

Reviewed changes — two commits since the prior pullfrog review.

  • Subagent localization keys registered — the 16 components.native-chat.subagents.* keys used by NativeChatSubagentRun.tsx are now in src/renderer/src/i18n/locales/en.json, clearing the catalog gate that has blocked CI since the first review (verify:localization-catalog exits 0, re-verified this run).
  • worker read twin detection by shape, not recompute — formatWorkerRead now detects the roster's plain-text twin with isSubagentGroupFallbackText instead of byte-comparing a recomputed sentence, so a roster written by a newer build (whose unknown state reads as unverifiable) no longer prints its sentence twice.
  • Roster twin filter narrowed — NativeChatMessageRow drops only the twin text block beside a roster block, so real prose sharing a message with a roster is preserved (mobile, which reads raw blocks, already kept it).

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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

✅ No new issues found.

Reviewed changes — one test-only commit since the prior pullfrog review.

  • Twin recognizer pinned against prose — native-chat-subagent-summary.test.ts gains an isSubagentGroupFallbackText suite asserting the shape-matcher accepts every sentence subagentGroupFallbackText produces (including an unknown state like cancelled that this build reads as unverifiable) and rejects prose that merely mentions subagents (I kicked off 2 subagents to look at this, Ran 2 subagents and then cleaned up, Ran two subagents). No production code changed; 13/13 pass.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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

Caution

This merge broke the node build. src/main/runtime/orchestration/worker-transcript-payload.ts references an undefined warnings identifier inside the subagent-group branch — pnpm tc:node fails with three TS2304: Cannot find name 'warnings' errors, so the PR cannot typecheck or merge.

Reviewed changes

  • Merged origin/main — the single new commit is a two-parent merge pulling main's refactor of worker-transcript-payload.ts (boundBlock's parameter warnings: Set<string> → state: TranscriptBoundState, with clipMetadata/clipText/markClipped now threaded on state) plus the formatWorkerRead details refactor in worker-output.ts and the nativeChatToolActivityLabel tool-row refactor in the renderer.
  • subagent-group clipping branch left on the old parameter name — the branch this PR added before the merge still calls clipMetadata(…, warnings), which no longer resolves; the surrounding code was correctly renamed to state, so this is an incomplete conflict reconciliation, not a pre-existing defect.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Merge Sim added 3 commits September 6, 2026 20:41
`git add -A` swept up the pnpm-lock.yaml mutation that every pnpm invocation
leaves in this repo. Nineteen lines, thirteen of them @pnpm/exe, and it fails
sixteen unrelated CI checks — native smoke, typecheck, packaging, xterm patch
sync — none of which name the lockfile.
…bagent-worklog

# Conflicts:
#	src/cli/handlers/orchestration/worker-output.ts
#	src/main/codex/codex-structured-journal-translation.ts
Inlining the subagent routing helper lost its null check: the roster returning
null means it did not claim the item, and the translator must keep looking.
Returning unconditionally once any thread item parsed swallowed every ordinary
item — twelve settlement tests, none of them about subagents.

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

Important

This delta is clean, but the PR is still not mergeable. The critical typecheck break flagged in the prior review (5126775652) is unchanged: src/main/runtime/orchestration/worker-transcript-payload.ts still passes warnings to clipMetadata at lines 136/139/140 inside boundBlock (whose parameter is now state: TranscriptBoundState), and pnpm tc:node still fails with three TS2304: Cannot find name 'warnings' errors (re-verified this run).

Reviewed changes — three commits since the prior pullfrog review.

  • Dropped the @pnpm/exe lockfile drift — removed the @pnpm/exe importers/packages/snapshots a merge staged into pnpm-lock.yaml; no source change.
  • Deduplicated the transcript formatter — the CLI's formatWorkerTranscriptMessage moved out of worker-output.ts into the shared src/shared/worker-transcript-text.ts (already used by terminal read), so a roster row renders identically from one copy instead of two.
  • Restored the item fall-through — the subAgentActivity routing was inlined (readCodexNotificationThreadItem + subagents.handleItem); a prior merge had dropped the null-admission fall-through that lets non-subagent item/started/item/completed frames reach items.handle, and this restores it so ordinary items are no longer swallowed.
  • Extracted settleCodexOversizedNotificationFrame — the oversized-notification arm moved to codex-structured-journal-translation-frames.ts so the translator reads as routing rather than shape checks.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…bagent-worklog

# Conflicts:
#	src/renderer/src/i18n/locales/en.json

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

Important

This delta is a clean merge reconciliation — no new issues — but the PR is still not mergeable. The critical typecheck break flagged in prior reviews (5126775652, 5128166075) is unchanged: src/main/runtime/orchestration/worker-transcript-payload.ts:136/139/140 still passes the undefined warnings identifier to clipMetadata inside boundBlock (whose parameter is now state: TranscriptBoundState), and pnpm tc:node still fails with three TS2304: Cannot find name 'warnings' errors (re-verified this run). The fix is a three-line rename: clipMetadata(block.groupId, warnings) → clipMetadata(block.groupId, state), likewise for agent.id and agent.label.

Reviewed changes

  • Merged origin/main — the single new commit pulls in four main-side commits (editor Shift+wheel combined-diff scrolling, mobile-push revert, structured /clear//compact commands, skills-guide trim) with no overlap into the PR's own code.
  • Deduplicated structuredSessionLaunchFailedDescription — en.json carried two copies of the key (an artifact of an earlier merge); the reconcile drops the duplicate, keeps the subagents.* block intact, and picks up main's new conversationCommand keys. The catalog still validates.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…d state

Main renamed clipMetadata's second parameter from a warnings set to a
TranscriptBoundState. The subagent-group arm still passed `warnings`, and git
merged both sides without a conflict because the lines never overlapped — the
rename and the new arm are in different hunks. Typecheck was the only thing
that could catch it, and did.

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

ℹ️ The critical typecheck break is fixed and the delta is clean. One prior nitpick (the misplaced doc comment) remains open and is the only thing standing between this PR and approval.

Reviewed changes — one commit since the prior pullfrog review.

  • Rebound the subagent-group arm to state — boundBlock's subagent-group branch now threads state (not the stale warnings identifier) through clipMetadata for groupId, agent.id, and agent.label. This resolves the critical typecheck break flagged in reviews 5126775652 and 5128166075; pnpm tc:node now exits 0 (re-verified this run).

The only remaining open finding is a non-blocking nitpick carried forward from review 5128166075: src/main/codex/codex-structured-journal-translation.ts:227 still carries /** Routes a \subAgentActivity` item to the roster; null when it is not one. */abovesettleOversizedNotification, which routes oversized notifications — the comment is wrong and redundant after handleSubagentItem` was inlined away. Deleting it clears the last open thread.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Merge Sim added 3 commits September 7, 2026 00:26
Main's #19055 added a `subAgentActivity` arm to the provider activity table,
which is reached only through `publishActivity`. The roster's admission returned
above that call, so every `subAgentActivity` item bypassed it and a fan-out that
reports nothing else left the turn tail stuck on the previous frame's text.

`publishActivity` already no-ops on a refused admission and on a non-primary
thread, so routing the roster's admission through it is safe.

Also corrects a docstring the frames extraction copy-pasted onto
`settleOversizedNotification`.
…rries it

The spawn-group arm was the one collection in the worker-transcript payload with
no cap, and the one block type mobile's `sanitizeBlock` forwarded verbatim. The
producer's `MAX_CODEX_SUBAGENTS_PER_GROUP` does not reach either boundary: the
journal schema declares no maximum on `agents`, and a remote host may run a build
with a different cap. Both transports now cap the roster and bound `id`, `label`
and the open `state` string; `label` and `id` also take the standard inline bound
on the journal write path, where every other provider string already does.

A token count is now persisted onto its entry at write time. `write` rebuilt
`tokens` from the LRU-capped thread map on every write, so an eviction silently
retracted a count the durable row had already shown.

Adds the first coverage of the three roster caps, including the group eviction
that rewrites a row from N children down to one.
…ck honest

The roster-only escape is keyed on `blocks.length === 0`, so a spawn group
sharing its message with tool-call blocks fell through to the settled-turn guard,
which returned bare null and took the roster with it — the exact regression the
escape above was written to avoid, after the message row had already counted the
group as renderable. Unreachable for Codex today; the block type is deliberately
provider-agnostic, so it is live for the Claude lane.

The elapsed clock also froze at a sibling's timestamp on a partial sweep: in a
group where one child completed and another is unaccounted for, the ended turn
left `working === 0` with the completed child's `settledAt`, and the row showed
that child's duration as the group's run length. No clock is drawn while any
child is `unverifiable` with no terminal timestamp.

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

✅ No new issues found.

Reviewed changes — three commits since the prior pullfrog review.

  • Published the turn tail for roster-claimed items — subAgentActivity frames now route through publishActivity instead of a bare return, and subAgentActivity joined CODEX_ITEM_ACTIVITY, so the turn's activity indicator reads "Coordinating with another agent" even when the roster claims the item. The prior review's misplaced doc comment above settleOversizedNotification was also corrected.
  • Bounded the roster on every boundary — provider-supplied id/label strings are bounded at journal write; per-child token counts are persisted into the group entry so LRU eviction of the token map can't retract a count the row already showed; the worker transcript caps spawn groups and clips groupId/id/label/state; and a new native-chat-rpc-block-sanitize.ts (extracted from native-chat.ts) bounds subagent-group blocks for mobile.
  • Kept the roster beside tool calls and its clock honest — NativeChatToolRun's settled-turn guard now returns the roster rows instead of null, so a group sharing a message with tool calls stays visible after the turn finishes; the elapsed clock is suppressed whenever a child is unverifiable without a settledAt.

The new tests are exact-value assertions that fail on revert, and I verified pnpm tc:node exits 0 with the affected node and renderer suites passing (148 tests). This resolves the last open thread; the PR is mergeable.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Merge Sim added 2 commits September 7, 2026 00:58
…ing them

`boundInlineText` computes a sha256 and a Buffer BEFORE it checks the length,
so the roster paid two digests per child on every write even when nothing was
truncated — and `write()` runs on every claimed activity item (each delivered
twice) and again from `handleTokenUsage`, which streams. A same-process A/B over
a 64-child group: 76.5 us/write before, 2.0 us/write after (plain, unbounded row
is 1.2 us).

The cap changes with the mechanism. 16 KB is the tool-output bound; both readers
of this row already clip the same fields to 512, so the producer was admitting
~2 MB per durable roster row for consumers to throw ~97% of away. One
`MAX_SUBAGENT_FIELD_CHARS` now serves the producer and both readers, and the
marker is an ellipsis rather than the tool-output truncation sentence — `id` is
the roster key and the renderer's React key.

Also raises the orchestration arm's per-group bound from 20 to the producer's
64, matching the mobile arm: a 21-64 child group is routinely producible here,
so that arm clipped children and warned while its sibling clipped none. The
slice and warning stay as the transport's own defence against a remote host with
a larger cap.
`hasTwin` was a single boolean over the whole message, so a message carrying two
`subagent-group` blocks and one plain-text twin printed one sentence and dropped
the second roster with no marker. Count the twins and claim one per group
instead. Not reachable from this branch's producer, which writes one group per
journal item, but the surrounding reasoning is explicitly about wire shapes the
producer never writes and this is the adjacent one it missed.

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

✅ No new issues found.

Reviewed changes — two commits since the prior pullfrog review.

  • Bounded the roster's provider strings with one shared constant — MAX_SUBAGENT_FIELD_CHARS = 512 now lives in native-chat-subagent-summary.ts and is used by the producer (boundSubagentField, now a plain length check instead of the sha256-digesting boundInlineText) and both readers (worker-transcript clipMetadata and the mobile block sanitize). The worker-transcript subagent cap was raised 20 → 64 to match MAX_CODEX_SUBAGENTS_PER_GROUP. The switch off boundInlineText loses no redaction — that helper only bounds and digests, never redacts — so no security surface changed.
  • Suppressed one roster block per twin, not all of them — formatWorkerTranscriptMessage now counts twin text blocks (unclaimedTwins) and consumes one per subagent-group block, so a message carrying two roster blocks and one twin prints both sentences instead of silently dropping the second roster. The new test drives the exact producer shape and asserts one occurrence per group.

All three caps (512 chars, 64 children) are consistent across the producer and both readers, and the new tests are exact-value assertions that fail on revert.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Real-agent visual proof at 471bd952062ee9e38e1b6f9a3bd297236155b3da, captured through CDP from a hidden Electron renderer in the QA child worktree (ORCA_BACKGROUND_LAUNCH=1).

Three real Codex children read README.md, package.json, and docs/STYLEGUIDE.md and each ran a bounded sleep 45; the parent ran pwd and git status --short in the same turn. No fixtures, mocked frames, journal edits, or source changes.

All three structured-chat flags were enabled before renderer reload. The tab is Codex Chat, with structured agent-session ID codex_7ce70cbf_cf3b_48a7_ae25_8bf475a60d93, local execution, and zero terminal renderers. Fetching NativeChatSubagentRun.tsx through this instance’s dev-server /@fs/ route returned runLengthUnknown at lines 146–147.

Live: collapsed roster shows three spawned children, one still working, and an advancing 1m 20s clock.
01-live.png

Expanded: all three child labels show working state and token counts.
02-expanded.png

Settled: all three completed; the clock stayed frozen at 1m 28s across subsequent observations (journal span: 88,462 ms).
03-settled.png

Ordinary tools coexist: the live roster remains above real pwd, git status --short, and read/shell rows in the same turn.
04-tools-coexist.png

Capture caveat: an earlier turn received a mid-turn safety clarification; its roster temporarily rendered working children as unverifiable after that transcript boundary. The four images above are from the subsequent uninterrupted turn. SSH and interrupted-turn behavior are not validated by these captures.

Five defects loop 2's own fixes introduced.

Twin claiming was order-blind: the count-based claim silenced whichever
roster block came first, so a lone twin belonging to a LATER group erased
an earlier group's roster and printed the later sentence twice. Exact-text
claims are now settled for every group before any leftover twin is claimed
by position; the positional fallback stays for a newer build's frozen twin,
which can never equal a recomputed sentence.

`boundSubagentField` sliced UTF-16 units and could leave a lone high
surrogate in a durable row, and the clip removed exactly the tail that told
two children apart — `id` is the renderer's React key and `claimLabel`
writes its repeat ordinal at the end. It now backs off a split pair and
reserves the child index inside the bound, so both readers' re-clip cannot
cut the disambiguator off again.

`MAX_SUBAGENT_FIELD_CHARS`'s doc claimed a `groupId` bound the producer
never applies; the doc now says so and why. The worker-transcript metadata
cap is a separate literal again: it governs message ids, turn ids, tool-call
names and image urls, so a roster-motivated change must not move it.

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

✅ No new issues found.

Reviewed changes — one commit since the prior pullfrog review.

  • Indexed, surrogate-safe field clipping — boundSubagentField(value, index) now reserves a …~${index} suffix out of the 512-char bound for clipped provider id/label strings, so two children sharing a long prefix no longer collapse to one React key / one claimLabel ordinal; the slice backs off a lone high surrogate so no malformed code unit reaches the durable row.
  • Twin claiming by text, then position — claimSubagentGroupTwins settles exact-text matches for every group before any positional fallback, so a lone twin is claimed by the group it names regardless of block order; the null-line filter on the final join also removes the blank line a suppressed group left behind.
  • DRY item-type key and metadata-bound decoupling — CODEX_ITEM_CLASSIFICATIONS now keys on CODEX_SUBAGENT_ITEM_TYPE instead of the subAgentActivity literal, and MAX_WORKER_TRANSCRIPT_METADATA_CHARS is a standalone 512 literal so a future roster-motivated change to MAX_SUBAGENT_FIELD_CHARS cannot silently move the transcript bound.

The new tests are exact-value assertions that fail on revert (suffix …~0/…~1, surrogate-pair round-trip through UTF-8, distinct ids/labels across clipped children, twin claimed by text in both leading and trailing positions). I verified pnpm tc:node exits 0 and the five affected suites pass (91 tests).

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready to merge

Full re-review of this PR on its current head. The branch had absorbed roughly 205 commits of main across three merges since it last passed review, so the pass focused on merge seams rather than re-deriving the design. Four review loops ran, plus a readiness pass at the start and end, and real-session visual proof.

Head moved 4f4a7d04c4 → 1087294f55 (6 new commits). Every fix below was ablated red/green — the fix was reverted, the specific test was confirmed to fail, then restored.

Two blockers, both from merge seams that git merged cleanly

Neither produced a conflict, because the changed lines never overlapped.

The turn tail stopped updating during a fan-out. main landed #19055 during this branch's merge window, adding a subAgentActivity arm to the turn-tail activity table. That table is only reached through publishActivity, and this branch had inserted an early return subagentAdmission above it — so the new arm was dead on the live path, and a fan-out that reports only subAgentActivity left the turn tail stuck on the previous frame's text. Now returns publishActivity(event, subagentAdmission). The arm had no test at all, which is why a green suite missed it; it has one now.

The orchestration transcript arm had no collection cap. It was the only boundBlock arm bounding element length but not collection size, and the byte budget cannot cover for that because both entry points admit the first message unconditionally. The producer-side cap does not reach that boundary either: the journal schema is deliberately z.array(...) with no max, and the same code path also reads a remote host's transcript, where the host may run a build with a different cap. It now has its own bound, and agent.state is clipped and redacted like every other transcript string.

A performance regression the review itself introduced

Bounding id and label through boundInlineText looked right, but boundPayload computes a Buffer.from and a SHA-256 digest before its length check. That runs twice per child per write, on a path that fires twice per activity item and once per streaming token-usage frame — 128 digests per write on a full group. Measured at 28–42× slower depending on group size. Replaced with a plain length check against a 512-char cap now shared with both readers, which also drops the worst-case retained size per session from roughly 64 MB to 2 MB. Re-measured after the fix.

Other fixes

  • The roster was dropped from any settled turn where it shared a message with tool calls — unreachable from the Codex lane today, but the block type is declared provider-agnostic.
  • A token-map eviction could retract a token count the row had already shown; the token is now persisted onto the entry.
  • The elapsed clock could present one child's duration as the whole group's while a sibling's fate was still unknown. It now renders no clock when a child is unverifiable with no settle time.
  • label and id reached the durable row and the mobile client unbounded, while the same fields were already clipped on the orchestration path.
  • Suppressing one text twin per roster block silenced the wrong group when the twin belonged to a later block; twins are now claimed by exact text first, then positionally.
  • Clipping could split a surrogate pair into a lone surrogate in a durable row, and could collapse two children onto the same id — which is the React key. Both closed.
  • Cap-boundary tests added for all three limits, including the group-eviction branch, which previously had none.

Verification

tc:node, tc:web, check:code-quality:changed (including React Doctor), oxlint and the max-lines ratchet are all clean. 770 test files / 6978 tests pass across the touched trees. All 33 CI checks on 1087294f55 are green with none pending. No lockfile change in the diff.

Visual proof from a real structured Codex session with three real spawned subagents is in this comment — live, expanded, settled, and coexisting with ordinary tool rows, captured on a hidden renderer with the served module verified against this branch. Those captures were taken at 471bd95206; the two commits since then do not change the rendered row.

Known limitations, unchanged and documented in code

Group eviction past 32 groups, and a restart on an outside-turn group id, can rewrite a durable row from N children down to one. The header comment names journal seeding as the fix. Left as scope.

One note for follow-up: the mobile sanitize arm added here sits on nativeChat.readSession, which serves provider transcripts, while the roster block actually reaches clients through agentSession.* — a surface with no client-kind sanitization at all. The guard is harmless and the exposure it protects against is also absent on that path, but it is not currently exercised by the wire the roster uses. Worth a follow-up rather than widening this PR.

Merge Sim added 3 commits September 7, 2026 02:07
QA drove a real Codex session with three live `spawn_agent` children and sent
a mid-turn correction. The roster row immediately read "Ran 3 subagents /
3 unverifiable" with no clock, while all three were still running — they
reported `completed` 57-87s after that turn ended.

Both sites rested on the same false premise: that a turn ending means no
event will ever settle a child. Children outlive their turn and keep
reporting into the same group.

- Renderer: drop `reconcileSubagentRoster`. Nothing plumbed to the component
  distinguishes a row written by a dead host from a turn that merely ended —
  journal render items carry no epoch, and a new epoch deletes the rows of the
  one it supersedes — so the row now draws the state the journal recorded.
  Under-claiming beats over-claiming.
- Main: stop sweeping on `turn/completed`. That sweep wrote `unverifiable`
  into the DURABLE journal, which mobile reads with no reconciliation.
  `turn/completed` is Codex's only turn-end notification, so an abort cannot
  be told apart from a clean finish; the safe default is not to sweep.

`settleSession` — the provider actually being gone — is unchanged and is now
the only sweep. `unverifiable` stays non-latching so a late verdict still lands.
The mid-turn correction opens a new turn, so the fan-out's row stops being
the current turn and the list hands the roster `activeTurnIsWorking={false}`.
Asserted through the list, not the component, because that prop is what
carried the wrong claim.
`settleSession` only fires when the provider goes away while this process is
alive. If the host itself dies, nothing sweeps and nothing reconciles on
restore, so a `subagent-group` row persisted as `working` claimed live children
forever — the mirror of the defect the previous commit fixed, and the same
`ssh-execution-boundary.md` violation in the other direction.

Reconciled host-side, at journal open, not in the renderer: mobile shows only
the durable text twin and reconciles nothing, so a renderer-only fix would
leave it claiming live children indefinitely. Opening the journal is also the
one moment a host can honestly say the previous writer is gone.

- `staleSubagentRosterRevisions` rewrites every child still reading `working`
  to `unverifiable` and regenerates the twin from the same summary, so the
  block and the sentence cannot disagree.
- No terminal timestamp: the child stopped being observable at an unknown
  moment, and stamping the reopen would report the downtime as its run length.
- Revises in place under the parsed identity, so a reopen upserts the row
  rather than appending a duplicate, and a second reopen writes nothing.
- Skipped on a corrupt load: that journal is still owed a rebuild from provider
  history, and content past the repair's free sequence retires the demand.

Reconciles journal ROWS, not roster state — the producer's in-process group map
is untouched, so the roster's known seeding limitation is unchanged, as is
`canReplaceSubagentState`: `unverifiable` still does not latch.

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

Important

Removing the renderer's roster reconciliation also removed the only safety net for the crash/restore case, so a working child the host never got to settle now renders as live forever on desktop.

Reviewed changes — two commits since the prior pullfrog review.

  • Dropped the turn-end sweep — CodexSubagentRoster.settleTurn and its call in completeTurn are gone; settleSession (fired on event.type === 'ended') is now the sole writer of unverifiable. The rationale is sound: spawn_agent children outlive their turn and keep reporting into the same group, and turn/completed is the only turn-end notification Codex sends, so a turn boundary can't tell an abort from a clean finish.
  • Dropped the renderer reconciliation — reconcileSubagentRoster and the activeTurnIsWorking prop threading into NativeChatSubagentRun are removed; the roster now draws every child state exactly as the journal recorded it.
  • Pinned the QA seam — new tests at the translator, roster, subagent-run, and message-list levels assert a mid-turn correction that opens a newer turn leaves live children working (no unverifiable, no Ran headline), and that a verdict landing after the turn ended still reports.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

block: NativeChatSubagentGroupBlock
}): React.JSX.Element | null {
const [open, setOpen] = useState(false)
const agents = block.agents

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.

Removing reconcileSubagentRoster also removes the only reconciliation for a roster restored after the writing host is gone. settleSession runs only on event.type === 'ended', so a crash, force-quit, or lost contact (SSH) that never emits ended leaves the durable block's working children permanently — and this component now draws them as live, pulsing, with a ticking clock, indefinitely. That is the liveness-collapse docs/reference/ssh-execution-boundary.md forbids, and it contradicts the PR body, which still says the desktop renderer reconciles working outside the live turn.

Technical details
# Restore the session-liveness reconciliation (keyed on session, not turn)

## Affected sites
- src/renderer/src/components/native-chat/NativeChatSubagentRun.tsx:164 — `const agents = block.agents` draws state verbatim; the removed `reconcileSubagentRoster` was the only place a stale `working` became `unverifiable`.
- src/main/codex/codex-structured-journal-translation.ts:129 — `settleSession` runs only on `event.type === 'ended'`, so a host that dies without a clean end never writes `unverifiable`.

## Required outcome
- A `subagent-group` block whose children are `working` must not render as live (`N working`, pulsing dot, ticking clock) once the session that wrote it is no longer live. The turn-boundary signal must stay unused for this (children outlive turns), but a session-liveness signal must reconcile `working` → `unverifiable`.

## Suggested approach (optional)
- The renderer already has the authoritative session signal at `NativeChatMessageList.tsx:238` (`isWorking || session.transcriptLifecycle?.state === 'working'`). Thread that session-level liveness (not `isCurrentTurn`) into the roster and reconcile `working` → `unverifiable` when it is `false`, mirroring the old `reconcileSubagentRoster` but keyed on the session rather than the turn.
- Alternatively, if this is deliberately accepted, update the PR body's "Carrier" section, which currently asserts the desktop renderer reconciles `working` outside the live turn.

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.

Addressed in 09531c6 — staleSubagentRosterRevisions reconciles a stale working roster to unverifiable on journal open (and moves the twin), so the producer now states the truth the dead host couldn't.

Pullfrog  | View workflow run | via Pullfrog | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

AFTER visual proof — mid-turn correction with three real Codex subagents (the after half of the reported before/after scenario).

A Codex agent drove this capture through Playwright CDP against a hidden Orca Electron renderer, launched with ORCA_BACKGROUND_LAUNCH=1 and a fresh profile. The real style, git, and ssh children read three Orca documents and each ran an actual sleep 90; no fixtures, synthetic frames, journal edits, or source changes were used.

Critical result: PASS. Immediately after submitting the second “MID-TURN CORRECTION” message, the original roster still showed “Kicked off 3 subagents” / “3 working” / “31s”. Expanded states were style: working, git: working, ssh: working, with no unverifiable child. The clock subsequently advanced to 46s. The same roster changed to “Ran 3 subagents” / “completed” / “1m 57s” only after all three completed, and remained frozen on a later check.

Code and route verification:

  • HEAD: 7b8917b39e2a32bef44ecb5d315654271243a92a.
  • Fetched http://127.0.0.1:5178/@fs/Users/brennanbenson/orca/workspaces/orca/codex-subagent-worklog-qa/src/renderer/src/components/native-chat/NativeChatSubagentRun.tsx; asserted both reconcileSubagentRoster and activeTurnIsWorking are absent from the served module.
  • Confirmed app identity points to that QA worktree. All three structured-route flags were enabled, followed by reload and CDP reattachment; the live tab is Codex Chat, with a composer and zero xterms.
  • Read-only journal evidence records the correction submission at 2026-09-07T09:20:46.060Z and retains the same three child IDs through completion. Earliest start 1788772815237, latest settlement 1788772933174: 117.937 seconds, consistent with the displayed 1m 57s. The correction creates the newer transcript turn; Codex accepted it as steering within its existing provider turn.

1. AFTER — real fan-out running (clock at 28s; three working children)

01-running.png

2. AFTER — immediately after the mid-turn correction (31s; all three still working)

02-correction.png

3. AFTER — same roster after genuine completion (clock frozen at 1m 57s)

03-completed.png

4. AFTER — expanded completed roster with per-child labels and states

04-expanded.png

This verifies the requested local structured Codex scenario; remote execution and other providers were not exercised.

@brennanb2025

brennanb2025 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Update: the escalated defect is fixed, with before/after proof

Live QA on this branch found a real defect after my earlier summary, and it turned out to be two defects resting on one false belief. Head is now 09531c620c.

What QA saw

Three real spawn_agent children running sleep 45. The user sent a mid-turn correction. The roster immediately read "Ran 3 subagents / 3 unverifiable" with no clock — claiming both that we had lost contact with children that were alive, and that the fan-out had finished. It is the worst output this feature can produce.

The belief that caused it, and the measurement that disproves it

Two places assumed that once a turn ends, a child still marked working can never be settled by a later event. The captured journal from that session shows otherwise. The correction landed at 1788768264965; the three children then reported completed:

child completed at after the turn ended
read_readme 1788768321898 +56.9s
read_package 1788768338189 +73.2s
read_styleguide 1788768351585 +86.6s

New children were still joining the same group after the correction. spawn_agent children outlive their turn and keep reporting, so a turn boundary is not evidence of anything about the children.

Both sites fixed

The renderer was the live bug. It mapped working → unverifiable whenever the turn was not current, and the correction opened a new turn. Once no child counts as working, the headline flips "Kicked off N" → "Ran N". That inference is gone; the row now draws the state the journal actually recorded. Nothing plumbed to the component distinguishes a row written by a dead host from a turn that merely ended — journal render items carry no epoch, and a new epoch deletes the rows of the one it supersedes — so where no honest signal exists, the row stays working. An overdue row is a smaller lie than a false loss-of-contact claim.

The main-process sweep on turn/completed was latent but strictly worse when it fires, because it writes unverifiable into the durable journal, and mobile reads that with no reconciliation and no way to recover. A transient display bug fixes itself on the next render; a poisoned journal row does not. That sweep is deleted. turn/completed is Codex's only turn-end notification, so an abort cannot be distinguished from a clean finish — the safe default is not to sweep. settleSession (the provider genuinely being gone) is unchanged and is now the only sweep, and unverifiable remains non-latching so a late verdict still lands.

A regression the first fix opened, and closed

Removing the renderer reconcile closed the over-claiming bug and opened its mirror: after a host crash, a persisted working row would have rendered working forever — a liveness claim no reader can verify. The old reconcile had been masking that by accident, so it belonged in this PR rather than a follow-up.

It is fixed at journal open rather than in the renderer, because mobile renders only the durable text twin and reconciles nothing — a renderer fix could never reach it. Any persisted roster child still reading working when a journal is reopened was written by a host that is gone, so it is rewritten to unverifiable and the twin is regenerated from the same settled roster so the two cannot disagree. No settle time is stamped: the child stopped being observable at an unknown moment, so any timestamp would report downtime as run length. The row therefore shows no clock.

One deliberate exception, which reads like an oversight without the reason: the reconcile is skipped on a corrupt journal. A corrupt journal already carries a demand to rebuild from provider history, and that demand is retired the moment anything is written past the repair's free sequence. Writing a reconcile row would trade a slightly more honest stale row for a silently abandoned rebuild — and the rebuild fixes the roster anyway, correctly, from source. The stale row is bounded and self-healing; a retired rebuild demand is permanent and leaves a truncated journal nobody knows to repair.

Proof, and exactly which evidence covers which fix

Before and after, both from real structured Codex sessions with real spawned subagents on hidden renderers, with the served module verified against the branch.

The after-capture drives the exact scenario that broke: immediately after the mid-turn correction the roster still reads "Kicked off 3 subagents / 3 working / 31s" with every child working, and only reads "Ran 3 subagents" once all three genuinely complete, with the clock frozen at a duration matching the journal span.

The three fixes are not all covered by the same evidence, so rather than leave that to inference:

Fix Covered by
Renderer no longer infers loss of contact from turn state Before/after captures at 7b8917b39e — before shows the wrong state, after shows live children still reading working / "Kicked off" once the turn ends
turn/completed sweep deleted Ablated unit regression test only. Codex accepted the correction as steering within its existing provider turn, so the capture does not itself exercise this path; the test asserts a child stays working across turn/completed and that a later completed still lands
Post-crash restore sweep (09531c620c) Ablated regression test only — no visual capture, deliberately. Reproducing it means killing a host mid-fan-out; the test drives the real journal store and asserts both halves on the same itemId (live host reads working, reopen reads unverifiable)

The captures were taken at 7b8917b39e, before the restore sweep landed. That is still valid for what they prove: the restore sweep only rewrites rows at journal open and never touches live rendering.

Every fix above was ablated red/green — reverted, the specific test confirmed failing, then restored. Remote execution and other providers were not exercised.

A pattern worth knowing if you touch these files next

Three defects in this PR took the same shape: main added something adjacent, this branch's older code silently voided it, and git reported no conflict because the lines never met. The #19055 turn-tail arm made dead by an early return, a renamed clipMetadata parameter, and an inlined routing helper that dropped its null check. Only the typechecker and the test suite caught them — never review of the diff, and never the merge. worker-transcript-payload.ts is one of the files it happened in.

Verification at 09531c620c

tc:node and tc:web pass, 771 test files / 6988 tests pass across the touched trees, check:code-quality:changed is clean on all three gates, and no lockfile change appears in the diff.

Still true from before, and out of scope

Child prose appearing in the parent transcript is pre-existing on main — there is no thread filter between the wire and the journal on either ref, and this PR's net effect on that surface is a reduction. The documented roster limitations (group eviction, no journal seeding on restore) are unchanged.

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

✅ No new issues found.

Reviewed changes — one commit since the prior pullfrog review.

  • Settled stale rosters at journal open — new staleSubagentRosterRevisions (journal-subagent-liveness.ts) reconciles any subagent-group row still carrying a working child to unverifiable when a journal is reopened, and rewrites the plain-text twin to match (Ran 2 subagents (1 unverifiable)), so mobile — which renders only the twin — also stops asserting liveness the dead host observed. Wired through openJournalStoreState/restoreJournalStore, skipped on read-only and corrupt loads, and it touches only working children with no synthesized settledAt, so a reader reports an unknown run length rather than "time since the host died".
  • Tests — journal-subagent-liveness.test.ts pins the reconcile end-to-end: a live row reads working before the host dies and unverifiable after reopen with the twin moved; the row is revised in place rather than appended; reopens are idempotent; settled/plain/unparseable rows are left alone.

This resolves the crash/restore liveness-collapse flagged in the prior review, and does so on the producer side, which also fixes the twin for text-only clients.

One non-blocking follow-up: the PR description's prose still describes the pre-e708790b design — the "Two sweeps" section, the "Carrier" claim that "the desktop renderer reconciles the block's working to unverifiable outside the live turn", and the "Known cost" line about "the turn-end sweep". Those no longer match the shipped behavior (there is no turn-end sweep; reconciliation happens at journal open on the producer). Worth a refresh so the description matches the code.

@brennanb2025
brennanb2025 merged commit 0252fe5 into main Sep 7, 2026
32 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