fix(term): provide OSC 8 linkHandler to fix hyperlinks not opening#3234
fix(term): provide OSC 8 linkHandler to fix hyperlinks not opening#3234s-zx wants to merge 1 commit intowavetermdev:mainfrom
Conversation
…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
|
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe change modifies Terminal initialization in termwrap.ts by adding a custom Estimated code review effort🎯 2 (Simple) | ⏱️ ~13 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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 defaultwindow.confirm()dialog, and clicking OK does nothing. Fixes #3165.The root cause: when no
linkHandleris set inITerminalOptions, xterm.js falls back towindow.confirm()+window.open(). In Electron's renderer,window.open()navigation is intercepted byshNavHandler/shFrameNavHandler— so the dialog appears but the browser never opens.Fix
Add a
linkHandlerto the terminal options inTermWrap's constructor. The handler:activatethroughopenLink(), using the same Cmd-click (macOS) / Ctrl-click (other platforms) convention already used byWebLinksAddonfor regex-detected URLs.hover/leavetohoveredLinkUriandonLinkHover, so the existingTermLinkTooltip("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 onlytermwrap.ts.Testing
web:openlinksinternallysetting)