feat(dom): opt-in linkify for clickable URLs in terminal output#42
Open
den1k wants to merge 11 commits into
Open
feat(dom): opt-in linkify for clickable URLs in terminal output#42den1k wants to merge 11 commits into
den1k wants to merge 11 commits into
Conversation
Block glyphs wrote an empty string into the linkify pre-pass rowText, causing findUrls to return ranges off by one per preceding block, so URLs following a block glyph rendered with the wrong boundaries. Emit a space placeholder so rowText is always exactly this.cols long.
… block-glyph alignment)
…anilla guide, and CHANGELOG
|
@den1k is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
Preserves the col→rowText 1:1 mapping that urlIdxAt() relies on. Code points above U+FFFF (emoji, supplementary plane) encode as surrogate pairs in JS strings (2 UTF-16 code units), which would make a single cell contribute 2 string indices and shift every subsequent column's URL mapping. Per VADE review on vercel-labs#42.
Linkify previously ran per-row, so a URL that hard-wrapped at the column
boundary became two anchors with two truncated hrefs (or none, when the
second row started without https://). Group consecutive rows where the
last column was written into ('continuesNext' heuristic), run the URL
regex once on the joined text, and emit one anchor per row segment all
sharing the same full href. Repaint a row when its URL ranges change so
edits on row N+1 propagate to row N's anchor.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in
linkifyoption to@wterm/dom'sWTerm/Rendererthat turnshttp(s)://…URLs in terminal output into real<a href>anchors. Pure renderer-side change — no wasm, no@wterm/core, noCell-struct changes.Design
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..wterm a.term-linkgive a subtle dotted-underline-on-hover treatment that inherits the terminal foreground color.linkify: true.Scope / limitations
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 torenderer.test.tscovering: 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/domgoes 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-checkgreenpnpm -r buildgreen