Skip to content

feat(desktop): pasting a link over selected composer text now hyperlinks it - #96034

Open
teknium1 wants to merge 1 commit into
mainfrom
buzz-port/composer-link-paste-selection
Open

feat(desktop): pasting a link over selected composer text now hyperlinks it#96034
teknium1 wants to merge 1 commit into
mainfrom
buzz-port/composer-link-paste-selection

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Pasting exactly one http(s) link while composer text is selected now turns that text into a markdown link ([selected text](url)) instead of replacing it — the behavior every rich text editor ships. Ported from block/buzz#6684.

Changes

  • apps/desktop/src/app/chat/composer/url-refs.ts
    • resolveExactLinkPaste() — recognizes a clipboard payload that is exactly one supported link (bare or <…>-wrapped, host required, no surrounding prose or trailing sentence punctuation) and returns the href.
    • selectionLinkLabel() — the selected composer text eligible for linking; rejects collapsed selections, selections outside the editor, selections spanning ref chips or line breaks, and whitespace-only selections.
    • markdownLinkFor() — builds the markdown link, escaping [/] in the label.
  • apps/desktop/src/app/chat/composer/index.tsxhandlePaste checks the pair ahead of the @url: chip path; any non-qualifying paste (prose, multiple links, chip/multiline selection, no selection) falls through to existing behavior unchanged.
  • apps/desktop/src/app/chat/composer/url-refs.test.ts — 13 new tests covering accept/reject shapes for all three helpers.

Ours vs theirs

Buzz's composer is TipTap/ProseMirror, so their implementation applies a link mark over the selection and collapses the caret. Hermes' composer is a contenteditable with its own chip/ref pipeline — the natural equivalent is emitting a markdown link through insertComposerContentsAtCaret (replacing the selection), which round-trips through the draft store and renders as a link downstream. Their deep-link canonicalization is Buzz-specific and was not ported; our recognizer reuses the composer's existing URL_RE/splitUrlTail/hasHost primitives so link acceptance stays consistent with the @url: chip path.

Validation

Check Result
vitest --project ui url-refs.test.ts 22/22 pass (13 new)
vitest --project ui src/app/chat/composer/ 47 files, 389/389 pass
tsc -p . --noEmit clean
eslint on touched files clean

Infographic

Paste a link, keep your words

…aste

Pasting exactly one http(s) link while composer text is selected now
turns the selection into a markdown link ([selected text](url)) instead
of replacing it — the behavior every rich text editor ships.

- resolveExactLinkPaste(): recognizes a clipboard payload that is exactly
  one supported link (bare or <...>-wrapped, host required, no prose or
  trailing punctuation) and returns the href.
- selectionLinkLabel(): the selected composer text eligible for linking;
  rejects collapsed selections, selections spanning ref chips or line
  breaks, and whitespace-only selections.
- markdownLinkFor(): builds the markdown link, escaping square brackets.
- handlePaste wires the three together ahead of the @url: chip path;
  any non-qualifying paste falls through to existing behavior.

Adapted from Buzz's TipTap link-mark approach to Hermes' contenteditable
composer: we emit a markdown link (the composer's native rich construct)
rather than a ProseMirror mark.
@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on d76bd67 — Port from block/buzz#6684: hyperlink selected composer text

⚠️ Warnings

OSV vulnerability scan · View job

6 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 1m59s vs 4m16s (-53.5%). 2 job(s) slower, 3 faster, 1 unchanged.

  • JS & TS checks / JS & TS checks: -21.0s
  • OSV scan / Scan lockfiles / osv-scan: -17.0s
  • All required checks pass: +2.0s
  • OSV scan / Emit review status: -1.0s
  • Check no committed infographics / check-no-committed-infographics: +1.0s

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/desktop Electron desktop app (apps/desktop/*) labels Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants