Files
fusion/packages/dashboard/app/hooks/modalPersistence.ts
gsxdsm 47ccd20669 feat(FN-936): add modal description persistence for re-entry
- Add modalPersistence hook for saving/restoring modal state (description, goal) via localStorage
- Update PlanningModeModal to persist and restore description across re-opens
- Update SubtaskBreakdownModal to persist and clear description on resume flow
- Update MissionInterviewModal to clear goal after starting interview
- Add unit tests for modalPersistence hook
- Add integration tests for modal re-entry behavior across all three modals
- Add changeset for published package patch bump
2026-04-04 15:56:46 -07:00

62 lines
1.7 KiB
TypeScript

// Storage keys — each modal type has independent storage
export const STORED_PLANNING_KEY = "kb-planning-last-description";
export const STORED_SUBTASK_KEY = "kb-subtask-last-description";
export const STORED_MISSION_KEY = "kb-mission-last-goal";
// Planning persistence
export function savePlanningDescription(description: string): void {
if (typeof window !== "undefined") {
localStorage.setItem(STORED_PLANNING_KEY, description);
}
}
export function getPlanningDescription(): string {
if (typeof window === "undefined") return "";
return localStorage.getItem(STORED_PLANNING_KEY) || "";
}
export function clearPlanningDescription(): void {
if (typeof window !== "undefined") {
localStorage.removeItem(STORED_PLANNING_KEY);
}
}
// Subtask persistence
export function saveSubtaskDescription(description: string): void {
if (typeof window !== "undefined") {
localStorage.setItem(STORED_SUBTASK_KEY, description);
}
}
export function getSubtaskDescription(): string {
if (typeof window === "undefined") return "";
return localStorage.getItem(STORED_SUBTASK_KEY) || "";
}
export function clearSubtaskDescription(): void {
if (typeof window !== "undefined") {
localStorage.removeItem(STORED_SUBTASK_KEY);
}
}
// Mission persistence
export function saveMissionGoal(goal: string): void {
if (typeof window !== "undefined") {
localStorage.setItem(STORED_MISSION_KEY, goal);
}
}
export function getMissionGoal(): string {
if (typeof window === "undefined") return "";
return localStorage.getItem(STORED_MISSION_KEY) || "";
}
export function clearMissionGoal(): void {
if (typeof window !== "undefined") {
localStorage.removeItem(STORED_MISSION_KEY);
}
}