Repository navigation
🪟 feat: Continue a Subagent's Thread as a Chat Beside the Conversation - #18417
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. |
5c6b0e8 to
5baccc5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5baccc559f
ℹ️ 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 contract = useDrivenContract({ id, followed, index }); | ||
| return ( | ||
| <> | ||
| <ContractThread contract={contract} messages={followed.messages} slots={slots} /> |
There was a problem hiding this comment.
Isolate side-chat reruns from the main chat's comparison target
When the main chat has an added comparison model, regenerating a response in the side chat also sends that comparison target. ContractThread inherits the app's useGetAddedConvo, which reads pane 1; both useMessageActions and useMessageHelpers pass its result to regenerate, and createPayload includes it as addedConvo. The backend's processAddedConvo consequently runs the main chat's comparison agent against the side conversation, producing unexpected additional responses and model usage. Override this host member with a null-returning getter for the independent side chat.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid, fixed in 0d401e7. The thread's messages host now answers useGetAddedConvo with nothing, beside the other members it already points away from main chat, so a rerun or edit here sends no comparison target. Test: "keeps a rerun in the side chat to its own conversation" (fails without the override).
| const openAsMain = useCallback(() => { | ||
| openConversation(pane.conversation ?? opened); | ||
| onClose(); |
There was a problem hiding this comment.
Transfer the unsent draft when opening the side chat as main
If the reader types a follow-up in the side composer and then clicks “Open as the main chat,” their text is silently discarded. The composer keeps its draft only in local value state, while this handler transfers only the conversation and immediately closes the panel; the main composer therefore cannot recover the draft. This also loses handed-over continuation text that ask refused and left in the field. Hand the current draft to the destination composer before unmounting the side panel.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid, fixed in 0d401e7. The panel now holds the draft (so it outlives the composer) and hands it to the destination with handOffComposerText before the conversation opens as the main chat, the same hand-off the continuation used to make. Tests: "takes the unsent words along when the conversation moves to the main chat" and "hands nothing along when nothing was written". The same lifted state takes back the words of a turn stopped before the server kept it (onWithdrawn, from #18413).
| <DrivenThread id={conversationId} index={SIDE_CHAT_PANE} followed={followed}> | ||
| {(contract) => ( | ||
| <SideChatComposer | ||
| contract={contract} | ||
| conversationId={conversationId} |
There was a problem hiding this comment.
Disable question handoff until the side composer can answer
When a side-chat agent pauses for ask_user_question, its message card still offers “Move to composer” through the app's AskUserQuestion adapter and useAskAnswerMode. Clicking it marks the question expanded, causing Question.tsx to replace the interactive card with an invisible placeholder, but SideChatComposer renders neither the answer popover nor its submit/collapse controls. The question therefore becomes unanswerable in the side panel. With Save Drafts disabled, that same handoff also writes the answer text into the enclosing main chat's form, because the side panel inherits its ChatFormProvider. Supply a side-scoped answer-mode integration, or withhold the move-to-composer action on this surface.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid, fixed in 0d401e7 by withholding the hand-off: the app's ask card offers "Answer from the message box" only in the main pane (ChatContext.index 0), so in any other pane the question stays in its card and nothing is written to main chat's form. Test in AskUserQuestionCollapse.test.tsx. This does not make pauses work in a side chat: answering resumes the generation through the app's resume route, and the side chat is not told to follow it yet. That is now listed under known gaps in the description rather than patched here.
| <SideChatHostProvider host={appSideChatHost}> | ||
| <Suspense fallback={null}> | ||
| <SideChatPanel | ||
| key={sideChat.conversation.conversationId} | ||
| chat={sideChat} |
There was a problem hiding this comment.
Scope subagent discovery to the side conversation
If the continued agent dispatches event-spawned subagents during a side-chat turn, their activity group never appears. This panel inherits the outer ParentSubagentsProvider, which is keyed to the main conversation, and neither SideChatPanel nor ContractThread supplies a replacement. EventSubagentActivityGroup reads that provider's byMessageId rather than fetching by its conversationId prop, so the side response's message IDs have no matching children and the component returns null. Detached tool-call previews likewise refresh the main conversation's index through useDetachedStatus. Wrap the side thread in a provider keyed to its own conversation and generation state so its child activity can be discovered and inspected.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid, fixed in 0d401e7. Presentation wraps the side chat in a ParentSubagentsProvider keyed to the side conversation, enabled for an agent conversation and fed the side pane's submitting flag. Test: "shows a side chat beside the conversation, with child activity read for its own conversation" (fails with the main conversation's id). Opening one of those children takes the panel slot, which closes the side chat; noted under known gaps.
5baccc5 to
0d401e7
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d401e7f72
ℹ️ 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".
| slots, | ||
| children, | ||
| }: DrivenThreadProps): ReactElement { | ||
| const contract = useDrivenContract({ id, followed, index }); |
There was a problem hiding this comment.
Isolate the side chat's turn services from the comparison pane
When the main chat's comparison target is not ready, the side composer silently refuses otherwise valid turns. This contract inherits appChatHost.useTurnServices, whose client/src/hooks/Chat/services.ts reads the main chat's addedConversation and requires isTargetReady(queryClient, addedConversation) before allowing any submission. It also includes that comparison agent in the side chat's code-workspace and approval derivations, so an unavailable workspace belonging only to the comparison agent can block the side conversation. Clearing useGetAddedConvo in the messages host fixes the rerun payload, but does not isolate these submission checks. Supply turn services that omit the main comparison conversation for this independent pane.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid, fixed in 37e45f4. useTurnServices now takes the comparison conversation only for main chat's own panes (0 and 1); any other pane gets none, so its readiness check, code workspace and approval derivations are the side conversation's alone. Test in services.readCodeInputs.spec.tsx: with an unloaded comparison agent, pane 0 refuses and is handed the comparison, pane 3 submits and is handed nothing (fails without the scoping).
| const openConversation = host.useOpenConversation(); | ||
| const { handOffComposerText } = useChatSurface(); | ||
| const conversationId = chat.conversation.conversationId ?? ''; | ||
| const [draft, setDraft] = useState(''); |
There was a problem hiding this comment.
Preserve the side draft across responsive layout changes
If the reader types a follow-up and then resizes the window or rotates a device across the side-panel breakpoint, their unsent text disappears. client/src/components/SidePanel/SidePanelGroup.tsx renders the panel inside ArtifactsPanel on wide screens and in a separate fixed container on narrow screens, so crossing that breakpoint unmounts and remounts SideChatPanel. This local state consequently resets to an empty string even though sideChatAtom still holds the same open conversation. Keep the draft in a conversation-keyed owner that survives that responsive remount, or preserve the panel's mounted identity when moving between layouts.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid, fixed in 37e45f4. The draft lives in sideChatDraftFamily(conversationId), an in-memory atom outside the panel, so the remount across the breakpoint keeps it (and nothing unsent is written to storage). Test: "keeps the unsent words when the layout draws the panel again" unmounts and mounts the panel (fails with the draft in panel state).
|
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". |
|
@codex review Head 1ce2724. Rebased onto #18413's rebased head (which is now on dev with #18424). Squashed to one commit. Hand-resolved: |
37e45f4 to
1ce2724
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1ce2724e0c
ℹ️ 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".
| endpoint, | ||
| enabled: id !== '', | ||
| onWithdrawn: options?.onWithdrawn, |
There was a problem hiding this comment.
Connect the side stream's attachment handler
When a side-chat agent emits attachment events, such as web-search sources or generated-file metadata, this call supplies no beside.onAttachment handler. createEventApplier in packages/chat/src/core/apply.ts forwards these events only to that callback; it does not merge them into messages. Consequently, the side thread's useAttachments receives no streamed attachments, so attachment-backed output remains unavailable until the generation finishes and messages reload. The app's file, memory, and preview caches also miss the updates performed by client/src/hooks/SSE/useAttachmentHandler.ts. Pass that handler through beside so side-chat tool results receive the same attachment processing as main-chat results.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid, fixed in 3a822a8. The side chat's host passes the app's useAttachmentHandler to useFollowChat as beside.onAttachment, so a streamed attachment lands on the rows through the same live-attachments store the driven contract reads, and in the file, memory and preview caches. New SideChatHostContext.spec.tsx drives a real stream through the app's host: an attachment frame after created shows up in the app's file list (fails without the wiring). Usage and title frames are still not wired here; that stays under known gaps.
What a tool hands back while a side chat's generation runs (search sources, a generated file) reached no handler, so it was missing from the rows and from the app's file, memory and preview caches. The side chat's stream now uses the app's attachment handler.
3a822a8 to
ce4c149
Compare
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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
When a subagent has finished, its panel offers "Continue in a new chat": the child's thread is forked into a conversation of the reader's own. Until now that navigated the page to the new conversation, leaving the one the child ran under, with the reader's words dropped into the new chat's composer to be sent again.
The continuation now opens where the child's activity was, beside the conversation. It is a side chat: the forked conversation drawn by main chat's message list, with a composer, driven through a core
Chat(#18413). The words the reader wrote to get there are sent as its next turn, the reply streams in, and further turns, reruns, edits and stops work from the panel. A control in its header moves it into the main chat's place.This is the surface the earlier steps were for (#18398 side frames, #18401 turn shape, #18411 transport send, #18413 driving contract), and the first place the app starts a generation through the
Chatclass. Stacked on #18413.Behavior change: "Continue in a new chat" no longer leaves the parent conversation.
interface.sideChat: falserestores the navigation (defaulttrue).How it works
The panel reuses what the child-activity panel uses: the same shell and header, the shared
Composerfrom@librechat/client, the reader's Enter-to-send preference and rebound submit shortcut, the sheet layout on narrow screens.Type of change
Testing
Tested environments/configuration:
Chromium on the mock e2e lane (in-memory Mongo, fake model), from this branch's own server: the new scenario below, and the capture above is from that run.
Automated tests:
e2e/specs/mock/subagent-activity.spec.ts, new@scenario:subagent-continue-opens-side-chat: a parent dispatches two children; the first one's panel is continued with a typed follow-up; the side chat opens with the URL unchanged, shows the child's history and the follow-up, and the reply arrives; exactly one generation is started, for the forked conversation; a second turn is sent from the side chat's composer; "Open as the main chat" navigates to it with both turns stored.packages/chat/src/components/side/__tests__/panel.spec.tsx(10), over the realuseFollowChat,useDrivenContractanduseTurns: loading then the stored rows under the title; a typed turn's posted body and rows, then Stop reaching the transport; a settled reply and the next turn answering it; handed-over words sent once; a failed load with Retry; open-as-main and close; unsent words handed to the main composer; the words of a turn the server never kept back in the field; no comparison model handed to its rows.packages/chat/src/components/subagents/__tests__/panel.spec.tsx(2): the continuation is handed beside with its words, and without navigating; with no words.client/src/Providers/__tests__/SubagentsHostContext.spec.tsx:openBesideis offered only with side chats on, and sets the side chat.client/src/components/Chat/Presentation.test.tsx(2): the side chat mounts with child activity read for its own conversation and gives way to a child's panel; it closes when the main conversation changes.client/.../Content/__tests__/AskUserQuestionCollapse.test.tsx: outside the main pane a live question stays in its card.client/src/Providers/__tests__/SideChatHostContext.spec.tsx(3), over the app's real host and a wire the test drives: the conversation read as a list; a streamed attachment reaching the app's file list; a stop reaching the app's abort with the conversation, stream and epoch.packages/data-schemas/src/app/interface.spec.ts(2): the flag reaches clients, and defaults on.packages/chatnpx jest(3989),npx tsc --noEmit;packages/data-providerconfig specs + tsc;packages/data-schemasapp specs + tsc; the client suites above andtscfiltered to the touched files;npm run static-checks -- --against origin/dev.Risk / compatibility
Followed.tsxchanges by extraction (ContractThread). Withinterface.sideChat: false, or before the deployment's config has answered, the panel navigates as it did.Pauses work in a side chat: a tool approval and an ask-user question are both answered from their card there, the answer is posted for the side conversation, and the rest of the reply arrives in the side chat. An earlier version of this description listed that as unsupported; that was read from the code, not observed, and a browser run showed otherwise. The follow-up PR adds the two scenarios.
Known gaps, not handled here:
useFollowChat({ beside })), so a new conversation's generated title shows after it is reopened. Streamed attachments are wired, through the app's own handler.