Files
fusion/packages/dashboard/app/utils/projectStorage.ts
Fusion f8abef2858 feat(FN-3626): migrate plugin storage to project-scoped storage
Migrated the dependency-graph plugin's storage layer to use the project's scoped storage API (`projectStorage`) and added canonical storage-key assertions. The ChatView.tsx utility reference was updated to match the new storage path.

Fusion-Task-Id: FN-3626
2026-05-06 22:17:35 -07:00

66 lines
1.7 KiB
TypeScript

export const GLOBAL_STORAGE_KEYS: string[] = [
"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",
];
export const PROJECT_STORAGE_KEYS: string[] = [
"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-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-files-line-numbers",
"fusion-plugin-dependency-graph:positions",
];
export function scopedKey(baseKey: string, projectId?: string): string {
if (typeof projectId !== "string" || projectId.length === 0) {
return baseKey;
}
return `kb:${projectId}:${baseKey}`;
}
export function getScopedItem(baseKey: string, projectId?: string): string | null {
if (typeof window === "undefined") {
return null;
}
return window.localStorage.getItem(scopedKey(baseKey, projectId));
}
export function setScopedItem(baseKey: string, value: string, projectId?: string): void {
if (typeof window === "undefined") {
return;
}
window.localStorage.setItem(scopedKey(baseKey, projectId), value);
}
export function removeScopedItem(baseKey: string, projectId?: string): void {
if (typeof window === "undefined") {
return;
}
window.localStorage.removeItem(scopedKey(baseKey, projectId));
}