diff --git a/muxplex/frontend/terminal.js b/muxplex/frontend/terminal.js index c794e22..3f4abe1 100644 --- a/muxplex/frontend/terminal.js +++ b/muxplex/frontend/terminal.js @@ -287,20 +287,37 @@ function createTerminal(fontSize) { }, scrollback: mobile ? 500 : 5000, allowProposedApi: true, + // Override OSC 8 hyperlink handler — the default shows a confirm() dialog. + // This opens links directly, matching native terminal behavior (Ghostty, iTerm2). + linkHandler: { + activate: function(event, uri) { + window.open(uri, '_blank'); + }, + }, }); _fitAddon = new window.FitAddon.FitAddon(); _term.loadAddon(_fitAddon); - // Clickable URLs — Ctrl+Click (Windows/Linux) or Cmd+Click (macOS) opens in new tab. - // xterm-addon-web-links auto-detects URLs and adds hover underlines. - // Plain click is preserved for normal terminal text selection. + // --- Link handling --- + // Two link systems work together: + // + // 1. WebLinksAddon: regex-detects plain-text URLs (http://..., https://...) + // and makes them clickable. Click opens in new tab. + // + // 2. OSC 8 hyperlinks: programs emit ESC]8;;URL\atext\aESC]8;;\a to make + // arbitrary text clickable (like Ghostty, iTerm2, etc.). xterm.js has + // built-in OscLinkProvider support, but its default handler shows a + // confirm() dialog. We override with a linkHandler that opens directly. + // + // Both open on plain click. Ctrl/Cmd+Click is not required — this is a + // browser-based terminal where the link-vs-select distinction comes from + // whether the user drags (select) or clicks (link). + var WebLinksAddon = window.WebLinksAddon && window.WebLinksAddon.WebLinksAddon; if (WebLinksAddon) { _term.loadAddon(new WebLinksAddon(function(event, uri) { - if (event.ctrlKey || event.metaKey) { - window.open(uri, '_blank'); - } + window.open(uri, '_blank'); })); }