Skip to content

fix(term): provide OSC 8 linkHandler to fix hyperlinks not opening#3234

Closed
s-zx wants to merge 1 commit intowavetermdev:mainfrom
s-zx:fix-3165-osc8-hyperlink-open
Closed

fix(term): provide OSC 8 linkHandler to fix hyperlinks not opening#3234
s-zx wants to merge 1 commit intowavetermdev:mainfrom
s-zx:fix-3165-osc8-hyperlink-open

Conversation

@s-zx
Copy link
Copy Markdown

@s-zx s-zx commented Apr 18, 2026

Problem

OSC 8 hyperlinks (e.g. printf '\e]8;;https://example.com\aClick me\e]8;;\a\n') render correctly in Wave, but clicking them shows xterm.js's default window.confirm() dialog, and clicking OK does nothing. Fixes #3165.

The root cause: when no linkHandler is set in ITerminalOptions, xterm.js falls back to window.confirm() + window.open(). In Electron's renderer, window.open() navigation is intercepted by shNavHandler / shFrameNavHandler — so the dialog appears but the browser never opens.

Fix

Add a linkHandler to the terminal options in TermWrap's constructor. The handler:

  • Routes activate through openLink(), using the same Cmd-click (macOS) / Ctrl-click (other platforms) convention already used by WebLinksAddon for regex-detected URLs.
  • Wires hover/leave to hoveredLinkUri and onLinkHover, so the existing TermLinkTooltip ("Cmd-click to open link") appears on OSC 8 links exactly like it does on plain URLs.

The change is a single block in TermWrap's constructor, touching only termwrap.ts.

Testing

# In a Wave terminal block:
printf '\e]8;;https://example.com\aClick me\e]8;;\a\n'
  • Hover over "Click me" → tooltip shows "Cmd-click to open link"
  • Cmd+click (macOS) / Ctrl+click (Linux/Windows) → opens in default browser or internal web widget (respecting web:openlinksinternally setting)
  • Plain click → no dialog, no action (consistent with bare-URL behavior)

…lick

xterm.js falls back to window.confirm() + window.open() for OSC 8
hyperlinks when no linkHandler is configured. In Electron's renderer,
window.open() is blocked by the navigation guards — so the confirmation
dialog appears but clicking OK silently fails.

Provide a linkHandler that routes OSC 8 clicks through openLink() with
the same Cmd/Ctrl-click requirement used by WebLinksAddon for regex-
detected URLs. Also wire up hover/leave to feed hoveredLinkUri, which
TermLinkTooltip uses to show the "Cmd-click to open link" tooltip.

Fixes #3165
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3636c3fd-ed01-4a3c-9c82-0b05318f472b

📥 Commits

Reviewing files that changed from the base of the PR and between 3e4fe8c and 2e81a45.

📒 Files selected for processing (1)
  • frontend/app/view/term/termwrap.ts

Walkthrough

The change modifies Terminal initialization in termwrap.ts by adding a custom linkHandler to the xterm.js options. This handler intercepts OSC 8 hyperlink activation and requires platform-specific modifier keys (Meta on macOS; Ctrl on other platforms) before opening links. The implementation also integrates OSC 8 hover and leave events to update the hoveredLinkUri state and trigger onLinkHover callbacks with mouse coordinates. Existing WebLinksAddon regex-based URL detection functionality remains unmodified.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~13 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding a linkHandler for OSC 8 hyperlinks to fix the issue where they don't open in the browser.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining both the problem and the implemented solution for OSC 8 hyperlinks.
Linked Issues check ✅ Passed The PR successfully addresses issue #3165 by implementing a linkHandler that routes OSC 8 activation through openLink() with proper modifier key conventions and hover feedback.
Out of Scope Changes check ✅ Passed All changes are scoped to termwrap.ts and directly address the OSC 8 hyperlink functionality, with no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@s-zx s-zx closed this by deleting the head repository Apr 18, 2026
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.

[Bug]: OSC 8 hyperlinks show confirmation dialog but do not open browser

3 participants