Skip to content

Native chat: read one saved row per subagent (part 1 of 2) - #27914

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/subagent-items
Oct 12, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/subagent-items

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​496 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​496
Prod 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​355 $\color{#cf222e}{\Huge{\mathbf{−}}}$​48 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​307

ELI5

When an agent in a native chat starts helpers (subagents), Orca saves a "Ran N subagents" row in the chat. Today that row is one saved record for the whole turn, rewritten every time any helper changes. That design forced hidden limits (64 helpers per row, 32 rows, 256 per chat): a helper past the 64th vanished from the saved chat while it was still running, and Claude's saved row could say a helper finished while the running-tasks strip still showed it working.

This PR is the first of two. It teaches Orca to read a new, simpler saved shape: one saved row per helper, updated in place. Nothing writes that shape yet, so nothing changes on screen with this PR alone. The follow-up PR, #27947, switches Claude, Codex and Grok to write it and deletes the old grouped machinery.

What Changed

  • New saved shape: a subagent row per helper, saved where the helper was started and revised in place for every later change and run. It records the helper's id, name, state, the run its state describes, who started it, and, for a stop, whether the stop came from the agent accepting Orca's Stop (stop-acknowledged) rather than the helper reporting its own end. Beside it sits a plain sentence ("Kicked off subagent Audit" / "Ran subagent Audit (failed)") that older apps show instead.
  • One grouped row on screen, derived: desktop and the phone fold a turn's helper rows into the same "Ran N subagents" row they draw today, at the first helper's place. Same-named helpers get "Audit 2"-style numbers here, at read time, instead of the numbers being saved.
  • Every other reader follows: the client's list of named helpers, the names a history page carries for helpers whose row is on an older page, the reopen pass that marks a helper a crashed app left "working" as "unverifiable", the phone payload limits, and the worker transcript text.
  • History pages: a helper's row doesn't count toward a page's 200-row window (a turn that starts 30 helpers would otherwise fill the opening page with rows that fold into one line); the page's byte budget still bounds it.
  • Nested helpers: helpers started by a helper fold into their own group, with their own group id, so opening one group on the phone doesn't open the other.
  • Persistence helpers for the follow-up: the row's key (one per helper id), its body, and reading a helper's saved row back by key.

User-facing: none yet. Old grouped rows still render exactly as before and stay readable.

Why

Three architects reviewed the closed #27585 and agreed the grouped row was the wrong saved model: every cap and most of #27585's bookkeeping existed only because siblings shared one row. One row per helper removes those caps, makes one helper's update write one helper-sized row instead of copying all its siblings, and gives the strip, sidebar, Stop and chat one record to agree on. The grouping the user sees stays, but is computed when drawing.

Splitting readers first means the follow-up switches the writers and deletes the old path in one step, with no release where a writer produces rows a reader can't draw. This PR is marked ready only when the follow-up (#27947) is reviewable, and should merge only together with it.

Differences from the common pattern, labelled:

  • Intended: Orca reuses its existing journal item/revision mechanism instead of a separate subagent table; one row per helper across all its runs; grouping and ordinals derived in the shared presentation; old grouped rows stay readable (read-only, never written again).
  • Intended: an older desktop or phone shows one plain line per helper ("Kicked off subagent Audit") instead of the grouped row, its helper sections are unnamed, and each line splits the surrounding tool run. That is the fallback older apps already use for block types they don't know.
  • Intended: ordinals are computed over what is loaded, so loading an older history page can renumber "Audit" to "Audit 2" (no duplicate rows; the group rejoins once both pages are loaded).
  • Temporary: none.

Linked Issue

Replaces #27585 (closed).

Visual Proof

N/A for this PR alone: no producer writes the new row yet, so nothing on screen changes. #27947 carries the before/after.

Testing

  • New focused tests: src/shared/native-chat-subagent-items.test.ts (grouping at the first helper's place, per turn and spawner, ordinals, stable rows while nothing changed, old rows untouched, tool runs not split, fallback text), journal-subagent-item.test.ts (one key per helper, schema, bounds, keyed read-back, revision keeps the spawn position, reopen marks a dead host's helper unverifiable).

  • Added cases to the client roster, off-page history roster, phone payload bounds, desktop sections (helper sections open under the derived row), and phone fold tests.

  • pnpm tc:node, tc:web, tc:cli pass; lint and code-quality gates pass via orca-ci-checks (its bun typecheck step fails locally on a tooling error, CI covers it). Phone tests need the phone app's own dependencies and run in CI.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Reviewed together with #27947 in four rounds, a readiness pass and live QA with real Claude, Codex and Grok; the review summary is on #27947. Fixes to this PR from the review: the saved background flag accepts any boolean (a fixed true would have made a later build's false unreadable), nested groups get their own id, and history pages stop counting helper rows.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Mixed versions: an older desktop or phone talking to a newer host shows the plain sentence per helper; a newer client reading an older host's grouped rows draws them as today. No wire opcode changes; the new block is a new type inside an existing message, which older readers already skip.
  • SSH / folder workspaces / Windows: all reads are on the shared projection or the execution host's journal; nothing is platform- or workspace-kind specific.
  • Performance: the fold is one pass over the conversation and hands back the same row object while no helper changed, so memoized rows don't redraw.

Checklist

  • This PR is small and focused
  • 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)

Adds the singular `subagent` journal block (one row per child, revised in
place, with a plain-text twin for older clients) and teaches every reader
to draw it: desktop and phone fold a turn's sibling rows into the existing
"Ran N subagents" row, the client and off-page rosters name children from
their own rows, the reopen pass settles a row a dead host left working,
and the phone and worker-transcript wires bound it. No producer writes the
block yet; that switch lands in the follow-up.
…page window skips subagent rows

- background is an open boolean so a later build's value never fails a chat load
- a helper's own helpers fold under a groupId of their own, so the phone opens them apart
- each subagent's own row rides along with the page window instead of counting as conversation
@brennanb2025
brennanb2025 marked this pull request as ready for review October 12, 2026 15:06
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Walkthrough

The change adds a standalone subagent block and shared helpers to fold eligible subagent rows into roster rows. Journal persistence and recovery, history-window selection, roster extraction, transcript rendering, and runtime bounding now handle standalone subagent blocks. Tests cover folding, persistence, recovery, history pages, rendering, and sanitization.


Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 3fde6

Nothing changes for users in this PR because the writer lands separately. Two small follow-ups are worth doing before the writer ships: align the background type with the saved-row schema, and make repeated-label numbering linear for large groups.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 39.47% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 38 functions across 21 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the native chat change and the first part of the two-part implementation. It is concise and related to the main changeset.
Description check Passed The description follows the repository template and clearly explains the change, motivation, scope, testing, compatibility, performance, and follow-up PR. It also documents that manual testing was not…
Linked Issues check Passed Issue #27585 is closed and completed. It provides historical context only, so its tracker, Stop, and row-limit criteria are not active coding requirements for this pull request. The pull request objec…
Out of Scope Changes check Passed The changes stay within the stated reader migration. They add the subagent block type and journal helpers, derive grouped desktop and phone rows, update transcript and roster readers, handle liveness …

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8e16c100-48db-4d1e-976e-489336b8c5ab
📥 Commits

Reviewing files that changed from the base of the PR and between c43ac3f and 3fde674.

📒 Files selected for processing (21)
  • mobile/src/session/mobile-native-chat-render-data.test.ts
  • mobile/src/session/mobile-native-chat-render-data.ts
  • src/main/native-chat/agent-session-journal/journal-subagent-item.test.ts
  • src/main/native-chat/agent-session-journal/journal-subagent-item.ts
  • src/main/native-chat/agent-session-journal/journal-subagent-liveness.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/runtime/orchestration/worker-transcript-activity-block-bounds.ts
  • src/main/runtime/orchestration/worker-transcript-payload.ts
  • src/main/runtime/rpc/methods/native-chat-rpc-block-sanitize.test.ts
  • src/main/runtime/rpc/methods/native-chat-rpc-block-sanitize.ts
  • src/renderer/src/components/native-chat/native-chat-subagent-sections.test.ts
  • src/shared/agent-session-journal-schemas.ts
  • src/shared/native-chat-subagent-items.test.ts
  • src/shared/native-chat-subagent-items.ts
  • src/shared/native-chat-transcript-projection.ts
  • src/shared/native-chat-types.ts
  • src/shared/structured-agent-session-subagent-roster.test.ts
  • src/shared/structured-agent-session-subagent-roster.ts
  • src/shared/worker-transcript-text.ts

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

Comment on lines +157 to +160
if (repeated.has(label) && claimed.has(label)) {
for (let ordinal = 2; taken.has(label) || claimed.has(label); ordinal++) {
label = `${block.label} ${ordinal}`
}

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.

🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

Advance the ordinal search for repeated labels.

If a group contains many siblings named Audit, each sibling searches again from Audit 2. Ten thousand such siblings cause roughly fifty million candidate checks during transcript folding. Keep the next available ordinal per original label, while continuing to skip names in taken.

* reported its own end; that run's own ending may still replace it. */
outcomeBasis?: 'stop-acknowledged'
/** Told to outlive the turn that spawned it. */
background?: true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Allow both saved background values in the type.

The journal schema accepts background: false, but NativeChatSubagentBlock permits only true. A writer cannot assign that valid saved value without a type error. Change this field to background?: boolean so the shared type matches the saved-row contract.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review summary (part 1 of 2; part 2 is #27947, stacked on this PR)

What this PR is: Orca can now read and draw one saved record per subagent. The "Ran N subagents" grouping and numbering are worked out when the chat is drawn, and older grouped rows still read. Nothing the agents send changes yet, so nothing looks different until #27947 switches Claude, Codex and Grok over.

Review: this PR was reviewed together with #27947, including a reviewer dedicated to the code that reads and draws subagent records.

  • Round 1 found 7 issues here:
    • P1: a saved-format definition that failed a CI check;
    • P2: nested subagent groups sharing one id;
    • P2: subagent rows using up the first history page;
    • four P3s.
  • Round 2 confirmed the P1 and P2 fixes (f97aec0). A round-3 reviewer recommended one small cleanup (3fde674).

Checked on its own against current main (c345741): this PR merges first and stays on main alone until #27947 lands, so it was checked that way. Merged cleanly, then:

  • typecheck of every project, including mobile: passes;
  • mobile test-typecheck check: passes;
  • lint of the changed files: passes;
  • 377 test files / 3,987 tests in the areas this touches: pass;
  • 247 mobile session test files / 2,337 tests: pass.

Open items:

Merge order: this PR first, then point #27947 at main and merge it.

@brennanb2025
brennanb2025 merged commit fe1f022 into main Oct 12, 2026
80 of 82 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/subagent-items branch October 13, 2026 05:55
registered2nd pushed a commit to registered2nd/orca that referenced this pull request Oct 14, 2026
…27914)

* feat(chat): read one saved row per subagent

Adds the singular `subagent` journal block (one row per child, revised in
place, with a plain-text twin for older clients) and teaches every reader
to draw it: desktop and phone fold a turn's sibling rows into the existing
"Ran N subagents" row, the client and off-page rosters name children from
their own rows, the reopen pass settles a row a dead host left working,
and the phone and worker-transcript wires bound it. No producer writes the
block yet; that switch lands in the follow-up.

* fix(chat): open subagent background flag, separate nested group ids, page window skips subagent rows

- background is an open boolean so a later build's value never fails a chat load
- a helper's own helpers fold under a groupId of their own, so the phone opens them apart
- each subagent's own row rides along with the page window instead of counting as conversation

* refactor(chat): a subagent's group entry as one object

(cherry picked from commit fe1f022)
brennanb2025 added a commit that referenced this pull request Oct 15, 2026
* feat(chat): read one saved row per subagent

Adds the singular `subagent` journal block (one row per child, revised in
place, with a plain-text twin for older clients) and teaches every reader
to draw it: desktop and phone fold a turn's sibling rows into the existing
"Ran N subagents" row, the client and off-page rosters name children from
their own rows, the reopen pass settles a row a dead host left working,
and the phone and worker-transcript wires bound it. No producer writes the
block yet; that switch lands in the follow-up.

* fix(chat): open subagent background flag, separate nested group ids, page window skips subagent rows

- background is an open boolean so a later build's value never fails a chat load
- a helper's own helpers fold under a groupId of their own, so the phone opens them apart
- each subagent's own row rides along with the page window instead of counting as conversation

* refactor(chat): a subagent's group entry as one object

(cherry picked from commit fe1f022)
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