summaryrefslogtreecommitdiffhomepage
path: root/packages/tauri/src
diff options
context:
space:
mode:
authorAdam <[email protected]>2025-12-18 04:26:17 -0600
committerAdam <[email protected]>2025-12-18 04:26:21 -0600
commite37a75a411c584d3e463662a0219fd342d4247ab (patch)
treeeb3944722e942b3244c4f13466855fca712bc3c6 /packages/tauri/src
parent194ff4919cd1e68caaaa8336da0b13b815c74072 (diff)
downloadopencode-e37a75a411c584d3e463662a0219fd342d4247ab.tar.gz
opencode-e37a75a411c584d3e463662a0219fd342d4247ab.zip
feat(desktop): custom update toast
Diffstat (limited to 'packages/tauri/src')
-rw-r--r--packages/tauri/src/index.tsx27
1 files changed, 21 insertions, 6 deletions
diff --git a/packages/tauri/src/index.tsx b/packages/tauri/src/index.tsx
index c77058eb9..025dfd540 100644
--- a/packages/tauri/src/index.tsx
+++ b/packages/tauri/src/index.tsx
@@ -1,14 +1,16 @@
// @refresh reload
import { render } from "solid-js/web"
import { App, PlatformProvider, Platform } from "@opencode-ai/desktop"
-import { onMount } from "solid-js"
import { open, save } from "@tauri-apps/plugin-dialog"
import { open as shellOpen } from "@tauri-apps/plugin-shell"
import { type as ostype } from "@tauri-apps/plugin-os"
import { AsyncStorage } from "@solid-primitives/storage"
-import { runUpdater, UPDATER_ENABLED } from "./updater"
+import { UPDATER_ENABLED } from "./updater"
import { createMenu } from "./menu"
+import { check, Update } from "@tauri-apps/plugin-updater"
+import { invoke } from "@tauri-apps/api/core"
+import { relaunch } from "@tauri-apps/plugin-process"
const root = document.getElementById("root")
if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
@@ -17,6 +19,8 @@ if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
)
}
+let update: Update | null = null
+
const platform: Platform = {
platform: "tauri",
@@ -66,15 +70,26 @@ const platform: Platform = {
}
return api
},
+
+ checkUpdate: async () => {
+ if (!UPDATER_ENABLED) return { updateAvailable: false }
+ update = await check()
+ if (!update) return { updateAvailable: false }
+ await update.download()
+ return { updateAvailable: true, version: update.version }
+ },
+
+ update: async () => {
+ if (!UPDATER_ENABLED || !update) return
+ await update.install()
+ await invoke("kill_sidecar")
+ await relaunch()
+ },
}
createMenu()
render(() => {
- onMount(() => {
- if (UPDATER_ENABLED) runUpdater({ alertOnFail: false })
- })
-
return (
<PlatformProvider value={platform}>
{ostype() === "macos" && (