fix(android): open external links via opener plugin (shell.open broke on Android) (#105)

The v1.7.2 global link interceptor routed external URLs through
`@tauri-apps/plugin-shell`'s `open()`, but that throws on Android:
"Scoped shell IO error: No such file or directory (os error 2)" — the
shell plugin has no native URL handler on mobile, so every tapped link
did nothing. (The earlier ConsentGate per-link shell.open from #98 had
the same flaw; it was simply never tap-tested on Android.)

Switch to `@tauri-apps/plugin-opener`'s `openUrl()`, whose `open_url` has
a real cfg(mobile) split that routes to the native Intent.ACTION_VIEW
handler. Plain `openUrl(url)` — no inAppBrowser (that option regressed
os-error-2 on Android 16, plugins-workspace#2913).

Wiring: tauri-plugin-opener crate + init, @tauri-apps/plugin-opener npm,
"opener:default" capability (its allow-open-url permits any URL). Shell
plugin removed entirely (openExternal was its only consumer) — also from
vite optimizeDeps, knip ignore, and the THIRD-PARTY/TAURI-NOTES docs.

Verified on emulator API 33 (Android 13, WebView Chromium 109): tapping
the consent-gate License link and footer X link both fire ActivityManager
START ACTION_VIEW and open Chrome; no shell error.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
poli0981andClaude Opus 4.8 authored and GitHub committed 2026-06-16 18:58:28 +07:00
1 parent 4370e36628
commit b1d461a18e
11 files changed
+56 -101

No files matched your search

+2 -2
View File
@@ -84,8 +84,8 @@ installed as a runtime dependency.
| `@tauri-apps/api` | ^2.0.0 | Apache-2.0 OR MIT | [tauri.app](https://tauri.app/) |
| `@tauri-apps/plugin-dialog` | ^2.0.0 | Apache-2.0 OR MIT | [tauri.app](https://tauri.app/) |
| `@tauri-apps/plugin-fs` | ^2.0.0 | Apache-2.0 OR MIT | [tauri.app](https://tauri.app/) |
| `@tauri-apps/plugin-opener` | ^2.0.0 | Apache-2.0 OR MIT | [tauri.app](https://tauri.app/) |
| `@tauri-apps/plugin-os` | ^2.0.0 | Apache-2.0 OR MIT | [tauri.app](https://tauri.app/) |
| `@tauri-apps/plugin-shell` | ^2.0.0 | Apache-2.0 OR MIT | [tauri.app](https://tauri.app/) |
| `@tauri-apps/cli` (devDep) | ^2.0.0 | Apache-2.0 OR MIT | [tauri.app](https://tauri.app/) |
### Rust crates (`src-tauri/Cargo.toml`)
@@ -96,8 +96,8 @@ installed as a runtime dependency.
| `tauri-build` | 2 | Apache-2.0 OR MIT | [crates.io/crates/tauri-build](https://crates.io/crates/tauri-build) |
| `tauri-plugin-dialog` | 2 | Apache-2.0 OR MIT | [crates.io/crates/tauri-plugin-dialog](https://crates.io/crates/tauri-plugin-dialog) |
| `tauri-plugin-fs` | 2 | Apache-2.0 OR MIT | [crates.io/crates/tauri-plugin-fs](https://crates.io/crates/tauri-plugin-fs) |
| `tauri-plugin-opener` | 2 | Apache-2.0 OR MIT | [crates.io/crates/tauri-plugin-opener](https://crates.io/crates/tauri-plugin-opener) |
| `tauri-plugin-os` | 2 | Apache-2.0 OR MIT | [crates.io/crates/tauri-plugin-os](https://crates.io/crates/tauri-plugin-os) |
| `tauri-plugin-shell` | 2 | Apache-2.0 OR MIT | [crates.io/crates/tauri-plugin-shell](https://crates.io/crates/tauri-plugin-shell) |
| `tauri-plugin-single-instance` | 2 | Apache-2.0 OR MIT | [crates.io/crates/tauri-plugin-single-instance](https://crates.io/crates/tauri-plugin-single-instance) |
| `serde` | 1 | Apache-2.0 OR MIT | [serde.rs](https://serde.rs/) |
| `serde_json` | 1 | Apache-2.0 OR MIT | [github.com/serde-rs/json](https://github.com/serde-rs/json) |
+5 -4
View File
@@ -15,8 +15,8 @@ process from outliving the main webview:
any spawned shell children (none today, but the hook is in place) are
signaled before the process exits.
If you ever add long-running spawned commands (e.g. via `tauri_plugin_shell`),
remember to track their handles and kill them in the same hook.
If you ever add long-running spawned commands (e.g. via a shell/command
plugin), remember to track their handles and kill them in the same hook.
## WebView2 GDI leak (Windows, upstream)
@@ -45,8 +45,9 @@ See `src-tauri/capabilities/default.json`. Scope is intentionally narrow:
- Filesystem reads/writes only inside `$HOME`, `$DOCUMENT`, `$DOWNLOAD`,
`$DESKTOP`.
- Dialog plugin for open/save.
- Shell plugin restricted to `shell:allow-open` (URL opening only — no
arbitrary command spawn).
- Opener plugin (`opener:default`) for handing external URLs to the system
browser — `shell:open` has no native Android URL handler, so the opener
plugin's `openUrl` is used instead.
Widening the scope requires both a capability edit and a CSP review in
`tauri.conf.json`.
+1 -1
View File
@@ -5,8 +5,8 @@
"@radix-ui/react-slot",
"tailwindcss",
"tw-animate-css",
"@tauri-apps/plugin-opener",
"@tauri-apps/plugin-os",
"@tauri-apps/plugin-shell",
"@testing-library/user-event"
],
"rules": {
+12 -12
View File
@@ -1,12 +1,12 @@
{
"name": "jsonprism",
"version": "1.7.1",
"version": "1.7.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "jsonprism",
"version": "1.7.1",
"version": "1.7.2",
"license": "Apache-2.0",
"dependencies": {
"@codemirror/lang-json": "^6.0.0",
@@ -31,8 +31,8 @@
"@tauri-apps/api": "^2.0.0",
"@tauri-apps/plugin-dialog": "^2.0.0",
"@tauri-apps/plugin-fs": "^2.0.0",
"@tauri-apps/plugin-opener": "^2.0.0",
"@tauri-apps/plugin-os": "^2.0.0",
"@tauri-apps/plugin-shell": "^2.0.0",
"@uiw/react-codemirror": "^4.25.10",
"bson": "^7.2.0",
"cbor-x": "^1.6.4",
@@ -3133,6 +3133,15 @@
"@tauri-apps/api": "^2.11.0"
}
},
"node_modules/@tauri-apps/plugin-opener": {
"version": "2.5.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-opener/-/plugin-opener-2.5.4.tgz",
"integrity": "sha512-1HnPkb+AmgO29HBazm4uPLKB+r7zzcTBW1d0fyYp1uP+jwtpoiNDGKMMzz58SFp49nOIrxdE3aUJtT57lfO9CQ==",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@tauri-apps/api": "^2.11.0"
}
},
"node_modules/@tauri-apps/plugin-os": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-os/-/plugin-os-2.3.2.tgz",
@@ -3142,15 +3151,6 @@
"@tauri-apps/api": "^2.8.0"
}
},
"node_modules/@tauri-apps/plugin-shell": {
"version": "2.3.5",
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-shell/-/plugin-shell-2.3.5.tgz",
"integrity": "sha512-jewtULhiQ7lI7+owCKAjc8tYLJr92U16bPOeAa472LHJdgaibLP83NcfAF2e+wkEcA53FxKQAZ7byDzs2eeizg==",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@tauri-apps/api": "^2.10.1"
}
},
"node_modules/@testing-library/dom": {
"version": "10.4.1",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.1.tgz",
+1 -1
View File
@@ -59,8 +59,8 @@
"@tauri-apps/api": "^2.0.0",
"@tauri-apps/plugin-dialog": "^2.0.0",
"@tauri-apps/plugin-fs": "^2.0.0",
"@tauri-apps/plugin-opener": "^2.0.0",
"@tauri-apps/plugin-os": "^2.0.0",
"@tauri-apps/plugin-shell": "^2.0.0",
"@uiw/react-codemirror": "^4.25.10",
"bson": "^7.2.0",
"cbor-x": "^1.6.4",
+23 -73
View File
@@ -860,15 +860,6 @@ version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7"
[[package]]
name = "encoding_rs"
version = "0.8.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
dependencies = [
"cfg-if",
]
[[package]]
name = "endi"
version = "1.1.1"
@@ -1875,8 +1866,8 @@ dependencies = [
"tauri-build",
"tauri-plugin-dialog",
"tauri-plugin-fs",
"tauri-plugin-opener",
"tauri-plugin-os",
"tauri-plugin-shell",
"tauri-plugin-single-instance",
]
@@ -2391,16 +2382,6 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "os_pipe"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
dependencies = [
"libc",
"windows-sys 0.61.2",
]
[[package]]
name = "pango"
version = "0.18.3"
@@ -3150,44 +3131,12 @@ dependencies = [
"digest",
]
[[package]]
name = "shared_child"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e362d9935bc50f019969e2f9ecd66786612daae13e8f277be7bfb66e8bed3f7"
dependencies = [
"libc",
"sigchld",
"windows-sys 0.60.2",
]
[[package]]
name = "shlex"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
[[package]]
name = "sigchld"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47106eded3c154e70176fc83df9737335c94ce22f821c32d17ed1db1f83badb1"
dependencies = [
"libc",
"os_pipe",
"signal-hook",
]
[[package]]
name = "signal-hook"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2"
dependencies = [
"libc",
"signal-hook-registry",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.8"
@@ -3618,6 +3567,28 @@ dependencies = [
"url",
]
[[package]]
name = "tauri-plugin-opener"
version = "2.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17e1bea14edce6b793a04e2417e3fd924b9bc4faae83cdee7d714156cceeed29"
dependencies = [
"dunce",
"glob",
"objc2-app-kit",
"objc2-foundation",
"open",
"schemars 0.8.22",
"serde",
"serde_json",
"tauri",
"tauri-plugin",
"thiserror 2.0.18",
"url",
"windows",
"zbus",
]
[[package]]
name = "tauri-plugin-os"
version = "2.3.2"
@@ -3636,27 +3607,6 @@ dependencies = [
"thiserror 2.0.18",
]
[[package]]
name = "tauri-plugin-shell"
version = "2.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8457dbf9e2bab1edd8df22bb2c20857a59a9868e79cb3eac5ed639eec4d0c73b"
dependencies = [
"encoding_rs",
"log",
"open",
"os_pipe",
"regex",
"schemars 0.8.22",
"serde",
"serde_json",
"shared_child",
"tauri",
"tauri-plugin",
"thiserror 2.0.18",
"tokio",
]
[[package]]
name = "tauri-plugin-single-instance"
version = "2.4.2"
+1 -1
View File
@@ -20,8 +20,8 @@ tauri-build = { version = "2", features = [] }
tauri = { version = "2", features = [] }
tauri-plugin-dialog = "2"
tauri-plugin-fs = "2"
tauri-plugin-opener = "2"
tauri-plugin-os = "2"
tauri-plugin-shell = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
+1 -1
View File
@@ -10,7 +10,7 @@
"core:webview:default",
"core:window:default",
"core:window:allow-set-title",
"shell:allow-open",
"opener:default",
"os:default",
"dialog:default",
"dialog:allow-open",
+1 -1
View File
@@ -42,7 +42,7 @@ pub fn run() {
}
let app = builder
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_os::init())
+8 -4
View File
@@ -154,16 +154,20 @@ export async function fileFromNativePath(path: string): Promise<File> {
/**
* Open an external URL. In Tauri the webview won't honour `target="_blank"`
* (Android in particular swallows it), so route through the shell plugin to
* hand the URL to the system browser. On the web, open a new tab as usual.
* (Android in particular swallows it), so hand the URL to the system browser
* via the opener plugin's `openUrl`. On the web, open a new tab as usual.
*
* NB: the shell plugin's `open()` throws "Scoped shell IO error: No such file
* or directory (os error 2)" on Android — it has no native URL handler there.
* The opener plugin routes through the platform's Intent/openURL API instead.
*/
export async function openExternal(url: string): Promise<void> {
if (!isTauri()) {
window.open(url, '_blank', 'noopener,noreferrer');
return;
}
const { open } = await import('@tauri-apps/plugin-shell');
await open(url);
const { openUrl } = await import('@tauri-apps/plugin-opener');
await openUrl(url);
}
/**
+1 -1
View File
@@ -138,8 +138,8 @@ export default defineConfig(({ mode }) => ({
'@tauri-apps/api',
'@tauri-apps/plugin-dialog',
'@tauri-apps/plugin-fs',
'@tauri-apps/plugin-opener',
'@tauri-apps/plugin-os',
'@tauri-apps/plugin-shell',
],
},
}));