From 2a10550a02442bb7b9c437778894964af187b099 Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:56:06 +0000 Subject: [PATCH] Paste copied reply text as displayed in plain-text targets (#10079) * fix(app): preserve literal text in selection copy * fix(app): keep literal angle brackets in copied selection HTML Unwrapping a recognized URL left displayed text such as `` in the Markdown that feeds text/html. Turndown does not escape `<`, so the clipboard renderer turned it into an autolink and dropped the brackets. Escape `<` in the Markdown flavor. Describe the renderer/copy link contract in docs/markdown-renderer.md instead of restating the code. Co-authored-by: Dan Berindei Co-Authored-By: Claude Opus 5.5 * fix(app): keep recognized web links and table pipes in rich and plain copy Unwrapping recognized links in the shared copy DOM removed them from both clipboard flavors, so a copied `#12` lost its forge URL in rich paste. The renderer now marks recognized links with their own attribute: text/plain carries them as the text the reply showed, and text/html keeps them as links when they point to a web page. Workspace paths stay plain text in both. text/plain still emits tables as GFM syntax, so keep the cell-pipe escape in both flavors. Co-authored-by: Dan Berindei Co-Authored-By: Claude Opus 5.5 * fix(app): copy recognized Windows drive paths as text in rich paste The rich-paste link check accepted any URI scheme, so `C:\repo\x.ts` kept a link with an unopenable `C:` href. Keep recognized links in text/html only for http and https URLs. Co-authored-by: Dan Berindei Co-Authored-By: Claude Opus 5.5 * fix(app): keep split line-start Markdown literal in copied selection HTML Selecting from the `#` in `**C#**` to the end of the paragraph left `#` and ` for ...` as separate text nodes after unwrapping, so Turndown did not escape the heading marker and rich paste showed a heading. Merge the text nodes before serializing. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Dan Berindei Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- docs/markdown-renderer.md | 2 +- .../browser/assistant-selection-copy.spec.ts | 81 +++++++++++- .../content.browser.test.ts | 88 +++++++++++++ .../assistant-selection-copy/content.web.ts | 117 ++++++++++++------ .../src/assistant-selection-copy/markup.ts | 2 + .../src/components/markdown/renderer.test.ts | 9 +- .../markdown/renderers.web.browser.test.tsx | 61 +++++++++ .../src/components/markdown/renderers.web.tsx | 14 ++- .../app/src/components/markdown/source.ts | 12 +- packages/app/src/utils/rich-clipboard.test.ts | 35 ++++++ packages/app/src/utils/rich-clipboard.ts | 17 +++ 11 files changed, 386 insertions(+), 52 deletions(-) create mode 100644 packages/app/src/components/markdown/renderers.web.browser.test.tsx diff --git a/docs/markdown-renderer.md b/docs/markdown-renderer.md index 255d68e8e..1bde975d2 100644 --- a/docs/markdown-renderer.md +++ b/docs/markdown-renderer.md @@ -24,7 +24,7 @@ Math and video are disabled. Task lists and admonitions are enabled; task checkb Mermaid fences use the existing isolated diagram runtime and fullscreen viewer. Web dispatches them through the library’s code-block override. Native has no block-renderer hook, so the renderer extracts only Mermaid fences and places the existing WebView host between library-rendered segments. This is the only block exception; see [native selection limitations](native-text-selection.md) for diagram grouping and leading inline images. Streaming keeps the last valid diagram visible while the next revision renders. -Native code blocks use the library's copy control and compiled grammars. Web code blocks use `HighlightedCodeBlock` through the library's `renderers.codeBlock` override. The patch also keeps the library's block spacing around the web code block override, preserves web list numbering and link titles, marks pending parses with `aria-busy` so Find waits for rendered text, and carries link syntax through native and web tap events. Web inline code inside a link inherits only the link colour; its code font, size and background stay intact. Keep link variants colour-only: native pills replace text runs and prevent paths from wrapping; Android pills also use the surrounding block’s font size. The package patch is tracked by [upstream PR #997](https://github.com/software-mansion/enriched-markdown/pull/997); remove the patch when the pinned release includes it. +Native code blocks use the library's copy control and compiled grammars. Web code blocks use `HighlightedCodeBlock` through the library's `renderers.codeBlock` override. Selection copy has to tell links Paseo recognized in the text (paths, forge references, code spans) from links in the Markdown, so the web link renderer marks the recognized ones. Plain-text paste carries them as the text the reply showed, and rich paste keeps them as links only when they point to an `http` or `https` URL. Authored links and parser autolinks such as a bare `www.example.com` copy as links. The patch also keeps the library's block spacing around the web code block override, preserves web list numbering and link titles, marks pending parses with `aria-busy` so Find waits for rendered text, and carries link syntax through native and web tap events. Web inline code inside a link inherits only the link colour; its code font, size and background stay intact. Keep link variants colour-only: native pills replace text runs and prevent paths from wrapping; Android pills also use the surrounding block’s font size. The package patch is tracked by [upstream PR #997](https://github.com/software-mansion/enriched-markdown/pull/997); remove the patch when the pinned release includes it. The package patch also keeps overflowing native horizontal blocks in control of their drags: Android claims parent interception at touch-down and releases it for vertical drags so the chat list can scroll; iOS keeps its scroll recognizer active for outward drags at the leading edge. This prevents compact sidebar pans from taking block scrolling without changing sidebar swipes on prose or non-overflowing blocks. Native changes require a client rebuild. diff --git a/packages/app/e2e/browser/assistant-selection-copy.spec.ts b/packages/app/e2e/browser/assistant-selection-copy.spec.ts index 0703ff134..98f23660b 100644 --- a/packages/app/e2e/browser/assistant-selection-copy.spec.ts +++ b/packages/app/e2e/browser/assistant-selection-copy.spec.ts @@ -72,14 +72,12 @@ const ASSISTANT_MARKDOWN = [ "| Current \\| active | ~~obsolete~~ | ready |", ].join("\n"); -const EXPECTED_WHOLE_SELECTION_MARKDOWN = ASSISTANT_MARKDOWN.replace( +// text/plain carries the selection as displayed, so an inline code span the renderer +// linked copies without its destination. +const EXPECTED_WHOLE_SELECTION_TEXT = ASSISTANT_MARKDOWN.replace( "www.example.com stays", "[www.example.com](http://www.example.com) stays", ) - .replace( - "`https://example.com/generated` stays", - "[`https://example.com/generated`](https://example.com/generated) stays", - ) .replace(`${CROSS_STRUCTURE_MARKDOWN}\n\n`, "") .replace( "", @@ -422,7 +420,7 @@ test("copying an assistant selection preserves Markdown structure and links", as await copySelection(page); const clipboard = await readRichClipboard(page); - expect(clipboard.plainText).toBe(EXPECTED_WHOLE_SELECTION_MARKDOWN); + expect(clipboard.plainText).toBe(EXPECTED_WHOLE_SELECTION_TEXT); expect(clipboard.html).not.toContain("