diff --git a/packages/app/src/components/settings-general.tsx b/packages/app/src/components/settings-general.tsx index b79b29f127..b5ec6e7fab 100644 --- a/packages/app/src/components/settings-general.tsx +++ b/packages/app/src/components/settings-general.tsx @@ -1,4 +1,4 @@ -import { Component, Show, createMemo, createResource, onMount, type JSX } from "solid-js" +import { Component, Show, createMemo, onMount, type JSX } from "solid-js" import { createStore } from "solid-js/store" import { Button } from "@opencode-ai/ui/button" import { Icon } from "@opencode-ai/ui/icon" @@ -11,7 +11,7 @@ import { showToast } from "@opencode-ai/ui/toast" import { useParams } from "@solidjs/router" import { useLanguage } from "@/context/language" import { usePermission } from "@/context/permission" -import { usePlatform } from "@/context/platform" +import { usePlatform, type DisplayBackend } from "@/context/platform" import { useGlobalSync } from "@/context/global-sync" import { useGlobalSDK } from "@/context/global-sdk" import { @@ -91,12 +91,10 @@ export const SettingsGeneral: Component = () => { const params = useParams() const settings = useSettings() - onMount(() => { - void theme.loadThemes() - }) - const [store, setStore] = createStore({ checking: false, + shells: [] as ShellOption[], + displayBackend: null as DisplayBackend | null, }) const linux = createMemo(() => platform.platform === "desktop" && platform.os === "linux") @@ -186,12 +184,22 @@ export const SettingsGeneral: Component = () => { const globalSync = useGlobalSync() const globalSdk = useGlobalSDK() - const [shells] = createResource(() => globalSdk.client.pty.shells().then((res) => res.data || [])) + const syncDisplayBackend = () => { + if (!linux() || !platform.getDisplayBackend) return + return Promise.resolve(platform.getDisplayBackend()).then((value) => setStore("displayBackend", value)).catch(() => undefined) + } + + onMount(() => { + void theme.loadThemes() + void globalSdk.client.pty.shells().then((res) => setStore("shells", res.data || [])).catch(() => undefined) + void syncDisplayBackend() + }) + const autoOption = { id: "auto", value: "", label: "Auto (Default)" } const currentShell = createMemo(() => globalSync.data.config.shell ?? "") const shellOptions = createMemo(() => { - const list = shells() || [] + const list = store.shells const current = globalSync.data.config.shell const nameCounts = new Map() @@ -220,6 +228,14 @@ export const SettingsGeneral: Component = () => { return options }) + const onDisplayBackendChange = (checked: boolean) => { + const update = platform.setDisplayBackend?.(checked ? "wayland" : "auto") + if (!update) return + void update.finally(() => { + void syncDisplayBackend() + }) + } + const colorSchemeOptions = createMemo((): { value: ColorScheme; label: string }[] => [ { value: "system", label: language.t("theme.scheme.system") }, { value: "light", label: language.t("theme.scheme.light") }, @@ -727,70 +743,32 @@ export const SettingsGeneral: Component = () => { - {/* - {(_) => { - const [enabledResource, actions] = createResource(() => platform.getWslEnabled?.()) - const enabled = () => (enabledResource.state === "pending" ? undefined : enabledResource.latest) - - return ( -
-

{language.t("settings.desktop.section.wsl")}

- - - -
- platform.setWslEnabled?.(checked)?.finally(() => actions.refetch())} - /> -
-
-
-
- ) - }} -
*/} - - {(_) => { - const [valueResource, actions] = createResource(() => platform.getDisplayBackend?.()) - const value = () => (valueResource.state === "pending" ? undefined : valueResource.latest) +
+

{language.t("settings.general.section.display")}

- const onChange = (checked: boolean) => - platform.setDisplayBackend?.(checked ? "wayland" : "auto").finally(() => actions.refetch()) - - return ( -
-

{language.t("settings.general.section.display")}

- - - - {language.t("settings.general.row.wayland.title")} - - - - - -
- } - description={language.t("settings.general.row.wayland.description")} - > -
- -
- - -
- ) - }} + + + {language.t("settings.general.row.wayland.title")} + + + + + + + } + description={language.t("settings.general.row.wayland.description")} + > +
+ +
+
+
+