Repository navigation
Description
Part of #769. Land this first: #771, #772 and #773 edit the same file and run their tests on top of it.
Summary
With autolink: true, formatting part of a link removes the link from part of its text. Bold over ple. in the link example.com leaves a plain exam and a link that holds only ple.com. The pad sets autolink: true (apps/webapp/src/components/TipTap/TipTap.tsx:233). The chat composer sets it too (apps/webapp/src/components/chatroom/components/MessageComposer/hooks/useTiptapEditor.ts:184). It is also the extension default (extensions/extension-hyperlink/src/hyperlink.ts:235). So every pad and every chat message can hit it. Upstream @tiptap/extension-link keeps the whole link.
Reproduce
- Open any pad.
- Type
see example.com(the space turns it into a link). - Select
ple.inside the link and pressMod-b. - Today:
examis plain text, and onlyple.comis linked. Expected: all ofexample.comstays one link, withple.bold.
The same happens with italic, strike, underline and inline code, with bold over two links at once, and with plain typing inside a link that already holds a bold part (from Markdown import, HTML paste or an earlier bold).
Cause (read from code)
extensions/extension-hyperlink/src/interactions/autolink.ts, the strip pass (lines 43-73 after the fix).
getMarksBetweenreturns one entry per text node. Another mark splits one link into several text nodes.- The old code took
newMarks[0], the first text node only, and read its text (exam). urls.detect('exam')is false, so the pass removed the link from that piece.
Fix (ready in the working tree, not committed)
Candidate "c2" from the review. It needs both parts. Each part alone fails 2 of 17 review cases.
- Read the whole link on both sides with
getMarkRange(doc.resolve(pos), type, attrs), not one text node. - Skip when the mapped text of the old link equals its new text, joined with
'\n'between blocks. A mark-only change keeps the text, so the link stays. The'\n'makes a split into two blocks count as a text change.
Files:
extensions/extension-hyperlink/src/interactions/autolink.ts: the fix (+14 / −4 lines).extensions/extension-hyperlink/src/interactions/__tests__/autolink.test.ts: 13 new cases.extensions/extension-hyperlink/CHANGELOG.md: aFixedline and anInternalline under[Unreleased].extensions/extension-hyperlink/scripts/bench/: the package bench (see Benchmark). The maintainer asked for it to land with this issue.
Benchmark
| Field | Value |
|---|---|
| Metric | Behaviour cases passing (18 jsdom cases, scripts/bench/behaviour.ts). Bytes a StarterKit app pays for Hyperlink (min / gzip). Six jsdom speed workloads, median of 9 rotated rounds. |
| Before | 5 / 18 cases. 70,854 / 25,213 B. Speed: see the bench table. All on main at 9f132692e, 2026-11-12. |
| After | 16 / 18 cases (the 2 left belong to #772). 70,997 / 25,258 B (+143 / +45). Speed: every workload inside the control noise band, except boldPartOfLink −26 %, where the fix does less work and changes the output by design. Working tree, 2026-11-12. |
| Confounds | None. Only src/interactions/autolink.ts changed. |
| Condition | jsdom on Bun 1.4.4, darwin arm64, one laptop. esbuild minify, Bun zlib level 9. |
| How to run | From extensions/extension-hyperlink: NODE_ENV=production bun scripts/bench/run.ts (before commit, base = main). After commit: --ref <commit>~1. |
| Pass rule | Behaviour count rises; no speed row moves outside the control band; bytes stay under +100 B gzip for a StarterKit app. |
| Guard | The UX contract below. |
| Owner | Agent in the repo: code, tests, bench, CHANGELOG. Maintainer: the chat-composer check and the production pad check after deploy. |
| Claim | "Formatting part of a link keeps the whole link (16 of 18 behaviour cases, from 5)." No speed claim. |
UX contract
Behaviour that must not change, and the check that proves it:
- A broken URL still loses its link: deleting
.comremoves it (unit test). - A space typed inside a link keeps the whole link, as today and upstream (unit test).
- A custom label such as "click here" stays linked when part of it is bold (unit test).
- Code still removes the link where it lands, because the code mark excludes other marks (unit test).
- One
Mod-zafter the bold gives back the plain link in one step. One redo gives back the bold with the whole link (unit test withprosemirror-history; real keys in the playground). - Pad (y-undo, link icons on):
Mod-b,Mod-z,Mod-Shift-zon part of a link keep one whole link, and the selection stays put (localdev-local, 2026-11-12). - Two tabs on one pad: a bold and an italic from one tab show the same single link in the other (local
dev-local, live Hocuspocus, 2026-11-12). -
Mod-kinside a split link opens the preview for the whole link (playground). - Chat composer (
prosemirror-history): bold part of a link, undo, redo. The link stays whole. Not checked in the webapp yet. - Production pad after deploy: the reproduce steps above.
Acceptance checks
-
src/interactions/__tests__/autolink.test.ts: 13 cases. With the fix reverted, 9 fail; with it, 0 fail (sabotage proof). -
bun run test:unit: 453 of 453 pass. -
bun run typecheckis clean. ESLint and Prettier are clean on every changed file. - Full package Cypress suite,
env -u ELECTRON_RUN_AS_NODE bun run test:e2e: 289 of 289 pass across 23 specs. -
dist/index.d.tscannot change: the diff touches no export (read from code). - Chat composer check above.
- Commit through the
commit-reviewskill, then post the bench table from--ref <commit>~1in a comment. - After deploy: the production pad check, then close.
Out of scope
- Enter inside a link: Hyperlink: decide what Enter inside a link does #778 (needs a ruling). The fix keeps today's behaviour there.
- Autolink rewrites a custom href: Hyperlink: keep a custom href when autolink runs over an existing link #772.
- A peer brings back a removed link: Hyperlink: keep a removed link removed when a peer edits the pad #771.
- Faster autolink: Hyperlink: cut autolink cost on big pastes and select-all formatting #773.
Activity
HMarzban commentedon Nov 12, 2026
Measured (2026-11-12, working tree, not committed yet)
Package bench, base =
mainat9f132692e, head = working tree with the fix:base =
main, head = working tree. jsdom on Bun 1.4.4, darwin arm64, 9 rounds, 2026-11-12T15:48:47.688Z.A speed change smaller than the control's is noise.
dist/index.js(min / gz)normalizeHref-only import (min / gz)Still failing on head: href: custom href after a space; href: custom href after bold 1-13.
Checks run:
src/interactions/__tests__/autolink.test.ts13 cases; 9 fail with the fix reverted, 0 with it.bun run test:unit453 / 453.env -u ELECTRON_RUN_AS_NODE bun run test:e2e).Mod-bonple.,Mod-z,Mod-Shift-z, thenMod-kon the split link. One whole link throughout; selection unchanged.dev-local, y-undo, link icons on): the same keys; one whole link; one undo step.Still owed: the chat composer check in the webapp, the commit, and the production pad check after deploy.
HMarzban commentedon Nov 12, 2026
Chat composer check: needs a signed-in user
On a local
dev-localpad, a signed-out visitor gets no chat composer, so the composer check (bold part of a link,Mod-z,Mod-Shift-z) needs a signed-in account. The composer usesprosemirror-history, the same undo route the playground check and the unit tests cover, and both pass. Owner: maintainer, on a signed-in local or staging session.HMarzban commentedon Nov 12, 2026
Committed
c9cd2c98aonmain, 2026-11-12, not pushed yet. One commit holds #770, #772, #773 and #776 together, by the maintainer's choice, so it cites each withRefs, and none closes on push. It is the same code the measured comments above describe.Open before this issue closes:
Mod-z,Mod-Shift-z.HMarzban commentedon Nov 12, 2026
The bench table against the commit's parent (
--ref c9cd2c98a~1) is on the tracking issue: #769 (comment). Behaviour 5 / 18 → 18 / 18 for the whole commit.HMarzban commentedon Nov 12, 2026
In-app check at
c9cd2c98a(2026-11-12, local webapp:3001)Setup: headless Chrome for Testing 158.0.8127.18 (build 1254), Playwright 1.64.1, Bun 1.4.4, Apple M5 Max, 1440x900. A local test user was signed in. All keys were real keyboard events.
In the chat composer:
see example.comautolinks it.ple.and pressing Mod-b gives one link holdingexam<strong>ple.</strong>com.ple.through all three steps.This passed in 6 of 6 sessions, plus 2 of 2 verifier re-runs: 8 of 8 in total.
Negative control. The verifier rewrote the served autolink chunk to the parent logic. With that, the check failed in 0 of 2 sessions. Bold gave
<strong>ple.</strong>comwithexamunlinked, which is the #770 symptom. This is not the parent build, because other HEAD code still ran.The app runs the fix. The served chunks hold the whole-link
getMarkRangeand the same-text skip fromc9cd2c98a.Earlier jsdom result (wf3): the parent gave
exam[ple] ¶ [.com], andc9cd2c98agivesexample ¶ [.com](Enter at pos 8).Limits:
The issue's Owner row gives the chat-composer check to the maintainer, so this is evidence for that tick. The production pad check after deploy is still owed.
Raw data: local workflow folders
wf4/p3-signed-in-ux(runs 7–12) andwf4/v-p3-signed-in-ux(v1, v2, s1, s2).fix(extension-hyperlink): keep links intact when autolink runs
perf(webapp): load HyperlinkBase in the pad and composer
ci: fail an extension-hyperlink PR above its byte budget
docs(extension-hyperlink): count 20 bench cases and exact bytes
docs(extension-hyperlink): name the code mark that still drops a link
HMarzban commentedon Nov 16, 2026
Production check, 2026-11-16. docs.plus at
b7888dce1(deployed 2026-11-15). Chrome on macOS, signed in. One scratch pad, never/demo. Each result was read from the editor DOM after the action. n = 1.see example.com, selectple., Mod-bhttps://example.com, textexample.com,ple.bold inside itBoth acceptance boxes pass on the live build. The fix is
c9cd2c98a, live since3d90636a9(2026-11-13) and still inb7888dce1. Release credit v2.3.8. Closing as done.