fix(linux): open external links in the system browser - #573
Conversation
The dashboard renders external links as `target="_blank"` (Service Status provider cards, leaderboard profiles, GitHub links). wry only connects WebKitGTK's `create` signal when a new-window handler is registered, and the Tauri window registered none, so those clicks were a silent no-op on Linux — no popup, no browser, no error. Route them to `xdg-open` the way the macOS (`createWebViewWith`) and Windows (`NewWindowRequested`) clients already do, and mirror the Windows navigation guard so a top-level navigation off the dashboard also leaves for the browser instead of stranding the user in a window with no chrome to get back.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe Linux Tauri application now keeps internal URLs in the webview and opens external HTTP(S) URLs with ChangesLinux external-link routing
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: 🟡 Moderate · up to External links will open in the system browser, but the new navigation policy also permits unapproved schemes and broadly trusts loopback origins inside the app. Tightening or validating those boundaries is recommended before merge. Sequence Diagram(s)sequenceDiagram
participant MainWebview
participant external
participant xdg_open
MainWebview->>external: classify navigation URL
alt Internal URL
external-->>MainWebview: allow in-app navigation
else External URL
MainWebview->>external: open_in_browser(URL)
external->>xdg_open: launch external URL
xdg_open-->>external: process result
external-->>MainWebview: block in-app navigation
end
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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
On the Linux client, clicking an external link inside the app window does nothing at all — no popup, no browser, no error. Most visible on the Service Status page, where every provider card is a link to that provider's status page, but it affects every
target="_blank"link in the dashboard (leaderboard profiles, the sidebar GitHub link, docs links).Cause: wry only connects WebKitGTK's
createsignal when a new-window handler is registered (wry/src/webkitgtk/mod.rs), and the Tauri window inmain.rsregistered none. WebKitGTK's defaultcreatereturns no webview, so the click is silently dropped.The other two desktop clients already handle this explicitly:
WKUIDelegate.createWebViewWith→NSWorkspace.shared.open(DashboardWindowController.swift:507)CoreWebView2.NewWindowRequested→OpenInBrowser(DashboardWindow.cs:364)Fix
New
src-tauri/src/external.rs:is_internal_url()— loopback hosts,*.localhost, and non-http(s)schemes (tauri://,about:,blob:) stay in the window. Port-agnostic, since the bundled server picks its port dynamically. Lookalike hosts such ashttps://127.0.0.1.evil.com/are treated as external.open_in_browser()— hands the URL toxdg-open, matching howoauth.rsalready launches the browser.Wired into the window builder:
.on_new_window(...)→ open externally,NewWindowResponse::Deny. This is the reported bug..on_navigation(...)→ mirrors the Windows navigation guard. The app window has no browser chrome, so a top-level navigation off the dashboard would otherwise strand the user with no way back.Testing
cargo test— all suites pass, including the newtests/external.rsand the unit tests inexternal.rs.cargo fmt --checkclean.Summary by CodeRabbit
New Features
Bug Fixes
Tests