Skip to content

fix(terminal): keep the closing bracket of IPv6 hosts in HTTP links - #37449

Merged
nwparker merged 1 commit into
stablyai:mainfrom
pqminh27:fix/terminal-ipv6-authority-links
Nov 3, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
pqminh27:fix/terminal-ipv6-authority-links

Conversation

@pqminh27

@pqminh27 pqminh27 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When a program in the terminal prints an address like http://[::1] (a common way dev servers say "running on this computer"), Orca treated the final ] as ordinary punctuation and cut it off. The link came out broken, so you couldn't hover or click it. Now Orca recognizes that ] as part of the address and keeps it, while still trimming real punctuation like a trailing period or a wrapping bracket.

What Changed

Before: see http://[::1] now, http://[::1]., (http://[::1]), http://user@[::1], and Server at http://[::1]: ready produced no link. The hover regex matched http://[::1 (missing ]), which xterm's WebLinksAddon then rejected as an invalid URL, and the click / hard-wrap extractor trimmed the ] the same way. URLs with a port or path after the host (http://[::1]:5173/) already worked.

After: the full http://[::1] is underlined on hover and opens on click, including across soft and hard wraps. Path brackets (http://h/[::1], http://example.com/a[b]) and surrounding prose brackets ([http://[::1]], http://[::1]:5173/app]) are trimmed exactly as before.

Mechanism:

  • src/shared/prose-url-boundary.ts: new IPV6_HTTP_HOST_SOURCE (optional userinfo, then [hex:.]) is matched as an explicit alternative right after the scheme inside PROSE_HTTP_URL_SOURCE, which feeds the xterm hover regex TERMINAL_HTTP_URL_REGEX. No regex lookbehind is used, because this module is bundled into the mobile terminal WebView, and WebKit before Safari 16.4 cannot parse lookbehind.
  • src/shared/terminal-http-url-extraction.ts: trimHttpUrlTrailingPunctuation computes a floor once from the same IPv6 authority source (anchored at the start of the candidate) and never trims back past it. This covers the click fallback, hard-wrap, and mobile tap paths, so hover and click agree.
  • src/shared/terminal-http-url-extraction.test.ts: one it.each with six cases that asserts the regex match and the extractor range together, including negatives for path brackets and wrapping prose brackets.

Why

The closing bracket belongs to the IPv6 host (RFC 3986 IP-literal), so treating it as trailing punctuation always produced an unparseable URL. Reusing one shared source for both the hover regex and the extractor trim floor keeps the two paths from drifting. The trim floor is a single prefix match, so it stays linear on long bracket runs.

Linked Issue

Fixes #37359

Visual Proof

N/A for screenshots: the change is in link-boundary detection, not layout. Behavior was verified with a headless @xterm/headless probe that runs xterm's real LinkComputer with TERMINAL_HTTP_URL_REGEX, plus createWrappedTerminalHttpLinkProvider for hard wraps. Excerpt:

Input main: hover / extract this PR: hover / extract
see http://[::1] now none / none http://[::1] / http://[::1]
see http://[::1]. now none / none http://[::1] / http://[::1]
(http://[::1]) none / none http://[::1] / http://[::1]
http://user@[::1] none / none http://user@[::1] / http://user@[::1]
HTTPS://[2001:DB8::1] none / none full URL / full URL
http://[::1]。次 none / none http://[::1] / http://[::1]
[http://[::1]] none / none http://[::1] / http://[::1]
http://[::1]:5173/app] http://[::1]:5173/app unchanged
http://h/[::1] http://h/[::1 unchanged
soft wrap see http://[::1] now at 14 cols no link http://[::1], range (5,1)-(2,2)
hard wrap http://[2001:db8::1]/ across 2 rows no link link on both rows

Testing

  • Reproduced on main: 4 of the 6 new test cases fail (http://[::1], see http://[::1]. now, Server at http://[::1]: ready, (http://user@[::1])); all pass with this change.

  • pnpm test src/shared/terminal-http-url-extraction.test.ts src/renderer/src/components/terminal-pane/terminal-url-link-hit-testing.test.ts: passed. Earlier review rounds also ran terminal-url-link-click, wrapped-terminal-http-link-provider, terminal-runtime-host-link-routing, remark autolink prose boundary, and dashboard preview composition tests (129 passed).

  • Perf: pathological 2k-character lines of ] or hex characters take under 1 ms through both the regex and the extractor.

  • oxlint, oxfmt --check, anti-slop oxlint, native-plugin oxlint, ast-grep, and the changed-code quality gate are clean on the touched files.

  • Platforms: macOS (headless xterm probe + Vitest). The change is in platform-neutral shared code used by local and SSH terminals and the mobile terminal WebView. Not run on Linux, Windows, or live SSH.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Risk

Level: Low

Limited to HTTP(S) URL boundaries for bracketed IPv6 hosts directly after the scheme. URL parsing and the protocol allowlist are unchanged, so invalid literals that now match the regex are still rejected before opening. Known limitation, unchanged from main: xterm's WebLinksAddon isUrl check rejects non-canonical IPv6 forms ([0:0::1], [::ffff:1.2.3.4]) and repeated raw @ in userinfo for hover, though click still opens them. Plain revert restores prior behavior.

Review

Reviewed hover/click agreement, soft and hard wraps, mobile WebView regex compatibility (no lookbehind), and linear-time trimming.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security: no new URL schemes or open paths. Cross-platform/SSH/mobile: shared code, no platform branches; mobile bundle stays parseable on older WebKit. Backwards compatibility: pure renderer-side matching, no protocol or settings changes. Performance: one extra anchored prefix match per candidate link.

Original fix by @pqminh27 in #37449. Simplified during review: the repeated-@ fallback link provider and the Electron e2e spec were dropped as out of scope; authorship is preserved via Co-authored-by.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@pqminh27
pqminh27 force-pushed the fix/terminal-ipv6-authority-links branch 2 times, most recently from 4e2bacb to 2ed3300 Compare November 2, 2026 11:28
@pqminh27
pqminh27 marked this pull request as ready for review November 2, 2026 11:44
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The shared URL source now matches bracketed IPv6 hosts, including hosts preceded by user information. Terminal URL extraction uses this pattern to preserve the closing bracket and trim punctuation after the IPv6 authority. Tests check matching and extracted link spans for IPv6 URLs with credentials, ports, and paths.

Severity of issue fixed: Low

Merge Risk: Minimal · up to 4d6c7

The IPv6 link-boundary test does not have the reported failure; this change is mergeable after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the actual change: bracketed IPv6 hosts in HTTP links keep their closing bracket. The raw summary and the description both describe this fix. The title follows the conventional commit …
Description check Passed The description follows the repository template and fills in every required section. It has an ELI5, a before/after account of what changed, the mechanism, the reason for the approach, a linked issue …
Linked Issues check Passed Issue [#37359] requires that http://[::1] be recognized as a complete link, including the closing ], and that the same boundary hold across terminal-row wraps. Trailing punctuation handling and UR…
Out of Scope Changes check Passed The changed set, per the raw summary, is src/shared/prose-url-boundary.ts, src/shared/terminal-http-url-extraction.ts, and src/shared/terminal-http-url-extraction.test.ts. All production edits c…
Full details: Title check

Explanation

The title names the actual change: bracketed IPv6 hosts in HTTP links keep their closing bracket. The raw summary and the description both describe this fix. The title follows the conventional commit style and is specific enough for a teammate scanning history.

Full details: Description check

Explanation

The description follows the repository template and fills in every required section. It has an ELI5, a before/after account of what changed, the mechanism, the reason for the approach, a linked issue (Fixes #37359), visual proof marked N/A with a reason, testing steps on macOS, a risk level with a revert path, and the review, upstream boundary, and checklist items. Two items remain unchecked: manual local testing, and the pnpm lint/typecheck/test/build checklist entry. The Linked Issue and Visual Proof sections are complete. The AI Disclosure section is left as the template comment, which the template allows for internal contributors and which the author may need to address for outside contributors.

Full details: Linked Issues check

Explanation

Issue [#37359] requires that http://[::1] be recognized as a complete link, including the closing ], and that the same boundary hold across terminal-row wraps. Trailing punctuation handling and URL paths must keep working.

At the reviewed head, src/shared/prose-url-boundary.ts adds IPV6_HTTP_HOST_SOURCE (optional userinfo followed by @, then \[[\dA-Fa-f:.]+\]). It is matched as an explicit alternative directly after the scheme in PROSE_HTTP_URL_SOURCE. This source feeds TERMINAL_HTTP_URL_REGEX, so the hover regex now matches the full bracketed host. No lookbehind is used.

src/shared/terminal-http-url-extraction.ts computes minEndIndex from IPV6_HTTP_AUTHORITY, anchored at the candidate start. trimHttpUrlTrailingPunctuation never trims below that floor. Consequences checked against the code:

  • http://[::1]. trims only the ..
  • (http://[::1]) trims only the ).
  • http://[::1]:5173/app] trims the trailing ] only, because the floor ends after the host.
  • http://h/[::1] does not match the authority pattern (no @ and no leading [ after ://), so path brackets keep the prior trim behavior.

The click and hard-wrap path uses extractTerminalHttpLinks, which calls the same trim function. The wrapped provider source is not part of the changed file set. Wrap support is therefore inferred from shared use, plus the author's headless probe. The test file summary lists a six-case it.each that asserts the regex match and the extracted span together, including the negative path and prose-bracket cases. Those tests are not re-run in this review.

The current PR description does not include the repeated-@ fallback provider or the Electron e2e spec. The raw summary lists only three changed files, so no code for them is present at head. The issue does not require them. The previous PASS relied on that removed fallback. This assessment does not depend on it.

Full details: Out of Scope Changes check

Explanation

The changed set, per the raw summary, is src/shared/prose-url-boundary.ts, src/shared/terminal-http-url-extraction.ts, and src/shared/terminal-http-url-extraction.test.ts. All production edits concern HTTP(S) boundary detection for bracketed IPv6 hosts, plus the matching trim floor in the extractor. The test edit covers the same behavior. No unrelated change is demonstrated.

One effect extends beyond terminal output. PROSE_HTTP_URL_SOURCE is a shared source. The current PR description notes that remark autolink prose-boundary and dashboard preview tests were run in earlier review rounds. That consumer effect follows from the same URL boundary rule and does not add unrelated behavior. URL parsing and the http:/https: allowlist in extractTerminalHttpLinks are unchanged.

The previous assessment's references to the repeated-@ fallback and the Electron e2e spec no longer apply at head. Their removal does not create a scope issue.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 3 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ast-grep (0.51.1)

ast-grep could not parse rule config: /ast-grep-rules/ast-grep-essentials/rules/swift/security/weak-hash-md5-commoncrypto-swift.yml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a52b57b8-40df-4faf-a0d8-e6a6e8c43b51
Commits

Reviewing files that changed from the base of the PR and between 767ee71 and 4d6c7f5.

Files selected for processing: 3
  • src/shared/prose-url-boundary.ts
  • src/shared/terminal-http-url-extraction.test.ts
  • src/shared/terminal-http-url-extraction.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up Comments

Nitpick Cover native-soft-wrap IPv6 links through the addon path.

52-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover native-soft-wrap IPv6 links through the addon path.

The existing soft-wrap click fixture does not use a bracketed IPv6 authority. The changed IPv6 test uses hard-wrapped rows and direct hit testing. The Electron IPv6 test is single-line and therefore does not exercise WebLinksAddon hover handling for a native soft wrap.

Add a focused native-soft-wrap fixture that splits before the IPv6 closing ]. Assert the closing bracket through the click path and WebLinksAddon hover path, and assert that the following prose bracket is not part of the link.

Open the source location

Comment thread src/shared/prose-url-boundary.ts Resolved
@pqminh27
pqminh27 force-pushed the fix/terminal-ipv6-authority-links branch 4 times, most recently from f72a249 to 767ee71 Compare November 3, 2026 03:31
Terminal link detection treated the closing `]` of a bracketed IPv6 host
(e.g. http://[::1]:5173) as trailing punctuation and dropped it, producing
unopenable links. Match an optional bracketed IPv6 authority after the
scheme, and never trim trailing punctuation back past that authority.
Avoids regex lookbehind so the mobile terminal WebView can still parse it.

Co-authored-by: pqminh27 <[email protected]>
@nwparker
nwparker force-pushed the fix/terminal-ipv6-authority-links branch from 767ee71 to 4d6c7f5 Compare November 3, 2026 03:47
@nwparker nwparker changed the title fix(terminal): preserve IPv6 brackets in HTTP links fix(terminal): keep the closing bracket of IPv6 hosts in HTTP links Nov 3, 2026
@nwparker
nwparker merged commit 438fb75 into stablyai:main Nov 3, 2026
51 checks passed
@pqminh27
pqminh27 deleted the fix/terminal-ipv6-authority-links branch November 3, 2026 04:22
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.

IPv6 URLs are not clickable in terminal output

2 participants