fix: persist whiteboard history (per-stage) and whiteboard content across refresh#136
Open
YizukiAme wants to merge 1 commit intoTHU-MAIC:mainfrom
Open
fix: persist whiteboard history (per-stage) and whiteboard content across refresh#136YizukiAme wants to merge 1 commit intoTHU-MAIC:mainfrom
YizukiAme wants to merge 1 commit intoTHU-MAIC:mainfrom
Conversation
a70c9ba to
efccd0d
Compare
…ross refresh 1. Whiteboard history persistence: - Refactor whiteboard-history.ts: snapshots -> snapshotsByStage (Record<stageId, snapshots>) - Add Zustand persist middleware (localStorage key: openmaic-whiteboard-history) - Pass stageId to pushSnapshot in all call sites (index.tsx, whiteboard-canvas.tsx, whiteboard-history.tsx, engine.ts) 2. Whiteboard content persistence (IndexedDB): - Add whiteboard field to StageRecord in database.ts - Include stage.whiteboard in saveStageData in stage-storage.ts
efccd0d to
cea1dbb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix whiteboard data loss on page refresh by:
Persisting whiteboard history per-stage — Refactored
whiteboard-history.tsto store snapshots grouped bystageId(viasnapshotsByStage: Record<string, WhiteboardSnapshot[]>) and added Zustandpersistmiddleware withlocalStoragebackend.Persisting current whiteboard content to IndexedDB — Added
whiteboard?: Whiteboard[]field toStageRecordindatabase.tsand includeddata.stage.whiteboardinsaveStageData()instage-storage.ts. Previously,stage.whiteboardwas silently dropped during serialization becauseStageRecorddidn't include this field.Changes
Whiteboard History Persistence (per-stage)
lib/store/whiteboard-history.tssnapshots→snapshotsByStage, all actions now acceptstageId. Addedpersistmiddleware (localStoragekey:openmaic-whiteboard-history).components/whiteboard/index.tsxstageIdtopushSnapshot()andgetSnapshots().components/whiteboard/whiteboard-history.tsxstageIdtogetSnapshots()andgetSnapshot().components/whiteboard/whiteboard-canvas.tsxstageIdto auto-snapshotpushSnapshot()call.lib/action/engine.tsstageIdtopushSnapshot()inexecuteWbClear().Whiteboard Content Persistence (IndexedDB)
lib/utils/database.tswhiteboard?: Whiteboard[]toStageRecordinterface.lib/utils/stage-storage.tsdata.stage.whiteboardwhen saving todb.stages.Testing
pnpm tsc --noEmitpassesstagestable containswhiteboardfield after savelocalStoragekeyopenmaic-whiteboard-historycontains per-stage snapshots