#42

feat(dom): opt-in linkify for clickable URLs in terminal output

Openden1kwants to merge intofrom

Summary

Adds an opt-in linkify option to @wterm/dom's WTerm / Renderer that turns http(s)://… URLs in terminal output into real <a href> anchors. Pure renderer-side change — no wasm, no @wterm/core, no Cell-struct changes.

Design

  • New module packages/@wterm/dom/src/linkify.ts: DEFAULT_URL_PATTERN, pure findUrls() / trimTrailing() helpers, LinkifyOption / LinkifyConfig types.
  • Renderer._buildRowContent gains a pre-pass that identifies URL ranges in the row text and flushes runs at URL boundaries (in addition to style boundaries). URL-internal runs are appended to a shared <a class="term-link" target="_blank" rel="noopener noreferrer"> element; onClick fires before the browser's default navigation.
  • CSS rules under .wterm a.term-link give a subtle dotted-underline-on-hover treatment that inherits the terminal foreground color.
  • Default is off — existing consumers see no change unless they pass linkify: true.

Scope / limitations

  • Per-row scoping: URLs that wrap across terminal lines are rendered as two separate (broken) anchors. Documented.
  • Explicit-scheme only (https?://). No www.-prefix autodetection or OSC 8 hyperlink support — the latter would need a new Cell slot on the core side and is out of scope for this PR.

Tests

Unit (vitest + jsdom): packages/@wterm/dom/src/__tests__/linkify.test.ts (13 helper tests) and additions to renderer.test.ts covering: single URL, multiple URLs, styled URL, trailing-punctuation trimming, linkify disabled, custom regex, cursor inside anchor, scrollback-row anchors, block-glyph col alignment, onClick. Total +23 tests; @wterm/dom goes from 68 → 91 passing. No Playwright e2e added — anchor rendering is fully observable in jsdom and browser-native behavior (target=\"_blank\", CSS hover) isn't our code to test.

Docs

  • packages/@wterm/dom/README.md — new "Clickable links" section.
  • apps/docs/src/app/api-reference/page.mdx — linkify row in Terminal Options table.
  • apps/docs/src/app/vanilla/page.mdx — "Clickable Links" subsection with examples.
  • CHANGELOG.md — "Unreleased" entry.

Test plan

  • pnpm -r test green (@wterm/react has 14 pre-existing test failures on main unrelated to this change — React 19 + Node 24 + testing-library compat)
  • pnpm -r type-check green
  • pnpm -r build green