From 7102c487c9860d9eb3e0f7ccbc8a155bd2351152 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" <219766164+opencode-agent[bot]@users.noreply.github.com> Date: Mon, 24 Aug 2026 12:59:50 +0800 Subject: [PATCH] fix(app): sync project list between windows (#44600) Co-authored-by: Brendonovich <14191578+Brendonovich@users.noreply.github.com> --- packages/app/src/runtime/persistence/storage.ts | 17 ++++++++++++++--- packages/app/src/runtime/server/registry.tsx | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/app/src/runtime/persistence/storage.ts b/packages/app/src/runtime/persistence/storage.ts index ffc1189520a..896ced93a50 100644 --- a/packages/app/src/runtime/persistence/storage.ts +++ b/packages/app/src/runtime/persistence/storage.ts @@ -1,7 +1,7 @@ import { Platform, usePlatform } from "@/runtime/platform/platform" -import { makePersisted, type AsyncStorage, type SyncStorage } from "@solid-primitives/storage" +import { makePersisted, messageSync, type AsyncStorage, type SyncStorage } from "@solid-primitives/storage" import { checksum } from "@opencode-ai/util/encode" -import { createResource, type Accessor } from "solid-js" +import { createResource, onCleanup, type Accessor } from "solid-js" import type { SetStoreFunction, Store } from "solid-js/store" import { pathKey } from "@/workspaces/path-key" import { ScopedKey, ServerScope } from "@/runtime/server/scope" @@ -16,6 +16,7 @@ type PersistedWithReady = [ type PersistTarget = { draft?: boolean + sync?: boolean storage?: string scope?: "window" workspaceStorageAliases?: string[] @@ -637,7 +638,17 @@ export function persisted( return api })() - const [state, setState, init] = makePersisted(store, { name: config.key, storage }) + const channel = + config.sync && typeof BroadcastChannel !== "undefined" + ? new BroadcastChannel(`opencode.persist:${config.storage ?? "default"}:${config.key}`) + : undefined + if (channel) onCleanup(() => channel.close()) + + const [state, setState, init] = makePersisted(store, { + name: config.key, + storage, + sync: channel ? messageSync(channel) : undefined, + }) const isAsync = init instanceof Promise const [ready] = createResource( diff --git a/packages/app/src/runtime/server/registry.tsx b/packages/app/src/runtime/server/registry.tsx index 7b44203af45..4387a99ea58 100644 --- a/packages/app/src/runtime/server/registry.tsx +++ b/packages/app/src/runtime/server/registry.tsx @@ -264,6 +264,7 @@ export const { use: useServers, provider: ServersProvider } = createSimpleContex const [store, setStore, _] = persisted( { ...Persist.global("server"), + sync: true, previousKey: "server.v3", migrate: (value) => migrateCanonicalLocalServerState(value, props.canonicalLocalServer), },