Repository navigation
feat(control-ui): selection popup with More details and Ask in side chat via /btw - #104205
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae2f9c7635
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| host.chatSideResultPending = { | ||
| question: extractSideQuestionDisplayText(message), | ||
| ts: Date.now(), | ||
| }; |
There was a problem hiding this comment.
Clear pending BTW cards when accepted runs fail
When a /btw request is accepted but later ends as a normal chat error/abort before emitting chat.side_result—for example /btw before an existing Codex thread, a provider failure, or a timeout—this pending card is created but never cleared: sendDetachedCommandMessage has already returned an accepted ack, and the terminal chat event is only ignored/associated after a side result registers the run id. Please track the side run id or clear pending on the terminal side-run event so the composer does not keep showing Thinking… indefinitely.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1735b637d0
ℹ️ 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".
| } else if (host.chatSideResultPending) { | ||
| // The side_result may already have landed and cleared pending; | ||
| // only tag the run id while the card is still waiting. | ||
| host.chatSideResultPending = { ...host.chatSideResultPending, runId: ack.runId }; |
There was a problem hiding this comment.
Bind BTW ACKs to their originating pending card
When two different /btw questions are sent before the first chat.send ACK returns, this updates whichever pending card happens to be current with the older ACK's runId (the submit guard only dedupes the same message, so overlapping different side questions are allowed). That can tag question B with run A, so B's own terminal event no longer clears the placeholder and run A can clear or replace the wrong card; keep a per-request token/run association before mutating chatSideResultPending.
Useful? React with 👍 / 👎.
| state.chatSideResult = sideResult; | ||
| state.chatSideResultPending = null; |
There was a problem hiding this comment.
Ignore stale BTW results while a newer question is pending
When a user asks a second /btw before the first side result arrives, an older chat.side_result still reaches this handler and unconditionally clears the newer pending card while displaying the old answer. The selection popup makes that overlap easy to hit, and the UI then loses the Thinking… feedback (or briefly shows the wrong answer) for the latest question; compare the result runId with the pending run before clearing/replacing it.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 4:23 AM ET / 08:23 UTC. Summary PR surface: Source +464, Tests +309, Docs +15. Total +788 across 19 files. Reproducibility: yes. for the patch defects: exact-head source gives deterministic paths for draft loss, archived-session actions, pending-run loss on route change, and stale popup teardown. The feature request itself is not a bug reproduction. Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Keep Do we have a high-confidence way to reproduce the issue? Yes for the patch defects: exact-head source gives deterministic paths for draft loss, archived-session actions, pending-run loss on route change, and stale popup teardown. The feature request itself is not a bug reproduction. Is this the best way to solve the issue? No in its current form; reusing Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 20fe3f46dbbe. Label changesLabel justifications:
Evidence reviewedPR surface: Source +464, Tests +309, Docs +15. Total +788 across 19 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (5 earlier review cycles)
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c3e46226c
ℹ️ 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".
| if ( | ||
| isTerminalChatState(payload?.state) && | ||
| typeof payload?.runId === "string" && | ||
| state.chatSideResultPending?.runId === payload.runId | ||
| ) { |
There was a problem hiding this comment.
Track superseded BTW terminal runs
When a user sends /btw A and then /btw B before A finishes, chatSideResultPending points only at B. If A terminates without chat.side_result, this guard misses because A's run id no longer equals the current pending run, so the event falls through to normal handleChatEvent and an idle pane can adopt the detached result/error into the main chat/status path. Fresh evidence in this revision is that the new swallow path tracks only state.chatSideResultPending?.runId; keep accepted detached BTW run ids tracked until their terminal event instead of only tracking the latest pending card.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b9c5f26f7
ℹ️ 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".
| onDismissSideResult: () => { | ||
| state.chatSideResult = null; | ||
| state.chatSideResultPending = null; |
There was a problem hiding this comment.
Keep dismissed pending BTW runs quarantined
When a user dismisses the Thinking… BTW card before the detached run finishes, this drops the only run id used by handleChatGatewayEvent to recognize resultless BTW terminal events. If that run later ends without chat.side_result (for example /btw before an existing Codex thread or a provider failure), the terminal chat event misses the pending guard and is handled as a normal chat event, so the BTW failure can appear in the main transcript/error path; remember the dismissed pending run and ignore its later side_result/terminal events instead of just nulling it.
Useful? React with 👍 / 👎.
| onAskSideChat: (selection) => { | ||
| const draft = buildSideChatComposerDraft(selection); | ||
| if (draft) { | ||
| props.onDraftChange(draft); |
There was a problem hiding this comment.
Avoid overwriting an unsent draft from the selection popup
If the composer already contains an unsent prompt, choosing Ask in side chat after selecting text replaces it with the generated /btw Regarding ... draft. handleChatDraftChange just assigns chatMessage, so the user's existing draft is lost without sending or confirmation; guard this action for non-empty drafts or insert/append the side-question text instead.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f000965ea
ℹ️ 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".
| @@ -556,6 +556,7 @@ export function resetChatStateForRouteSession( | |||
| state.chatSending = false; | |||
| state.chatSendingScopeKey = null; | |||
| state.chatSideResult = null; | |||
| state.chatSideResultPending = null; | |||
There was a problem hiding this comment.
Retire pending BTW runs when switching sessions
When a /btw side question is pending and the user changes sessions, this direct clear drops the generated run id instead of retiring it. If that detached run later terminates without chat.side_result (for example the missing-context/provider-failure path handled in handleChatGatewayEvent), the terminal chat event no longer matches chatSideResultPending or chatSideResultTerminalRuns; handleChatEvent can then cache the assistant error under the old session, so the BTW failure appears in the transcript after switching back. Retire the pending run before clearing it.
Useful? React with 👍 / 👎.
| @@ -1459,8 +1462,12 @@ class ChatPane extends OpenClawLightDomElement { | |||
| onQueueRetry: (id) => void state.retryQueuedChatMessage(id), | |||
| onQueueSteer: (id) => void state.steerQueuedChatMessage(id), | |||
| onGoalCommand: (command) => void state.handleSendChat(command), | |||
| onSideQuestion: (command) => void state.handleSendChat(command), | |||
There was a problem hiding this comment.
Gate side-question actions for archived sessions
Archived sessions set canSend false for the composer, but this unconditional selection-popup handler still calls handleSendChat('/btw ...') from an archived transcript. Selecting text and choosing More details (or Ask in side chat) can therefore issue a backend send or surface BTW pending/error UI despite the archived-session guard telling the user to restore before starting new work; omit or disable this action when the selected session is archived.
Useful? React with 👍 / 👎.
…less terminal runs
…nd ignore stale side results
…and suppress superseded runs
…reach the transcript
9f00096 to
aa8ea09
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa8ea0905c
ℹ️ 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".
| document.body.appendChild(popup); | ||
| activeSelectionPopup = popup; |
There was a problem hiding this comment.
Dismiss selection popup on pane teardown
Because this toolbar is portaled to document.body, it is no longer owned by the chat pane DOM once rendered. resetChatViewState()/resetChatThreadPresentationState() only clear the reply context menu, so if the pane is disconnected or the route/session changes without a document pointerdown first (for example browser navigation or programmatic pane changes), the stale popup can remain visible and its buttons still invoke the old render's onSideQuestion/onDraftChange closures for the previous selection. Please hook removeChatSelectionPopup() into the chat view/thread reset path.
Useful? React with 👍 / 👎.
… selection-popup test lint
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d4ca8b005
ℹ️ 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".
| state.chatSideResult = sideResult; | ||
| state.chatSideResultPending = null; |
There was a problem hiding this comment.
Gate side results against the pending run id
When this pane has a pending /btw run and another same-session side result arrives first, such as from a split pane showing the same session, this unconditionally installs that other result and clears the local pending card. Fresh evidence after the suppression change is that runs started in another pane are never retired into this state’s chatSideResultTerminalRuns, so the local run loses its quarantine; if it later finishes without chat.side_result, its terminal chat event can fall through normal transcript handling. Keep the pending card unless sideResult.runId matches the pending run, or otherwise suppress unrelated same-session BTW results while a local pending run exists.
Useful? React with 👍 / 👎.
| } | ||
| state.chatMessages = []; | ||
| state.chatSideResult = null; | ||
| state.chatSideResultPending = null; |
There was a problem hiding this comment.
Retire pending BTW runs when clearing history
If the user clears history while a /btw question is pending, this drops the only run id that identifies the detached run; the following lifecycle reconcile also clears the terminal-run suppression set. When that side run later aborts or errors without chat.side_result, it no longer matches either chatSideResultPending or chatSideResultTerminalRuns, so its terminal chat event can be handled as normal chat for the just-cleared session. Retire the pending run and preserve that suppression until its terminal event is swallowed.
Useful? React with 👍 / 👎.
|
Follow-up on the review feedback (PR landed before the last review rounds finished): Fixed before merge (during the pre-land review cycles on this branch):
Fixed on main in c071fcfeb67e6efc4127f79eb2266222633bd90a and c48cbabfc18ed549969399d13c6e97f27e937756:
All with regression tests (362 focused tests green), On the maintainer decision: both actions stay — "More details" (implicit instant |
…hat via /btw (openclaw#104205) * feat(control-ui): add chat selection popup with More details and Ask in side chat * fix(control-ui): keep BTW pending card visible and clear it on resultless terminal runs * fix(control-ui): route failed BTW runs to an error side-result card and ignore stale side results * fix(control-ui): correlate BTW pending cards by pre-generated run id and suppress superseded runs * fix(control-ui): retire abandoned BTW runs so late side events never reach the transcript * chore(docs): regenerate docs map for btw selection-popup section; fix selection-popup test lint
Closes #104204
What Problem This Solves
Digging into a specific phrase of an assistant reply required hand-writing a
/btwside question: retype the fragment, phrase the question, send. There was no fast path from "I don't understand this part" to an answer, even though the gateway already supports ephemeral side questions end to end.Why This Change Was Made
Adds a Codex-app-style selection popup to the Control UI chat, built entirely on the existing
/btwmachinery. Selecting text inside a chat bubble shows a floating toolbar with two actions: More details immediately sends an implicit/btw Explain "<selection>" from this conversation in more detail.and the answer arrives as the existing live side result; Ask in side chat pre-fills the composer with/btw Regarding "<selection>":so the user types their own question. Because/btwsends detached and previously gave zero feedback untilchat.side_resultarrived, the side-result panel now shows a pending "Thinking…" card from the moment the question is sent (also benefiting hand-typed/btw). Selection snippets are whitespace-collapsed and capped at 600 chars because/btwquestions are single-line. Non-goals: no popup on TUI/external channels, no "Add to task" action, no change to/btwserver semantics.User Impact
In the Control UI you can highlight any part of a chat message and either get an instant contextual explanation (never written to session history) or start a pre-quoted side question in the composer. Sending
/btwnow shows immediate pending feedback instead of silence.Evidence
chat.send/chat.side_resultroundtrip with a real Anthropic model): selection popup appears over the bubble, More details shows the pending card instantly and the BTW side result replaces it; Ask in side chat pre-fills the composer draft/btw Regarding "trust validation, s":and the typed question returns a side result labeled "Not saved to chat history".ui/src/lib/chat/side-question.test.ts(snippet collapsing/caps, command/draft builders),ui/src/pages/chat/components/chat-selection-popup.test.ts(popup show/dismiss, action routing, bubble scoping), pending-card render coverage inui/src/pages/chat/chat-composer.test.ts.pnpm check:changedgreen on Blacksmith Testbox; focused UI test shards green remotely.docs/tools/btw.mdsurface table updated (the "Control UI has no consumer yet" line was already stale) plus a new selection-popup section.Screenshots (live gateway, this branch)
Selecting text in an assistant reply shows the popup:
"More details" instantly shows the pending BTW card while the implicit
/btwruns:The live side result replaces it (never written to chat history):
"Ask in side chat" pre-fills the composer with a quoted
/btwdraft: