Skip to content

Copy visible text for code, formatted spans and plain prose selections - #6487

Merged
ymichael merged 3 commits into
mainfrom
slopcop/issue-6484
Oct 28, 2026
Merged

ymichael merged 3 commits into
mainfrom
slopcop/issue-6484

Conversation

@bb-slop-cop

@bb-slop-cop bb-slop-cop Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · new-issue-autopilot

Human comments

What was wrong

Selection copy writes Markdown to text/plain, so Markdown syntax leaked into pastes where people expect the visible text (the same class as #6376 and #5776):

  • Inline code (Regression in 0.47.1: copying an inline code span from the timeline includes the backticks #6484): copying a code-only selection such as valet restart nginx pasted `valet restart nginx`. Only pre bypassed the serializer.
  • Formatted spans: copying a word inside bold, italic, strikethrough or a link pasted **important** or [deployment](https://example.com/deploy).
  • Prose escapes: escapeText escaped every \ ` * _ [ ] < >, so copying config_loader.py, C:\Users\me\notes.txt or x < y, arr[0] pasted config\_loader.py, C:\\Users\\me\\notes.txt and x \< y, arr\[0\]. It also turned <https://example.com> into <https://example.com\>, which re-renders as the wrong URL.

What changed

  • selectionClipboard copies the visible text when the whole selection sits inside one pre, inline code, link, strong/b, em/i or del/s span. Wider selections, cross-message selections and Add to chat keep Markdown. Math inside such a span still copies as TeX, because KaTeX's hidden duplicate layout would otherwise be pasted twice.
  • escapeText escapes a character only where Markdown would reinterpret it: _ unless between letters or digits, \ before punctuation or at the end, [ and > at line start, ] before (, [ or :, < before a tag or autolink start, and always ` and *.
  • Rich HTML is unchanged. No public API, wire, schema or storage changes.

How you verified

  • Real app (pnpm start:worktree, headless Chromium, real mouse triple-click, double-click and drag on an agent reply, reading the copy event's text/plain), main compared with this branch:

    Selection main this PR
    triple-click / drag valet restart nginx `valet restart nginx` valet restart nginx
    double-click my_old_var in prose my\_old\_var my_old_var
    Open C:\Users\me\notes.txt paragraph C:\\Users\\me\\notes.txt C:\Users\me\notes.txt
    x < y and y > z, arr[0] paragraph x \< y and y \> z, arr\[0\] unchanged text
    double-click a bold word **important** important
    word inside a named link [deployment](https://example.com/deploy) deployment
    paragraph mixing prose, bold and italic, lists, quotes, tables, whole message Markdown unchanged Markdown
  • New tests: visible-text copy for every span type across five selection shapes; a round trip that copies tricky prose, re-renders the copied Markdown and requires the same text (fails on main for the over-escaped cases and the autolink); math inside bold (fails without the math guard). Four existing tests that pinned the old Markdown-around-a-span output were updated.

  • pnpm exec turbo run test --filter=@bb/app -- src/components/thread/timeline src/components/secondary-panel src/lib src/components/ui/markdown-preview: 215 files, 2173 passed. pnpm exec turbo run lint typecheck --filter=@bb/app passes.

  • Not verified: native Cmd+C in bb Desktop or Android (same DOM copy path).

Fixes #6484

AGENT GENERATED

🤖 Generated with Claude Code

ymichael and others added 2 commits October 28, 2026 16:12
Selection copy escaped every `_ [ ] < > \` in prose, so copying
config_loader.py, C:\Users\me or arr[0] pasted backslashes. Escape a
character only where Markdown would otherwise reinterpret it, and check
that copied prose renders back to the same text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copying a word inside bold, italic, strikethrough or a link pasted its
Markdown (**word**, [word](url)), the same problem #6484 had with inline
code. Copy the visible text whenever the selection stays within one such
span, and keep Markdown for wider selections and Add to chat.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael ymichael changed the title Copy raw text for code-only selections Copy visible text for code, formatted spans and plain prose selections Oct 28, 2026
@ymichael
ymichael merged commit 0950d00 into main Oct 28, 2026
31 checks passed
@ymichael
ymichael deleted the slopcop/issue-6484 branch October 28, 2026 23:46
@polevaultweb

Copy link
Copy Markdown

Thanks folks! 🎉

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.

Regression in 0.47.1: copying an inline code span from the timeline includes the backticks

3 participants