feat(desktop): make updates persistent and responsive (#31191)

This commit is contained in:
Luke Parker
2026-06-07 05:20:56 +00:00
committed by GitHub
parent f20655bef4
commit 9b4d5b0395
26 changed files with 511 additions and 398 deletions
+9 -11
View File
@@ -15,10 +15,11 @@ import {
useCommand,
useWslServers,
} from "@opencode-ai/app"
import type { UpdaterState } from "@opencode-ai/app/updater"
import * as Sentry from "@sentry/solid"
import type { AsyncStorage } from "@solid-primitives/storage"
import { MemoryRouter } from "@solidjs/router"
import { createEffect, createMemo, createResource, onCleanup, onMount, Show } from "solid-js"
import { createEffect, createMemo, createResource, createSignal, onCleanup, onMount, Show } from "solid-js"
import { render } from "solid-js/web"
import pkg from "../../package.json"
import { initI18n, t } from "./i18n"
@@ -59,6 +60,9 @@ if (import.meta.env.VITE_SENTRY_DSN) {
void initI18n()
const [updaterState, setUpdaterState] = createSignal<UpdaterState>({ status: "disabled" })
void window.api.updater.subscribe(setUpdaterState)
const deepLinkEvent = "opencode:deep-link"
const emitDeepLinks = (urls: string[]) => {
@@ -177,16 +181,10 @@ const createPlatform = (): Platform => {
storage,
checkUpdate: async () => {
const config = await window.api.getWindowConfig().catch(() => ({ updaterEnabled: false }))
if (!config.updaterEnabled) return { updateAvailable: false }
return window.api.checkUpdate()
},
updateAndRestart: async () => {
const config = await window.api.getWindowConfig().catch(() => ({ updaterEnabled: false }))
if (!config.updaterEnabled) return
await window.api.installUpdate()
updater: {
state: updaterState,
check: () => window.api.updater.check(),
install: () => window.api.updater.install(),
},
exportDebugLogs: () => window.api.exportDebugLogs(),
-12
View File
@@ -1,12 +0,0 @@
import { initI18n, t } from "./i18n"
export async function runUpdater({ alertOnFail }: { alertOnFail: boolean }) {
await initI18n()
try {
await window.api.runUpdater(alertOnFail)
} catch {
if (alertOnFail) {
window.alert(t("desktop.updater.checkFailed.message"))
}
}
}