2 Commits
Author SHA1 Message Date
poli0981andClaude Opus 4.8 b1d461a18e 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>
2026-06-16 18:58:28 +07:00
poli0981andClaude Opus 4.8 4370e36628 fix(android): open external links via system browser + release v1.7.2 (#103)
Tapping any external link did nothing on the Android build: Tauri's
WebView (Android especially) silently ignores `target="_blank"`, so the
plain anchors in Header, Footer and About never opened. Only ConsentGate
had a per-link workaround (PR #98).

Replace that with one app-wide delegated click interceptor
(`useExternalLinkInterceptor`, mounted at the App root): when `isTauri()`
it catches clicks on any `a[href^=http]` and hands the URL to the system
browser via `openExternal()` / plugin-shell. The web build is untouched —
the listener is gated behind `isTauri()` so it is never installed there,
and in-app router links keep relative hrefs so they aren't intercepted
(reads `getAttribute('href')`, not the absolutising `.href` property).

Removes the now-redundant onClick handler from ConsentGate.

No Tauri/Rust/manifest/CSP changes were needed — shell:allow-open and
plugin-shell were already correct (ConsentGate proved it on Android).

Bumps version to 1.7.2 (Android versionCode 10702).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 18:12:43 +07:00
15 changed files with 96 additions and 115 deletions

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",
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "jsonprism",
"private": true,
"version": "1.7.1",
"version": "1.7.2",
"type": "module",
"description": "Disperse JSON into many formats — JSONL, CSV, YAML, XML, TOML, RESX, Markdown, SQL — fully client-side.",
"author": "poli0981 <https://github.com/poli0981>",
@@ -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",
+24 -74
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"
@@ -1867,7 +1858,7 @@ dependencies = [
[[package]]
name = "jsonprism"
version = "1.7.1"
version = "1.7.2"
dependencies = [
"serde",
"serde_json",
@@ -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"
+2 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "jsonprism"
version = "1.7.1"
version = "1.7.2"
description = "Disperse JSON into many formats."
authors = ["poli0981 <https://github.com/poli0981>"]
license = "Apache-2.0"
@@ -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())
+2 -2
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "JSONPrism",
"version": "1.7.1",
"version": "1.7.2",
"identifier": "com.poli0981.jsonprism",
"build": {
"beforeDevCommand": "npm run dev",
@@ -78,7 +78,7 @@
},
"android": {
"minSdkVersion": 31,
"versionCode": 10701
"versionCode": 10702
}
},
"plugins": {
+3
View File
@@ -5,6 +5,7 @@ import { ErrorBoundary } from '@/components/common/ErrorBoundary';
import { ConsentGate } from '@/components/common/ConsentGate';
import { Layout } from '@/components/layout/Layout';
import { Toaster } from '@/components/ui/sonner';
import { useExternalLinkInterceptor } from '@/hooks/useExternalLinkInterceptor';
// Routes are code-split so the entry chunk stays small and the consent gate +
// app shell paint before any page's heavy graph (editor, parsers) loads.
@@ -14,6 +15,8 @@ const NotFound = lazy(() => import('@/pages/errors/NotFound'));
const ErrorRoute = lazy(() => import('@/pages/errors/ErrorRoute'));
export function App() {
useExternalLinkInterceptor();
return (
<ThemeProvider defaultTheme="system">
<ErrorBoundary>
-9
View File
@@ -9,7 +9,6 @@ import {
DialogTitle,
} from '@/components/ui/dialog';
import { useConsentStore } from '@/stores/consentStore';
import { isTauri, openExternal } from '@/lib/tauri';
const REPO_URL = 'https://github.com/poli0981/jsonPrism';
@@ -57,14 +56,6 @@ export function ConsentGate({ children }: { children: ReactNode }) {
href={l.href}
target="_blank"
rel="noopener noreferrer"
onClick={(e) => {
// Tauri webviews (notably Android) ignore target="_blank";
// hand the URL to the system browser instead.
if (isTauri()) {
e.preventDefault();
void openExternal(l.href);
}
}}
className="text-primary inline-flex items-center gap-1 underline-offset-4 hover:underline"
>
{t(`consent.links.${l.key}`)}
+32
View File
@@ -0,0 +1,32 @@
import { useEffect } from 'react';
import { isTauri, openExternal } from '@/lib/tauri';
/**
* Route external-link clicks to the system browser inside Tauri.
*
* Tauri webviews (notably Android) silently ignore `target="_blank"`, so a
* tapped `<a href="https://…">` does nothing. A single delegated listener
* catches every external anchor app-wide and hands the URL to the OS browser
* via the shell plugin. No-op on the web build (browsers open new tabs
* natively) and for in-app router links (relative hrefs don't match).
*/
export function useExternalLinkInterceptor(): void {
useEffect(() => {
if (!isTauri()) return;
const handler = (e: MouseEvent) => {
if (e.button !== 0 || e.defaultPrevented) return;
const anchor = (e.target as Element | null)?.closest('a');
if (!anchor) return;
// Raw attribute, NOT `anchor.href`: the property absolutises relative
// router links ("/about" → "http://…/about") and would match.
const href = anchor.getAttribute('href');
if (!href || !/^https?:\/\//i.test(href)) return;
e.preventDefault();
void openExternal(href);
};
document.addEventListener('click', handler);
return () => document.removeEventListener('click', handler);
}, []);
}
+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',
],
},
}));