feat(web): persist workspace presentation across browser hosts — #205

This commit is contained in:
2026-08-15 01:24:23 +02:00
parent 723e2987ef
commit 3b8ce66e33
6 changed files with 542 additions and 13 deletions

View File

@ -0,0 +1,48 @@
import { describe, expect, it } from "vitest";
import {
DEFAULT_WEB_WORKSPACE_PRESENTATION,
parseWebWorkspacePresentationState,
withOpenedSurface,
} from "./webWorkspaceSession";
describe("web workspace presentation persistence (#205)", () => {
it("parses the persisted presentation state and filters unknown opened surfaces", () => {
expect(
parseWebWorkspacePresentationState(
JSON.stringify({
version: 1,
activePanel: "tickets",
primaryRailOpen: false,
secondaryRailOpen: true,
openedSurfaces: {
tickets: "tab",
git: "window",
projects: "tab",
bogus: "window",
agents: "dock",
},
}),
),
).toEqual({
version: 1,
activePanel: "tickets",
primaryRailOpen: false,
secondaryRailOpen: true,
openedSurfaces: {
tickets: "tab",
git: "window",
},
});
});
it("falls back to null for invalid or old state", () => {
expect(parseWebWorkspacePresentationState("not-json")).toBeNull();
expect(parseWebWorkspacePresentationState(JSON.stringify({ version: 0 }))).toBeNull();
});
it("records only openable project surfaces", () => {
expect(withOpenedSurface({}, "tickets", "tab")).toEqual({ tickets: "tab" });
expect(withOpenedSurface(DEFAULT_WEB_WORKSPACE_PRESENTATION.openedSurfaces, "projects", "tab")).toEqual({});
});
});