Repository navigation
feat(ui): redesign /btw side chat into a floating multi-turn panel - #104749
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5118bec22b
ℹ️ 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".
| props.onFollowUp(command); | ||
| input.value = ""; |
There was a problem hiding this comment.
Preserve failed follow-up drafts
When a side-chat follow-up is submitted while the Gateway is disconnected or chat.send rejects/returns a terminal ACK, this clears the only copy of the user's typed follow-up before handleSendChat(command) has accepted it. That handler is wired as a messageOverride, so the existing composer restore path has no previousDraft for the panel input; users lose the follow-up text on transient send failures. Please keep the input populated until the detached send is accepted, or plumb a failure result back before clearing it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ef2872026c
ℹ️ 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".
| onSideChatClear: () => { | ||
| state.chatSideChatTurns = []; | ||
| state.chatSideChatHidden = false; | ||
| // Retire (not just clear) so a discarded question's still-running | ||
| // detached run cannot leak its late reply into the transcript. | ||
| retirePendingChatSideQuestion(state); |
There was a problem hiding this comment.
Abort pending BTW runs when clearing side chat
When the trash button is pressed while a side question is pending, this only retires the local pending record; it never aborts the generated runId via chat.abort. I checked the gateway path in src/tui/embedded-backend.ts:450-495, and run-id aborts can cancel the BTW run, so the model work keeps running after the UI/docs say clear discards it and stops a pending run. Please abort the pending run before retiring it, or stop advertising clear as a stop action.
Useful? React with 👍 / 👎.
The inline BTW side-result card becomes a floating Side chat panel pinned to the thread column: multi-turn conversation with markdown answers, a follow-up input that carries the previous side answer as context, and header actions to clear (retires the pending run) or close (conversation and pending run survive; an arriving answer reopens the panel).
…ion structurally Review follow-ups: the /btw follow-up command now embeds both the previous side question and answer (answers alone lose the referents), and the panel shows the user's typed question via structured state (pending record correlated by runId) instead of parsing a marker out of user-controlled command text.
…drafts Trash now sends a targeted chat.abort for the pending /btw run (the retire set still suppresses its late events if the abort races), the follow-up input is hidden while disconnected like other slash sends, and a rejected detached send restores the typed follow-up into the panel input.
ef28720 to
cfddcb5
Compare
|
Codex review: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
There was a problem hiding this comment.
💡 Codex Review
openclaw/ui/src/pages/chat/chat-send.ts
Line 2187 in 223d595
When a side-chat follow-up is submitted while a model/profile picker patch is in flight and that patch resolves false, this return exits before btwPending is created and before opts.onSideQuestionSendRejected runs. The side-chat input is unmanaged and renderSideChatPanel has already cleared it after calling onFollowUp, so the user's typed follow-up disappears even though no chat.send was attempted; call the rejection callback or defer clearing on this early-failure path.
ℹ️ 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".
| canFollowUp: | ||
| canCompose && props.connected && typeof props.onSideQuestion === "function", |
There was a problem hiding this comment.
Disable follow-ups while a side question is pending
When a pending side question is visible, this still renders an enabled follow-up input. If the user submits another follow-up before the first answer arrives, handleSendChat treats it as a new /btw and retires the existing pending run (retirePendingChatSideQuestion), so the first answer is suppressed instead of accumulating as a turn while its model work can continue; hide/disable the composer while sideChatPending exists, or explicitly queue/abort the prior pending run.
Useful? React with 👍 / 👎.
…n pre-send exits A follow-up while a question is pending would retire the in-flight run and silently drop its answer, so the panel input is disabled until the answer lands. The rejection callback now fires on every non-accepted path of the guarded detached send (early exits, guard dedupe, rejected acks), not just rejected acknowledgements.
Pending and turn questions are already display-ready (chat-send strips composer commands, the server echo carries no /btw prefix, panel follow-ups pass structured text); re-extracting corrupted questions that begin with a command token.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d611f310c
ℹ️ 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".
| canFollowUp: | ||
| canCompose && props.connected && typeof props.onSideQuestion === "function", |
There was a problem hiding this comment.
Preserve follow-up drafts across disconnects
When the Gateway drops while a user has typed a side-chat follow-up but has not submitted it yet, this props.connected gate flips canFollowUp to false; renderSideChatPanel then removes the footer entirely, and the side-chat input is unmanaged state, so the draft is recreated empty after reconnect. The fresh path is the connected gate here rather than the rejected-send path already handled; keep the composer mounted disabled or persist the side-chat draft before hiding it.
Useful? React with 👍 / 👎.
|
Merged via squash.
|
…penclaw#104749) * feat(ui): redesign /btw side chat into floating multi-turn panel The inline BTW side-result card becomes a floating Side chat panel pinned to the thread column: multi-turn conversation with markdown answers, a follow-up input that carries the previous side answer as context, and header actions to clear (retires the pending run) or close (conversation and pending run survive; an arriving answer reopens the panel). * fix(ui): carry prior side question in follow-ups; display typed question structurally Review follow-ups: the /btw follow-up command now embeds both the previous side question and answer (answers alone lose the referents), and the panel shows the user's typed question via structured state (pending record correlated by runId) instead of parsing a marker out of user-controlled command text. * fix(ui): stop pending side runs on clear and keep rejected follow-up drafts Trash now sends a targeted chat.abort for the pending /btw run (the retire set still suppresses its late events if the abort races), the follow-up input is hidden while disconnected like other slash sends, and a rejected detached send restores the typed follow-up into the panel input. * test(ui): attach side-chat panel test container for restore assertion * fix(ui): block side-chat follow-ups while pending; notify rejection on pre-send exits A follow-up while a question is pending would retire the in-flight run and silently drop its answer, so the panel input is disabled until the answer lands. The rejection callback now fires on every non-accepted path of the guarded detached send (early exits, guard dedupe, rejected acks), not just rejected acknowledgements. * fix(ui): render side-chat questions verbatim Pending and turn questions are already display-ready (chat-send strips composer commands, the server echo carries no /btw prefix, panel follow-ups pass structured text); re-extracting corrupted questions that begin with a command token.
What Problem This Solves
Closes #104747.
The
/btwside-question answer (#104204) rendered as a full-width inline "BTW" card between the thread and the composer: it pushed the composer down, a new question replaced the previous answer (no follow-ups), and dismissing was all-or-nothing — closing the card retired the pending run and threw the answer away.Why This Change Was Made
Side questions are a side conversation and should read like one. This redesigns the card into a floating Side chat panel pinned to the top-right of the thread column (fixed bottom sheet ≤768px), modeled after Claude Code's desktop side-chat popover:
chat.abortfor a pending run) and X (close; the conversation and a pending run survive — a new question or an arriving answer reopens the panel)./btw. Detached side answers never enter session history, so the follow-up command carries capped quotes of the previous side question and answer as context (buildSideChatFollowUpCommand). The panel displays the user's typed question via structured state (the pending record, correlated by run id) — the command text is prompt-only and never parsed back apart.State model: the single
chatSideResultbecomeschatSideChatTurns(append-only per conversation) pluschatSideChatHidden; the pending/suppression machinery (chatSideResultPending,chatSideResultTerminalRuns) is unchanged, so retired runs still cannot leak late replies into the transcript.User Impact
Control UI chat users get a persistent, conversational side chat: ask a
/btw(typed or via the selection popup), read the answer in a floating panel, ask follow-ups inline, close it without losing the thread, and clear it when done. No gateway/protocol changes;chat.side_resultis consumed as before.Mobile bottom sheet (375x812)
Evidence
pnpm testoverchat-gateway,chat-send,chat-state,chat-composer,chat-side-chat,chat-view,side-question, andchat-responsive.browsersuites — 8 files, 628 tests passed on the final revision, including the rewritten desktop scroll-containment and mobile-overlay assertions.pnpm check:changed(delegated to Testbox) — lint/type/i18n lanes green.gpt-5.6-sol, xhigh), four rounds; each accepted finding fixed in-branch: follow-ups now carry the previous question+answer (answer-only context lost referents), the typed question travels as structured state instead of marker-parsing command text, trash actually aborts the pending run, rejected/pre-send-failed sends restore the typed follow-up, and the input is disabled while a question is pending so an in-flight answer cannot be silently superseded. Remaining known limitation (deferred, see below): panes other than the initiating one render a follow-up's server-echoed question as the full context command.pnpm dev:ui:mock(mock gateway):/btwsend shows the pending turn;chat.side_resultrenders the markdown answer; panel follow-up (Enter and ↵ button) sends/btwwith carried context and clears the input; X hides the panel and a new question reopens it with prior turns intact; trash clears and retires the pending run — a latechat.side_resultfor the retired run neither reopens the panel nor reaches the transcript.chat-side-chat.test.ts(panel render/interaction incl. disabled-while-pending and draft restore), gateway turn-accumulation + reopen-on-arrival + pending-question preference, follow-up builder round-trip inside-question.test.ts, rejection-callback coverage for failed and pre-send-exit detached sends inchat-send.test.ts.Follow-up (out of scope here): an additive
chat.side_resultfield carrying the display question, so non-initiating panes/clients render follow-up questions cleanly instead of the embedded context command.