Repository navigation
refactor(native-chat): a subagent's rows live in its own section, not in the parent's conversation - #23752
Conversation
… in the conversation A subagent's rows were drawn in its parent's conversation, each captioned with the subagent's name. They now belong to the subagent: the transcript projection keeps the session's own rows as the conversation and each subagent's rows apart, keyed by the agent id its roster entry already carries, folded on their own. Desktop: a subagent's rows open in a section under the roster row that names it, from that agent's roster entry, and are windowed like any other rows. A subagent no loaded roster names opens where its first row happened, inside the section of the agent that spawned it or in the conversation. Its edits still count in the turn they were made, and revealing one opens the sections around it. Mobile shows the conversation, with each spawn's roster line. Worker reads and structured terminal reads serve the worker's own rows. Removes what the move makes redundant: the per-row caption and its copy, the producer check in the tool fold and the turn answer, the per-agent frontier interleaved in the conversation, worker-text subagent tags, and the agent id on worker-read messages.
Revealing a subagent's edit opens the sections around it from the target the rollup already holds, instead of looking the row up at click time. The section head keeps to the agent's name and dot; its state in words stays on the roster entry. The worker page test stubs the host through its module rather than a cast.
… windows its own rows A subagent's section is open while its agent works and closes once it settles, the way the turn's own live run does; a section the reader opened or closed by hand keeps that choice. A subagent another subagent spawned opens inside that one's section, so a working grandchild shows inside its working parent. Openness is derived from the roster's state and the reader's choices; nothing stores an automatic open. A worker page is now the newest page of the worker's own rows. The host windows the read over them before the limit, so a subagent's burst can no longer crowd the worker's rows off the page, and "older" still means older worker rows. The scope is an in-process argument of the host's history read; no wire request carries it.
…for the outline rail
…-subagent-rows-with-subagent
…on is shown in, for the outline rail A background subagent's rows written during a later turn carried that later turn onto their slots, so scrolling through its section lit the later turn's rail tick and then snapped back. The rollup still counts each edit in the turn it was made; only the slot, which the rail reads, takes the shown turn.
…s rows Mobile draws only the session's own rows, so an older page made entirely of a subagent's rows landed as nothing: the reader tapped Load earlier, saw the spinner, and got the same transcript back. One load now reads on (up to 8 pages) until a page holds a row of the session's own, then applies the pages in order.
…nce per change to them The rollup flattened and re-sorted every subagent row on each update, including every token the parent streamed. The ordering now keys on the projection's subagent rows, which keep their identity while only the conversation changes.
…ing the list under its line limit
… reads back on its own Opened while a subagent is busy, the newest page can hold nothing but that subagent's rows. Mobile draws none of them, so the reader saw an empty chat with a Load earlier button, and an empty list cannot be scrolled to page. The hook now reads back once from each such head, and the read runs on to the session's own rows.
… a subagent's burst keeps its roster The live window kept the newest 1,024 rows of every agent. A subagent writing more than that trimmed its own spawn's roster row and the prompt, and its section fell back to a closed, unnamed header. The window now keeps the newest 1,024 of the session's own rows and everything after, with an 8,192-row cap on every agent's rows as the memory backstop. A transcript with no subagent rows trims exactly as before.
…ith a subagent's rows riding along A history page held the newest 200 rows of every agent, so a subagent's burst could fill a page on its own: the phone opened on an empty chat and "Load earlier" landed nothing. A page now starts at the oldest of the newest `limit` rows of the session's own and serves every row from there, so the subagent's rows come with the conversation they happened in. The page stays contiguous, the cursor still names its first row, and the byte bound still applies. A transcript with no subagent rows gets the same pages as before. Clients already take a page larger than its limit: both reducers raise their retained window to the page's size. The mobile read-on and read-back stay for older hosts.
…ving a subagent-only page
…ows with it The live window trimmed to just after the own row it dropped, so a subagent whose roster row went kept its rows at the top as an unnamed section until the parent wrote again. Trim to the oldest own row kept instead; it still fires only once an own row passes the limit, so a paged-in run of subagent rows at the head stays until then. With no subagent rows nothing changes.
…elta's re-derivation Every live batch re-derives the transcript over every retained row. On the largest real window (7,374 rows) that cost 7-8 ms a delta on desktop against 0.6 ms at the old 1,024-row window, and held about 26 MB of row content. 4,096 halves both. The most rows any local journal puts between a roster and its subagent's last row, with the parent inside its own-row limit, is 3,005, so no observed subagent loses its roster to the lower cap.
…he running scope's live frontier A section used to open whenever its roster said the subagent was working, anywhere in the transcript and whether or not the session was running, so a background subagent's section stayed open and grew mid-transcript while the parent moved on. It now opens by default only while the session runs and the roster row naming the subagent is the newest thing the parent produced, user rows aside. Newer parent output closes it even while the subagent still works; the roster row keeps showing that live state. A subagent still working is a running scope of its own for the sections it spawned; a settled one closes its scope. Derived every render, no latch; the reader's own open or close still wins.
…window never trims A section took its name and state from a roster row in the loaded window. Once a burst trimmed that row, or the row sat on an older page, the section fell back to an unnamed, closed "Subagent" header. The shared reducer now keeps a roster keyed by agent id, folded from every roster row and revision the client receives: pages, older pages and live batches, including revisions of roster rows outside the window, which live batches already carry. The first roster naming an agent wins and its revisions update it; a removed roster row drops its entries; it is rebuilt on every page that replaces the window and bounded to 512 agents. Sections take their name, state and live-frontier place from it; placement stays under the loaded roster row, else at the section's first loaded row. Only a subagent no roster ever named stays unnamed.
…row is older than it A page is a contiguous run of the journal whose older-page cursor is its first item, so it cannot pull an older roster row in without skipping the rows between. When a page held a subagent's rows but not the roster row naming it (about 11% of the moments a reader could open a session on local journals), that subagent drew as an unnamed "Subagent" header. History and hydration pages now carry an optional `subagentRoster`: the first roster entry naming each subagent whose rows are on the page and whose roster row is not, with the row's id, sequence and revision; bounded to 64 entries and 16 KB. Items and cursor are unchanged. The client seeds its roster from it. Rule 1 in docs/reference/remote-wire-compatibility.md: an optional field on an existing frame, no capability gate. An older client ignores it (the released reducer reads a page with it exactly as one without); against an older host the field is absent and the section falls back to an unnamed header.
…bagent rows with it" This reverts commit 2207865. Its only purpose was to stop a subagent whose roster row an own-row trim had dropped from showing at the head of the window as an unnamed section. The client roster now names that section whatever the window holds, so the cut is back at just after the own row the limit passes. The retention test that pinned the unnamed-section case now asserts the section at the head keeps its name.
… no name depends on the window Own-row retention keeps the conversation a reader sees from being crowded out by rows drawn as a one-row section on desktop and not at all on mobile; the every-agent cap bounds memory and each live delta's re-derivation. Neither is about keeping a roster row loaded any more.
…ng can see closure writes
…ient roster too A revision that stops naming an agent (the host drops an entry it learns is not a subagent, or re-keys a provisional one) left the client roster holding the old entry, often still "working", with nothing to re-derive it. The section then read as working forever and could auto-open, while a fresh read of the same journal left it unnamed. The fold now drops an entry when a newer revision of the row that named it no longer does, before any roster takes it over.
…hey name open A subagent section auto-opened only while its roster row was the running session's newest row, so any later row closed it: a Codex wait on the agent, or the parent's text before its next spawn call. Now a row that is part of delegating to a subagent keeps that subagent open: - a Codex collab call (spawn, wait, resume, message, close) opens each agent its receiver thread ids name; one naming none is ordinary output; - a Claude spawn call names no agent, so it counts toward the roster announcing it; - a roster row at the frontier opens its most recently added agent, not all of them. A roster or call naming only agents one subagent spawned is that subagent's output, so a grandchild's roster, which the host journals as the session's row, no longer closes the spawner's section.
…ubagent's section A parent's tool calls after a roster row fold into the tool run drawn above the roster, so the roster stayed the newest drawn row and its section stayed open while the parent was already reading or running commands. The fold now records the newest journal position among the rows it merged, and the live frontier orders rows by that newest part. The layout is unchanged. A spawn call folded there still counts as part of the roster announcing it.
…the first A Codex collab call that names several agents opened every one of their sections. It now counts as delegating to the first agent it names, so one section opens, the same as a call naming one agent.
Collapsing a roster row's list of subagents left their open sections drawn, so the section's own head became the only way to close them. And the list's open state lived in the row, so a row the window unmounted came back collapsed. The transcript now holds each roster list's open state beside the section choices. A closed list hides every section it anchors; each section keeps its own open or closed choice for when the list reopens. With no choice from the reader, a list is open while a section under it is open. Closing a section from its entry keeps the list open, and revealing a subagent's edit opens the list it sits under.
…set lookup per entry
An open section drew the agent's name twice: its entry in the roster's list, then a separate section head above its rows. The entry is now the head. The roster row draws its entries through the first open one, that agent's rows follow, then the entries after it, each run in its own windowed slot. A section no loaded roster row holds (an older page, a grandchild, an unnamed agent) keeps its own head. A roster list is open while the live frontier or a reader's choice is on one of its agents, unless the reader closed the list, so closing an agent from its entry no longer needs to pin the list open. The section emitter moves to its own module, and the trailing-run predicates it shares with the slot builder to theirs, to keep the slot builder under its line limit.
…s roster's type The roster row's list inherits the system row's small muted type; the entries that follow an open section sit outside that row, so they now carry the same type.
…agent's rows A page is bounded by bytes after it is windowed by the session's own rows, so a burst that fills the bound yields a page, or an opening page, with none of the session's own rows. Mobile's read-on and read-back therefore serve current hosts too, not only older ones; the comments said otherwise. The retention comment still described a closed section as a row of its own; it now sits behind its roster entry.
Main now groups chat rows by the turn the host's turn records say produced them (#23671), anchors a provider-opened turn's bar on its first row, and renders the terminal-backed chat through the structured turn status (#22090). This branch moves each subagent's rows out of the conversation into its own section under its roster entry. Conflicts, resolved so both hold: - Slots: main's owning-turn liveness, statusAbove and last-row rollup placement, on this branch's message/section/entries slot union. - Message list: main's nativeChatRowTurnKeys and active-turn key feed the slots; this branch's rollup still merges subagent rows into turn order. - Transcript row: main's bar-above on this branch's section-indented wrapper. - Slot tests: main's turn-owned grouping tests kept; the inline subagent caption tests stay removed with the caption. Subagent rows now take their turn from the same rule: the transcript projection runs nativeChatRowTurnKeys over every row with the host's attribution, and only a user row the conversation draws opens a turn by position. The positional rule it replaces put an edit made after a send queued mid-turn into that send's turn, and never used a turn keyed to its own record, so the edit counted in the wrong turn's changed files.
…-subagent-rows-with-subagent
… inside the section An assistant row's hover controls (copy, scroll-to-top, timestamp) hang 20px below the row into the gap before the next one (`-mb-5`). Inside a subagent's section that put them below the section's left border, and on the section's last row they touched the parent's next row with no gap. Inside a section the controls now stay in flow, so the border covers them and the next row sits the normal gap below. The row-height estimate reserves the same 20px for a section's prose so windowing does not jump on measure.
Review status: ready for review (not merged)Verdict. The review loop is clean, Electron and mobile QA passed, and CI is green at What the review changed, as new commits on this branch (no force-push):
QA (a separate macOS machine, real Claude CLI, isolated profile and home):
Checks.
Scope, for your judgment before merging. The PR is larger than a follow-up usually is: 83 files, +4.2k / −0.8k lines. It now includes:
Each fixes a failure the restructure would otherwise leave (see Why in the body). None of it is persisted or needs a migration. Known and tracked separately (not this PR):
Already on main (not caused by this PR):
Minor residuals, all consistent with the rules above:
|
|
| if (!entries.has(agent.id) && rows.has(agent.id)) { | ||
| entries.set(agent.id, agent) | ||
| rosters.set(agent.id, { rowId: message.id, position: message.journalPosition }) |
There was a problem hiding this comment.
Resumed child shows stale state When a Codex child thread works again in a later turn, Codex can create a new roster row that says it is working. This code keeps the first roster entry for that child, so its section can still say “completed” and treat its nested sections as settled while the child is working.
Knowledge Base Used: Agent workspaces and sessions
There was a problem hiding this comment.
ℹ️ Minor edge case inline — no blocking issues found.
Reviewed changes
A restructure of how a subagent's rows are projected into a structured chat, plus the retention and host-paging changes that keep a subagent's burst from crowding the conversation out.
- Projection split (
native-chat-transcript-projection.ts).projectNativeChatTranscriptnow separates the session's own rows (conversation) from each subagent's rows (subagentRows, keyed by agent id), folding each agent's run apart and chunking a run at turn boundaries;projectNativeChatTranscriptMessagesis the conversation-only wrapper every existing reader uses. A transcript with no producer linkage projects exactly as before. - Sections (
native-chat-subagent-sections.ts,-section-slots.ts,-live-frontier.ts,-delegation.ts). Each subagent's rows render under its roster entry (or its spawner's section when nested); sections auto-open only at the parent's live delegation (roster / Codex collab call / Claude spawn), and the reader's own open/close outranks that. New slot kindssubagentandsubagent-entriescarry depth, turn key and estimated height for the outline rail and virtualizer. - Client roster + host pages.
structured-agent-session-subagent-roster.tskeeps a per-agent roster from every roster row/revision and the new optional page fieldsubagentRoster;agent-session-history-page.tswindows backward/tail pages over the session's own rows and adds an in-processown-agentscope used by every worker-read path. - Retention (
structured-agent-session-reducer.ts). The live window is now trimmed in the session's own rows (retainedOwnItemLimit1024) with a 4096-rowretainedItemCap. - Removed as redundant. The per-row subagent caption (desktop + mobile),
native-chat-subagent-attribution.ts, thewrittenByi18n key, and the worker text[..., subagent …]tags;formatWorkerTranscriptMessagescollapses to the single-message form.
I verified the one part of this large diff with a real external contract: boundMessage in worker-transcript-payload.ts no longer strips or bounds agentId/parentAgentId/providerParentRef/producerKind/attempt (it only drops journalPosition). Every producer call path is either own-agent-scoped (readStructuredJournalPage → host.history(..., 'own-agent')) or a terminal transcript decoder that sets no producer linkage, so nothing reachable leaks — the deleted bounds test exercised an unreachable input. The safety rests on isRootAgentJournalItem keying on agentId only, which is worth preserving.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| } | ||
| own += 1 | ||
| if (own > ownLimit) { | ||
| start = index + 1 |
There was a problem hiding this comment.
The trim cuts by array index, so when the boundary lands inside one journal write whose items share a sequence (a multi-question ask: sequenceIndex 0..n), it keeps one item of the group and drops another at the same sequence. The dropped row then has no page: the host's before filter is strictly sequence < cursor.sequence, and the oldest retained item is the kept sibling at that same sequence — equal, so excluded. Paging runs to the start and the row is gone for good.
Technical details
# A trim can orphan a row it left behind
## Affected sites
- `src/shared/structured-agent-session-reducer.ts:185` — `start = index + 1` drops the item at `index` while `index + 1` may share its `sequence`.
- `src/shared/structured-agent-session-reducer.ts:177` — the `cap` branch (`items.length - cap`) splits a group the same way.
- `src/main/native-chat/agent-session-wire/agent-session-history-page.ts:101` — `older` filters `sequence < cursor.sequence`; a same-sequence sibling is unreachable.
- `src/shared/structured-agent-session-reducer.ts:338` — `oldestStructuredAgentSessionCursor` is `{ epoch, sequence }` only, so the cursor cannot disambiguate a `sequenceIndex`.
## Required outcome
- Anything `trimRetainedItems` drops must remain reachable through a normal `before` page: every item left in the retained window must have a strictly greater `sequence` than every dropped item, or the cursor must otherwise be able to name the cut point.
## Suggested approach (optional)
- Snap `start` forward past the whole `sequence` group containing the item being trimmed (all items with `items[i].sequence === items[index].sequence`), rather than to `index + 1`, so the retained head's `sequence` is strictly greater than the dropped group's. Apply the same to the `cap` branch.
- A test with two root items sharing one `sequence` straddling the 1024-own-row boundary would pin this; the retention tests today use one item per sequence.|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Warning Review limit reachedNext included review available in 2 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (88)
📝 WalkthroughWalkthroughThe change separates session conversation rows from subagent transcript rows and adds expandable subagent sections to the native chat renderer. History paging and retention now account separately for root-agent and subagent rows, and history pages can carry roster metadata for subagents. Mobile history loading traverses subagent-only pages to reach root-agent rows. Worker transcript output now formats messages individually and omits subagent speaker attribution. Priority: ➖ Normal Merge Risk: 🔵 Low · up to Subagent rows now appear in their own sections instead of in the parent conversation. One narrow mobile case remains: if the app is reconnecting when a chat opens with only subagent rows loaded, the automatic load of older messages may never run, and the conversation can stay empty. Otherwise the change looks ready to merge after that small fix. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change affects conversation history across multiple clients. Inspected paths keep reads tied to the selected conversation and bound returned data. No increased privileges or cross-conversation exposure was established, but access-control and recovery coverage is incomplete. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 46.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 111 functions across 61 files. (7 skipped: 7 unsupported.) ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Main now places rows in turns from the journal's turn records (nativeChatTurnMembership) and draws a send queued mid-turn after the earlier turn's rows. A subagent's rows take their turn from the same rule: the projection runs the membership over every row, with only the conversation's drawn user rows able to open a turn, so a subagent's edit counts in the turn its record names on scoped and unscoped hosts alike. Also kept from both sides: the failed-turn answer and compaction fold fields (the fold reads only the conversation, so the subagent check moves to a slots test), the queue publication beside the scoped history read, and the waiting-behind-a-command split, which now splits message slots only. The list's projection moves into use-native-chat-transcript-projection to keep the list under the line limit.
Main moved the journal onto one database per host and retired journal-store-test-open; this branch's history-window and worker-page tests open their journals through journal-host-database-test-support with a stateDirectory, as main's own tests now do.
…rnal now requires
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 2c2ddcb9-87e7-47ff-bd7b-22884b04bc2f
📒 Files selected for processing (33)
mobile/src/session/MobileNativeChatView.tsxmobile/src/session/use-mobile-structured-agent-state.tssrc/main/native-chat/agent-session-wire/agent-session-history-conversation-window.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-background-task-channel.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host.tssrc/main/runtime/orchestration/structured-worker-journal-page.test.tssrc/renderer/src/components/native-chat/NativeChatMessageList.subagent-sections.test.tsxsrc/renderer/src/components/native-chat/NativeChatMessageList.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.tsxsrc/renderer/src/components/native-chat/NativeChatTranscriptItems.tsxsrc/renderer/src/components/native-chat/native-chat-message-list-projection.tssrc/renderer/src/components/native-chat/native-chat-rail-outline-parity.test.tssrc/renderer/src/components/native-chat/native-chat-subagent-sections.test.tssrc/renderer/src/components/native-chat/native-chat-transcript-slots.test.tssrc/renderer/src/components/native-chat/native-chat-transcript-slots.tssrc/renderer/src/components/native-chat/use-native-chat-transcript-projection.tssrc/renderer/src/components/native-chat/use-structured-agent-session.tssrc/renderer/src/i18n/en-runtime-required.jsonsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/shared/agent-session-wire.tssrc/shared/native-chat-transcript-projection.test.tssrc/shared/native-chat-transcript-projection.tssrc/shared/native-chat-turn-fold.test.tssrc/shared/native-chat-turn-fold.tssrc/shared/native-chat-turn-grouping.tssrc/shared/native-chat-turn-membership.tssrc/shared/native-chat-types.tssrc/shared/structured-agent-session-projection.ts
💤 Files with no reviewable changes (1)
- src/shared/native-chat-turn-fold.test.ts
🚧 Files skipped from review as they are similar to previous changes (7)
- src/shared/structured-agent-session-projection.ts
- src/renderer/src/i18n/locales/ja.json
- src/renderer/src/i18n/locales/fr.json
- src/renderer/src/i18n/locales/en.json
- src/renderer/src/i18n/locales/ko.json
- src/renderer/src/i18n/locales/es.json
- src/renderer/src/i18n/locales/zh.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
| useEffect(() => { | ||
| if (drawsNothingFrom === null || loadingOlder || readBackFromRef.current === drawsNothingFrom) { | ||
| return | ||
| } | ||
| readBackFromRef.current = drawsNothingFrom | ||
| loadEarlier() | ||
| }, [drawsNothingFrom, loadEarlier, loadingOlder]) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Read-back can stall when loadEarlier bails out early.
The effect records readBackFromRef.current before it calls loadEarlier(). loadEarlier returns early in these cases: client is null, loadingOlder is true, or the cursor is missing. The key is then marked consumed and never retried. This can happen if client is null at that moment (for example, during reconnect). The list stays empty with no scroll trigger to recover.
Set the ref only after loadEarlier actually starts. For example, check client and sessionId in the effect before you set the ref. Add client to the dependencies.
Proposed fix
useEffect(() => {
- if (drawsNothingFrom === null || loadingOlder || readBackFromRef.current === drawsNothingFrom) {
+ if (
+ drawsNothingFrom === null ||
+ !client ||
+ loadingOlder ||
+ readBackFromRef.current === drawsNothingFrom
+ ) {
return
}
readBackFromRef.current = drawsNothingFrom
loadEarlier()
- }, [drawsNothingFrom, loadEarlier, loadingOlder])
+ }, [client, drawsNothingFrom, loadEarlier, loadingOlder])📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| useEffect(() => { | |
| if (drawsNothingFrom === null || loadingOlder || readBackFromRef.current === drawsNothingFrom) { | |
| return | |
| } | |
| readBackFromRef.current = drawsNothingFrom | |
| loadEarlier() | |
| }, [drawsNothingFrom, loadEarlier, loadingOlder]) | |
| useEffect(() => { | |
| if ( | |
| drawsNothingFrom === null || | |
| !client || | |
| loadingOlder || | |
| readBackFromRef.current === drawsNothingFrom | |
| ) { | |
| return | |
| } | |
| readBackFromRef.current = drawsNothingFrom | |
| loadEarlier() | |
| }, [client, drawsNothingFrom, loadEarlier, loadingOlder]) |
There was a problem hiding this comment.
ℹ️ No new issues in the delta since the prior review — no inline suggestions this round.
Reviewed changes
Re-reviewed the three commits that landed after the prior pullfrog review: two merges of origin/main and a test-only turn-scope tweak. The branch's net new behavior is the conflict adaptation to main's turn-record model.
- Subagent turn keys adapted to main's turn-record model.
nativeChatRowTurnKeysandnativeChatTurnMembershipgained anopensTurnparameter, andprojectNativeChatTranscriptpasses a predicate restricted to the conversation's drawn user rows. A subagent's own prompt no longer opens a turn, while its rows still take the turn theirturnScopenames. Conversation rendering keeps the separate conversation-only membership call frommain. - Merge preserved both parents. The failed-turn and compaction fold fields, the queue publication beside the scoped history read, and the waiting-behind-a-command split (now filtering message slots only) all survived; the list's projection moved into
use-native-chat-transcript-projection.tsto stay under the line limit. - Tests adapted to main's journal. Test helpers now pass
stateDirectoryandturnScope: AGENT_JOURNAL_THREAD_SCOPE, and the subagent-own-row retention cases were added.
I confirmed the opensTurn narrowing does not change any conversation row's turn key on either a scope-stating host or a journal-order host, that the conflict resolution dropped nothing from main (the per-agent trailing-run frontier relocated into the section slots), and that mobile's new conversation filter keeps exactly the session's own rows. The earlier inline finding on trimRetainedItems was not touched by these commits, so it remains open and is not re-raised here.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…-subagent-rows-with-subagent # Conflicts: # mobile/src/session/use-mobile-structured-agent-state.ts # src/renderer/src/components/native-chat/NativeChatMessageList.tsx
…-subagent-rows-with-subagent # Conflicts: # src/renderer/src/i18n/locales/es.json
There was a problem hiding this comment.
ℹ️ No new PR-authored changes in the delta since the prior review — the only commit is a merge of
origin/main. No inline suggestions this round.
Reviewed changes
- Merged
origin/maininto the branch. The branch's only commit since the prior review is the merge, and its effect on files this PR also edits is main's own content: the mobile queued-message feed inuse-mobile-structured-agent-state.ts, main's removal of theProviderFrameRowre-export fromNativeChatMessageList.tsx, the Codex terminal-server-isolation settings/copy and agent-trust preset changes, retiredNativeChatSubagentRuntests, and i18n additions. The PR's own additions (projection split, subagent sections, client roster, own-row windowing) survive unchanged, and the removednative-chat-subagent-attributionmodule andwrittenBykey have no dangling references.
The prior inline finding on structured-agent-session-reducer.ts:185 is untouched by the merge and remains open; it is not re-raised here.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No new issues in the delta since the prior review. No inline suggestions this round.
Reviewed changes
- Merged
origin/mainagain (branch base now6b36a2c). Brought main's mid-turn editable queued-message cards (use-structured-agent-session.ts, the transport state,NativeChatStructuredSession.tsx, and the reducer'squeuePublicationField) plus the Claude Stop fix. The conflict resolution kept both sides: the reducer's early-return now guards on main'squeuedMessages/queuePauseand the PR'ssubagentRoster, and the PR's roster wiring survives inuse-structured-agent-session.ts, the transport state andNativeChatStructuredSession.tsx. - Extracted the client journal retention policy into
src/shared/structured-agent-session-item-retention.ts.MAX_RETAINED_OWN_ITEMS,MAX_RETAINED_ITEMS,ownItemCountandtrimRetainedItemsmoved verbatim out ofstructured-agent-session-reducer.ts, which now imports them. No logic change; the test suite still exercises them through the reducer.
The prior inline finding on the retention trim (shared-sequence group bisected by the array-index cut) moved with the code into structured-agent-session-item-retention.ts unchanged, so it remains open and is not re-raised here.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
When the agent in a chat hands work to a helper agent (a subagent), the helper's work used to be mixed into the main conversation. #23605 labelled each of those lines as the helper's, but they were still interleaved with the agent's own words, so a helper-heavy chat was mostly helper output.
After this PR, the main conversation is only you and the agent you're talking to. Each helper's work lives in its own section under the line that says the helper was started. A helper's section opens by itself while the agent is waiting on it, and folds as soon as the agent moves on. You can open or close any helper's section yourself at any time, and your choice sticks.
Scope: structured chats (Claude and Codex) on desktop, mobile, and in orchestration worker reads. Chats with no subagent linkage render exactly as before. That covers terminal-backed chats and journals from before #22299. Follow-up to #23605, which is on main.
What Changed
Before (user-facing). A subagent's tool calls, prose and edits appeared inline in the parent's timeline, each captioned "Written by subagent …". Parallel or background subagents interleaved with the parent row by row. On one real session: 3,584 subagent tool calls and 299 subagent prose rows sat inside the parent's own 3,353 and 461.
After (user-facing).
orca orchestration worker-read, the release archive, andterminal readon a structured worker return only the worker's own conversation. The worker's roster line still says a subagent ran.Mechanism.
projectNativeChatTranscript) splits rows by the agent that wrote them. The session's own rows are the conversation. Each subagent's rows are kept apart, keyed by the agent id that its rows and its roster entry share, and folded per agent within each turn. Both take their turn from the journal's turn records through one rule (nativeChatTurnMembership), so a subagent's edit counts in the turn it was made, and a subagent's own prompt never opens a turn.native-chat-subagent-sections.tsandnative-chat-subagent-section-slots.tsplace each subagent's rows under its roster entry, or inside its spawner's section when another subagent spawned it. Open sections are ordinary windowed rows, so a long helper run mounts lazily like the rest of the chat. A subagent whose roster row isn't loaded gets its own small head at its first loaded row.native-chat-subagent-live-frontier.ts). This is worked out on every render from the rows alone; nothing is stored.structured-agent-session-subagent-roster.ts). It is built from every roster row and revision received, including revisions of rows the window has trimmed. It is cleared when a page replaces the window, bounded at 512 agents, and drops an entry when the host withdraws it. Sections take their name and live state from it, so a long subagent burst no longer turns a watched section into an unnamed header.agent-session-history-page.ts), so a busy subagent can't crowd the conversation out of a page or of the window.subagentRoster, with that subagent's roster entry. It is bounded to 64 entries and 16 KB.writtenBystring in all six locales;[assistant, subagent …]worker text tags and the agent id served on worker-read messages.Why
The failure class. In #23605, every reader of one mixed list answered "whose row is this?" on its own, so every new reader was a new chance to present a helper's words as the agent's. Splitting once in the projection makes the conversation safe by construction. A reader gets only the session's own rows unless it asks for a subagent's by id.
Why these rules.
Alternatives considered.
Wire and persistence. No schema change, no migration, no new persisted fact. Sections and the roster are derived from linkage the journal already stores.
subagentRosteris a new optional field on history pages, so it is safe per Rule 1 ofdocs/reference/remote-wire-compatibility.md. An older client ignores it; the released v1.4.216 reducer reads a page with it exactly as one without. A newer client talking to an older host gets no field, and a subagent whose roster it has never seen shows as an unnamed "Subagent" header, as before.Windowing pages by the session's own rows changes what the host publishes (Rule 3): a page can now hold more than
limititems. Old clients cope, and no capability gate is needed:The released v1.4.216 host and reducer were paired with this build in all four combinations, and a walk back through two real journals had no gaps or duplicates. The cross-version agent-session suite passes.
Worker reads filter to the worker's own rows before the 200-row limit, on the execution host that owns the journal. Worker-read cursors are computed on the host from the same filtered page.
Performance.
Known weaknesses.
Linked Issue
Linear: STA-8138. Follow-up to #23605, which relanded the fix reverted in #22058. This PR restructures #23605's transcript half so a subagent's rows live with that subagent.
Visual Proof
Electron QA ran on a separate macOS machine with a real Claude CLI, in an isolated profile and home, comparing BEFORE (main with #23605,
e8e144bf3ca) against AFTER (this branch merged with current main,a1f3ea3197e). Mobile ran on an Android emulator paired to the AFTER build's host.One subagent while the parent waits. Before: the subagent's captioned rows are interleaved in the conversation. After: its rows stream directly under its roster entry, named once; they fold when the parent answers, and one click reopens them.
Two parallel subagents. Before: their rows alternate one by one in the conversation. After: only the newest agent's section is open while the roster says "2 working"; the other opens on click, and its rows sit under its own entry.
The parent moves on. When the parent runs its own command right after spawning, the section stays closed and the roster keeps showing that the subagent is working.
The reader's toggles. Before: the roster toggle showed only a name and a state. After: an entry opens its rows. Collapsing the list hides its sections, and re-expanding keeps each section's choice, including after the row scrolls out of the window and back.
The collapsed turn shows the parent's own answer (unchanged, correct on both).
Scrolled up while a subagent streams: the row being read moved 0 px over two 30 s windows on both builds.
Background subagent. Before: its rows were hidden while it ran, then split across two turns. After: its section stays closed while the roster ticks, nothing grows mid-transcript, and when opened its rows sit together under its entry in the turn that started it.
Mobile: the phone shows the roster line and the parent's answer, with no subagent rows.
A section's copy and timestamp controls stay inside it (
8efc714714f): on hover the strip sits inside the section's border, with the normal gap before the parent's next row.Testing
Every new or changed test was proven red with the code it covers broken, and green once restored. Coverage:
subagentRosteron opening and older pages, and its bound;Gates:
oxlintandoxfmt --checkon the changed files;verify-localization-catalogsandgenerate-runtime-required-english-catalogfail on main because of an unrelated key already there; they fail identically on this branch.AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)