Skip to content

🧰 feat: Give a Side Chat Main Chat's Composer - #18469

Draft
danny-avila wants to merge 1 commit into
danny-avila/side-chat-announcementsfrom
danny-avila/side-chat-composer
Draft

danny-avila wants to merge 1 commit into
danny-avila/side-chat-announcementsfrom
danny-avila/side-chat-composer

Conversation

@danny-avila

@danny-avila danny-avila commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A conversation open beside the chat (#18417) has a plain text field for a composer: it sends text and stops a reply, and nothing else. No attachments, no tools or MCP servers, no reasoning control, no context gauge, no dictation, no prompts or skills. A file dropped anywhere on the side chat lands in main chat's composer instead.

This change gives the side chat main chat's own composer. The app's ChatForm is mounted a second time, for the side conversation's pane, reading that conversation's chat contract. What is attached, dropped, pasted, typed and stopped there belongs to that conversation; the chat on screen keeps its own.

The side chat's composer holding a file dropped on the side conversation

The form was written for one composer per page, so the parts of it that speak to the page rather than to a pane now apply only to the composer the route addresses (pane 0):

  • The textarea id. Main chat's keeps prompt-textarea, which shortcuts, quotes and focus look up; any other pane's composer takes prompt-textarea-<pane>.
  • The route's query (?prompt=…&submit=true) and a navigation's focus request. A composer beside the routed one no longer polls the query (it used to keep a 100 ms timer running for as long as it was mounted) and leaves the focus request for the composer it was meant for.
  • @ and + mentions, which pick the model for main chat's conversation, and auto-played audio, which follows main chat's run and owns the page's one audio element.

Five behaviours that assumed one composer are now scoped to the pane they happen in:

  • A dropped file goes to the innermost drop target under it. The side chat has its own inside the page's, and the page's target neither takes such a drop nor lights up for it.
  • The submit shortcut clicks the send button of the pane holding focus, as the stop and upload shortcuts already did; the side panel is marked as a pane.
  • Dictation. The browser's speech recognizer is one per page and reports to every composer mounted; a take is now collected, and shown as recording, only by the composer that started it; a second composer cannot start one while another is recording (it says so); and a composer that goes away mid-take ends it.
  • A question arriving in one conversation takes focus only from the empty composer of its own pane, not from one the reader is in beside it.
  • Stop. A pane's stream session can only stop a generation its start has named, so the form disables Stop until then. A chat that stops through a core Chat finds the generation itself, and says so on its contract (stopsUnnamed), so its Stop is live as soon as a reply is on its way.

Known and not fixed here: words typed while a side reply is still running are lost when that conversation is opened as the main chat. They are handed over, but main chat empties its composer when it attaches to a run it did not start and clears the conversation's saved draft when that run ends. That is main chat's behaviour without any side chat (regenerating a reply with a draft in the composer reproduces it) and is fixed separately in #18472. For the same reason, with drafts saved, a side chat closed while its reply runs and opened again before it ends shows an empty composer until the run ends, when the conversation's saved draft comes back unless something was typed meanwhile.

Not in this change: sending during a run. Queue and steer are still limited to main chat's composer (useSteering gates on pane 0, and the run-end signal that drains a queue comes from the stream session), so text entered while a side chat reply streams stays in the field. Mentions are off in a side chat for the same reason they are scoped above; choosing another model for a side conversation is separate work. Live usage frames are not wired to the side chat yet, so the context gauge there shows the conversation's stored totals (seen after a turn; that it stays still while a reply streams is read from the code, not measured). The question-answer selection state is one per page (askAnswerSelectionAtom), which only matters if both conversations pause on a question at once.

Stacked on #18467. Related to #18417.

How it works

packages/chat
├── react/side/host.tsx            # SideChatHost.Surface?: the host's composer, around the list
├── components/side/panel.tsx      # draws host.Surface when there is one, else its plain field;
│                                  #   marks itself data-chat-pane=3 and a size container
├── components/pane/Driven.tsx     # children(contract, thread): the surface arranges the two
├── react/chat/contract.ts         # stopsUnnamed
└── core/composer.ts               # composerTextareaId(index), isComposerTextarea

client
├── components/Chat/Side/Surface.tsx   # ChatForm for pane 3, under its own providers
├── components/Chat/Input/ChatForm.tsx # routed = index === 0
├── hooks/Input/useQueryParams.ts      # routed
├── hooks/Chat/useFocusChatEffect.ts   # enabled
├── hooks/Files/useDragHelpers.ts      # innermost drop target wins
└── hooks/useKeyboardShortcuts.ts      # submit in the focused pane

Surface.tsx puts around the form what ChatView puts around main chat's, each this conversation's alone:

ChatContext            = the driven contract (ask, files, conversation, stop)
TargetContext          = useTarget(conversation)          # agent / model readiness
ChatFormProvider       = its own react-hook-form state
ComposerRestoreProvider                                    # a reclaimed steer's words, for this composer
ComposerPreferencesContext (from ChatView)                 # enterToSend, autoSendText, speech settings
AddedChatContext       = none: a side chat is compared with no other model
DragDropWrapper        = a drop target around the list and the form
  {the message list}
  <ChatForm index={3} routePending={!ready} … />

A pane shows one conversation after another, and is drawn again when the layout moves it between a column and a sheet, so what the composer holds has to follow the conversation and not the pane:

  • Unsent words are kept by the panel, per conversation and in memory, as they were for the plain field. The form starts from them, reports every change, and shows a change the panel makes (the words of a turn the server never kept come back this way). So they survive a layout change, come back when the conversation is opened beside the chat again, and are handed to main chat's composer when the conversation becomes the main chat, whatever Save Drafts is. Main chat's composer adds nothing when the saved draft has already put the same words there.
  • Staged files belong to the conversation that staged them: useDrivenContract empties the pane's file map when the pane takes a different conversation, and keeps it for the same one drawn again.
  • What is written while a reply runs is saved under the pane's pending key. A composer that saw a run moves that to its conversation when it goes away (settlePendingDraft), under the ownership guards the composer's own run-end migration applies, so the next conversation in the pane does not find it and another tab's record is never touched.
  • Staged files whose upload has finished go with the conversation when it becomes the main chat: taken before the navigation clears the panes, and added by main chat's composer once it holds that conversation, with drafts saved or not. An upload still on its way stays with the composer that started it.
  • Words handed over with the conversation are sent once as its next turn, and the field takes focus when the conversation is in.

A host that supplies no Surface keeps the panel's plain field, so the package still draws a working side chat on its own.

Type of change

  • Feature
  • Bug fix

Testing

Driven in a real browser on the mock e2e lane, with an earlier conversation open beside the current one:

  1. Attach a file from the side composer's palette: the chip is in the side composer only, the turn's request carries the file and the side conversation's id, and the file shows on the sent message.
  2. Drop a file on the side chat, then one on the chat: each lands in its own composer. Pasting a file into the side field does too.
  3. Send a slow reply and stop it from the side composer: it stops, and the composer takes the next turn.
  4. Type in both composers, then open the side conversation as the main chat: its words are in the main composer, and the other chat's draft was never touched. The same with Save Drafts off.
  5. With Save Drafts off: resize across the sheet breakpoint and the words are still in the field; stage a file in one side chat, close it, open another, and the second has nothing staged and sends no file.
  6. Type while a side reply runs, close the side chat, open a different conversation beside the chat: its field is empty, and the first conversation has the words when it is opened again.
  7. The page holds no textarea id twice (prompt-textarea, prompt-textarea-3), and the side field has focus when the conversation opens.

The nine existing side chat scenarios (open beside, small screen sheet, pauses, continue a child as a chat, read state, announcements) pass unchanged against the new composer.

Each new test was run with its part of the change switched off and fails there: attach and drop without the host composer, Stop without stopsUnnamed, and the three hook cases without their gates. The draft scenario guards behaviour the plain field also had.

Not measured: render cost of the second form. It mounts only while a side chat is open, and main chat's form gains one constant and one prop.

Tested environments/configuration:

  • Chromium via Playwright, mock e2e lane (in-memory MongoDB, fake model), desktop 1440×900; the small-screen sheet scenario at 390×844.

Automated tests:

  • packages/chat: npx jest (249 suites, 4023 tests), tsc --noEmit. New cases in components/side/__tests__/panel.spec.tsx (the host's composer is drawn around the list on the conversation's contract; the panel is its own pane; a withdrawn turn's words come back to it; what is written in it survives a remount and goes with the conversation), react/chat/__tests__/driven.spec.tsx (stopsUnnamed; staged files dropped for another conversation and kept for the same one), core/__tests__/composerId.spec.ts, react/parts/__tests__/arrival.spec.ts.
  • client: new cases in hooks/Chat/__tests__/useFocusChatEffect.spec.tsx, hooks/Input/useQueryParams.spec.ts (no staging, no submit, no timer when not routed) and hooks/useKeyboardShortcuts.spec.tsx (submit goes to the focused pane), hooks/Input/useTextarea.spec.tsx (a hand-off the composer already holds adds nothing), utils/drafts.spec.ts (settlePendingDraft and its ownership guards), and hooks/Input/__tests__/useSpeechToTextBrowser.spec.tsx (a take belongs to the composer that started it). Dictation across two composers was not exercised in a browser. npx jest src/components/Chat src/hooks/Input src/hooks/Messages src/hooks/Files src/hooks/Chat src/Providers src/hooks/useKeyboardShortcuts: 239 of 240 suites pass; hooks/Chat/__tests__/target.spec.tsx fails two cases locally with ECONNREFUSED 127.0.0.1:3080, as it does on dev in this checkout, and passes in CI.
  • New e2e/specs/mock/scenarios/side-chat-composer.spec.ts (ten scenarios); all nineteen side chat scenarios pass.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head: 9e5bf6f

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T03:12:25.940225Z d53f1fe Manual request
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e5bf6ff72

ℹ️ 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".

Comment on lines +106 to +110
<ChatForm
index={contract.index}
routePending={!ready}
isLandingPage={false}
enterToSend={enterToSend}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Scope browser dictation to the composer that started recording

With browser speech recognition selected and a side chat open, mounting this second ChatForm also mounts a second useSpeechToTextBrowser. Both call useSpeechRecognition() without a transcription gate; the library documents that transcription defaults to enabled independently of the global microphone state. Both hook instances therefore forward transcripts into their respective forms. The inactive instance's undefined take ID passes the guards in useDictation, so dictating in one pane overwrites the other pane's draft and, with Auto Send Text enabled, can submit the transcript to both conversations. Gate transcript collection and callbacks on ownership of the recording before mounting another browser dictation consumer.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, fixed in d95fab6. useSpeechToTextBrowser now tracks whether this composer started the take (owns), passes useSpeechRecognition({ transcribing: owns }) so an instance that did not start it collects nothing, and reports isListening only when it owns the take. Ownership is taken in startRecording and released when the take settles after a stop, when it is aborted, or when the recognizer ends it by itself (after the effects that write the last transcript down). New case in useSpeechToTextBrowser.spec.tsx; it fails with the option removed.

Comment on lines +42 to +44
const enterToSend = useRecoilValue(store.enterToSend);
const autoSendText = useRecoilValue(store.autoSendText);
const speechSettingsInitialized = useRecoilValue(store.speechSettingsInitialized);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Pass app-global preferences through the side-chat host

The new side-chat surface directly subscribes to enterToSend, autoSendText, and speechSettingsInitialized through ~/store, although it only consumes these app-global preferences. This violates the client-state ownership rule in AGENTS.md, which explicitly names enterToSend as state that must arrive through props or a host-supplied context rather than a feature-local store lookup. Read these values in the app host and supply them to the surface, leaving the shared Recoil atoms unchanged so the side-chat feature retains its intended ownership boundary.

AGENTS.md reference: AGENTS.md:L188-L194

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, fixed in d95fab6. ChatView already reads these three and hands them to main chat's form; it now also provides them through ComposerPreferencesContext, and the side surface reads that instead of ~/store. Side/Surface.tsx no longer imports Recoil or the store.

focusWhenReady,
children,
}: SideChatSurfaceProps) {
const methods = useForm<ChatFormValues>({ defaultValues: { text: '' } });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the in-memory draft when using the host composer

When Save Drafts is disabled, typing in the side composer and choosing “Open as the main chat” now loses the unsent text. The host surface holds its text only in this private form, while SideChatPanel.openAsMain still reads sideChatDraftFamily, which this surface never updates. useAutoSave skips persistence and restoration when saveDrafts is false, so there is no fallback copy. Previously the plain composer updated the panel's in-memory draft and handed it to the main chat regardless of that preference. Connect the host composer's live text to the panel's handoff state instead of relying exclusively on persistent autosave.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, fixed in d95fab6. The host's composer now gives the panel a reader for its unsent words (SideChatSurfaceProps.onUnsentWords), which openAsMain uses for the hand-off. The app's surface registers it only when Save Drafts is off: with drafts saved the words are already kept under the conversation's id, and handing them over as well would insert them a second time. New case in panel.spec.tsx and new scenario @scenario:side-chat-composer-draft-follows-without-saved-drafts; without the hand-off the scenario ends with an empty main composer.

(active instanceof HTMLTextAreaElement &&
active.id === mainTextareaId &&
active.value.trim().length === 0)
(isComposerTextarea(active) && active.value.trim().length === 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict question arrival focus to the question's own pane

If main chat produces an ask_user_question while the user has focused the still-empty side composer, this predicate now treats that other conversation's textarea as idle. The arrival callbacks in components/parts/ask/Question.tsx and Questions.tsx then move focus into main chat's question controls, so subsequent typing or Enter acts on the wrong conversation. Previously the side chat's plain field did not satisfy this predicate. Pass the arriving question's pane into the idle check and only claim an empty composer belonging to that pane, while retaining the existing body/no-focus fallback.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, fixed in d95fab6. isFocusIdle takes the arriving question's element and counts an empty composer as idle only when it is in the same pane (getChatPane); focus that is nowhere is idle as before. Both callers pass their card. New react/parts/__tests__/arrival.spec.ts covers both directions (main's question with the side composer focused, and the reverse); it fails with the pane comparison removed.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head: d95fab6

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d95fab68b1

ℹ️ 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 { saveDrafts } = useChatSettings();
useEffect(() => {
onUnsentWords(saveDrafts ? null : () => methods.getValues('text'));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Carry the live draft when promoting a running side chat

With Save Drafts enabled, type a follow-up while the side chat is generating, then choose “Open as the main chat”: the unsent text does not follow the conversation. The new reader fixes the drafts-disabled case, but useAutoSave stores text under getPendingDraftId(index) during generation, so this draft lives under pane 3's pending key rather than the conversation ID. Main chat uses pane 0's pending key, and neither its restoration nor openAsMain reads pane 3's key. Provide a live handoff for this case as well instead of assuming every saved draft is already stored under the conversation ID.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, and it turned out to be three things. Two are fixed in 5a805c7; the third is main chat's own and is not fixed here.

  1. The side composer now hands its unsent words over in every case, not only with drafts off, and main chat's composer adds nothing when it already holds exactly those words (the saved draft and the hand-off would otherwise put them in twice). New case in useTextarea.spec.tsx.
  2. Found while reproducing this: a side chat closed while its reply runs left its draft under the pane's pending key, and the next conversation opened beside the chat found those words in its composer. The surface now moves the pane's pending text and attachments to their conversation on the way out. New scenario @scenario:side-chat-composer-draft-stays-with-its-conversation; before the change the second conversation's composer held the first one's words.
  3. The exact case you describe still loses the words, for a reason outside this change: when main chat attaches to a run it did not start in the conversation on screen, its autosave switches to the pending key, empties the composer, and at the end of the run the conversation's saved draft is cleared. I reproduced that on main chat alone with two tabs (type a draft in one, start a reply in the same conversation from the other: the first tab's composer empties when it attaches). So the words now reach main chat's composer and are then dropped by it. That needs its own change in useAutoSave, which I am tracking separately; I wrote the scenario for this case and left it out of this pull request because it cannot pass until that lands.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head: 5a805c7

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a805c7081

ℹ️ 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".

Comment on lines +107 to +109
migrateTextDraft(pending, conversationId);
if (getFilesDraft(pending).fileIds.length > 0) {
migrateFilesDraft(pending, conversationId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Check draft ownership before migrating pending records

With two tabs open, closing an idle side chat in one tab can move the other tab's unsent text and attachments into the wrong conversation. getPendingDraftId(3) is shared across tabs, and neither migration helper checks ownership before deleting the source and replacing the destination. Unlike the migration in useAutoSave, this cleanup checks neither isFilesDraftOwnedByThisTab nor destination writability, and runs even when this composer never used the pending key. Apply the existing source-ownership and destination-writability guards before migrating either record.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, fixed in 2fe6ab6. The move is now settlePendingDraft in utils/drafts.ts, under the guards the composer's own run-end migration applies: the pending record must be this tab's (isFilesDraftOwnedByThisTab) and the conversation's key must be owned and writable by it (mayWriteComposerText); otherwise nothing is touched. The surface only calls it when its composer saw a run while it was mounted, so an idle side chat closing never looks at the pending key. New cases in drafts.spec.ts, including another live tab owning the pending record and another live tab owning the destination; both fail with the guards removed.

focusWhenReady,
children,
}: SideChatSurfaceProps) {
const methods = useForm<ChatFormValues>({ defaultValues: { text: '' } });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the live draft across responsive remounts

With Save Drafts disabled, resizing the window across the side-panel breakpoint now erases everything typed in the side composer. SidePanelGroup unmounts the column panel and mounts it in the sheet location, so this private form starts empty again; useAutoSave does not restore text with that preference disabled. Previously, sideChatDraftFamily retained the text outside the panel specifically across these layout changes. Keep the live text in conversation-scoped in-memory state, or otherwise restore it when the surface remounts, rather than using the reader only for promotion to main chat.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, fixed in 2fe6ab6, by going back to one keeper for the unsent words: the panel's conversation-scoped in-memory draft (sideChatDraftFamily), which is what the plain field used. The host's composer now starts from it (draft), reports every change (onDraftChange), and shows a change the panel makes (the words of a turn the server never kept). That replaces the reader and the returned-text props from the last two rounds, so the hand-off on promotion and the survival across a remount are the same mechanism again, whatever Save Drafts is. New case in panel.spec.tsx and scenario @scenario:side-chat-composer-draft-survives-a-layout-change (drafts off, resized across the sheet breakpoint); before the change the field came back empty.

Comment on lines +138 to +139
<ChatForm
index={index}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Isolate staged attachments when changing side conversations

With Save Drafts disabled, attach a file in side conversation A, close that panel without sending, then open side conversation B: A's file remains attached and is included when sending B's next message. The new composer uses contract.files, which useDrivenContract stores in the persistent filesFamily(3) atom, but closing the panel only clears its conversation. The normal file reset in useAutoSave is skipped entirely when saveDrafts is false, and neither the surface nor upload cleanup clears the map. Scope staged files to the side conversation or explicitly swap/reset them when its identity changes so a later conversation cannot submit another conversation's attachments.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, fixed in 2fe6ab6, at the source: useDrivenContract records which conversation staged the pane's files (filesOwnerFamily) and empties the pane's file map when the pane takes a different one, in a layout effect ahead of the composer's own effects (which, with drafts saved, put that conversation's saved attachments back). The same conversation drawn again keeps its files. New case in driven.spec.tsx and scenario @scenario:side-chat-composer-files-stay-with-their-conversation (drafts off: stage a file in one side chat, close, open another; before the change the chip was there and would have gone out with the second conversation's turn).

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head: 2fe6ab6

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2fe6ab649c

ℹ️ 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".

focusWhenReady,
children,
}: SideChatSurfaceProps) {
const methods = useForm<ChatFormValues>({ defaultValues: { text: draft } });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the side form's reset baseline empty

With Save Drafts disabled, type a draft and resize across the side-panel breakpoint (or close and reopen the same side conversation), then send it. The remounted form captures that nonempty draft as its defaultValues, so useSubmitMessage's successful methods.reset() restores the original draft instead of clearing the composer. The already-sent text remains available for another submission and is retained as the conversation's unsent draft. Initialize the live text separately while keeping the reset baseline empty, or explicitly reset to empty text on consumption.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, fixed in b34605a. The form's default is empty again, which is what methods.reset() returns to after a send, and the draft the panel holds is put into the field by a layout effect (before paint), the same path that already applied a draft the panel changes. The layout scenario now sends from the composer drawn again and checks the field is empty afterwards; before the change it still held the sent words.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head: b34605a

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b34605a6b2

ℹ️ 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".

Comment on lines +78 to +84
useLayoutEffect(() => {
if (draft === reported.current) {
return;
}
reported.current = draft;
if (methods.getValues('text') !== draft) {
methods.setValue('text', draft, { shouldValidate: true });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the live draft when reopening a running side chat

With Save Drafts enabled, type a follow-up during a side-chat reply, close the panel, and reopen that conversation before the reply finishes. The unmount cleanup moves its pending draft to the conversation key, but the remounted ChatForm's useAutoSave still selects pane 3's now-empty pending key while isSubmitting is true. Its passive restoration overwrites the text installed by this layout effect, leaving the composer empty until the run ends; typing another message in that interval can replace the original saved draft. Coordinate autosave restoration with the panel's live draft so reopening a running conversation does not hide or overwrite its unsent text.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, and not fixed in this pull request. The cause is the same as the case I left open two rounds ago (words written during a run, then the conversation opened as the main chat): when a composer's storage switches to the pending key because a run it did not start is under way, useAutoSave restores the pending draft over whatever the field holds instead of carrying the field across. That is main chat's own behaviour on dev with no side chat involved (two tabs on one conversation reproduce it), and patching around it from the side surface is what the last rounds kept running into. I am fixing it where it lives, in useAutoSave, as its own change, and it will carry this case and the earlier one with it. Until then, as you say, the reopened composer is empty until the run ends, when the conversation's saved draft comes back unless something was typed meanwhile. The description lists this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Follow-up: the change in useAutoSave is up as #18472. It keeps a composer's words when a run it did not send starts, and keeps the words a composer is first drawn with when there is no record to restore, which is the reopened-while-running case here. Once it is in, I will add the two scenarios this pull request left out (promote while a reply runs, reopen while a reply runs).

Comment on lines +145 to +146
<ChatForm
index={index}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Transfer staged files when promoting the side conversation

With Save Drafts disabled, attach a file in the side composer and choose “Open as the main chat” before sending. This form stages the attachment in filesFamily(3), but SideChatPanel.openAsMain hands off only text, and main chat reads filesFamily(0). Since useAutoSave skips attachment persistence and restoration with that preference disabled, the promoted conversation has no attachment and its next submission omits the file. Transfer the staged file map along with the live text when promoting the conversation, without replacing the departing main conversation's draft files.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, fixed in cbb304e. Opening the side conversation as the main chat now takes what its composer has staged before the navigation clears every pane's files, and leaves it under the conversation's id (handedComposerFilesFamily, in memory like the handed text) for main chat's composer to add to its own once it holds that conversation. The departing conversation's staged files are untouched: they are cleared by the navigation as they always were, and nothing is written into pane 0 until it shows the promoted conversation. New scenario, run with drafts saved and not saved; the latter failed before the change. With drafts saved the file is restored from the conversation's draft as before and merged by id, so it shows once.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head: cbb304e

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cbb304e9a9

ℹ️ 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".

Comment on lines +106 to +109
const staged = store.get(filesFamily(SIDE_CHAT_PANE));
const { conversationId } = conversation;
if (staged.size > 0 && conversationId != null && conversationId !== '') {
store.set(handedComposerFilesFamily(conversationId), staged);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Finish or transfer active uploads before promoting the side chat

With Save Drafts disabled, start uploading a file in the side composer and choose “Open as the main chat” before it finishes. This copies the incomplete file record into main chat, but the upload's completion handler in useFileHandling still targets the side pane and is fenced by that composer's captured ownership. Closing the side composer invalidates that ownership, so the transferred record never receives progress: 1; main chat's hasIncompleteFiles consequently keeps sending disabled until the attachment is removed. Either prevent promotion while uploads are incomplete or transfer their completion lifecycle along with the staged map.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, fixed in 34c4e8d the first way you suggest: only files whose upload has finished are handed over (stagedForHandoff). One still on its way stays with the composer that started it, so main chat never receives a record nothing will complete. With drafts saved it still reaches the conversation the way it always did, through the files draft once the upload lands. New store/__tests__/handoff.spec.ts; the staged-file scenarios pass three times each with the filter in place.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head: 34c4e8d

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 34c4e8d303

ℹ️ 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".

Comment on lines 62 to +64
browserSupportsSpeechRecognition,
} = useSpeechRecognition();
const isListening = listening;
} = useSpeechRecognition({ transcribing: owns });
const isListening = listening && owns;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Abort an owned browser recording when its composer unmounts

With browser dictation and continuous recognition enabled, start recording in the side chat and then close the panel. Nothing in this hook or useDictation aborts recognition on unmount, so the page-global recognizer keeps the microphone running after its owning composer disappears. Main chat now reports isListening: false because it does not own that take, leaving no visible recording indicator or Stop control. Add ownership-aware unmount cleanup that aborts this composer's take without stopping a recording owned by another composer.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, fixed in db6568c. useSpeechToTextBrowser now ends its take on unmount when it owns one (abort, or stop where the module cannot abort, and the pending auto-send timer is cleared), and does nothing when it does not, so a take another composer started is left running. Ownership is also kept in a ref so a take started and the composer removed before the next render is still seen. New case in useSpeechToTextBrowser.spec.tsx; it fails with the ownership check removed.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head: db6568c

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: db6568cd0a

ℹ️ 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".

Comment on lines +177 to 180
setOwns(true);
SpeechRecognition.startListening({
language: languageSTT,
continuous: autoTranscribeAudio,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Enforce exclusive ownership when starting browser dictation

With continuous browser dictation running in main chat, starting dictation in the side composer sets this second hook's owns flag without releasing or rejecting the first owner's take. Both instances then transcribe the page-global recognizer, writing speech into both drafts and potentially submitting it to both conversations when Auto Send Text is enabled. The fresh evidence beyond the previously fixed idle-consumer case is this second-start path: useDictation.startDisabled checks only the instance's own activity, and startRecording unconditionally claims ownership. Use a shared recording owner or refuse a start while another composer owns the recognizer; an instance-local boolean does not provide exclusive ownership.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, fixed in 55398ae. Ownership is now exclusive across composers: the hook module keeps the one composer holding the page's recognizer, startRecording refuses (with a localized message, com_ui_speech_in_use) while another composer holds it, and the holder is released wherever a take ends: settled after a stop, aborted, ended by the recognizer, or its composer unmounted. New case in useSpeechToTextBrowser.spec.tsx with two composers: the second start does not reach the recognizer and that composer does not show as listening, and it can start once the first take is over. It fails with the check removed.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Head: 55398ae

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 55398ae72b

ℹ️ 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".

@danny-avila
danny-avila force-pushed the danny-avila/side-chat-announcements branch from 52b530a to 00e0c59 Compare November 19, 2026 03:10
@danny-avila
danny-avila force-pushed the danny-avila/side-chat-composer branch from 55398ae to d53f1fe Compare November 19, 2026 03:10
@danny-avila

Copy link
Copy Markdown
Collaborator Author

Rebased onto current dev (which now has #18480 in the same files); no change in behaviour.

@codex review

Head: d53f1fe

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: d53f1feed6

ℹ️ 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".

This branch has not been deployed

No deployments
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