diff options
| author | Adam <[email protected]> | 2026-03-02 10:50:50 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-03-02 10:50:50 -0600 |
| commit | 8176bafc555e562ade48a675dffa3f38751ed8c9 (patch) | |
| tree | 7d4b0f6e98f431999b89c1f24687f6f53bd0bc6b /packages/app/src/context/global-sync | |
| parent | 0a3a3216db5974efd3edc9a213054fd97d8dbd34 (diff) | |
| download | opencode-8176bafc555e562ade48a675dffa3f38751ed8c9.tar.gz opencode-8176bafc555e562ade48a675dffa3f38751ed8c9.zip | |
chore(app): solidjs refactoring (#13399)
Diffstat (limited to 'packages/app/src/context/global-sync')
| -rw-r--r-- | packages/app/src/context/global-sync/child-store.ts | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/packages/app/src/context/global-sync/child-store.ts b/packages/app/src/context/global-sync/child-store.ts index 2fe5b7830..e2ada244f 100644 --- a/packages/app/src/context/global-sync/child-store.ts +++ b/packages/app/src/context/global-sync/child-store.ts @@ -1,4 +1,4 @@ -import { createRoot, createEffect, getOwner, onCleanup, runWithOwner, type Accessor, type Owner } from "solid-js" +import { createRoot, getOwner, onCleanup, runWithOwner, type Owner } from "solid-js" import { createStore, type SetStoreFunction, type Store } from "solid-js/store" import { Persist, persisted } from "@/utils/persist" import type { VcsInfo } from "@opencode-ai/sdk/v2/client" @@ -131,8 +131,7 @@ export function createChildStoreManager(input: { ) if (!vcs) throw new Error("Failed to create persisted cache") const vcsStore = vcs[0] - const vcsReady = vcs[3] - vcsCache.set(directory, { store: vcsStore, setStore: vcs[1], ready: vcsReady }) + vcsCache.set(directory, { store: vcsStore, setStore: vcs[1], ready: vcs[3] }) const meta = runWithOwner(input.owner, () => persisted( @@ -154,10 +153,12 @@ export function createChildStoreManager(input: { const init = () => createRoot((dispose) => { + const initialMeta = meta[0].value + const initialIcon = icon[0].value const child = createStore<State>({ project: "", - projectMeta: meta[0].value, - icon: icon[0].value, + projectMeta: initialMeta, + icon: initialIcon, provider: { all: [], connected: [], default: {} }, config: {}, path: { state: "", config: "", worktree: "", directory: "", home: "" }, @@ -181,16 +182,27 @@ export function createChildStoreManager(input: { children[directory] = child disposers.set(directory, dispose) - createEffect(() => { - if (!vcsReady()) return + const onPersistedInit = (init: Promise<string> | string | null, run: () => void) => { + if (!(init instanceof Promise)) return + void init.then(() => { + if (children[directory] !== child) return + run() + }) + } + + onPersistedInit(vcs[2], () => { const cached = vcsStore.value if (!cached?.branch) return child[1]("vcs", (value) => value ?? cached) }) - createEffect(() => { + + onPersistedInit(meta[2], () => { + if (child[0].projectMeta !== initialMeta) return child[1]("projectMeta", meta[0].value) }) - createEffect(() => { + + onPersistedInit(icon[2], () => { + if (child[0].icon !== initialIcon) return child[1]("icon", icon[0].value) }) }) |
