From b4532cb2131be66baef81516a078d148eadf9cbd Mon Sep 17 00:00:00 2001 From: Subhamoy Biswas Date: Mon, 2 Mar 2026 10:47:51 +0530 Subject: [PATCH] refactor: use tauri js opener api for sandboxes --- src-tauri/capabilities/default.json | 16 ++++++++++++++++ .../pages/settings/extensionSettings.tsx | 13 +++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 8de15af..ebf9e45 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -38,6 +38,22 @@ } ] }, + { + "identifier": "opener:allow-reveal-item-in-dir", + "allow": [ + { + "path": "**" + } + ] + }, + { + "identifier": "opener:allow-open-url", + "allow": [ + { + "url": "**" + } + ] + }, { "identifier": "fs:scope", "allow": [ diff --git a/src/components/pages/settings/extensionSettings.tsx b/src/components/pages/settings/extensionSettings.tsx index 6b17b8b..b0077f1 100644 --- a/src/components/pages/settings/extensionSettings.tsx +++ b/src/components/pages/settings/extensionSettings.tsx @@ -15,6 +15,8 @@ import { invoke } from "@tauri-apps/api/core"; import { SlidingButton } from "@/components/custom/slidingButton"; import clsx from "clsx"; import { NumberInput } from "@/components/custom/numberInput"; +import { openUrl } from "@tauri-apps/plugin-opener"; +import { useLogger } from "@/helpers/use-logger"; const websocketPortSchema = z.object({ port: z.coerce.number({ @@ -31,14 +33,21 @@ const websocketPortSchema = z.object({ }); function ExtInstallSettings() { - const openLink = async (url: string, app: string | null) => { + const LOG = useLogger(); + const openLink = async (url: string, app: string | undefined) => { try { - await invoke('open_file_with_app', { filePath: url, appName: app }).then(() => { + // await invoke('open_file_with_app', { filePath: url, appName: app }).then(() => { + // toast.info("Opening link", { + // description: `Opening link with ${app ? app : 'default app'}.`, + // }) + // }); + await openUrl(url, app).then(() => { toast.info("Opening link", { description: `Opening link with ${app ? app : 'default app'}.`, }) }); } catch (e) { + LOG.error('NEODLP', `Failed to open link: ${e}`); console.error(e); toast.error("Failed to open link", { description: "An error occurred while trying to open the link.",