Repository navigation
Description
Part of #769. Depends on #771: its remote skip must also gate the new path. Priority: low.
Summary
Autolink checks only the last word before the whitespace that ends an insert. Typed key by key, each word ends in its own transaction, so every URL gets checked. One transaction that inserts a whole phrase is different: a URL in its middle is never linked. Dictation, an IME phrase commit and macOS text replacement can insert one chunk. That last part is read from code only. Upstream @tiptap/extension-link 3.32.2 has the same rule. So this is old behaviour, not a regression.
Reproduce
On the local stack, on a new scratch pad. Never use /demo.
- Put the caret at the end of an empty paragraph.
- Insert
see example.com nowas one chunk. In Playwright:page.keyboard.insertText('see example.com now '). example.comstays plain text.- Type the same text key by key on a new line.
example.combecomes a link.
With the URL last (go to example.com ), both paths link.
Measured (before)
| Case | Linked | Condition | n |
|---|---|---|---|
Pad, one-chunk insertText of see example.com now |
0 of 10 | local webapp :3001, next dev, c9cd2c98a, headless Chrome for Testing 158, one fresh pad per run |
5, then 5 by a verifier |
| Pad, CDP IME phrase commit, same text | 0 of 10 | same | 5 + 5 |
| Pad, key by key (control) | 10 of 10 | same | 5 + 5 |
| Pad, URL last, each chunk path (control) | 5 of 5 | same | 5 |
Pad, key-type more after the miss |
0 of 20 | same, plus a 1.8 s wait | 20 |
Scratch Tiptap page, one-chunk insertText |
0 of 5 Chromium, 0 of 5 WebKit 27.2 | package scratch page | 5 each |
| Scratch Tiptap page, review prototype | 5 of 5 in each engine | same | 5 each |
Not tested: Enter, blur, edits inside the URL, and reload after the miss.
Raw files (local, gitignored): Notes/local-docs/2026-11-12-hyperlink-bundle/wf4/evidence/p5-chunked-pad/out-2026-11-12T20-49-50-291Z/raw.json, wf4/evidence/v-p5-chunked-pad/out-2026-11-12T20-53-10-560Z/raw.json, wf3/evidence/v-e13/browser-chromium.json and browser-webkit.json. Re-run on a pad: cd wf4/evidence/p5-chunked-pad && bun chunked-pad.ts --n 5.
Cause (read from code)
extensions/extension-hyperlink/src/interactions/autolink.ts:86-108(working tree with Hyperlink: keep a removed link removed when a peer edits the pad #771): the one-block path runs only when the inserted range ends in whitespace. Then it checks onlylastWordBeforeSpace.- Upstream
@tiptap/extension-link3.32.2src/helpers/autolink.ts:139-155has the same rule. - prosemirror-view builds one transaction from one DOM change. So a phrase that arrives in one input event is one insert. This covers dictation, an IME commit and text replacement. Read from code only.
Fix (proposal)
Try a smaller fix first. The bar is the prototype below.
The review prototype (wf3/evidence/e13-chunked-input/proto-final.diff) scans every finished word that touches a local one-block insert. Everything else keeps the last-word rule. The new path has five guards:
- Skip paste and drop (
uiEvent). The paste rule already links those. - Only
ReplaceSteps. A mark step is not an insert. A draft without this guard and the scroll guard made Bold 32 % slower. - Only transactions with
scrolledIntoView. prosemirror-view sets it for typed and dictated input.setContentandinsertContentdo not set it. - Not history (
isHistoryTransaction), and not remote. - Stop after the last whitespace, because the next word may still be typed.
Why it depends on #771. The prototype tests getMeta('y-sync$'). The app's key is y-sync$1, so that guard never fires in the app. The #771 early return skips only a batch where every transaction is remote. So the new path needs a per-transaction check. Export one from src/interactions/remoteSync.ts and reuse it. Do not test the key string again.
Prototype costs (before #771, scratch page and jsdom):
| Row | HEAD | Prototype | Change | Condition |
|---|---|---|---|---|
| StarterKit app (min / gzip B) | 70,776 / 25,582 | 71,331 / 25,816 | +555 / +234 | bench run.ts, exact |
npm dist/index.js (min / gzip B) |
57,013 / 20,861 | 57,681 / 21,145 | +668 / +284 | same |
| 200 dictated sentences, no URL (µs per insert) | 28.821 | 18.649 | −35.3 % (re-run −34.7 %) | jsdom, 21 rounds, twice; A/A −1.1 % |
| 200 sentences with a mid URL (µs per insert) | 27.529 | 101.453 | +268.5 % (re-run +259 %): the cost of 200 new links | same; A/A +2.4 % |
| One 2,000-word insert, no URL / 200 URLs (ms) | 0.167 / 0.149 | 1.288 / 5.381 | +1.121 / +5.232 | same |
| Key-by-key typing at the end of 2,000 words (µs per key) | 30.651 | 28.326 | inside noise | same; A/A +29.2 % |
Sabotage on the prototype: the history and scroll guards each fail a test alone. The step and y-sync guards fail a test only with the scroll guard also off.
Benchmark
| Field | Value |
|---|---|
| Metric | Link rate for a mid URL in one-chunk input on a pad (runs linked / n): insertText, IME phrase, key by key (control), URL last (control). Bytes a StarterKit app pays. Package bench speed rows and behaviour count. |
| Before | Pad, c9cd2c98a: insertText 0 of 10, IME phrase 0 of 10, key by key 10 of 10, URL last 5 of 5 per path. Bytes: 70,776 / 25,582 B at c9cd2c98a. Take new bytes and speed on top of #771, #774, #775 and #778 before the first commit. |
| After | not measured yet |
| Confounds | #771, #774, #775 and #778 (built, not committed). #701 (the y-tiptap meta and key). Record each commit hash. |
| Condition | Pad: local webapp, one fresh anonymous scratch pad per run, headless Chrome for Testing 158. Engines: Chromium and WebKit 27.2 on the scratch page. Bytes: bench run.ts. Speed: jsdom, Bun 1.4.4, 9 rounds, with the control copy. |
| How to run | Pad: bun chunked-pad.ts --n 5 (local harness in wf4/evidence/p5-chunked-pad/). Package: NODE_ENV=production bun scripts/bench/run.ts --ref <commit before this issue> from extensions/extension-hyperlink. |
| Pass rule | insertText and IME phrase link the mid URL 10 of 10 on a pad. Controls stay 10 of 10 and 5 of 5. At most +250 B gzip for a StarterKit app (prototype +234). boldAll2000 and typeEnd2000 inside the control band. Behaviour count rises by the new chunked case and loses none. |
| Guard | The UX contract below. |
| Owner | Agent in the repo: code, tests, bench and pad runs. Maintainer: one real macOS dictation and one text replacement, on a local scratch pad. |
| Claim | "A dictated or IME phrase now links a URL in its middle, as typed words do (local pad, Chrome and WebKit)." Internal until the dictation check passes. |
UX contract
- Key-by-key typing links exactly as before.
- Paste and drop link exactly as before.
- A word with no whitespace after it is not linked yet.
- Undo after a one-chunk insert behaves as for a URL typed key by key.
- A peer's insert is not linked on other clients (Hyperlink: keep a removed link removed when a peer edits the pad #771).
- y-undo and history redo add no links through the new path.
- Bold over a sentence with a URL adds no link and no extra step.
- A custom href is never rewritten. Code marks and image Markdown are skipped for every candidate word.
- Each guard fails a test alone when removed, or the issue says why not.
- Maintainer: a real macOS dictation of a phrase with a URL in its middle links the URL.
- Maintainer: a macOS text replacement that expands to such a phrase links the URL.
Acceptance checks
- Hyperlink: keep a removed link removed when a peer edits the pad #771 is committed first.
-
bun run test:unit, typecheck, lint and the full package Cypress suite pass. - Before and after bench tables are posted here.
- One CHANGELOG line under
[Unreleased]Fixed.
Out of scope
- Inserts that span blocks: the first-block rule stays.
- Linking an old miss later, on Enter, blur or reload.
- URLs that the server writes (MCP, REST): Hyperlink: keep a removed link removed when a peer edits the pad #771 keeps them out of client autolink.
- An upstream Tiptap issue: optional, after this lands.
Activity
HMarzban commentedon Nov 13, 2026
Measured, 2026-11-13: #780 before and after (one-chunk autolink).
13cd8ab27. It holds Hyperlink: keep a removed link removed when a peer edits the pad #771, Hyperlink: keep PURE comments so helper-only imports tree-shake #774, Hyperlink: add HyperlinkBase without the prebuilt popovers #775 and Hyperlink: decide what Enter inside a link does #778. After is the working tree on3d90636a9, with the uncommitted Hyperlink: autolink misses a URL in the middle of a one-chunk insert #780 diff insrc/interactions/autolink.tsandsrc/interactions/remoteSync.ts.bbd6730077e143081cdb9f99208b0c26f04d3c59a1e9a890f70106f792e8d77d, headca64ce9a77b9f43418664c5af96832e808af6b0de8fc35440c622d158e66f6ef.next dev15.5.28 with Turbopack. The pad loaded the package dist built from the working tree, sha2563916264b08343038301e96d1f001092f3bf195c843b919dd8881bf1402d46e26..next/cacheheld only two small config files (8 KB), so no stale compile cache existed.NODE_ENV=production bun scripts/bench/run.ts --ref 13cd8ab27 --runs 9, in jsdom. It ran twice: once before the pad runs, once after the stack stopped.bun run test:unit, then the full clean-room Cypress suite against the rebuiltdist/.--n 5, two passes. Each round opens one fresh anonymous scratch pad. Each round writes every case into its own empty paragraph, once with no prefix and once afterIntro words.. So one pass gives 10 rows per mid-URL method and 5 rows per URL-last path.Bytes (exact, equal in both runs)
dist/index.jsHyperlinkBasenormalizeHref-only importBehaviour (jsdom, both runs)
The bench has no chunked case yet.
scripts/bench/behaviour.tsis unchanged, so the count did not rise.Speed (jsdom, 9 rounds per run, median (min–max))
Other rows outside their control change:
#780 does not change the mount path, so one control per run understates the noise on this loaded laptop. Every workload ended with the same document as before.
Speed in a real browser, #780 only
Chrome for Testing 158.0.8127.18, headless, one laptop. 6 sessions × 15 rounds of
NODE_ENV=production bun scripts/bench/drive.ts --ref 13cd8ab27 --runs 15. Base is13cd8ab27(before #780); head adds only the #780 diff. Pooled withsummarize.ts; the session is the unit.The jsdom
typeEnd2000result (+5 %, +4 %) does not hold in the browser.pasteOverSelection250kdoes: about 0.7 ms more on a 250k-character paste over a selection.Tests
bun run test:unitPad (linked rows / rows)
c9cd2c98a)insertTextofsee example.com nowIntro words.Intro words.Intro words.go to example.com,insertText(control)The "none" rows match the issue's "10 of 10" (5 + 5). The prefixed rows are 10 more.
Each linked row links exactly
example.comtohttps://example.com.see,nowand the latermorestay plain.Each one-chunk row was one doc transaction. The IME rows fired one
compositionend.The link was still there 1.5 s later, and after a key-typed
more, in 80 of 80 rows.Raw data: local, not attached. Pass 1
raw.jsonsha256da51f1a2bad33c976b6f6d0859397bb36d6740e9b3fd63626341700d0a2fb4bd. Pass 2raw.jsonsha2566bc8d2ead4f862eb107c795e63e1b3a73744af8f5bd2cb26742804c309608f54. Bench run 1 JSON sha256982e9fcdd4453b498e21d6db1f53abb705e499de186262e17ad4831432a700fe. Bench run 2 JSON sha256352c071fa224a3f2783c3f68a421101f3e0670ade21c0ee481e559ed5c787e7e. Harnesschunked-pad.tssha2567429f0dc4633ecf2394bec70610d47f293c023fda908542b1dcafcc591f3a96c. Cypress log sha25639231074a435ad17c82b2ec237a11f7a8c250513d3844457bf877907286a5bc5. Browser Hyperlink: autolink misses a URL in the middle of a one-chunk insert #780-only sessions s1–s6:63e2e9b2c442ac0ac6b314e9757c08d701994a6207c1e627546d72f6d480f8a9,7aebfe4f6289349ec698f07f55fbf17ebdc6531d23994b0795be5a5fc340cf1a,3898bb03e5fb522b32f69737b241b8bd56ee0aaddffe704740b1c13db5d11ca3,b472cf103d390d8e5da5b3d53f3961caac7f1daa89498bc08e1824c1764accc5,66b23ca1c98f9200434dcf3e244c07e09112919e14d9f98f6550f08135789b71,eee54bb72119e641b254704e6568789ef7b94109142d0ed71d1ebcd5a8ff3d32; summary7fd56aaa943cad97583e1d7d3d86caa09cd2228d6197141e89d29eb9be048fb4. Every file, the bench scripts included, is listed in aMANIFEST.sha256, itself sha256fa29e56faf6047b325eef81ec92fa5bdb8e647a986dc0da7b1a5613c227f763d.Not measured:
typeEnddispatches with noscrollIntoView, so it never takes that path. Real typing does. Read from code, the typeEnd2000 change comes from theisTypedChunkcheck, or frommatchAllon each typed space.browser.ts).matchAll). Base split the same text into strings. The bench types a space every few keys, so typeEnd2000 runs that path often.Verdict: split.
insertText(10 of 10) and IME phrase commits (10 of 10). Controls held: key by key 10 of 10, URL last 5 of 5 per path in each pass.fix(extension-hyperlink): link a URL in the middle of a typed chunk
chore(extension-hyperlink): add browser drivers to the bench
HMarzban commentedon Nov 13, 2026
Measured, 2026-11-13: the #780 paste cost is fixed.
pasteOverSelection250k4.5 % slower (Measured). Is it gone?matchAllmatch object for every word in the whole block, only to keep the words near the insert. On a 250k-character paste that is tens of thousands of objects.843305131(not pushed yet). The scan walks back from the end only as far as the candidate words. The last word is still always a candidate; removing that guard fails "a second space still links the word before the first". Unit tests 530 of 530 pass. It costs +59 B gzip, so Hyperlink: autolink misses a URL in the middle of a one-chunk insert #780 adds about +221 B to a StarterKit app in all, under its +250 B limit.NODE_ENV=production bun scripts/bench/drive.ts --ref ead539a38 --runs 15. Base is the committed Hyperlink: autolink misses a URL in the middle of a one-chunk insert #780; head adds the fix.perf(extension-hyperlink): scan back for autolink candidate words
ci: fail an extension-hyperlink PR above its byte budget
fix(webapp): free a left pad by giving each editor its own marked
HMarzban commentedon Nov 16, 2026
Measured, 2026-11-16: #780 guard sabotage pass.
isTypedChunk, and the guards next to it, one at a time. Then I ranbun test --isolate src(530 tests) and restored the exact original.src/interactions/autolink.tsstill has sha256e66157af…80f4d, andgit diffon it is empty.045a6a62f.uiEvent !== 'paste'uiEvent !== 'drop'ReplaceStepstr.scrolledIntoView!isHistoryTransactionySyncOrigin === nullMath.min)every→somein the callevery→somefails nothing (read from code): the two differ only when one batch mixes a typed chunk with a non-typed transaction that a higher-priority plugin appended. No test builds such a batch.somecould only widen the chunk path, and no current plugin makes that batch on typed input. So it is not a real regression risk, and I added no test.scrollIntoViewon a focused remote or y-undo change (dist line 1586). So theySyncOriginguard matters in a real browser. The test "a y-undo insert is not linked" already pins it.HMarzban commentedon Nov 16, 2026
One-chunk insert check, 2026-11-16: pass in WebKit and Chrome.
Dictation and text replacement reach the page as one text insert, not as key presses. A real spoken dictation was not possible here, so this check sends that same one-chunk insert to the production pad (
b7888dce1), with a URL in the middle of the phrase.keyboard.insertText(input-method commit)see example.net nowexample.netlinked tohttps://example.netdocument.execCommand('insertText')see example.edu nowkeyboard.insertTextsee example.io nowexecCommand('insertText')see example.dev nowexecCommand('insertText')see example.app nowead539a38, live sinceeeb1ab727, with the paste-cost fix843305131live sinceb7888dce1.Release credit v2.3.8. Closing as done.