feat(draft): add local autosave + restore prompt + publish label

This commit is contained in:
2026-01-29 03:16:31 +00:00
parent b3f3329c79
commit a7039c5875
3 changed files with 211 additions and 9 deletions

View File

@@ -63,6 +63,9 @@ interface SpecStoreActions {
// WebSocket integration - set spec directly without API call
setSpecFromWebSocket: (spec: AtomizerSpec, studyId?: string) => void;
// Local draft integration (S2) - set spec locally (no API call) and mark dirty
setSpecLocalDraft: (spec: AtomizerSpec, studyId?: string) => void;
// Full spec operations
saveSpec: (spec: AtomizerSpec) => Promise<void>;
replaceSpec: (spec: AtomizerSpec) => Promise<void>;
@@ -402,6 +405,20 @@ export const useSpecStore = create<SpecStore>()(
});
},
// Set spec locally as a draft (no API call). This is used by DraftManager (S2).
// Marks the spec as dirty to indicate "not published".
setSpecLocalDraft: (spec: AtomizerSpec, studyId?: string) => {
const currentStudyId = studyId || get().studyId;
console.log('[useSpecStore] Setting spec from local draft:', spec.meta?.study_name);
set({
spec,
studyId: currentStudyId,
isLoading: false,
isDirty: true,
error: null,
});
},
// =====================================================================
// Full Spec Operations
// =====================================================================