Registry Mirror
Skip to content

Conversation

@backnotprop

@backnotprop backnotprop commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

What broke

A bare URL that follows other text was linked only up to its first underscore. Open http://localhost:3011/w/ws_01M5JCNXKERX0XDNABX0S8K9D0/docs/plan.md linked http://localhost:3011/w/ws and left the rest as plain text. Every Workspaces id has an underscore (ws_, doc_, prj_), and so do many real URLs. Seen in the Inbox; the renderer is shared, so plan review and annotate had it too. A URL at the very start of a line, and [text](url) links, were fine.

Cause

InlineMarkdown walks the text in plain-text chunks, and a chunk ends at the next character that can start inline syntax: * _ \ [ ! ~ \ < # @ $. The bare-URL branch only runs when a URL starts the remaining text; a URL in the middle of a chunk is found by </code>emitPlainTextWithBareUrls<code>, which sees only the chunk, so the URL was cut where the chunk ended (</code>_<code>, but also </code>~<code>, </code>#<code>, </code>@<code>, $, !`).

Fix

When a bare http(s):// URL starts inside the chunk at a word boundary and, matched whole from its start (sticky regex, then trimUrlTail), ends past the chunk, end the chunk where the URL starts. The next pass hits the existing bare-URL branch, which takes the URL whole and trims trailing sentence punctuation as before (a period, a comma, !, an unbalanced closing paren stay outside). A URL that ends inside its chunk stays on the old one-pass path, so output for every URL the bug did not touch is the same as main (checked against main on 50,000 generated lines: every difference was an input with a cut URL), and a paragraph of many plain URLs stays linear (16,000 URLs: about 60 ms, as on main).

Unchanged: _word_ emphasis and snake_case in prose, a URL inside inline code (stays code), a URL inside _..._ emphasis (linked whole inside the <em>), a scheme glued to a word (foohttps://…, not linked).

Tests

packages/ui/components/InlineMarkdown.test.ts, "bare URL autolinks keep underscores": the reported URL after text; two underscore runs with ~, %, a query and a fragment, comma outside; two URLs on one line; an unbalanced closing paren; a trailing !; $ and @ and # inside a URL; a URL inside _..._; inline code; snake_case and _word_; a scheme glued to a word. The cut-URL cases fail on main and pass here. A time budget (2 s for 32,000 plain URLs, about 0.1 s now) guards the one-pass path; it failed at 7.7 s on the first version of this branch.

  • bun test packages/ui packages/editor packages/inbox: 0 fail
  • bun run typecheck: clean
  • guides.show viewer manifest: rebuilt, unchanged (check:manifest in sync)

backnotprop and others added 2 commits October 22, 2026 14:20
A bare URL after other text was cut at the first `_` (or `~`, `#`, `@`,
`$`, `!`): those characters end a plain-text chunk in InlineMarkdown, and
the chunk's own URL scan only saw the text up to there. End the chunk where
a bare URL starts instead, so the bare-URL branch takes the URL whole.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up. Splitting the plain-text chunk at every bare URL gave
each URL its own loop turn, and each turn rescans the rest of the text,
so a paragraph of many URLs went quadratic (16,000 URLs: about 3 s, against
about 60 ms on main). Split only when the URL, matched whole at its start,
ends past the chunk; a URL that ends inside the chunk is linked in the same
pass as before. Tests for a trailing ! and a $ inside a URL, and a
generous time budget for 32,000 plain URLs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@backnotprop
backnotprop merged commit 867ff69 into main Oct 22, 2026
29 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant