Persist workflow choices across dashboard board surfaces so operators return to their selected lane reliably. - Add project-scoped durable storage helpers for board workflow selection with stale-id validation and cleanup. - Share the workflow selection hook across Board, List, Header, and Graph surfaces while preserving cached payloads on transient refresh failures. - Update List quick-create/planning handoffs, cross-surface tests, and dashboard documentation for durable workflow selection behavior. - Add patch changesets for the published Fusion package. Files changed: .changeset/fn-7234-durable-board-workflow-selection.md | 7 ++ .changeset/workflow-selection-board-list.md | 7 ++ docs/dashboard-guide.md | 5 +- .../workflow-selection-cross-surface.test.tsx | 66 ++++++++-- packages/dashboard/app/components/ListView.tsx | 111 ++++------------- .../app/components/__tests__/Board.test.tsx | 45 +++++++ .../__tests__/GraphWorkflowSwitcherSlot.test.tsx | 57 +++++++++ .../__tests__/HeaderWorkflowSwitcherSlot.test.tsx | 42 ++++++- .../app/components/__tests__/ListView.test.tsx | 122 +++++++++++++++++++ .../app/hooks/__tests__/useBoardWorkflows.test.ts | 29 +++++ packages/dashboard/app/hooks/useBoardWorkflows.ts | 64 ++++++++- .../utils/__tests__/boardWorkflowSelection.test.ts | 135 +++++++++++++++++++++ .../app/utils/__tests__/projectStorage.test.ts | 3 +- .../dashboard/app/utils/boardWorkflowSelection.ts | 49 ++++++++ packages/dashboard/app/utils/projectStorage.ts | 1 + 15 files changed, 633 insertions(+), 110 deletions(-) Fusion-Task-Id: FN-7234 Fusion-Task-Lineage: 6ebc000c-19c3-4a8e-9303-4e18a59902ed Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
149 lines
5.5 KiB
TypeScript
149 lines
5.5 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
import {
|
|
GLOBAL_STORAGE_KEYS,
|
|
PROJECT_STORAGE_KEYS,
|
|
getScopedItem,
|
|
removeScopedItem,
|
|
scopedKey,
|
|
setScopedItem,
|
|
} from "../projectStorage";
|
|
|
|
describe("projectStorage", () => {
|
|
beforeEach(() => {
|
|
localStorage.clear();
|
|
});
|
|
|
|
describe("scopedKey", () => {
|
|
it("returns scoped key when projectId is provided", () => {
|
|
expect(scopedKey("kb-dashboard-list-columns", "proj-abc")).toBe(
|
|
"kb:proj-abc:kb-dashboard-list-columns",
|
|
);
|
|
});
|
|
|
|
it("returns base key unchanged when projectId is undefined", () => {
|
|
expect(scopedKey("kb-dashboard-list-columns", undefined)).toBe("kb-dashboard-list-columns");
|
|
});
|
|
|
|
it("returns base key unchanged when projectId is omitted", () => {
|
|
expect(scopedKey("kb-dashboard-list-columns")).toBe("kb-dashboard-list-columns");
|
|
});
|
|
|
|
it("returns base key unchanged when projectId is empty", () => {
|
|
expect(scopedKey("kb-dashboard-list-columns", "")).toBe("kb-dashboard-list-columns");
|
|
});
|
|
|
|
it("returns base key unchanged when projectId is null", () => {
|
|
expect(scopedKey("kb-dashboard-list-columns", null as any)).toBe("kb-dashboard-list-columns");
|
|
});
|
|
});
|
|
|
|
it("uses scoped keys for get/set/remove with projectId", () => {
|
|
setScopedItem("kb-dashboard-list-columns", "value", "proj-abc");
|
|
|
|
expect(localStorage.getItem("kb:proj-abc:kb-dashboard-list-columns")).toBe("value");
|
|
expect(getScopedItem("kb-dashboard-list-columns", "proj-abc")).toBe("value");
|
|
|
|
removeScopedItem("kb-dashboard-list-columns", "proj-abc");
|
|
expect(localStorage.getItem("kb:proj-abc:kb-dashboard-list-columns")).toBeNull();
|
|
});
|
|
|
|
it("uses unscoped keys for get/set/remove without projectId", () => {
|
|
setScopedItem("kb-dashboard-list-columns", "value");
|
|
|
|
expect(localStorage.getItem("kb-dashboard-list-columns")).toBe("value");
|
|
expect(getScopedItem("kb-dashboard-list-columns")).toBe("value");
|
|
|
|
removeScopedItem("kb-dashboard-list-columns");
|
|
expect(localStorage.getItem("kb-dashboard-list-columns")).toBeNull();
|
|
});
|
|
|
|
it("includes all global storage keys", () => {
|
|
expect(GLOBAL_STORAGE_KEYS).toEqual(
|
|
expect.arrayContaining([
|
|
"kb-dashboard-theme-mode",
|
|
"kb-dashboard-color-theme",
|
|
"kb-dashboard-view-mode",
|
|
"kb-dashboard-current-project",
|
|
"kb-dashboard-recent-projects",
|
|
"fn-agent-log-markdown",
|
|
"fn-agent-log-tool-output",
|
|
]),
|
|
);
|
|
expect(GLOBAL_STORAGE_KEYS).toHaveLength(7);
|
|
});
|
|
|
|
it("includes all project-scoped storage keys", () => {
|
|
expect(PROJECT_STORAGE_KEYS).toEqual(
|
|
expect.arrayContaining([
|
|
"kb-dashboard-task-view",
|
|
"kb-dashboard-list-columns",
|
|
"kb-dashboard-hide-done",
|
|
"kb-dashboard-list-collapsed",
|
|
"kb-dashboard-selected-tasks",
|
|
"kb-dashboard-list-selected-task",
|
|
"kb-dashboard-list-sidebar-width",
|
|
"kb-dashboard-mailbox-sidebar-width",
|
|
"kb-dashboard-agents-sidebar-width",
|
|
"kb-dashboard-github-import-list-width",
|
|
"kb-quick-entry-text",
|
|
"kb-inline-create-text",
|
|
"fn-agent-view",
|
|
"kb-terminal-tabs",
|
|
"kb-planning-last-description",
|
|
"kb-subtask-last-description",
|
|
"kb-mission-last-goal",
|
|
"kb-usage-view-mode",
|
|
"kb-usage-hidden-windows",
|
|
"kb-usage-modal-size",
|
|
"kb-usage-provider-order",
|
|
"kb-chat-active-session",
|
|
"kb-dashboard-working-branch-filter",
|
|
"kb-dashboard-base-branch-filter",
|
|
"kb-capacity-risk-banner-dismissed",
|
|
"kb-files-line-numbers",
|
|
"kb-dashboard-dock-files-current",
|
|
"kb-dashboard-board-workflow-selection",
|
|
"fusion-plugin-dependency-graph:positions",
|
|
]),
|
|
);
|
|
expect(PROJECT_STORAGE_KEYS).toHaveLength(29);
|
|
});
|
|
|
|
it("stores branch filter values as scoped strings per project", () => {
|
|
setScopedItem("kb-dashboard-working-branch-filter", "feature/a", "proj-1");
|
|
setScopedItem("kb-dashboard-base-branch-filter", "__fusion:no-branch__", "proj-1");
|
|
setScopedItem("kb-dashboard-working-branch-filter", "feature/b", "proj-2");
|
|
|
|
expect(getScopedItem("kb-dashboard-working-branch-filter", "proj-1")).toBe("feature/a");
|
|
expect(getScopedItem("kb-dashboard-base-branch-filter", "proj-1")).toBe("__fusion:no-branch__");
|
|
expect(getScopedItem("kb-dashboard-working-branch-filter", "proj-2")).toBe("feature/b");
|
|
expect(getScopedItem("kb-dashboard-working-branch-filter", "proj-3")).toBeNull();
|
|
});
|
|
|
|
it("getScopedItem returns null when localStorage.getItem is unavailable", () => {
|
|
vi.stubGlobal("window", { localStorage: {} });
|
|
expect(getScopedItem("kb-dashboard-list-columns", "proj-abc")).toBeNull();
|
|
vi.unstubAllGlobals();
|
|
});
|
|
|
|
it("setScopedItem is a no-op when localStorage.setItem is unavailable", () => {
|
|
vi.stubGlobal("window", { localStorage: {} });
|
|
expect(() => setScopedItem("kb-dashboard-list-columns", "value", "proj-abc")).not.toThrow();
|
|
vi.unstubAllGlobals();
|
|
});
|
|
|
|
it("removeScopedItem is a no-op when localStorage.removeItem is unavailable", () => {
|
|
vi.stubGlobal("window", { localStorage: {} });
|
|
expect(() => removeScopedItem("kb-dashboard-list-columns", "proj-abc")).not.toThrow();
|
|
vi.unstubAllGlobals();
|
|
});
|
|
|
|
it("has no overlap between global and project-scoped keys", () => {
|
|
const globalSet = new Set(GLOBAL_STORAGE_KEYS);
|
|
const overlap = PROJECT_STORAGE_KEYS.filter((key) => globalSet.has(key));
|
|
|
|
expect(overlap).toEqual([]);
|
|
});
|
|
});
|