#42
feat(dom): opt-in linkify for clickable URLs in terminal output
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, purefindUrls()/trimTrailing()helpers,LinkifyOption/LinkifyConfigtypes. Renderer._buildRowContentgains 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;onClickfires before the browser's default navigation.- CSS rules under
.wterm a.term-linkgive 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?://). Nowww.-prefix autodetection or OSC 8 hyperlink support — the latter would need a newCellslot 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—linkifyrow in Terminal Options table.apps/docs/src/app/vanilla/page.mdx— "Clickable Links" subsection with examples.CHANGELOG.md— "Unreleased" entry.
Test plan
-
pnpm -r testgreen (@wterm/reacthas 14 pre-existing test failures on main unrelated to this change — React 19 + Node 24 + testing-library compat) -
pnpm -r type-checkgreen -
pnpm -r buildgreen
Activity
143cbd83evercel[bot]reviewed6mo ago
vercel[bot]reviewed6mo ago
@den1k is attempting to deploy a commit to the Vercel Labs Team on Vercel.
A member of the Team first needs to authorize it.