From 4b1b920e8bc557a592f505a4619062b1067a233e Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Mon, 22 Jun 2026 14:55:45 +0900 Subject: feat: persist sidebar layout + open/closed state between refreshes Sidebar panel layout (which views are open and their order) and the sidebar open/closed toggle are now persisted to localStorage. Default layout is just the Model view at the top. - ViewSidebar accepts an onChange callback that reports panel kinds - App.svelte creates two createLocalStore instances (dispatch.sidebar.views + dispatch.sidebar.open) using the store's storage adapter - AppStore exposes its storage instance so the shell persists via the same adapter (test-injectable, not globalThis.localStorage) - Tests pre-populate fake storage with ["extensions"] for the 4 tests that need the Extensions view visible 686 tests green. 0 svelte-check warnings (2 pre-existing errors from missing transport-contract exports, unchanged). --- src/app/App.test.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/app/App.test.ts') diff --git a/src/app/App.test.ts b/src/app/App.test.ts index d22f84b..6a39296 100644 --- a/src/app/App.test.ts +++ b/src/app/App.test.ts @@ -98,6 +98,12 @@ function createFakeStorage(): Storage { }; } +function createFakeStorageWithViews(views: readonly string[] = ["extensions"]): Storage { + const storage = createFakeStorage(); + storage.setItem("dispatch.sidebar.views", JSON.stringify(views)); + return storage; +} + function sentMessages(ws: FakeSocket) { return ws.sent.map((s) => JSON.parse(s)); } @@ -161,7 +167,7 @@ describe("App component interaction tests", () => { const store = createAppStore({ socketFactory: () => ws, fetchImpl: fakeFetchImpl(), - localStorage: createFakeStorage(), + localStorage: createFakeStorageWithViews(), }); ws.resolveOpen(); @@ -225,7 +231,7 @@ describe("App component interaction tests", () => { const store = createAppStore({ socketFactory: () => ws, fetchImpl: fakeFetchImpl(), - localStorage: createFakeStorage(), + localStorage: createFakeStorageWithViews(), }); ws.resolveOpen(); @@ -345,7 +351,7 @@ describe("App component interaction tests", () => { const store = createAppStore({ socketFactory: () => ws, fetchImpl: fakeFetchImpl(), - localStorage: createFakeStorage(), + localStorage: createFakeStorageWithViews(), }); ws.resolveOpen(); @@ -388,13 +394,13 @@ describe("App component interaction tests", () => { const store = createAppStore({ socketFactory: () => ws, fetchImpl: fakeFetchImpl(), - localStorage: createFakeStorage(), + localStorage: createFakeStorageWithViews(), }); ws.resolveOpen(); render(App, { props: { store } }); - // Extensions is the default view, so the modules table renders immediately. + // Extensions view is pre-populated in the fake storage, so the modules table renders immediately. expect(screen.getByRole("columnheader", { name: "Module" })).toBeInTheDocument(); for (const name of [ "chat", -- cgit v1.2.3