Skip to content

fix(gui): open external links in system browser from desktop shell - #426

Open
SerienYang wants to merge 3 commits into
andrewyng:mainfrom
SerienYang:fix/external-links-opener
Open

fix(gui): open external links in system browser from desktop shell#426
SerienYang wants to merge 3 commits into
andrewyng:mainfrom
SerienYang:fix/external-links-opener

Conversation

@SerienYang

Copy link
Copy Markdown

$(cat /tmp/pr_body.md)

The macOS/Linux webview silently drops target=_blank popups, so links in
agent replies (rendered as <a target=_blank> by Markdown.tsx) did nothing
when clicked in the packaged app, while the browser dev build worked.

Root cause (upstream issue andrewyng#227/andrewyng#270): the shell never registered an
opener — no on_new_window handler, no opener plugin, no shell plugin — so
the webview's open-new-window request vanished.

Fix (port of upstream PRs andrewyng#241/andrewyng#271 + guard):
- src-tauri: add tauri-plugin-opener, register it, and add on_navigation
  that forwards http(s)/mailto to the system browser while letting the
  SPA itself (tauri://, tauri.localhost, Vite devUrl:1420) load. This also
  fixes the webview context-menu "Open Link" (issue andrewyng#270).
- capabilities: grant opener:allow-default-urls (scoped to mailto:/tel:/http(s)).
- tauri.ts: openExternal() now calls __TAURI__.opener.openUrl() in the shell.
- Markdown.tsx: route <a> clicks through openExternal() (artifact: chips
  keep the in-app viewer).
- main.tsx: capture-phase fallback for any other <a href> http(s) link
  (connector cards, dangerouslySetInnerHTML, future surfaces).

Verified: tsc --noEmit clean, vitest 7/7, cargo check clean.
…xternal links

Left-click was silently dropped because the capability only granted
opener:allow-default-urls (a URL scope) without opener:allow-open-url,
so the open_url command was rejected by the ACL. Right-click "Open
Link" on target=_blank links never reached on_navigation (WKWebView
routes them to createWebViewWith), so add an on_new_window handler that
opens external URLs in the system browser and denies the new window.

Also log openExternal / navigation decisions to make future issues
observable.
@SerienYang
SerienYang force-pushed the fix/external-links-opener branch from 5ec9b24 to c9a0e99 Compare August 3, 2026 10:47
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.

1 participant