The open source coding agent.
TypeScript
fix(app): persist workspace order and collapsed state
Adamda3dea0429a3
diff --git a/packages/app/src/pages/layout.tsx b/packages/app/src/pages/layout.tsxindex 72224f34952..2a36a99f25e 100644--- a/packages/app/src/pages/layout.tsx+++ b/packages/app/src/pages/layout.tsx@@ -16,6 +16,7 @@ import {import { A, useNavigate, useParams } from "@solidjs/router"import { useLayout, getAvatarColors, LocalProject } from "@/context/layout"import { useGlobalSync } from "@/context/global-sync"+import { Persist, persisted } from "@/utils/persist"import { base64Decode, base64Encode } from "@opencode-ai/util/encode"import { Avatar } from "@opencode-ai/ui/avatar"import { ResizeHandle } from "@opencode-ai/ui/resize-handle"@@ -62,13 +63,16 @@ import { Titlebar } from "@/components/titlebar"import { useServer } from "@/context/server"export default function Layout(props: ParentProps) {- const [store, setStore] = createStore({- lastSession: {} as { [directory: string]: string },- activeProject: undefined as string | undefined,- activeWorkspace: undefined as string | undefined,- workspaceOrder: {} as Record<string, string[]>,- workspaceExpanded: {} as Record<string, boolean>,- })+ const [store, setStore, , ready] = persisted(+ Persist.global("layout.page", ["layout.page.v1"]),+ createStore({+ lastSession: {} as { [directory: string]: string },+ activeProject: undefined as string | undefined,+ activeWorkspace: undefined as string | undefined,+ workspaceOrder: {} as Record<string, string[]>,+ workspaceExpanded: {} as Record<string, boolean>,+ }),+ )let scrollContainerRef: HTMLDivElement | undefinedconst xlQuery = window.matchMedia("(min-width: 1280px)")@@ -289,6 +293,7 @@ export default function Layout(props: ParentProps) {})createEffect(() => {+ if (!ready()) returnconst project = currentProject()if (!project) return@@ -708,7 +713,7 @@ export default function Layout(props: ParentProps) {const id = params.idsetStore("lastSession", directory, id)notification.session.markViewed(id)- untrack(() => setStore("workspaceExpanded", directory, true))+ untrack(() => setStore("workspaceExpanded", directory, (value) => value ?? true))requestAnimationFrame(() => scrollToSession(id))})