|
|
@@ -20,7 +20,6 @@ import { createEffect, createResource, onCleanup, onMount, Show } from "solid-js
|
|
|
import { render } from "solid-js/web"
|
|
|
import pkg from "../../package.json"
|
|
|
import { initI18n, t } from "./i18n"
|
|
|
-import { UPDATER_ENABLED } from "./updater"
|
|
|
import { webviewZoom } from "./webview-zoom"
|
|
|
import "./styles.css"
|
|
|
import { useTheme } from "@opencode-ai/ui/theme"
|
|
|
@@ -43,8 +42,7 @@ const emitDeepLinks = (urls: string[]) => {
|
|
|
}
|
|
|
|
|
|
const listenForDeepLinks = () => {
|
|
|
- const startUrls = window.__OPENCODE__?.deepLinks ?? []
|
|
|
- if (startUrls.length) emitDeepLinks(startUrls)
|
|
|
+ void window.api.consumeInitialDeepLinks().then((urls) => emitDeepLinks(urls))
|
|
|
return window.api.onDeepLink((urls) => emitDeepLinks(urls))
|
|
|
}
|
|
|
|
|
|
@@ -57,13 +55,18 @@ const createPlatform = (): Platform => {
|
|
|
return undefined
|
|
|
})()
|
|
|
|
|
|
+ const isWslEnabled = async () => {
|
|
|
+ if (os !== "windows") return false
|
|
|
+ return window.api.getWslConfig().then((config) => config.enabled).catch(() => false)
|
|
|
+ }
|
|
|
+
|
|
|
const wslHome = async () => {
|
|
|
- if (os !== "windows" || !window.__OPENCODE__?.wsl) return undefined
|
|
|
+ if (!(await isWslEnabled())) return undefined
|
|
|
return window.api.wslPath("~", "windows").catch(() => undefined)
|
|
|
}
|
|
|
|
|
|
const handleWslPicker = async <T extends string | string[]>(result: T | null): Promise<T | null> => {
|
|
|
- if (!result || !window.__OPENCODE__?.wsl) return result
|
|
|
+ if (!result || !(await isWslEnabled())) return result
|
|
|
if (Array.isArray(result)) {
|
|
|
return Promise.all(result.map((path) => window.api.wslPath(path, "linux").catch(() => path))) as any
|
|
|
}
|
|
|
@@ -137,7 +140,7 @@ const createPlatform = (): Platform => {
|
|
|
if (os === "windows") {
|
|
|
const resolvedApp = app ? await window.api.resolveAppPath(app).catch(() => null) : null
|
|
|
const resolvedPath = await (async () => {
|
|
|
- if (window.__OPENCODE__?.wsl) {
|
|
|
+ if (await isWslEnabled()) {
|
|
|
const converted = await window.api.wslPath(path, "windows").catch(() => null)
|
|
|
if (converted) return converted
|
|
|
}
|
|
|
@@ -159,12 +162,14 @@ const createPlatform = (): Platform => {
|
|
|
storage,
|
|
|
|
|
|
checkUpdate: async () => {
|
|
|
- if (!UPDATER_ENABLED()) return { updateAvailable: false }
|
|
|
+ const config = await window.api.getWindowConfig().catch(() => ({ updaterEnabled: false }))
|
|
|
+ if (!config.updaterEnabled) return { updateAvailable: false }
|
|
|
return window.api.checkUpdate()
|
|
|
},
|
|
|
|
|
|
update: async () => {
|
|
|
- if (!UPDATER_ENABLED()) return
|
|
|
+ const config = await window.api.getWindowConfig().catch(() => ({ updaterEnabled: false }))
|
|
|
+ if (!config.updaterEnabled) return
|
|
|
await window.api.installUpdate()
|
|
|
},
|
|
|
|
|
|
@@ -194,11 +199,7 @@ const createPlatform = (): Platform => {
|
|
|
return fetch(input, init)
|
|
|
},
|
|
|
|
|
|
- getWslEnabled: async () => {
|
|
|
- const next = await window.api.getWslConfig().catch(() => null)
|
|
|
- if (next) return next.enabled
|
|
|
- return window.__OPENCODE__!.wsl ?? false
|
|
|
- },
|
|
|
+ getWslEnabled: () => isWslEnabled(),
|
|
|
|
|
|
setWslEnabled: async (enabled) => {
|
|
|
await window.api.setWslConfig({ enabled })
|
|
|
@@ -249,6 +250,7 @@ listenForDeepLinks()
|
|
|
|
|
|
render(() => {
|
|
|
const platform = createPlatform()
|
|
|
+ const [windowConfig] = createResource(() => window.api.getWindowConfig().catch(() => ({ updaterEnabled: false })))
|
|
|
const loadLocale = async () => {
|
|
|
const current = await platform.storage?.("opencode.global.dat").getItem("language")
|
|
|
const legacy = current ? undefined : await platform.storage?.().getItem("language.v1")
|
|
|
@@ -325,7 +327,7 @@ render(() => {
|
|
|
return (
|
|
|
<PlatformProvider value={platform}>
|
|
|
<AppBaseProviders locale={locale.latest}>
|
|
|
- <Show when={!defaultServer.loading && !sidecar.loading && !windowCount.loading && !locale.loading}>
|
|
|
+ <Show when={!defaultServer.loading && !sidecar.loading && !windowConfig.loading && !windowCount.loading && !locale.loading}>
|
|
|
{(_) => {
|
|
|
return (
|
|
|
<AppInterface
|