From 4d63acde4b8b8a312c55dac9e617d7c7605ecb00 Mon Sep 17 00:00:00 2001 From: lunar-seal Date: Fri, 24 Jul 2026 13:11:41 +0200 Subject: [PATCH 1/3] fix: (tauri) open homeserver-url in user chip via opener plugin --- .changeset/fix-homeserver-external-link.md | 5 +++++ src/app/components/user-profile/UserChips.tsx | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .changeset/fix-homeserver-external-link.md diff --git a/.changeset/fix-homeserver-external-link.md b/.changeset/fix-homeserver-external-link.md new file mode 100644 index 000000000..9dca15968 --- /dev/null +++ b/.changeset/fix-homeserver-external-link.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +tauri: use external browser to follow homeserver url in profile chip \ No newline at end of file diff --git a/src/app/components/user-profile/UserChips.tsx b/src/app/components/user-profile/UserChips.tsx index c2709a9b3..b75e9f295 100644 --- a/src/app/components/user-profile/UserChips.tsx +++ b/src/app/components/user-profile/UserChips.tsx @@ -2,6 +2,7 @@ import type { KeyboardEventHandler, MouseEventHandler } from 'react'; import type { CSSProperties } from 'react'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { useNavigate } from 'react-router-dom'; +import { isTauri } from '@tauri-apps/api/core'; import FocusTrap from 'focus-trap-react'; import { isKeyHotkey } from 'is-hotkey'; import type { Room } from '$types/matrix-sdk'; @@ -173,8 +174,15 @@ export function ServerChip({ size="300" radii="300" onClick={() => { - window.open(`https://${server}`, '_blank'); + const url = `https://${server}`; close(); + if (isTauri()) { + import('@tauri-apps/plugin-opener') + .then(({ openUrl }) => openUrl(url)) + .catch(() => window.open(url, '_blank')); + return; + } + window.open(url, '_blank'); }} className={css.UserHeroMenuItem} style={heroMenuItemStyle( From 0a6503c1a4878caacc7945701bc3d65ec8830b02 Mon Sep 17 00:00:00 2001 From: lunar-seal Date: Fri, 24 Jul 2026 22:18:23 +0200 Subject: [PATCH 2/3] fix: open external links on android in system browser --- .changeset/fix-homeserver-external-link.md | 5 ----- .changeset/fix-tauri-external-link.md | 5 +++++ src-tauri/src/lib.rs | 24 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) delete mode 100644 .changeset/fix-homeserver-external-link.md create mode 100644 .changeset/fix-tauri-external-link.md diff --git a/.changeset/fix-homeserver-external-link.md b/.changeset/fix-homeserver-external-link.md deleted file mode 100644 index 9dca15968..000000000 --- a/.changeset/fix-homeserver-external-link.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -tauri: use external browser to follow homeserver url in profile chip \ No newline at end of file diff --git a/.changeset/fix-tauri-external-link.md b/.changeset/fix-tauri-external-link.md new file mode 100644 index 000000000..4d2297a7d --- /dev/null +++ b/.changeset/fix-tauri-external-link.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +tauri: make sure external links open in separate browser, instead of replacing the app \ No newline at end of file diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 527663833..048a1924c 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -141,6 +141,30 @@ pub fn show_or_create_main_window(app: &AppHandle) -> taur .use_https_scheme(true) .background_color(tauri::window::Color(0x1A, 0x1C, 0x28, 0xFF)); + // Only android: intercept navigation to external URLs and open them in the system browser + // Other platforms: might need other URI schemes, and on_navigation might get called on iframe urls + // (as of now, the following is confirmed not to work with linux/webkit2gtk) + #[cfg(target_os = "android")] + let builder = { + let nav_handle = app.clone(); + builder.on_navigation(move |url| { + let internal = url.scheme() == "tauri" + || url.host_str() == Some("tauri.localhost") + || (cfg!(dev) && url.host_str() == Some("localhost")); + if !internal { + // open in new thread + // open_url blocks on the ui thread but we are on the ui thread... + let handle = nav_handle.clone(); + let url = url.to_string(); + std::thread::spawn(move || { + use tauri_plugin_opener::OpenerExt; + let _ = handle.opener().open_url(url, None::<&str>); + }); + } + internal + }) + }; + #[cfg(desktop)] let title = main_window_title(app); From 3efcc505aaeab3fc25b12ca27bcd2b4596493c39 Mon Sep 17 00:00:00 2001 From: lunar-seal Date: Fri, 24 Jul 2026 23:47:44 +0200 Subject: [PATCH 3/3] fix: add ending newline in fix-tauri-external-link.md --- .changeset/fix-tauri-external-link.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/fix-tauri-external-link.md b/.changeset/fix-tauri-external-link.md index 4d2297a7d..38c0f6343 100644 --- a/.changeset/fix-tauri-external-link.md +++ b/.changeset/fix-tauri-external-link.md @@ -2,4 +2,4 @@ default: patch --- -tauri: make sure external links open in separate browser, instead of replacing the app \ No newline at end of file +tauri: make sure external links open in separate browser, instead of replacing the app