Skip to content

feat(web): copy and add notes on text selected in agent pages - #1063

Merged
badcuban merged 1 commit into
mainfrom
fix/html-chat-text-actions
Nov 23, 2026
Merged

badcuban merged 1 commit into
mainfrom
fix/html-chat-text-actions

Conversation

@badcuban

Copy link
Copy Markdown
Collaborator

Selecting text in an agent page (a show_page page) did nothing, while text in the chat gets the Copy / Add note bar. Pages run in a sealed frame, so the app can't see a selection inside one.

How it works now:

  • The script every page runs under reports what the reader selected: the text, its box (cut to the page's own scroll boxes), and the page's viewport width. It reports after the reader's own click or key, again when the page scrolls or resizes, and when the selection is gone.
  • The transcript selection layer places the bar from that report. This works for pages inline in the chat and in the full-size view, at any zoom.
  • A report only opens the bar while the reader is in that page and in the window, so a page can't raise it by itself. A click with nothing selected in any page closes the bar, the same as a click elsewhere in the chat.
  • Highlights get a page source. The prompt block names the page by the id show_page gave the agent (- page <pageId>), and saved drafts accept it. Older drafts still load.
  • Escape anywhere in the note form closes only the note, not the full-size view around it. The full-size view keeps the page mounted behind Source, so a note being written isn't lost.

Known gap: selecting in a page within about 1.5s of typing in the app shows no bar. AgentPageFrame's focus guard treats that as the page taking focus and hands focus back. This is left as is on purpose.

Tests: new browser tests in AgentPageFrame.browser.tsx cover inline and full-size selection, zoom, a page's forged report, clicking into a second page, Escape on the note buttons, and Source keeping the note. There's also a prompt round-trip case in transcriptHighlightContext.test.ts. The existing transcript selection browser tests still pass.

Selecting text in an agent page did nothing, while chat text gets the
Copy / Add note bar. Pages run in a sealed frame, so the app cannot see
a selection inside one.

The page bootstrap now reports the reader's selection (text, its box cut
to the page's own scroll boxes, and the page's viewport width) after the
reader's own click or key, again on scroll and resize, and when it is
gone. The transcript selection layer places the bar from that report,
inside the chat and in the page's full-size view at any zoom. A report
only opens the bar while the reader is in that page and window, and a
click with nothing selected in any page closes it, as a click elsewhere
in the chat does.

Highlights gain a "page" source: the prompt names the page by the id
show_page gave the agent, and saved drafts accept it. Escape anywhere in
the note form closes only the note, and the full-size view keeps the
page mounted behind Source so a note being written survives.
@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
threadlines Skipped Skipped Nov 23, 2026 6:27pm UTC

Request Review

@badcuban
badcuban added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 3b849ac Nov 23, 2026
23 checks passed
@badcuban
badcuban deleted the fix/html-chat-text-actions branch November 23, 2026 18:40

This branch was previously deployed

1 inactive deployment
Preview — 79b33383 Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant