Skip to content

refactor(native-chat): a subagent's rows live in its own section, not in the parent's conversation - #23752

Merged
brennanb2025 merged 40 commits into
mainfrom
brennanb2025/sta-8138-subagent-rows-with-subagent
Sep 30, 2026
Merged

brennanb2025 merged 40 commits into
mainfrom
brennanb2025/sta-8138-subagent-rows-with-subagent

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 30 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2554 $\color{#cf222e}{\Huge{\mathbf{−}}}$​383 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2171
Prod 58 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1926 $\color{#cf222e}{\Huge{\mathbf{−}}}$​474 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1452

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

  • The conversation shows only the session's own rows. Each subagent's rows sit directly under that subagent's entry in the "Kicked off N subagents" roster row, and each agent is named once.
  • A section opens by itself only while the running agent's newest action is delegating to that subagent: the roster row, or a call that spawns, waits on, resumes or messages it. Anything newer the agent does closes it again, even while the subagent keeps working. With two spawns in one turn, only the newest opens.
  • The closed roster row keeps showing live state ("Kicked off 2 subagents · 1 working", with a pulsing dot and a clock), so nothing is hidden about whether a helper is still running.
  • The reader's own open or close always wins. It is kept while the row scrolls out of view. Collapsing the roster list hides its sections, and reopening it restores each section's own choice.
  • Mobile shows the conversation plus the roster line, never subagent rows.
  • orca orchestration worker-read, the release archive, and terminal read on a structured worker return only the worker's own conversation. The worker's roster line still says a subagent ran.

Mechanism.

  • One split, before anything reads. The shared transcript projection (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.
  • Sections. native-chat-subagent-sections.ts and native-chat-subagent-section-slots.ts place 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.
  • When a section opens (native-chat-subagent-live-frontier.ts). This is worked out on every render from the rows alone; nothing is stored.
    • While the session runs, the newest row the agent produced is found, ignoring the user's own messages. A folded tool run counts as new as the newest call it merged.
    • That row opens a section only if it delegates to that subagent:
      • a Codex collab call opens the first agent it names;
      • a Claude spawn call counts as part of the roster row announcing it;
      • the roster row opens the agent it added most recently.
    • The same rule applies inside a working subagent, for the subagents it spawned.
  • A roster the window can't lose. The client reducer keeps a per-agent roster keyed by agent id (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.
  • The window counts the conversation. Live retention keeps the newest 1,024 of the session's own rows plus everything after them, with a 4,096-row total cap. The host windows history pages the same way (agent-session-history-page.ts), so a busy subagent can't crowd the conversation out of a page or of the window.
  • Pages name off-page subagents. When a history or opening page holds a subagent's rows but not the roster row that names it, the page carries a new optional field, subagentRoster, with that subagent's roster entry. It is bounded to 64 entries and 16 KB.
  • Removed as redundant now that nothing downstream sees a mixed list:
    • the tool fold's cross-agent check;
    • the "answer must be the session's own prose" turn rule;
    • the interleaved per-agent live-run logic;
    • the per-row subagent caption on desktop and mobile, with its shared module and the writtenBy string in all six locales;
    • the [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.

  • Keying on the subagent's agent id, not the spawning call's id: the call id is re-minted every time a subagent resumes, and the linkage contract says it is provenance, never a join key. The agent id is stable and equals the roster entry's id.
  • Opening only at the live delegation, rather than whenever the roster says "working": the broader rule opened sections mid-transcript and grew them above the reader, and closed them under a reader who was watching. The live-frontier rule never auto-opens anything the agent has moved past, and the closed row still shows the live state.
  • A client roster plus the page field, rather than more retention rules: four review rounds each patched a different way the roster row fell out of the window. Keeping the roster separately removes that class.
  • The page field is a separate optional field, not the roster row itself, because the older-page cursor is the page's first item sequence. Pulling an older roster row onto the page would move the cursor past every row in between, for every client.

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.

  • subagentRoster is a new optional field on history pages, so it is safe per Rule 1 of docs/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 limit items. Old clients cope, and no capability gate is needed:

    • the page is still one contiguous run;
    • the cursor still names its first item;
    • the byte ceiling is unchanged;
    • every released reducer grows its window to the page's size;
    • a transcript with no subagent rows gets identical pages.

    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.

  • The split is one linear pass.
  • At the 4,096-row cap, one live batch costs 2.2–2.5 ms of derivation on desktop, against 0.5 ms at main's 1,024-row window. That is about 4% of the main thread at the 60 ms batch interval. The live-frontier walk and the roster fold add about 0.01 ms.
  • Closed sections cost nothing beyond their entry line.
  • Host page reads cost 1–3 ms per page on the largest local journals.

Known weaknesses.

  • A separately tracked host bug stamps some rows of a resumed Claude subagent with its spawn-call id instead of its task id. No roster names those rows, so they show under an unnamed "Subagent" head rather than under the named entry. They are never shown as the parent's.
  • A section whose roster row isn't loaded is named and shows live state, but it sits at its first loaded row until that older history loads.
  • Mobile keeps a bounded read-ahead for "Load earlier" and a one-time read-back when the newest page holds none of the session's own rows. An older host still sends pages counted across every agent, and a current host can send such a page when a subagent's burst fills the page's byte budget.
  • A turn in which the agent writes nothing at all shows no changed-files rollup for a subagent's edit. No provider path produces such a turn today.
  • A background subagent's edit made after the parent's turn has ended belongs to no turn under main's turn-record rule, so it shows in no changed-files rollup. It is still visible in the subagent's section.

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.

BEFORE: captioned subagent rows interleaved in the parent timeline
AFTER: rows directly under the roster entry, streaming while the parent waits
AFTER: parent answered, section folded, roster shows completed
AFTER: reopened by the reader

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.

BEFORE: both subagents' captioned rows alternating in the timeline
AFTER: only the newest agent's section open while 2 are working
AFTER: both opened by the reader; the next entry continues below the first agent's rows

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.

AFTER: the parent's own ls/Read after the spawn; section closed, roster 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.

BEFORE: the roster toggle shows only the name and state
AFTER: entry open, rows under it
AFTER: list collapsed, section hidden
AFTER: list re-expanded, the section's choice kept

The collapsed turn shows the parent's own answer (unchanged, correct on both).

BEFORE: collapsed turn shows PARENT ANSWER
AFTER: collapsed turn shows PARENT ANSWER

Scrolled up while a subagent streams: the row being read moved 0 px over two 30 s windows on both builds.

AFTER: parked at 40% while the subagent streams below
AFTER: 30 s later, identical viewport

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.

BEFORE: background rows landed inside the later turn
AFTER: roster closed and working while the next answer streams
AFTER: opened, rows directly under the entry in the spawning turn

Mobile: the phone shows the roster line and the parent's answer, with no subagent rows.

AFTER: phone, turn collapsed: Ran 1 subagent and PARENT ANSWER
AFTER: phone, turn expanded: the parent's Agent call, Ran 1 subagent, PARENT ANSWER; 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.

AFTER: hover on the subagent's last prose row; the strip sits inside the section with a normal gap to the next parent row

Testing

  • I manually tested these changes locally (Electron QA on a separate macOS machine, both builds side by side; mobile on an Android emulator; results above)
  • Automated tests added/updated

Every new or changed test was proven red with the code it covers broken, and green once restored. Coverage:

  • Projection: the split; per-agent folding at turn boundaries; turn keys from the host's turn records; "no linkage renders exactly as before".
  • Live frontier:
    • open at the live delegation, closed once superseded (including a call folded above the roster);
    • the newest of two spawns;
    • Codex waits, including one naming no agent;
    • nested scopes;
    • the reader's choice winning both ways.
  • Client roster: a burst that trims the roster keeps the section named and live; revisions outside the window; withdrawal; epoch reset; the bound.
  • Host pages:
    • own-row windowing;
    • subagentRoster on opening and older pages, and its bound;
    • identical pages without subagent rows;
    • a worker page yielding own rows under a busy subagent.
  • List: the entry heads its rows; list collapse hides sections and keeps choices across scroll-out; reveal from the changed-files rollup; the outline rail's turn.
  • Mobile: subagent rows are not drawn; "Load earlier" and the first page read past subagent-only pages.

Gates:

  • root typecheck (node, web, CLI), the mobile typecheck, and the mobile tests-typecheck ratchet;
  • oxlint and oxfmt --check on the changed files;
  • the changed-code quality gate and React Doctor;
  • the native-chat, shared, agent-session-wire, orchestration, CLI orchestration and cross-version agent-session suites;
  • the mobile session suite.

verify-localization-catalogs and generate-runtime-required-english-catalog fail on main because of an unrelated key already there; they fail identically on this branch.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Cross-platform: no platform-specific code.
  • SSH/remote: the split happens in the shared projection over the journal items a remote host already serves. Page windowing, the page field and the worker-read filter run on the execution host that owns the journal.
  • Mobile: mobile draws only the conversation and the roster line.
  • Answering a subagent: its pending question or approval card mounts in the composer's place, so it can always be answered whatever a section's state.

Checklist

  • This PR is small and focused. It is not small: 83 files. The restructure, the host page changes and the client roster ship together because each fixes a failure the others would leave; see Why.
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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

Copy link
Copy Markdown
Contributor Author

Review status: ready for review (not merged)

Verdict. The review loop is clean, Electron and mobile QA passed, and CI is green at 8efc714714f. Marked ready for review. Not merged, and auto-merge is not enabled.

What the review changed, as new commits on this branch (no force-push):

  • Merged current main twice. The second merge reconciles fix(native-chat): group chat rows by the turn that produced them #23671's turn grouping with this PR, so a subagent's rows and the conversation's rows now take their turn from one rule.
  • When a section opens. It now opens only while the running agent's newest action is delegating to that subagent: its roster row, or a spawn or wait call for it. Any newer output closes it again, and with two spawns only the newest opens. Previously a section opened wherever the roster said "working", which grew sections mid-transcript and closed them under a reader who was watching.
  • A client-side subagent roster keyed by agent id. It is never trimmed with the transcript window. Previously a long subagent burst could push its roster row out of the window, turning a watched section into a closed, unnamed "Subagent" header. In local journals, 27 of 677 subagent runs were long enough for that.
  • A new optional history page field, subagentRoster. It names subagents whose roster row sits on an older page. Previously about 11% of the moments a reader could open a session showed at least one unnamed section.
  • The live window and history pages count the conversation's own rows, with a 4,096-row cap, so a busy subagent can't crowd the conversation out.
  • Mobile. "Load earlier" and the first page now read past pages that hold only subagent rows. Previously the button could land nothing, and a session could open onto the empty-chat screen.
  • The roster entry is its section's head, so each agent is named once. Collapsing the roster list hides its sections, and the reader's choices survive scrolling.
  • Smaller fixes:
    • the outline rail lit the wrong turn for a background subagent;
    • a withdrawn subagent could stay "working" forever;
    • the changed-files rollup re-sorted every subagent row on each token;
    • a section's copy and timestamp strip overhung the next row.

QA (a separate macOS machine, real Claude CLI, isolated profile and home):

  • Every scenario passed, before vs after, on the merged head. Screenshots are embedded in the PR body.
  • The test app was driven by Claude, because the Grok quota was exhausted (402).
  • Mobile passed on an Android emulator: the phone shows only the roster line and the parent's answer. One deviation: a dev-server URL was opened on the phone once with adb am start rather than through orca emulator, and phone screenshots used adb screencap.

Checks.

  • Readiness checklist at the start and the end: PASS, with no P0 or P1.
  • Root, mobile, and mobile test-file typechecks pass.
  • The native-chat, shared, agent-session-wire, orchestration, CLI and cross-version suites pass, as do the mobile session suite, lint, format, the changed-code quality gate, and React Doctor.

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:

  • a host-side change to what history pages contain;
  • a new optional page field;
  • the client roster;
  • the close rule.

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):

  • A host bug stamps some resumed Claude subagent rows with the spawn-call id instead of the task id. Those rows show under an unnamed "Subagent" head instead of the named entry. It is being fixed in its own branch (sta-8138-subagent-resume-id).

Already on main (not caused by this PR):

  • Claude's Edit tool produces no diff items, so Claude edits (parent or subagent) never show a "N changed files" rollup.
  • A foreground Claude subagent's closing paragraph appears only in the parent's tool result.
  • Opening anything while the view is pinned to the bottom scrolls it to the end.
  • verify-localization-catalogs and generate-runtime-required-english-catalog fail on an unrelated key.

Minor residuals, all consistent with the rules above:

  • A section appears about 2 s after the roster, once the subagent's first row arrives. If the parent acts at once, it is never seen open.
  • After a turn settles, reopening a section takes two clicks: the list, then the entry.
  • A section has about 28 px of bottom padding under its last prose row.

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 2/5

[Medium risk] Restructures how subagent messages display in chat.

The PR does not appear safe to merge while queued messages can disappear from view or acquire duplicate sendable copies.

Findings

  1. P1 Resumed child shows stale state ▶

Summary

The PR separates subagent rows from the parent conversation across desktop, mobile, history pages, and worker reads. Changes since the previous review also add desktop queued follow-ups, card controls, capability negotiation, and revised Stop handling.

  • Queued sends can temporarily disappear before the host publishes their cards.
  • Editing a queued card can leave sendable copies in both the queue and composer if deletion fails.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Send[Composer send] --> Outbox[Local outbox]
  Outbox --> Host[Host queue]
  Host --> Card[Queued card]
  Card -->|Send now| Turn[Agent turn]
  Card -->|Edit| Draft[Composer draft]
  Card -->|Delete succeeds| Removed[Removed from queue]
Loading

Reviews (4) · Last reviewed commit: "refactor(native-chat): the client's jour..."

Comment on lines +112 to +114
if (!entries.has(agent.id) && rows.has(agent.id)) {
entries.set(agent.id, agent)
rosters.set(agent.id, { rowId: message.id, position: message.journalPosition })

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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

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

ℹ️ 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). projectNativeChatTranscript now 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; projectNativeChatTranscriptMessages is 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 kinds subagent and subagent-entries carry depth, turn key and estimated height for the outline rail and virtualizer.
  • Client roster + host pages. structured-agent-session-subagent-roster.ts keeps a per-agent roster from every roster row/revision and the new optional page field subagentRoster; agent-session-history-page.ts windows backward/tail pages over the session's own rows and adds an in-process own-agent scope used by every worker-read path.
  • Retention (structured-agent-session-reducer.ts). The live window is now trimmed in the session's own rows (retainedOwnItemLimit 1024) with a 4096-row retainedItemCap.
  • Removed as redundant. The per-row subagent caption (desktop + mobile), native-chat-subagent-attribution.ts, the writtenBy i18n key, and the worker text [..., subagent …] tags; formatWorkerTranscriptMessages collapses 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.

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

}
own += 1
if (own > ownLimit) {
start = index + 1

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

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

Next included review available in 2 minutes.

Check out review usage here.

View limit details

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 9a2a9ab7-d900-402f-96dd-e858240f71ab

📥 Commits

Reviewing files that changed from the base of the PR and between ccb5d03 and b48025b.

📒 Files selected for processing (88)
  • mobile/src/session/MobileNativeChatMessage.test.ts
  • mobile/src/session/MobileNativeChatMessage.tsx
  • mobile/src/session/MobileNativeChatView.tsx
  • mobile/src/session/mobile-native-chat-message-styles.ts
  • mobile/src/session/mobile-native-chat-render-data.test.ts
  • mobile/src/session/mobile-native-chat-render-data.ts
  • mobile/src/session/use-mobile-structured-agent-session-prompt-cancel.test.tsx
  • mobile/src/session/use-mobile-structured-agent-state.test.tsx
  • mobile/src/session/use-mobile-structured-agent-state.ts
  • src/cli/handlers/orchestration/worker-output.ts
  • src/main/native-chat/agent-session-wire/agent-session-history-conversation-window.test.ts
  • src/main/native-chat/agent-session-wire/agent-session-history-page.ts
  • src/main/native-chat/agent-session-wire/agent-session-history-subagent-roster.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-background-task-channel.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-history-result.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
  • src/main/runtime/orchestration/structured-worker-journal-page.test.ts
  • src/main/runtime/orchestration/structured-worker-journal-page.ts
  • src/main/runtime/orchestration/worker-transcript-payload.test.ts
  • src/main/runtime/orchestration/worker-transcript-payload.ts
  • src/main/runtime/structured-worker-terminal-read.ts
  • src/renderer/src/components/native-chat/NativeChatMessageList.older-history.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageList.subagent-sections.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageList.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRow.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
  • src/renderer/src/components/native-chat/NativeChatSubagentRun.test.tsx
  • src/renderer/src/components/native-chat/NativeChatSubagentRun.tsx
  • src/renderer/src/components/native-chat/NativeChatSubagentSectionHead.tsx
  • src/renderer/src/components/native-chat/NativeChatToolRun.tsx
  • src/renderer/src/components/native-chat/NativeChatTranscriptItems.tsx
  • src/renderer/src/components/native-chat/NativeChatTranscriptRow.tsx
  • src/renderer/src/components/native-chat/native-chat-expanded-keys.ts
  • src/renderer/src/components/native-chat/native-chat-message-list-projection.test.ts
  • src/renderer/src/components/native-chat/native-chat-message-list-projection.ts
  • src/renderer/src/components/native-chat/native-chat-message-rail-items.ts
  • src/renderer/src/components/native-chat/native-chat-rail-outline-parity.test.ts
  • src/renderer/src/components/native-chat/native-chat-row-height-estimate.test.ts
  • src/renderer/src/components/native-chat/native-chat-row-height-estimate.ts
  • src/renderer/src/components/native-chat/native-chat-subagent-delegation.test.ts
  • src/renderer/src/components/native-chat/native-chat-subagent-delegation.ts
  • src/renderer/src/components/native-chat/native-chat-subagent-live-frontier.ts
  • src/renderer/src/components/native-chat/native-chat-subagent-section-slots.ts
  • src/renderer/src/components/native-chat/native-chat-subagent-sections-retention.test.ts
  • src/renderer/src/components/native-chat/native-chat-subagent-sections.test.ts
  • src/renderer/src/components/native-chat/native-chat-subagent-sections.ts
  • src/renderer/src/components/native-chat/native-chat-tool-fold.test.ts
  • src/renderer/src/components/native-chat/native-chat-trailing-run.ts
  • src/renderer/src/components/native-chat/native-chat-transcript-slots.test.ts
  • src/renderer/src/components/native-chat/native-chat-transcript-slots.ts
  • src/renderer/src/components/native-chat/native-chat-turn-diffs.ts
  • src/renderer/src/components/native-chat/structured-agent-session-transcript-order.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-provisional-launch.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-subagent-sections.ts
  • src/renderer/src/components/native-chat/use-native-chat-transcript-projection.ts
  • src/renderer/src/components/native-chat/use-native-chat-transcript-window.options.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-transcript-window.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-provisional.test.tsx
  • src/renderer/src/components/native-chat/use-structured-agent-session-transport-state.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session.ts
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/agent-session-wire.ts
  • src/shared/native-chat-subagent-attribution.ts
  • src/shared/native-chat-tool-fold.ts
  • src/shared/native-chat-transcript-projection.test.ts
  • src/shared/native-chat-transcript-projection.ts
  • src/shared/native-chat-turn-fold.test.ts
  • src/shared/native-chat-turn-fold.ts
  • src/shared/native-chat-turn-grouping.ts
  • src/shared/native-chat-turn-membership.ts
  • src/shared/native-chat-types.ts
  • src/shared/structured-agent-session-item-retention.test.ts
  • src/shared/structured-agent-session-item-retention.ts
  • src/shared/structured-agent-session-projection.ts
  • src/shared/structured-agent-session-reducer.ts
  • src/shared/structured-agent-session-subagent-roster.test.ts
  • src/shared/structured-agent-session-subagent-roster.ts
  • src/shared/worker-transcript-background-task-text.test.ts
  • src/shared/worker-transcript-subagent-attribution.test.ts
  • src/shared/worker-transcript-text-scaling.test.ts
  • src/shared/worker-transcript-text.ts
📝 Walkthrough

Walkthrough

The 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 ccb5d

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 Review

Security architecture risk: 🔵 Low · up to ccb5d

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
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The inspected history path selects a journal using request.sessionId; the new own-agent scope narrows rows within that journal. Which sessions a remote identity may select remains outside independently verified coverage.

Trust Boundaries and Controls

  • observed — The new history scope is in-process-only. Wire requests retain the existing all-agent read behavior; they cannot request a broader scope through the added argument.
  • observed — The mobile state-cache key encodes source identity, provider identity, and session ID as a JSON tuple. History continuations also check the captured key and stream generation before applying pages.

Resilience and Maintainability Implications

  • observed — Off-page roster metadata is capped at 64 entries and 16 KiB. History content uses a separate byte budget with a 64 KiB envelope reserve, providing containment for the added metadata.
  • observed — Automatic mobile back-reading records its session, epoch, and head key before the read completes. A failed read does not clear that marker, so returning to ready with the same key does not automatically retry.

Hardening Proposals

  • proposed — Consider bounded retry or backoff for failed automatic back-reading, while preserving session-generation, epoch, and cursor-anchor checks. This is a recovery improvement, not an established security finding.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 identifies the main change: subagent rows move from the parent conversation into their own sections.
Description check ✅ Passed The description is substantially complete. It includes the ELI5 explanation, user-facing changes, rationale, alternatives, linked issue, visual proof, testing, compatibility notes, known weaknesses, a…
Full details: Docstring Coverage

Explanation

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 💡
  • Commit to this branch
  • Create a new PR

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.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 2c2ddcb9-87e7-47ff-bd7b-22884b04bc2f

📥 Commits

Reviewing files that changed from the base of the PR and between 8efc714 and ccb5d03.

📒 Files selected for processing (33)
  • mobile/src/session/MobileNativeChatView.tsx
  • mobile/src/session/use-mobile-structured-agent-state.ts
  • src/main/native-chat/agent-session-wire/agent-session-history-conversation-window.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-background-task-channel.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
  • src/main/runtime/orchestration/structured-worker-journal-page.test.ts
  • src/renderer/src/components/native-chat/NativeChatMessageList.subagent-sections.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageList.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
  • src/renderer/src/components/native-chat/NativeChatTranscriptItems.tsx
  • src/renderer/src/components/native-chat/native-chat-message-list-projection.ts
  • src/renderer/src/components/native-chat/native-chat-rail-outline-parity.test.ts
  • src/renderer/src/components/native-chat/native-chat-subagent-sections.test.ts
  • src/renderer/src/components/native-chat/native-chat-transcript-slots.test.ts
  • src/renderer/src/components/native-chat/native-chat-transcript-slots.ts
  • src/renderer/src/components/native-chat/use-native-chat-transcript-projection.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session.ts
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/agent-session-wire.ts
  • src/shared/native-chat-transcript-projection.test.ts
  • src/shared/native-chat-transcript-projection.ts
  • src/shared/native-chat-turn-fold.test.ts
  • src/shared/native-chat-turn-fold.ts
  • src/shared/native-chat-turn-grouping.ts
  • src/shared/native-chat-turn-membership.ts
  • src/shared/native-chat-types.ts
  • src/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.

Comment on lines +255 to +261
useEffect(() => {
if (drawsNothingFrom === null || loadingOlder || readBackFromRef.current === drawsNothingFrom) {
return
}
readBackFromRef.current = drawsNothingFrom
loadEarlier()
}, [drawsNothingFrom, loadEarlier, loadingOlder])

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.

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

Suggested change
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])

@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 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. nativeChatRowTurnKeys and nativeChatTurnMembership gained an opensTurn parameter, and projectNativeChatTranscript passes 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 their turnScope names. Conversation rendering keeps the separate conversation-only membership call from main.
  • 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.ts to stay under the line limit.
  • Tests adapted to main's journal. Test helpers now pass stateDirectory and turnScope: 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.

Pullfrog  | Fix it ➔ | View workflow run | Using 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

@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 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/main into 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 in use-mobile-structured-agent-state.ts, main's removal of the ProviderFrameRow re-export from NativeChatMessageList.tsx, the Codex terminal-server-isolation settings/copy and agent-trust preset changes, retired NativeChatSubagentRun tests, and i18n additions. The PR's own additions (projection split, subagent sections, client roster, own-row windowing) survive unchanged, and the removed native-chat-subagent-attribution module and writtenBy key 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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (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 in the delta since the prior review. No inline suggestions this round.

Reviewed changes

  • Merged origin/main again (branch base now 6b36a2c). Brought main's mid-turn editable queued-message cards (use-structured-agent-session.ts, the transport state, NativeChatStructuredSession.tsx, and the reducer's queuePublicationField) plus the Claude Stop fix. The conflict resolution kept both sides: the reducer's early-return now guards on main's queuedMessages/queuePause and the PR's subagentRoster, and the PR's roster wiring survives in use-structured-agent-session.ts, the transport state and NativeChatStructuredSession.tsx.
  • Extracted the client journal retention policy into src/shared/structured-agent-session-item-retention.ts. MAX_RETAINED_OWN_ITEMS, MAX_RETAINED_ITEMS, ownItemCount and trimRetainedItems moved verbatim out of structured-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.

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

@brennanb2025
brennanb2025 merged commit 21124db into main Sep 30, 2026
39 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/sta-8138-subagent-rows-with-subagent branch September 30, 2026 06:55
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