Skip to content

fix(web): batch subagent rows per user message instead of per turn - #11

Merged
orbitingflea merged 1 commit into
mainfrom
fix/spawn-row-per-segment
Sep 2, 2026
Merged

orbitingflea merged 1 commit into
mainfrom
fix/spawn-row-per-segment

Conversation

@orbitingflea

Copy link
Copy Markdown
Owner

What changed

When the agent starts helper agents, the timeline shows one row for them: "Kicked off N subagents" while they run, "Ran N subagents" once they finish. That row used to gather every direct spawn of a turn, placed where the turn's first spawn landed.

#10 folds the timeline per segment, where a segment is everything between two of your messages, so a steer splits its turn. The subagent row did not follow: it stayed one row per turn, so after a steer the row above the steer counted agents that were launched after it, and the segment below the steer had no row at all.

The row now gathers the direct spawns of a segment. Each direct spawn keeps its own work-log row, and the timeline merges the spawn rows a segment holds into the segment's first one, which keeps its id, time and turn. A steer opens a new segment, so the agents kicked off before it and the agents it caused each get their own row.

In practice:

  • A turn without a steer looks as before: one row where the first spawn landed.
  • A steered turn shows one row per segment that spawned agents, each counting only that segment's agents.
  • Workflow spawns are unchanged: one row per workflow run, as before.
  • The fold logic no longer merges spawn rows itself, since they arrive already batched; that code is removed.
  • Codex reports its subagents only through progress rows, so a Codex subagent is placed where its first progress row landed. A subagent launched before a steer that first reports after it lands in the segment below the steer. The old rule had the opposite fault, since a steer keeps the turn id: agents launched after the steer merged into the row above it.

Mobile has no subagent row, so it is unchanged.

Screenshots

The before column is main at commit 292931c; the after column is main plus this branch. Both run in Docker from a production build, driven by the same script. The script's first message asks the agent to launch one subagent that runs a 5 s command, then run a 30 s command itself. While the 30 s command is still running, the script sends a second message: "launch one more subagent, then reply pong".

Before (main) After (this PR)
Claude Sonnet 5, collapsed A, "Ran 2 subagents", "Worked for 12s", B, "Worked for 28s", separator, pong. The row above the steer counts the agent launched after it, and the segment below has no row. A, "Ran 1 subagent", "Worked for 14s", B, "Worked for 30s", "Ran 1 subagent", separator, pong

Codex is not covered: the Codex CLI in the test image does not expose subagent spawning, so the scenario cannot be driven there. The change is provider-neutral; it runs on the web timeline after the adapters have produced their work-log rows.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes (not applicable)

Written by Claude Fable 5.1 running in Claude Code, driven from T3 Code.

Direct subagent spawns were batched into one "Kicked off N subagents" row
per turn, so steering a turn mid-run left the row stranded in the segment
of the first spawn, counting agents that were launched after the steer.
Each direct spawn now gets its own work-log row, and the timeline merges
the spawns a segment holds into that segment's first row, so each side of
a steer shows its own row with its own agents.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 2, 2026 16:29
Comment thread apps/web/src/session-logic.ts Resolved
Comment thread apps/web/src/session-logic.ts Resolved
Comment thread apps/web/src/session-logic.ts Resolved
Comment thread apps/web/src/session-logic.ts Resolved
Comment thread apps/web/src/session-logic.ts Resolved
});
});

it("batches a turn's direct spawns per segment, so a steer splits the CTA row", () => {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

新增测试:同一 turn 里 steer 前后各生成两个子代理,期望得到两行,分别是 [task-a, task-b] 和 [task-c, task-d],第一行保留 spawn-1 的 id、时间和 turn。

it("folds timelineBypass agent rows into one CTA (Codex children, workflow members)", () => {
// Codex children carry their parent's spawn turn (spawnTurnId stamping),
// which is what batches a fleet into one CTA.
it("keeps timelineBypass agent rows as CTA rows (Codex children, workflow members)", () => {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Codex 子代理和工作流成员的测试:work log 层现在每个直接生成的子代理各一行,所以期望值从一行改成每个子代理一行;工作流成员仍合并成一行。

it("turn-less direct spawns do not collapse into one global batch", () => {
// Rows that lost their turn id (defensive path) group per task, so two
// unrelated turn-less spawns never merge into one immortal CTA.
it("direct spawns do not collapse into one global batch", () => {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

原来的“无 turn id 兜底”测试改写成新规则:每个直接生成的子代理在 work log 层各自一行。

};

it("merges direct-spawn CTA rows across a synthetic continuation into the segment's first one", () => {
it("keeps every spawn CTA row visible when the fold collapses", () => {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

原来这个测试断言折叠层会合并两条子代理行;现在折叠层不再合并,改为断言两条行都保持可见、不进折叠。

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-02T16:35:20.917991Z 8df70c5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M labels Sep 2, 2026
@orbitingflea
orbitingflea merged commit fa64403 into main Sep 2, 2026
6 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants