diff options
| author | Adam <[email protected]> | 2026-03-24 18:36:37 -0500 |
|---|---|---|
| committer | Adam <[email protected]> | 2026-03-24 18:36:37 -0500 |
| commit | a379eb38673aad097e1f178307865ec40a5ac3ea (patch) | |
| tree | 5df060e30638eefb2d95f1d8c1abbd6066922df8 /packages/app/src/components/settings-general.tsx | |
| parent | cbe1337f2401066cf33eb9009b597eafb49123ba (diff) | |
| download | opencode-a379eb38673aad097e1f178307865ec40a5ac3ea.tar.gz opencode-a379eb38673aad097e1f178307865ec40a5ac3ea.zip | |
Revert "fix(app): startup efficiency (#18854)"
This reverts commit 546748a461539ca63e188ee07ab2b143c5ac2c83.
Diffstat (limited to 'packages/app/src/components/settings-general.tsx')
| -rw-r--r-- | packages/app/src/components/settings-general.tsx | 50 |
1 files changed, 12 insertions, 38 deletions
diff --git a/packages/app/src/components/settings-general.tsx b/packages/app/src/components/settings-general.tsx index f4b8198e7..b768bafcc 100644 --- a/packages/app/src/components/settings-general.tsx +++ b/packages/app/src/components/settings-general.tsx @@ -1,41 +1,27 @@ -import { Component, Show, createMemo, createResource, onMount, type JSX } from "solid-js" +import { Component, Show, createMemo, createResource, 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" import { Select } from "@opencode-ai/ui/select" import { Switch } from "@opencode-ai/ui/switch" import { Tooltip } from "@opencode-ai/ui/tooltip" -import { useTheme, type ColorScheme } from "@opencode-ai/ui/theme/context" +import { useTheme, type ColorScheme } from "@opencode-ai/ui/theme" import { showToast } from "@opencode-ai/ui/toast" import { useLanguage } from "@/context/language" import { usePlatform } from "@/context/platform" import { useSettings, monoFontFamily } from "@/context/settings" -import { playSoundById, SOUND_OPTIONS } from "@/utils/sound" +import { playSound, SOUND_OPTIONS } from "@/utils/sound" import { Link } from "./link" import { SettingsList } from "./settings-list" let demoSoundState = { cleanup: undefined as (() => void) | undefined, timeout: undefined as NodeJS.Timeout | undefined, - run: 0, -} - -type ThemeOption = { - id: string - name: string -} - -let font: Promise<typeof import("@opencode-ai/ui/font-loader")> | undefined - -function loadFont() { - font ??= import("@opencode-ai/ui/font-loader") - return font } // To prevent audio from overlapping/playing very quickly when navigating the settings menus, // delay the playback by 100ms during quick selection changes and pause existing sounds. const stopDemoSound = () => { - demoSoundState.run += 1 if (demoSoundState.cleanup) { demoSoundState.cleanup() } @@ -43,19 +29,12 @@ const stopDemoSound = () => { demoSoundState.cleanup = undefined } -const playDemoSound = (id: string | undefined) => { +const playDemoSound = (src: string | undefined) => { stopDemoSound() - if (!id) return + if (!src) return - const run = ++demoSoundState.run demoSoundState.timeout = setTimeout(() => { - void playSoundById(id).then((cleanup) => { - if (demoSoundState.run !== run) { - cleanup?.() - return - } - demoSoundState.cleanup = cleanup - }) + demoSoundState.cleanup = playSound(src) }, 100) } @@ -65,10 +44,6 @@ export const SettingsGeneral: Component = () => { const platform = usePlatform() const settings = useSettings() - onMount(() => { - void theme.loadThemes() - }) - const [store, setStore] = createStore({ checking: false, }) @@ -129,7 +104,9 @@ export const SettingsGeneral: Component = () => { .finally(() => setStore("checking", false)) } - const themeOptions = createMemo<ThemeOption[]>(() => theme.ids().map((id) => ({ id, name: theme.name(id) }))) + const themeOptions = createMemo(() => + Object.entries(theme.themes()).map(([id, def]) => ({ id, name: def.name ?? id })), + ) const colorSchemeOptions = createMemo((): { value: ColorScheme; label: string }[] => [ { value: "system", label: language.t("theme.scheme.system") }, @@ -166,7 +143,7 @@ export const SettingsGeneral: Component = () => { ] as const const fontOptionsList = [...fontOptions] - const noneSound = { id: "none", label: "sound.option.none" } as const + const noneSound = { id: "none", label: "sound.option.none", src: undefined } as const const soundOptions = [noneSound, ...SOUND_OPTIONS] const soundSelectProps = ( @@ -181,7 +158,7 @@ export const SettingsGeneral: Component = () => { label: (o: (typeof soundOptions)[number]) => language.t(o.label), onHighlight: (option: (typeof soundOptions)[number] | undefined) => { if (!option) return - playDemoSound(option.id === "none" ? undefined : option.id) + playDemoSound(option.src) }, onSelect: (option: (typeof soundOptions)[number] | undefined) => { if (!option) return @@ -192,7 +169,7 @@ export const SettingsGeneral: Component = () => { } setEnabled(true) set(option.id) - playDemoSound(option.id) + playDemoSound(option.src) }, variant: "secondary" as const, size: "small" as const, @@ -344,9 +321,6 @@ export const SettingsGeneral: Component = () => { current={fontOptionsList.find((o) => o.value === settings.appearance.font())} value={(o) => o.value} label={(o) => language.t(o.label)} - onHighlight={(option) => { - void loadFont().then((x) => x.ensureMonoFont(option?.value)) - }} onSelect={(option) => option && settings.appearance.setFont(option.value)} variant="secondary" size="small" |
