diff options
| author | Adam <[email protected]> | 2026-01-15 07:00:53 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2026-01-15 07:29:13 -0600 |
| commit | 564d3edfac6e3cc872d35d7b2d1e8bc1ea4b84bd (patch) | |
| tree | 1b012bf5ba4ce00b943c234034d1a4025d7eb0f5 /packages/app/src/context/layout.tsx | |
| parent | 679270d9e0731c2b3e2c059d83907cb4086d90e2 (diff) | |
| download | opencode-564d3edfac6e3cc872d35d7b2d1e8bc1ea4b84bd.tar.gz opencode-564d3edfac6e3cc872d35d7b2d1e8bc1ea4b84bd.zip | |
fix(app): new layout issues
Diffstat (limited to 'packages/app/src/context/layout.tsx')
| -rw-r--r-- | packages/app/src/context/layout.tsx | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/packages/app/src/context/layout.tsx b/packages/app/src/context/layout.tsx index ba332be7b..a49e891bf 100644 --- a/packages/app/src/context/layout.tsx +++ b/packages/app/src/context/layout.tsx @@ -47,13 +47,34 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext( const globalSdk = useGlobalSDK() const globalSync = useGlobalSync() const server = useServer() + + const isRecord = (value: unknown): value is Record<string, unknown> => + typeof value === "object" && value !== null && !Array.isArray(value) + + const migrate = (value: unknown) => { + if (!isRecord(value)) return value + const sidebar = value.sidebar + if (!isRecord(sidebar)) return value + if (typeof sidebar.workspaces !== "boolean") return value + return { + ...value, + sidebar: { + ...sidebar, + workspaces: {}, + workspacesDefault: sidebar.workspaces, + }, + } + } + + const target = Persist.global("layout", ["layout.v6"]) const [store, setStore, _, ready] = persisted( - Persist.global("layout", ["layout.v6"]), + { ...target, migrate }, createStore({ sidebar: { opened: false, width: 280, - workspaces: false, + workspaces: {} as Record<string, boolean>, + workspacesDefault: false, }, terminal: { height: 280, @@ -305,12 +326,15 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext( resize(width: number) { setStore("sidebar", "width", width) }, - workspaces: createMemo(() => store.sidebar.workspaces ?? false), - setWorkspaces(value: boolean) { - setStore("sidebar", "workspaces", value) + workspaces(directory: string) { + return createMemo(() => store.sidebar.workspaces[directory] ?? store.sidebar.workspacesDefault ?? false) + }, + setWorkspaces(directory: string, value: boolean) { + setStore("sidebar", "workspaces", directory, value) }, - toggleWorkspaces() { - setStore("sidebar", "workspaces", (x) => !x) + toggleWorkspaces(directory: string) { + const current = store.sidebar.workspaces[directory] ?? store.sidebar.workspacesDefault ?? false + setStore("sidebar", "workspaces", directory, !current) }, }, terminal: { |
