refactor: stop persisting workspace state in the browser

This commit is contained in:
2026-08-14 17:43:10 +02:00
parent 3978008aed
commit fd3b62ce6f
11 changed files with 101 additions and 310 deletions
+28 -4
View File
@@ -1,15 +1,39 @@
import { expect, test } from "vitest";
import { beforeEach, expect, test } from "vitest";
import { workspacePreferences } from "./preferences";
test("migrates legacy selections once and keeps later browser choices", () => {
beforeEach(() => {
localStorage.clear();
workspacePreferences.reset();
});
test("keeps selections only in current application memory", () => {
localStorage.setItem("unrelated", "keep-me");
workspacePreferences.save({
workspaceId: "research",
provider: "deepseek",
model: "deepseek-v4-pro",
thinking: "high",
});
expect(workspacePreferences.load()).toEqual({
workspaceId: "research",
provider: "deepseek",
model: "deepseek-v4-pro",
thinking: "high",
});
expect(localStorage.length).toBe(1);
expect(localStorage.getItem("unrelated")).toBe("keep-me");
expect(localStorage.getItem("thothii.workspace-registry.v1.preferences")).toBeNull();
});
test("seeds memory from backend settings once and returns defensive copies", () => {
expect(workspacePreferences.migrate({
workspaceId: "psd-clinical", provider: "zai", model: "glm-5.2", thinking: "medium",
})).toMatchObject({ workspaceId: "psd-clinical", model: "glm-5.2" });
workspacePreferences.save({ workspaceId: "research", provider: "deepseek", model: "deepseek-v4-pro", thinking: "high" });
const snapshot = workspacePreferences.load();
snapshot.workspaceId = "mutated-copy";
expect(workspacePreferences.migrate({ workspaceId: "legacy" })).toMatchObject({
workspaceId: "research", provider: "deepseek", model: "deepseek-v4-pro", thinking: "high",
workspaceId: "psd-clinical", provider: "zai", model: "glm-5.2", thinking: "medium",
});
});