Skip to content

fix(gui): exclude trailing Markdown emphasis delimiters from autolinked URLs (#197) - #210

Merged
justrach merged 3 commits into
release/v0.0.210from
fix/197-chatlinks-md-delimiters
Jul 22, 2026
Merged

fix(gui): exclude trailing Markdown emphasis delimiters from autolinked URLs (#197)#210
justrach merged 3 commits into
release/v0.0.210from
fix/197-chatlinks-md-delimiters

Conversation

@justrach

@justrach justrach commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Problem

Bare URLs wrapped in Markdown emphasis (**url**, *url*, ~~url~~) captured the closing delimiters in the link target. On macOS, Cmd-hover/Cmd-click then underlined the trailing markers and tried to open an invalid destination such as http://localhost:3003**.

Markdown-rendered messages normally split strong spans first, but raw/plain-text paths (ChatInlineText / getInlineTextSegments) pass the markers straight into getChatLinkMatches.

Fix

The matcher now recognizes a contiguous Markdown delimiter immediately before a bare URL and removes only the matching closing delimiter from the candidate. This keeps Markdown syntax outside the clickable span without stripping valid URL characters from unwrapped links.

input clickable target
**http://localhost:3003** http://localhost:3003
*https://example.com* https://example.com
~~https://example.com~~ https://example.com
https://example.com/path* unchanged
https://example.com/~ unchanged
*https://example.com/path** https://example.com/path*

The delimiter handling is URL-specific, so generic file/path candidate cleanup does not accidentally remove legitimate trailing markers.

Tests

  • bun test: 157 passed, 0 failed.
  • bunx eslint src/components/chat/utils/chatLinks.ts src/components/chat/utils/chatLinks.test.ts: passed.
  • bunx tsc -b: passed.
  • Added regressions for bold, italic, strikethrough, mixed delimiters, offsets, punctuation, multi-byte characters, and legitimate trailing * / ~ URL characters.

Repository-wide bun run lint remains blocked by eight pre-existing errors in unrelated GUI files. The Vite build also reaches the bundler but is blocked by the repository's existing missing esbuild dependency.

Closes #197

@justrach

Copy link
Copy Markdown
Owner Author

CI baseline note for reviewers:

  • The branch-head workflow for d1056cf passed Zig, SDK, and Windows.
  • The pull-request merge workflow passed all 231 Zig unit tests, then failed the JSON live-control integration test after 8/19 cases stopped receiving events.
  • Rerunning reproduced that integration failure.
  • Current main fails identically in run 29633443960: 231/231 Zig tests pass, then the same JSON-control test stops after 8/19.

This is an existing main CI failure and is unrelated to this GUI-only URL matcher/test diff. Local validation for the changed area is green: 157 Bun tests, targeted ESLint, and TypeScript project checking.

justrach and others added 3 commits July 22, 2026 16:52
…ed URLs (#197)

Bare URLs wrapped in Markdown emphasis (**url**, *url*, ~~url~~) captured the
closing delimiters in the link target, so Cmd-hover/Cmd-click on macOS underlined
and tried to open an invalid destination like http://localhost:3003**.

trimLinkCandidate now strips trailing * and ~ (the emphasis/strikethrough
markers) alongside the punctuation and unmatched-closer trimming it already did,
looping so interleaved runs like "...3003.**" are fully cleaned. Interior URL
characters (http://a.com/x*y) and legitimately balanced parens
(en.wikipedia.org/wiki/Foo_(bar)) are preserved.

Tests: new chatLinks.test.ts (9 cases incl. the report's three, span end, and
non-regression); full gui bun test 144/144; eslint clean.

Refs #197

Co-Authored-By: blackfloofie <265516171+blackfloofie@users.noreply.github.com>
Adversarial coverage for trimLinkCandidate: stacked (`***`) and mixed (`~~*…*~~`)
trailing emphasis strip fully, and a URL ending in a multi-byte glyph (accents,
emoji) is preserved byte-for-byte — trimming only ever removes ASCII markers, so
it can never cut a codepoint in half.

Refs #197

Co-Authored-By: blackfloofie <265516171+blackfloofie@users.noreply.github.com>
@justrach
justrach force-pushed the fix/197-chatlinks-md-delimiters branch from d1056cf to bb623af Compare July 22, 2026 08:53
@justrach
justrach changed the base branch from main to release/v0.0.210 July 22, 2026 08:54
@justrach
justrach merged commit d8200ca into release/v0.0.210 Jul 22, 2026
6 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.

Bare URL autolinker includes trailing Markdown asterisks in link target

1 participant