Skip to content

feat(ui): ask follow-up questions about selected answers - #2837

Merged
esokullu merged 8 commits into
webbrain-one:mainfrom
alectimison-maker:feat/selection-quote-follow-up
Aug 18, 2026
Merged

feat(ui): ask follow-up questions about selected answers#2837
esokullu merged 8 commits into
webbrain-one:mainfrom
alectimison-maker:feat/selection-quote-follow-up

Conversation

@alectimison-maker

@alectimison-maker alectimison-maker commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add an Ask WebBrain a question action when text is selected inside an assistant answer.
  • Insert the selected text as an editable quote in the existing composer without sending automatically.
  • Mirror the behavior across Chrome and Firefox.

Motivation

Users currently need to copy part of a long WebBrain answer manually before asking a follow-up. This PR implements the design agreed in #2836 and keeps the reading-to-follow-up flow in the side panel.

Design

The side panel observes selections and accepts only ranges contained in one assistant .message-text element. A localized, accessible floating button is positioned near the selection. Clicking it builds a plain-text Markdown quote in the existing textarea, preserves any existing draft after the quote, focuses the composer, and places the caret at the end. The action is coalesced onto one animation frame, rejects detached ranges, and is dismissed on selection changes, outside interaction, scrolling, resizing, send, Escape, tab changes, and conversation clears. No background protocol, persistence format, or model request changes are required.

Testing

  • node test/run.js — 1827 passed; 1 unrelated pre-existing failure: the stale Opera-safe flag license filename assertion expects a 32.1.0 archive while the checked-in archive is 32.0.0.
  • npm run test:toolbar-guard — passed (33 tests).
  • npm run test:security — passed (60/60 checks).
  • node --check on both sidepanel and selection-quote modules — passed.
  • Targeted full review against upstream/main — no blocking findings after fixing stale-range, rAF/layout, localization, and Escape lifecycle issues.
  • Chrome MV3 unpacked extension check — passed: localized Chinese action rendered, selection action was clickable, quote appeared in the textarea, action dismissed, and console/errors were empty.
  • Firefox manual browser check — unavailable in this environment.

Compatibility and risks

This is a local UI-only change. Assistant text is inserted through the textarea value, not HTML, so selected markup remains literal text. The quote action does not auto-submit. Chrome was manually exercised; Firefox parity is covered by mirrored source and focused tests but was not manually exercised.

Scope

Richer quote chips, persistent answer anchors, automatic send, and cross-turn answer navigation are intentionally deferred.

Closes #2836

@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown

@alectimison-maker is attempting to deploy a commit to the esokullu's projects Team on Vercel.

A member of the Team first needs to authorize it.

@esokullu

Copy link
Copy Markdown
Collaborator

great idea! looking into it.

Wait until pointerup before showing the chip so a downward drag does not hit the button, write the label only when it changes, and omit in-bubble chrome such as Copy from quoted text.

Co-authored-by: Cursor <cursoragent@cursor.com>
@esokullu

Copy link
Copy Markdown
Collaborator

Review findings (fixed in bde18a6)

Pushed follow-up commit bde18a66 (fix(ui): harden selection quote follow-up action) to address the review on this PR.

P1 — Wait for pointerup before showing the quote action
The chip was scheduled from selectionchange during an in-progress drag, and positionSelectionAskAction placed it 6px below the live range. A downward select could land on the button, extend the range out of .message-text, and dismiss the action. The chip now waits for pointerup / pointercancel (keyboard selection still uses selectionchange / keyup), and .selection-ask-action is user-select: none.

P2 — Do not rewrite a live region on every refresh
The button had aria-live="polite" and textContent was assigned on every refresh, including each animation frame while the selection changed. Removed aria-live. The label is written only when the locale or text actually changes.

P3 — Exclude in-bubble chrome from quoted text
selection.toString() included Copy buttons, code headers, and language labels inside .message-text. Quote text now walks the range and skips that chrome.

node test/run.js: 1828 passed. The remaining failure is the pre-existing Opera archive filename mismatch, unrelated to this change.

@esokullu
esokullu merged commit e421f56 into webbrain-one:main Aug 18, 2026
1 of 2 checks passed
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.

Design: ask follow-up questions about selected answer text

2 participants