From 009de295088a321c351d83070a30ca801a8d9a4a Mon Sep 17 00:00:00 2001 From: QQ Date: Wed, 11 Nov 2026 22:32:50 +0800 Subject: [PATCH] Import src/client/stores.ts --- src/client/stores.ts | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/client/stores.ts diff --git a/src/client/stores.ts b/src/client/stores.ts new file mode 100644 index 0000000..fdd8729 --- /dev/null +++ b/src/client/stores.ts @@ -0,0 +1,44 @@ +/** + * The workspace-groups viewing store: category / workspace folder expansion, + * persisted across reloads under an independent key (the official + * ui-workspace store keeps its own `dsh.workspace.view.v5` — we never touch + * it). Module level exports the factory only (a module-level handle would pin + * the store identity across plugin reloads); register() receives the factory + * and the browser derives its PropsStore share from the return type. + * + * The action implementations live in `store-core.ts` (pure, runtime-free) so + * unit tests exercise the real semantics without a browser module loader; + * this file only binds them through defineStore. + */ +import { defineStore, type EngineStoreHandle } from '@deepseek-ai/dsh-client-store' +import { + retainKeysImpl, + setCategoryExpandedImpl, + setWorkspaceExpandedImpl, + type GroupsViewState, +} from './store-core.ts' + +/** Annotation twin of the actions literal below (structural type, satisfies `ActionsDecl`). */ +type GroupsViewActions = { + setCategoryExpanded: typeof setCategoryExpandedImpl + setWorkspaceExpanded: typeof setWorkspaceExpandedImpl + retainKeys: typeof retainKeysImpl +} + +/** + * Create the workspace-groups viewing store handle. + * @returns the store handle (spec + type + identity + factory in one). + */ +export function createGroupsViewStore(): EngineStoreHandle { + return defineStore({ + init: () => ({ categoryExpansion: {}, workspaceExpansion: {} }), + persist: 'dsh.workspace.groups.view.v1', + actions: { + setCategoryExpanded: setCategoryExpandedImpl, + setWorkspaceExpanded: setWorkspaceExpandedImpl, + retainKeys: retainKeysImpl, + }, + }) +} + +export type { GroupsViewState } from './store-core.ts'