diff options
| author | adamelmore <[email protected]> | 2026-01-26 10:04:59 -0600 |
|---|---|---|
| committer | adamelmore <[email protected]> | 2026-01-26 11:26:17 -0600 |
| commit | d05ed5ca83e03904c7c3dda23a6dcccfd607bdce (patch) | |
| tree | 1afcb055bcedf8b477472f0b25432b318a95f53b /packages/app/src/context/command.tsx | |
| parent | 37f1a1a4ef36eacb60ad5493db8aeb1130c5fa91 (diff) | |
| download | opencode-d05ed5ca83e03904c7c3dda23a6dcccfd607bdce.tar.gz opencode-d05ed5ca83e03904c7c3dda23a6dcccfd607bdce.zip | |
chore(app): createStore over signals
Diffstat (limited to 'packages/app/src/context/command.tsx')
| -rw-r--r-- | packages/app/src/context/command.tsx | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/packages/app/src/context/command.tsx b/packages/app/src/context/command.tsx index dc5228b82..791569584 100644 --- a/packages/app/src/context/command.tsx +++ b/packages/app/src/context/command.tsx @@ -1,4 +1,4 @@ -import { createEffect, createMemo, createSignal, onCleanup, onMount, type Accessor } from "solid-js" +import { createEffect, createMemo, onCleanup, onMount, type Accessor } from "solid-js" import { createStore } from "solid-js/store" import { createSimpleContext } from "@opencode-ai/ui/context" import { useDialog } from "@opencode-ai/ui/context/dialog" @@ -165,8 +165,10 @@ export const { use: useCommand, provider: CommandProvider } = createSimpleContex const dialog = useDialog() const settings = useSettings() const language = useLanguage() - const [registrations, setRegistrations] = createSignal<Accessor<CommandOption[]>[]>([]) - const [suspendCount, setSuspendCount] = createSignal(0) + const [store, setStore] = createStore({ + registrations: [] as Accessor<CommandOption[]>[], + suspendCount: 0, + }) const [catalog, setCatalog, _, catalogReady] = persisted( Persist.global("command.catalog.v1"), @@ -184,7 +186,7 @@ export const { use: useCommand, provider: CommandProvider } = createSimpleContex const seen = new Set<string>() const all: CommandOption[] = [] - for (const reg of registrations()) { + for (const reg of store.registrations) { for (const opt of reg()) { if (seen.has(opt.id)) continue seen.add(opt.id) @@ -230,7 +232,7 @@ export const { use: useCommand, provider: CommandProvider } = createSimpleContex ] }) - const suspended = () => suspendCount() > 0 + const suspended = () => store.suspendCount > 0 const palette = createMemo(() => { const config = settings.keybinds.get(PALETTE_ID) ?? DEFAULT_PALETTE_KEYBIND @@ -297,9 +299,9 @@ export const { use: useCommand, provider: CommandProvider } = createSimpleContex return { register(cb: () => CommandOption[]) { const results = createMemo(cb) - setRegistrations((arr) => [results, ...arr]) + setStore("registrations", (arr) => [results, ...arr]) onCleanup(() => { - setRegistrations((arr) => arr.filter((x) => x !== results)) + setStore("registrations", (arr) => arr.filter((x) => x !== results)) }) }, trigger(id: string, source?: "palette" | "keybind" | "slash") { @@ -321,7 +323,7 @@ export const { use: useCommand, provider: CommandProvider } = createSimpleContex }, show: showPalette, keybinds(enabled: boolean) { - setSuspendCount((count) => count + (enabled ? -1 : 1)) + setStore("suspendCount", (count) => count + (enabled ? -1 : 1)) }, suspended, get catalog() { |
