Skip to content

feat(control-ui): selection popup with More details and Ask in side chat via /btw - #104205

Merged
steipete merged 6 commits into
mainfrom
claude/side-chat-btw-feature-1d0336
Jul 11, 2026
Merged

steipete merged 6 commits into
mainfrom
claude/side-chat-btw-feature-1d0336

Conversation

@steipete

@steipete steipete commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #104204

What Problem This Solves

Digging into a specific phrase of an assistant reply required hand-writing a /btw side 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 /btw machinery. 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 /btw sends detached and previously gave zero feedback until chat.side_result arrived, 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 /btw questions are single-line. Non-goals: no popup on TUI/external channels, no "Add to task" action, no change to /btw server 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 /btw now shows immediate pending feedback instead of silence.

Evidence

  • Live-tested against a scratch gateway from this branch (vite dev UI + chat.send/chat.side_result roundtrip 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".
  • New unit tests: 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 in ui/src/pages/chat/chat-composer.test.ts.
  • pnpm check:changed green on Blacksmith Testbox; focused UI test shards green remotely.
  • Docs: docs/tools/btw.md surface 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:

Selection popup with More details and Ask in side chat

"More details" instantly shows the pending BTW card while the implicit /btw runs:

Pending BTW card

The live side result replaces it (never written to chat history):

BTW side result

"Ask in side chat" pre-fills the composer with a quoted /btw draft:

Composer prefilled with /btw draft

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: L maintainer Maintainer-authored PR labels Jul 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

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: 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".

Comment thread ui/src/pages/chat/chat-send.ts Outdated
Comment on lines +2186 to +2189
host.chatSideResultPending = {
question: extractSideQuestionDisplayText(message),
ts: Date.now(),
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

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: 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".

Comment thread ui/src/pages/chat/chat-send.ts Outdated
} 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 };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment on lines 321 to +322
state.chatSideResult = sideResult;
state.chatSideResultPending = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 4:23 AM ET / 08:23 UTC.

Summary
The branch adds a Control UI text-selection toolbar for immediate or drafted /btw questions, pending/error feedback for detached side runs, tests, styles, and documentation.

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
Relationship: fixed_by_candidate
Canonical: #104204
Summary: This PR is the direct implementation candidate for the paired feature issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦐 gold shrimp
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Fix the four current-head findings.
  • Attach redacted browser proof showing both actions, pending-to-result replacement, draft preservation, session switching, and teardown.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body claims a real scratch-gateway/model run but provides no inspectable current-head screenshot, recording, live output, logs, or linked artifact; add redacted proof, update the body, and request @clawsweeper re-review if a fresh review does not trigger automatically. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Mantis proof suggestion
After source blockers are fixed, the supported web UI chat lane can directly prove the selection and side-result lifecycle. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis web UI chat proof: verify and capture both selection actions, pending-to-result replacement, draft preservation, popup teardown, and session switching during a pending side question.

Risk before merge

  • [P1] An existing unsent composer draft can be silently discarded when Ask in side chat is selected.
  • [P1] Selection actions remain available in archived or otherwise non-composable sessions despite the composer being disabled.
  • [P1] Late detached /btw events can escape suppression after a session switch and be associated with cached transcript or status state.
  • [P1] A body-portaled popup can survive chat teardown and retain callbacks from the previous render.
  • [P1] No inspectable current-head real behavior proof demonstrates the visible flow or lifecycle edge cases.

Maintainer options:

  1. Repair lifecycle before merge (recommended)
    Fix draft preservation, compose gating, pending-run retirement, and popup teardown, then add exact-head browser proof.
  2. Narrow to draft-only
    Remove immediate sending and pending detached-run UI if maintainers prefer a smaller session-state surface.
  3. Pause the feature
    Close the PR if selection-driven side questions do not justify the added Control UI lifecycle complexity.

Next step before merge

  • [P1] The contributor must resolve the four findings and add inspectable proof before the protected maintainer product-direction decision; this is not safe automated repair routing.

Maintainer decision needed

  • Question: After the correctness blockers are fixed, should text selection immediately send an implicit More details model request, or only prefill a side-chat draft?
  • Rationale: The immediate action introduces a new implicit model invocation and user-facing interaction; the protected maintainer label requires explicit product ownership after technical readiness.
  • Likely owner: steipete — Recent merged work spans adjacent Control UI chat and Codex-session behavior, providing the strongest available product-direction routing signal.
  • Options:
    • Adopt both actions (recommended): Approve immediate and draft actions after all lifecycle fixes and current-head browser proof are complete.
    • Ship draft-only: Keep selection ergonomics but require the user to edit and explicitly send every side question.
    • Retain manual /btw: Decline the popup and keep the existing explicit command workflow.

Security
Cleared: The diff adds no dependencies, workflow permissions, secret handling, downloaded execution, package-resolution changes, or other concrete security or supply-chain concern.

Review findings

  • [P1] Preserve the existing composer draft — ui/src/pages/chat/components/chat-thread.ts:582
  • [P1] Disable selection actions when chat cannot compose — ui/src/pages/chat/chat-view.ts:241
  • [P1] Retire pending BTW runs before switching sessions — ui/src/pages/chat/chat-state.ts:559
Review details

Best possible solution:

Keep /btw as the sole backend path, but share the composer’s availability and draft-preservation rules, retire pending runs in the canonical route-session reset, remove the popup in the canonical view teardown, and attach exact-head browser proof before approving the interaction.

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 /btw is the narrowest backend design, but the UI implementation must reuse existing compose, draft, session-reset, and teardown ownership.

Full review comments:

  • [P1] Preserve the existing composer draft — ui/src/pages/chat/components/chat-thread.ts:582
    Choosing Ask in side chat replaces the current draft through onDraftChange without checking whether the user already has unsent text. Preserve, append to, or confirm replacement so this shortcut cannot silently discard work.
    Confidence: 0.99
  • [P1] Disable selection actions when chat cannot compose — ui/src/pages/chat/chat-view.ts:241
    The thread receives onSideQuestion even when props.canSend is false, while only the composer uses that availability guard. Archived or otherwise disabled sessions can therefore invoke More details or rewrite the draft despite the UI saying new work cannot start; omit the callback or pass the compose state into the popup.
    Confidence: 0.97
  • [P1] Retire pending BTW runs before switching sessions — ui/src/pages/chat/chat-state.ts:559
    Route-session reset directly nulls the pending card, losing the detached run id needed to suppress late resultless terminal events. Call the retirement helper before clearing so a failure from the prior session cannot later enter cached transcript or status handling.
    Confidence: 0.96
  • [P2] Remove the portaled popup during chat teardown — ui/src/pages/chat/components/chat-thread.ts:204
    The new toolbar is appended to document.body, but the canonical thread reset still removes only the reply context menu. Add removeChatSelectionPopup() to this reset so navigation or pane disconnect cannot leave a visible popup whose buttons call stale render closures.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 20fe3f46dbbe.

Label changes

Label justifications:

  • P3: This is optional Control UI ergonomics rather than a regression in a currently supported workflow.
  • merge-risk: 🚨 session-state: The patch has concrete detached-run and stale-view lifecycle gaps that can mis-associate UI or transcript state after merge.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body claims a real scratch-gateway/model run but provides no inspectable current-head screenshot, recording, live output, logs, or linked artifact; add redacted proof, update the body, and request @clawsweeper re-review if a fresh review does not trigger automatically. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +464, Tests +309, Docs +15. Total +788 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 13 474 10 +464
Tests 4 309 0 +309
Docs 2 16 1 +15
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 799 11 +788

What I checked:

Likely related people:

  • steipete: Recent merged history includes adjacent Control UI chat, session-diff, and native Codex-session work, so the PR author also has relevant current-main history beyond proposing this branch. (role: recent adjacent Control UI contributor and likely product decision owner; confidence: high; commits: 5b451b5d1c7a, 1d72c0f423c0, f94a7dc183c6; files: ui/src/pages/chat/chat-send.ts, ui/src/pages/chat/chat-view.ts, ui/src/pages/chat/chat-pane.ts)
  • Vincent Koc: Current-main blame attributes the central chat view reset, can-compose plumbing, and route-session reset structure to recent work that established the lifecycle boundaries this patch must preserve. (role: recent Control UI area contributor; confidence: medium; commits: 96b1be10f559; files: ui/src/pages/chat/chat-view.ts, ui/src/pages/chat/chat-state.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (5 earlier review cycles)
  • reviewed 2026-07-11T06:16:52.449Z sha 4b9c5f26f7453fee5896356c73e4168d8e7e54b4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-11T06:24:43.048Z sha 9f000965eab37b8b975d4f29c44b2bfa9a340cdf :: needs real behavior proof before merge. :: [P1] Preserve the existing composer draft
  • reviewed 2026-07-11T06:33:36.283Z sha 9f000965eab37b8b975d4f29c44b2bfa9a340cdf :: needs real behavior proof before merge. :: [P1] Preserve the existing composer draft | [P1] Disable selection actions for archived sessions | [P1] Retire pending runs before resetting sessions
  • reviewed 2026-07-11T06:57:33.045Z sha 9f000965eab37b8b975d4f29c44b2bfa9a340cdf :: needs real behavior proof before merge. :: [P1] Preserve the existing composer draft | [P1] Disable selection actions for archived sessions | [P1] Retire pending runs before resetting sessions
  • reviewed 2026-07-11T07:31:18.558Z sha aa8ea09 :: needs real behavior proof before merge. :: [P1] Preserve the existing composer draft | [P1] Disable selection actions when the session cannot compose | [P1] Retire pending BTW runs before switching sessions | [P2] Remove the portaled popup during chat teardown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

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: 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".

Comment on lines +289 to +293
if (
isTerminalChatState(payload?.state) &&
typeof payload?.runId === "string" &&
state.chatSideResultPending?.runId === payload.runId
) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

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: 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".

Comment thread ui/src/pages/chat/chat-pane.ts Outdated
onDismissSideResult: () => {
state.chatSideResult = null;
state.chatSideResultPending = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

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: 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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 11, 2026
@steipete
steipete force-pushed the claude/side-chat-btw-feature-1d0336 branch from 9f00096 to aa8ea09 Compare July 11, 2026 07:04

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

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: 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".

Comment on lines +104 to +105
document.body.appendChild(popup);
activeSelectionPopup = popup;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

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: 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".

Comment on lines 341 to +342
state.chatSideResult = sideResult;
state.chatSideResultPending = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@steipete
steipete merged commit 236d1b2 into main Jul 11, 2026
80 checks passed
@steipete
steipete deleted the claude/side-chat-btw-feature-1d0336 branch July 11, 2026 08:42
@steipete

Copy link
Copy Markdown
Contributor Author

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):

  • Pending BTW card cleared when an accepted run fails before chat.side_result (converted to an error side-result card, event swallowed) — ui/src/pages/chat/chat-gateway.ts
  • ACKs bound to their originating pending card via a pre-generated run id — ui/src/pages/chat/chat-send.ts
  • Stale side results ignored while a newer question is pending; superseded runs tracked — suppression set in ui/src/pages/chat/chat-gateway.ts
  • Dismissed pending runs quarantined (retirePendingChatSideQuestion) — ui/src/pages/chat/chat-pane.ts
  • Screenshots/proof added to the PR body before merge.

Fixed on main in c071fcfeb67e6efc4127f79eb2266222633bd90a and c48cbabfc18ed549969399d13c6e97f27e937756:

  • "Ask in side chat" no longer discards an unsent draft: prose drafts carry over as the question part (combineSideChatComposerDraft, newline-collapsed so the single-line /btw send loses nothing); slash-command drafts are replaced — ui/src/lib/chat/side-question.ts, ui/src/pages/chat/components/chat-thread.ts
  • Selection actions gated on canSend: archived/non-composable sessions get no popup — ui/src/pages/chat/chat-view.ts
  • Body-portaled popup removed on pane teardown/route change — resetChatThreadPresentationState in ui/src/pages/chat/components/chat-thread.ts
  • Pending BTW runs retired (not dropped) on session switch and clear-history, after the suppression-set wipe, so late resultless terminal events cannot enter cached or fresh transcripts — ui/src/pages/chat/chat-state.ts, ui/src/pages/chat/chat-history.ts
  • Same-session side results from other runs (split panes) no longer replace a live pending card or expose it to dismiss-retirement; their terminal events are still swallowed — ui/src/pages/chat/chat-gateway.ts

All with regression tests (362 focused tests green), check:changed green on Testbox, and a clean structured review on the final diff.

On the maintainer decision: both actions stay — "More details" (implicit instant /btw) and "Ask in side chat" (draft-only), per the feature direction in #104204.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Control UI: selection popup for instant /btw side questions (More details / Ask in side chat)

1 participant