Repository navigation
🪟 feat: Show a Running Subagent's Current Row on Its Card - #18279
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7989dafa4
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| isSubmitting: true, | ||
| isLast: true, | ||
| isLatestMessage: false, |
There was a problem hiding this comment.
Preserve the live state when rendering the preview row
When the child's newest part is an unfinished tool call, isLatestMessage: false overrides isSubmitting: true: the app's ContentParts.tsx computes effectiveIsSubmitting as false for non-latest messages and passes that value to the tool renderer. Until the tool receives a terminal runStepStatus, resolveToolCallPhase consequently classifies it as cancelled because its progress is below 1. This makes a running child's preview display a cancelled tool instead of its live row. Preserve the live-message signal here and suppress unwanted cursor behavior separately.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid. Fixed in d0e4c8a: the row is handed to the renderer as the latest, live message, so a tool call still running is drawn running instead of stopped. With that the renderer draws the row exactly as the thread draws a live reply, which for a tool batch is its live fold header. Pinned in SubagentCall.spec.tsx (the row is rendered live), which fails against the previous code. Checked in Chromium with a child held mid-run; expandHistory in the browser spec now leaves a card's row alone, since its folds take no pointer.
| for (let index = parts.length - 1; index >= 0; index--) { | ||
| const part = parts[index]; | ||
| if (part != null) return part; |
There was a problem hiding this comment.
Skip invisible placeholders when selecting the preview part
When a background child finishes a tool batch, createActivityLabelWiring in packages/api/src/agents/activityLabels/wiring.ts appends and emits an empty, pending ACTIVITY_LABEL reservation. This selector immediately chooses that reservation instead of the preceding visible tool row, but the app's Part.tsx activity-label renderer returns null for an empty label. The card therefore replaces its activity with a blank preview until the label fills or another content part arrives. Select the newest visible part, skipping empty label reservations as the existing lastVisibleContentIdx helper does.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid. Fixed in d0e4c8a: both sources of the row (a foreground child's progress and a background child's thread) now pick the last part that draws something with lastVisibleContentIdx, the helper the content renderers use, so an empty label reservation at the end of a tool batch no longer blanks the card. Pinned by keeps the last row that draws something when an empty label reservation follows it, which fails against the previous code.
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
🟡 Changes recommended
The review found an issue that should be addressed before approval.
2 open issues
What changed in this PR
Replaces the subagent card’s ticker with a one-row preview rendered by the child conversation’s content renderer, including live background activity without opening the panel.
Changes:
- Adds shared, capped thread followers so cards and panels reuse one stream.
- Adds newest-part previews and index discovery for newly dispatched children.
- Updates unit/E2E coverage and removes unused English ticker strings.
Validation: Ran a self-contained overflow-preview check. Project tests and typechecks were not run.
| File | Description |
|---|---|
packages/chat/src/react/subagents/parents.tsx |
Adds child discovery and shared follower ownership. |
packages/chat/src/react/subagents/follows.tsx |
Implements follower registration, preview limits, and delayed release. |
packages/chat/src/react/subagents/__tests__/follows.spec.tsx |
Tests sharing, lifecycle, and preview limits. |
packages/chat/src/components/subagents/panel.tsx |
Reuses shared followers when available. |
packages/chat/src/components/parts/SubagentCall.tsx |
Renders foreground and detached child previews. |
packages/chat/src/components/parts/__tests__/SubagentCall.spec.tsx |
Tests preview rendering, throttling, and detached discovery. |
packages/chat/src/components/parts/__tests__/SubagentCall.share.spec.tsx |
Removes the obsolete ticker prop. |
e2e/specs/mock/subagent-activity.spec.ts |
Checks background previews and stream reuse. |
client/src/locales/en/translation.json |
Removes unused ticker strings. |
client/src/components/Chat/Messages/Content/Parts/SubagentCall.tsx |
Removes ticker-specific MCP-name wiring. |
Review effort: Balanced
| if (part == null || !live) { | ||
| return null; |
There was a problem hiding this comment.
Valid. Fixed in b358ec0. The registry now says whether a thread is among those being followed (ThreadFollows.isFollowed, returned by useThreadInterest through a subscription to the followed set only), and a card shows a background child's row only while that is true. A child that has lost its place, such as a fourth preview after its panel is closed, shows its status without a row instead of the last thing read for it. Pinned at the registry (tells a preview whether its thread is being followed, including once it loses its room) and at the card (shows no row for a child the page has no room to follow, whatever was last read for it); the card case fails with the check removed.
| if (part == null || !live) { | ||
| return null; | ||
| } | ||
| return <SubagentPreview key={index} part={part} messageId={`${threadId}:${taskId}:preview`} />; |
There was a problem hiding this comment.
Valid. Fixed in b358ec0: the part and its index are throttled together by one hook, useThrottledRow, which both the foreground and the detached path now use, with the same pass-through for short text. Pinned by refreshes a long live row on the throttle, as a foreground child does under the detached child, which fails with the detached row left unthrottled.
…tle a Detached Row Too
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a729ba4e5
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| {host.renderContentParts({ | ||
| content, | ||
| messageId, | ||
| conversationId: null, |
There was a problem hiding this comment.
Isolate artifact registration from the preview renderer
When a child's current text contains an artifact, rendering it through the full content renderer also runs Artifact in client/src/components/Artifacts/Artifact.tsx, whose effect registers it in the app-global artifactsState on /c/* routes. Neither inert nor conversationId: null suppresses that effect. Because the preview supplies a synthetic message ID, opening the child's transcript registers the same artifact again under its real message ID, leaving duplicate entries in the artifact selector; the preview entry also remains after the card drops its row. Give the preview a rendering mode that suppresses artifact registration rather than treating this read-only picture as another message.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid. Fixed in cd57759, as a class and not only for artifacts: a real row has effects beyond painting, and the card's row is a picture of a row that is drawn elsewhere and has them already.
- The row is rendered under
PartsPreviewContext(useIsPartsPreview(), new in the package). The app'sArtifactreads it and keeps the artifact local instead of registering it withartifactsState, the way it already does off an artifact route. - Its parts host answers every tool-artifact claim as held by someone else and ignores attempts to take one, so the picture can neither draw nor take a file card from the row it pictures.
- It gets a neutral
FailedRevealContext, so a request to reveal a failure on the group around the card does not reach a row inside it.
Pinned by client/src/components/Artifacts/__tests__/Artifact.preview.test.tsx (an artifact registers from a message row and not under the preview context; fails with the guard removed) and in SubagentCall.spec.tsx (the row is told it is a preview, takes no claim, and sees no reveal request; fails against the previous code). The nine subagent browser tests pass locally.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cd577591c3
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| export class ThreadFollows { | ||
| private readonly interests = new Map<string, Set<ThreadInterest>>(); | ||
| /** What each thread's readers last asked for, which holds while none of them is present. */ | ||
| private readonly asked = new Map<string, { live: boolean; opened: boolean }>(); | ||
| private readonly results = new Map<string, FollowedChat>(); |
There was a problem hiding this comment.
Store the shared follower registry in feature-owned Jotai state
The new registry holds shared, mutable frontend state—reader interests, admission decisions, and follower results—but implements its own store and subscription system instead of using Jotai. This violates the explicit client-state ownership requirement in AGENTS.md that new state use Jotai and that state a feature reads and writes remain feature-owned. Represent the registry with provider-scoped Jotai atoms, retaining the stream lifecycle and delayed-release behavior, rather than introducing another frontend state mechanism.
AGENTS.md reference: AGENTS.md:L178-L183
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid: new client state is Jotai, and the registry kept its own store and subscriptions. Fixed in a6f41f3. The readers per thread, the set of followed threads (a derived atom, stable while unchanged) and each thread's last result are atoms created by the provider, so they are scoped to one page and one parent conversation, and the admission check a card makes is a selectAtom over the followed set. The follower lifecycle is unchanged: one follower per thread, the preview cap, and the 250 ms linger after the last reader leaves.
The provider also owns the store those atoms are read in. A reader can sit under a different Jotai provider than the followers do (the card's spec does), and with the ambient store each would have seen its own copy of the registry.
No behavior changed, so the existing specs are the check: follows.spec.tsx (6), the card's detached cases and the panel's follow cases all pass unchanged, as do the nine subagent browser tests.
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6f41f3430
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| * last read for it, which is not what it is doing now, so its row is shown only while it is | ||
| * being followed. | ||
| */ | ||
| const followed = useThreadInterest(threadId, { live: true, enabled: live, passive: true }); |
There was a problem hiding this comment.
Retry preview attachment when the child stream becomes available
If the card discovers a running child before its generation job opens, this interest can leave the preview disconnected for the entire run. In packages/api/src/agents/subagentThreads.ts, thread preparation and wakeup registration precede the awaited openGeneration, so the parent index can expose the running task before its stream exists. createGenerationTransport then returns null for the initial attachment, and useFollowChat marks it unattached without retrying. Since this interest stays live: true across subsequent index refreshes, nothing triggers another attachment once the job becomes available. Retry an unattached preview while the task remains running, rather than retaining that initial unsuccessful follower indefinitely.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid. Fixed in dfe2810, in the hook so the panel gets it too: when the caller says a run is going (live) and the attachment finds none, useFollowChat looks again, twice, a second and then two seconds later (ABSENT_RETRIES, on the reconnect delays), before it reports isUnattached. A run is announced as running before its generation is opened, so the first look can simply be early. The count is short on purpose: a panel on a server that gives children no generation job is waiting on that answer to fall back to the durable view, and now waits about three seconds for it.
Pinned by follows a run whose stream opens a moment after the caller learns of it and says a run the caller knows of has no stream only after looking for it again in follow.spec.tsx; both fail without the retry.
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |

Summary
The card main chat draws for a subagent showed what the child was doing as three lines of monospace ticker text ("Reasoning: …", "Using tool(args)", "tool → output"), a rendering of its own that looks like nothing else in the product. For a background child it showed nothing at all once the parent's turn had ended: the card read "Agent activity" with no status and no preview, even while the child was running, unless the reader opened the panel.
This redesigns the card's body as a one-row window onto the child's own conversation. The row is the child's newest content part, drawn by the renderer the thread itself uses, so it is the same tool row, reasoning row or line of text a reader sees after opening the child, shown one row at a time. A running background child's card now shows that row, its name and its status with no panel open.
Related to #18197.
How it works
The row.
SubagentPreviewhands one part, the newest that draws something, torenderContentParts, the app's renderer, as a live reply, inside a fixed one-row window that is pinned to its last line and fades at the top, so streamed text shows what was written most recently and a tool batch shows the live fold header the thread shows. Long live text refreshes on the 400 ms throttle the ticker used, whichever source the row comes from.A picture, not a row. It sits over the card rather than inside its button (tool rows hold buttons of their own), takes no pointer or focus (
inert), and is hidden from assistive technology, which reads the card's label. A real row also has effects beyond painting, and the row it pictures has them already, so the picture is rendered underPartsPreviewContext(useIsPartsPreview()): the app'sArtifactregisters nothing with the artifact panel there, its parts host answers every tool-artifact claim as taken, and a request to reveal a failure on the group around the card does not reach it.One follower per child thread. A background child's content reaches the page only through its own generation stream. The panel followed it with
useFollowChat(#18192); a card doing the same would open a second stream for the same thread.ThreadFollowsis a small registry underParentSubagentsProvider, kept in Jotai atoms the provider creates and reads in its own store: readers register interest in a thread, the page mounts one follower for it, and the card and the panel read the same stream. A follower is let go when its last reader leaves, after 250 ms, because a card is replaced rather than removed when its reply settles under the stored message id.Preview-only followers are capped at three (
MAX_PREVIEWED_THREADS). A followed thread holds a connection open, and over HTTP/1.1 a browser allows six per origin, which main chat's own stream and every request share. A thread the reader opened is always followed; a fourth previewed child shows its status without a row until one of the others finishes. A card shows a row only while its thread is among those followed, since the thread's messages outlive the following and would otherwise show as current.A run announced before its stream. A child is listed as running before its generation is opened, so the first look for its stream can be early.
useFollowChatlooks again twice, a second and then two seconds later, before it reports that a run the caller knows of has nothing to attach to. The count is short because a panel on a server that gives children no generation job is waiting on that answer to fall back to the durable view.The index learns about new children. The card takes a background child's status from the parent's subagent index, which was read once, early, and never again unless a child in it was already running, so a child dispatched after that read stayed unknown. A card whose child the index does not list now asks it to read again (
discover), once per child and once per commit. That is also what replaces "Agent activity" with the child's name and "Running".Type of change
Testing
Tested environments/configuration:
Chromium via Playwright,
e2e/playwright.config.mock.ts, server and client built from this branch, in-memory Mongo, fake model, Linux (WSL2).Automated tests:
e2e/specs/mock/subagent-activity.spec.ts(6 cases) andscenarios/subagent-card-states.spec.ts(3 cases) pass on this head. The detached-activity case now asserts that, with no panel open, each of two running children's cards shows a row from its own thread and the status "Running"; that opening a child adds no stream to the one its card was reading; and that a finished child's card drops its row.packages/chat/src/react/subagents/__tests__/follows.spec.tsx(new, 5): one follower for several readers of a thread, released after the last leaves; kept through a reader being replaced; the opening state until the follower reports; the preview cap, an opened thread always followed, and a freed slot going to the next preview; nothing followed where no page shares followers.SubagentCall.spec.tsx: the three ticker tests are replaced by the row (newest part only, outside the button,inertandaria-hidden), the waiting line, the throttle, and a detached child (followed once while it runs and showing its thread's row; not followed once finished; the index asked once for a child it does not list).packages/chat:npx jest(3925 tests),npx tsc --noEmit.npm run static-checks -- --against origin/dev.Not measured: the render cost in main chat. The row is its own leaf and reads the thread's tail through a cache selector, so a streamed token re-renders that row and not the card or the message around it, but I have not run a dev-versus-branch render benchmark.
Screenshots / recordings
Two background children running, no panel open (dark):
Risk / compatibility
SubagentProgress.tickerStateandfoldSubagentEventIntoTickerno longer have a reader; removing them touches the progress type and a dozen specs, so it is left for a follow-up. The fivecom_ui_subagent_ticker_*English strings are removed here.subagentActivity.generationJobs: false, the panel now takes about three seconds longer to fall back to the durable view for a running child, the time spent looking again for its stream.MAX_PREVIEWED_THREADSis a constant, not alibrechat.yamlfield: it guards a browser connection limit, and the client reads nosubagentActivityconfig today.