fix(web): copy final code block lines as plain text - #8044
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
There was a problem hiding this comment.
Pull request overview
Fixes web clipboard handling so final or single-line code selections copy as plain code instead of fenced Markdown.
Changes:
- Detects code selections trailing only whitespace outside
<pre>. - Preserves Markdown serialization when selections extend into prose.
- Adds focused unit tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
apps/web/src/markdown-clipboard.ts |
Implements plain-text handling for eligible code selections. |
apps/web/src/markdown-clipboard.test.ts |
Tests contained, final-line, and prose-spanning selections. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ccd2921. Configure here.
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused clipboard bug fix that changes only how code-block selections are classified, preserving Markdown serialization for selections that extend into prose. The added unit tests cover the new final-line behavior and the surrounding fallback cases. You can add or adjust custom eligibility rules. Learn more. |
|
Note 🤖 GPT-6 Astra (preview) responding on behalf of Theo This was closed as part of an automated cleanup pass. If you believe it was closed in error, reply here and we will get it reopened. Closing because #8448 already fixes this on This no longer needs a separate implementation. |

Fixes #8042.
Triple-clicking the final or only line of a code block can place the selection's trailing boundary outside
<pre>. The clipboard handler then serializes the partial block back into fenced Markdown.Treat the selection as plain code when it starts inside
<pre>and contains no non-whitespace text after the block. Selections that continue into prose still use the Markdown serializer.Tests:
vp test run --project unit src/markdown-clipboard.test.ts(6 passed)vp run --filter @t3tools/web typecheckBuilt with GPT-5.6-Sol using the Codex harness.
Note
Low Risk
Clipboard behavior change in the web markdown copy path; logic is narrow and covered by new unit tests, with intentional fallback when selections span code and prose.
Overview
Fixes clipboard copy when a code selection’s trailing boundary sits outside
<pre>(e.g. triple-click on the last line), which previously forced fenced Markdown on paste.Adds
plainTextForCodeSelectionso copy usesrange.toString()when the range is fully inside a<pre>, or when it starts in<pre>and nothing meaningful follows the block (whitespace-only trailing content). If the selection continues into prose or other nodes, the helper returnsnullandchatMarkdownClipboardPayloadkeeps using markdown serialization.Unit tests cover in-
<pre>selections, final-line boundary cases, and mixed code+prose selections.Reviewed by Cursor Bugbot for commit 36a3a20. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix copying final code block lines as plain text in web client
Adds
plainTextForCodeSelection(range)to markdown-clipboard.ts, which returnsrange.toString()when a selection is fully within a<pre>or only its trailing boundary exits the block with no following content. Otherwise it returnsnullso the caller falls back to markdown serialization. UpdateschatMarkdownClipboardPayloadto use this helper instead of the prior inlineclosest('pre')check.Macroscope summarized 36a3a20.