Repository navigation
🎦 feat: Open Background Subagent Conversations in the Panel - #18197
Conversation
71eef07 to
097a068
Compare
|
@codex review |
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: 097a068bf4
ℹ️ 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".
| const unfollowable = | ||
| followed != null && | ||
| (followed.isLoadError || (followLive && !followed.isLoading && !followed.isFollowing)); |
There was a problem hiding this comment.
Wait for attachment resolution before latching the durable fallback
If the messages finish loading before the task transitions from dispatched to running, this condition treats the first render with followLive: true as proof that no generation exists. However, useFollowChat only starts attaching in its effect, so isFollowing is still false during that render. The panel's effect consequently latches followMode to durable, and the subsequent successful attachment cannot change it. The reader remains on the old transcript while both the generation stream and activity stream run. Distinguish an attachment that has not started yet from a confirmed absence before permanently selecting the fallback.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid. Fixed in e6c5e80688. The panel no longer infers "nothing to follow" from !isFollowing. useFollowChat reports isUnattached, which is false until an attachment has actually been tried and true only when it found no generation or lost its stream for good; the durable fallback is chosen on that. Pinned by does not take an attachment that has not started yet for one that found nothing (panel) and says a run the caller knows of has no stream only once an attachment found none (hook); the panel case fails with the old condition restored.
| {follows && followed != null ? ( | ||
| <FollowedChildThread | ||
| threadId={threadId} | ||
| followed={followed} | ||
| agentId={taskView?.agentId ?? foregroundAgentId} |
There was a problem hiding this comment.
Preserve durable history when stored message content is omitted
For completed children created with generationJobs: false, generationContentBytes: 0, or content exceeding the configured retention budget, SubagentThreadTaskStore.generationContent() and persistResult() deliberately omit the message's content while retaining its transcript/activity projection. The messages route returns those ordinary message rows without reconstructing the projection, so the read succeeds and this branch replaces the durable transcript with only the final text, losing the previously available tool history and intermediate output. A streamed oversized run also loses its displayed history when useFollowChat rereads the stored rows at completion. Preserve the durable view for these records or reconstruct their retained history before rendering them as conversations.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid. Fixed in e6c5e80. When the stored rows are what is on screen (first read, or the read at a run's end) and a reply came without its content parts, the panel keeps the durable view, whose projection is the only place that history lives. That covers children run without a generation job, with generationContentBytes: 0, over the row budget, and rows written before content was stored; a streamed oversized run hands over to the durable view when its stored row is read. A reply still being streamed is not judged by the parts it has so far. Pinned by keeps the durable view for a finished thread whose stored reply lacks its parts, draws a finished thread whose stored reply holds its parts as a conversation and does not judge a reply still being streamed by the parts it has so far; removing the check, or applying it mid-stream, fails one of them.
| const contentStream = panelStore.useActivityStream( | ||
| selection, | ||
| !durableTerminal || eventTaskRunning, | ||
| !follows && (!durableTerminal || eventTaskRunning), |
There was a problem hiding this comment.
Recover the live transcript after a generation stream disconnects
After a network interruption on an already-followed child, createSSETransport reports the disconnect without retrying it (its automatic retry only handles token refresh), and Chat.resumeStream() records the failure and resolves. useFollowChat then rereads stored messages but never reattaches while live remains true. Because the panel has latched the followed mode, this condition also keeps the previously retrying activity stream disabled. The panel therefore stops receiving output for the remainder of the run and can lose the in-progress reply when the stored rows replace it, with no retry control exposed. Reconnect the generation stream or restore the activity fallback when the followed connection drops.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid. Fixed in two places. In #18192 (2d5c947) the hook reattaches a dropped stream on main chat's reconnect schedule and keeps what it showed instead of reading stored rows over it. Here (e6c5e80), if that schedule runs out the hook reports isUnattached and the panel hands the run back to the durable view, which reopens its own retrying activity stream; the durable choice now wins over an earlier followed one. Pinned by hands a run back to the durable view when its followed stream is lost for good (panel, asserts the activity stream is enabled again) and says the stream is gone once a dropped one could not be attached again (hook).
000d128 to
e6c5e80
Compare
|
@codex review Head e6c5e80688. |
|
Codex Review: Didn't find any major issues. Breezy! 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". |
e6c5e80 to
ba56efc
Compare
ba56efc to
5d8b118
Compare
5d8b118 to
70e2f2e
Compare
1c71c9b to
984931a
Compare
984931a to
efa6b9e
Compare
d440c2f to
bd39f29
Compare
bd39f29 to
71ba063
Compare
71ba063 to
5457d5d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5457d5d465
ℹ️ 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".
| {follows && followed != null ? ( | ||
| <FollowedChildThread | ||
| threadId={threadId} | ||
| followed={followed} |
There was a problem hiding this comment.
Keep pending control receipts visible in followed threads
When a user queues guidance or submits a steer that remains accepted but unapplied, this branch replaces the durable transcript containing SubagentControlHistory, which renders the pending receipt and its Withdraw button (subagents/transcript.tsx:199–213). The followed conversation supplies neither replacement: FollowedThread disables pending-steer rendering, and the panel footer only displays failed receipts. Consequently, guidance disappears after submission until it is applied, and users can no longer withdraw it while the child is busy. Preserve the control-receipt history and cancellation action alongside the followed messages.
AGENTS.md reference: AGENTS.md:L50-L53
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid for this PR on its own. The fix was the next PR in the stack, #18217; it is now folded into this one (b2fcc9a is this PR's head), so the conversation body never ships without it. Guidance the child has not taken yet is drawn after the last row through the list's renderPendingSteers slot, using the same SubagentControlHistory the durable view renders, with Withdraw wired to the panel's cancel_message command; refused or failed guidance shows there with its reason, and guidance the reply already shows is not drawn twice. Pinned by six cases in followed.spec.tsx, one in panel.spec.tsx, and the browser case "guidance the child has not taken yet waits after the last row and can be withdrawn", which fails with the change removed and the client rebuilt.
|
Codex Review: Didn't find any major issues. Swish! 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
Opening a background subagent in the panel shows a transcript the panel assembles itself: a durable thread view projected into turns, with live content from an activity feed that keeps the last 100 events for five minutes. Whether the reader sees the child's latest output depends on when they opened the panel relative to that window, which is the "sometimes it has the latest events, sometimes it does not" behavior. Switching chats does not have this problem, because a chat attaches to its generation job and replays it.
Since #18169 a background child has a generation job of its own, keyed by its thread id, and #18187 added parent-scoped routes that read a child thread's messages and tool calls. Nothing in the client used either. This PR is that entry point: the panel opens a background child's thread as a conversation. It reads the thread's messages through the parent, attaches to the child's generation job the way a chat reattaches to its own, and draws the result with main chat's message list. A reader who opens the panel late sees what one who watched from the start sees.
Last in a stack, on #18196. This is the frontend entry point the review of #18187 asked for. It includes the change that was #18217 (guidance still waiting on the child, with its Withdraw), folded in so the conversation body never ships without it.
Verified in Chromium against a server started from this branch (the mock e2e lane: in-memory Mongo, fake model), including the case this work is for: a child that has produced more history than the activity feed keeps, opened late while it is still running.
How it works
The panel's shell is unchanged: header, actor picker, the composer that steers the child, continue-as-chat. Only the body changes, and only for a background child. Foreground children (no thread of their own) and event threads (a per-task timeline) keep the durable view.
States the body can be in:
LoadingstatussubagentActivity.generationJobs: false)The first two fallbacks keep the panel working against an older API replica and with the feature's off switch. The third is what happens after
useFollowChat(#18192) has run out its reconnect schedule. The fourth covers children whose result row holds only text: run without a generation job, withgenerationContentBytes: 0, over the row's budget, or written before rows stored content. It is judged only on stored rows (the first read, or the read at a run's end), never on a reply still being streamed.The durable view is kept once chosen for a thread, so the transcript does not swap back when the run it was drawing ends. A thread that has not fallen back stays the conversation when its run ends before the task view catches up.
While the thread is followed the activity feed's stream stays closed: one stream per thread.
Two additions to
useFollowChatsupport this:enabled, so the panel can call the hook for every selection,isFollowing, which is true from the start of an attachment until its run has ended and been read, andisUnattached, which is false until an attachment has been tried and true only when it found no generation or lost its stream for good. The panel falls back onisUnattached, so an attachment that has not started yet is not taken for one that found nothing. It also reads the stored messages again when the caller'sliveturns false, which covers a run that ended without a stream.FollowedThreadnow supplies its own messages host over the page's: a row'suseGetMessagesreads the followed list, there is no queued turn of the reader's, and reading the thread marks no conversation of theirs seen.Guidance the child has not taken yet
The durable view shows guidance that was sent to the child but not taken yet, dimmed, after the transcript, with the control that withdraws it. The conversation body keeps that. Main chat's message list has a slot for exactly this position,
renderPendingSteers: what is waiting on the conversation's run, after the last row.FollowedThreadleaves it empty by default; the panel fills it.SubagentControlHistoryis the list the durable view already renders; it is exported and reused, not copied, so the two bodies decide what counts as "already shown" with one rule: a receipt whose steer part is in the content is left out. The durable view's receipt can still sayacceptedfor a moment after the stream has delivered the applied steer, and the reply's part wins. The list sits in main chat's row column (getMessageRowWidthClass), so it lines up with the turns above it.Main chat's own
PendingSteerscomponent is not used: it reads main chat's steer chips and cancels through main chat's steer routes, and a child's guidance is a different record (a control receipt) withdrawn through the subagent control route. Sharing the slot and the bubble is the part that is the same.Type of change
Testing
Tested environments/configuration:
e2e/playwright.config.mock.ts, server and client built from this branch, in-memory Mongo, fake model, Linux (WSL2).subagentActivity.generationJobsat its default (on).Automated tests:
e2e/specs/mock/subagent-activity.spec.ts, all four cases pass locally on this head:steerPlacementnow finds its conversation root in either body.expandHistoryno longer waits on a fold that closed between being counted and being clicked. On the Redis lane the late-open and cold-reload cases failed about one run in eight with the new body, and the cause was this helper, not the pane: sampling the page through a failing window showed all 113 rows present and in order from 0.25 s after the live call was released, with no fold collapsed, while the helper sat in a click on the live call's "running" card, which is replaced by the call's own row when the call ends about 0.1 s later. The conversation body draws the live row in about 0.17 s, early enough to land the helper's first pass inside that window. With the click bounded, both cases pass 26 of 26 on Redis locally.The same parity test also passes with the messages read blocked at the network, which is the mixed-version fallback: the panel mounts the durable view and stays on it through the end of the run (again checked with the DOM probe).
client/src/Providers/__tests__/SubagentsHostFollow.spec.tsx(5),packages/chat/src/components/subagents/__tests__/panel.spec.tsx(9 new),followed.spec.tsx(6),follow.spec.tsx(3 new); each panel rule was removed in turn to confirm its test fails.packages/chat:npx jest src/components/subagents src/components/pane src/components/messages src/react/__tests__/follow.spec.tsx(752 tests),npx tsc --noEmit.client: the two host specs,hosts.test.tsx, the Subagents data-provider tests,Presentation.test.tsx(52 tests).npm run static-checks -- --against origin/dev. CI's client typecheck passes on this PR.Guidance waiting on the child:
subagent-activity.spec.ts, case "guidance the child has not taken yet waits after the last row and can be withdrawn": with a child held before its next tool boundary, a steer sent to it appears after everything the child has done, with one Withdraw; clicking it postscancel_messageto the control route and the button goes away; the child then finishes without that guidance in its reply. It passed on the memory lane and 4 of 4 on Redis, and fails with the change removed and the client rebuilt ("waiting guidance: expected 1, received 0").followed.spec.tsx(6 more): waiting guidance after the last row and its withdrawal; no receipt for guidance the reply already shows; no Withdraw while the task cannot be controlled; the reason for refused guidance; the "earlier control activity" notice; nothing added when no guidance was sent.panel.spec.tsx(1 more): the panel hands the conversation the task's waiting receipts, and Withdraw sendscancel_messagewith the task and control ids.Screenshots / recordings
A background child with 100+ tool calls, opened late. "Before" is the durable view, which is what
devdraws; it is produced on this build by blocking the messages read, so both columns are one build, one fixture, one viewport (1440x900).The two are meant to look alike: the durable view already drew its rows with the package's message row and content renderers, so what changes is where the content comes from, not how it is drawn. The visible difference is on the left, in the parent's card (see the first risk below).
Guidance waiting on a running child, in the conversation body:
Risk / compatibility
endpoints.agents.subagentActivity.generationJobs: falsekeeps running children on the durable view; finished threads still open as conversations, which needs only the read routes.