fix(gui): open external links in system browser (fixes #270) - #271
Open
EvanProgramming wants to merge 1 commit into
Open
fix(gui): open external links in system browser (fixes #270)#271EvanProgramming wants to merge 1 commit into
EvanProgramming wants to merge 1 commit into
Conversation
Left-click and right-click 'Open Link' on web links did nothing in the desktop app: the webview silently drops target=_blank popups and no opener plugin was wired up. - Add tauri-plugin-opener (Cargo.toml, lib.rs, opener:default capability) - Intercept full-page navigations (on_navigation) so context-menu 'Open Link' hands external URLs to the system browser instead of being dropped - Route markdown link clicks through openExternal(); add a capture-phase fallback in main.tsx for links rendered outside Markdown - Test: clicking an ordinary markdown link is prevented and goes through openExternal
SerienYang
added a commit
to SerienYang/Openworker
that referenced
this pull request
Aug 3, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #270 — links reported by OpenWorker could not be opened by left-click or right-click "Open Link"; nothing happened and no permission dialog appeared (v0.1.6, macOS).
Root cause
tauri-plugin-openerwas not a dependency, not registered inlib.rs, and noopenerpermission existed incapabilities/default.json.src/tauri.tseven noted it: "the desktop webview has no opener plugin wired yet".openExternal()therefore fell back towindow.open(), and markdown links rely on<a target="_blank">— both are silently dropped by the Tauri v2 webview (no popup, no error), which matches the "nothing happens" report.on_navigationhandler it was dropped as well.Fix
Rust shell (
surfaces/gui/src-tauri/)tauri-plugin-opener = "2", registertauri_plugin_opener::init(), and grantopener:default.on_navigationhandler on the main window: the SPA's own origins (tauri://,http://tauri.localhost, the Vite devUrl in dev builds) stay in-app; any otherhttp/https/mailtonavigation is handed to the system browser viaopen_urland blocked in the webview — this fixes right-click "Open Link".Frontend (
surfaces/gui/src/)Markdown.tsx: external links nowpreventDefault()and go throughopenExternal(href)— this fixes left-click. Browser builds keep the same behavior viawindow.open.main.tsx: capture-phase click fallback (desktop only) so links rendered outsideMarkdown(connector cards, future surfaces) also open externally.tauri.ts: updated the now-stale comment.Behavior before / after
artifact:chipsNote on the screenshot guideline: the broken state renders identically to the fixed state (the bug is that clicking produces no visible response at all), so a static screenshot cannot show the difference. Happy to attach a short screen recording if that helps review.
Tests
npx tsc --noEmit— cleannpx vitest run— 69/69 passing, including a newMarkdown.test.tsxcase asserting link clicks are prevented and routed throughopenExternalcargo check— clean