From 0da8af8a28658d155646725a4b1190cb7bd15784 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Fri, 27 Feb 2026 14:17:24 +0800 Subject: desktop: move open_path to rust (#15323) --- packages/desktop/src/bindings.ts | 2 +- packages/desktop/src/index.tsx | 25 +------------------------ 2 files changed, 2 insertions(+), 25 deletions(-) (limited to 'packages/desktop/src') diff --git a/packages/desktop/src/bindings.ts b/packages/desktop/src/bindings.ts index 8e1b4127a..80548173e 100644 --- a/packages/desktop/src/bindings.ts +++ b/packages/desktop/src/bindings.ts @@ -18,7 +18,7 @@ export const commands = { checkAppExists: (appName: string) => __TAURI_INVOKE("check_app_exists", { appName }), wslPath: (path: string, mode: "windows" | "linux" | null) => __TAURI_INVOKE("wsl_path", { path, mode }), resolveAppPath: (appName: string) => __TAURI_INVOKE("resolve_app_path", { appName }), - openInPowershell: (path: string) => __TAURI_INVOKE("open_in_powershell", { path }), + openPath: (path: string, appName: string | null) => __TAURI_INVOKE("open_path", { path, appName }), }; /** Events */ diff --git a/packages/desktop/src/index.tsx b/packages/desktop/src/index.tsx index 188a37eb8..17b4638bd 100644 --- a/packages/desktop/src/index.tsx +++ b/packages/desktop/src/index.tsx @@ -17,7 +17,6 @@ import { getCurrent, onOpenUrl } from "@tauri-apps/plugin-deep-link" import { open, save } from "@tauri-apps/plugin-dialog" import { fetch as tauriFetch } from "@tauri-apps/plugin-http" import { isPermissionGranted, requestPermission } from "@tauri-apps/plugin-notification" -import { openPath as openerOpenPath } from "@tauri-apps/plugin-opener" import { type as ostype } from "@tauri-apps/plugin-os" import { relaunch } from "@tauri-apps/plugin-process" import { open as shellOpen } from "@tauri-apps/plugin-shell" @@ -116,29 +115,7 @@ const createPlatform = (): Platform => { void shellOpen(url).catch(() => undefined) }, async openPath(path: string, app?: string) { - const os = ostype() - if (os === "windows") { - const resolvedPath = await (async () => { - if (window.__OPENCODE__?.wsl) { - const converted = await commands.wslPath(path, "windows").catch(() => null) - if (converted) return converted - } - - return path - })() - const resolvedApp = (app && (await commands.resolveAppPath(app))) || app - const isPowershell = (value?: string) => { - if (!value) return false - const name = value.toLowerCase().replaceAll("/", "\\").split("\\").pop() - return name === "powershell" || name === "powershell.exe" - } - if (isPowershell(resolvedApp)) { - await commands.openInPowershell(resolvedPath) - return - } - return openerOpenPath(resolvedPath, resolvedApp) - } - return openerOpenPath(path, app) + await commands.openPath(path, app ?? null) }, back() { -- cgit v1.2.3