Skip to content

fix: persist whiteboard history (per-stage) and whiteboard content across refresh#136

Open
YizukiAme wants to merge 1 commit intoTHU-MAIC:mainfrom
YizukiAme:fix/whiteboard-persistence
Open

fix: persist whiteboard history (per-stage) and whiteboard content across refresh#136
YizukiAme wants to merge 1 commit intoTHU-MAIC:mainfrom
YizukiAme:fix/whiteboard-persistence

Conversation

@YizukiAme
Copy link
Contributor

@YizukiAme YizukiAme commented Mar 19, 2026

Summary

Fix whiteboard data loss on page refresh by:

  1. Persisting whiteboard history per-stage — Refactored whiteboard-history.ts to store snapshots grouped by stageId (via snapshotsByStage: Record<string, WhiteboardSnapshot[]>) and added Zustand persist middleware with localStorage backend.

  2. Persisting current whiteboard content to IndexedDB — Added whiteboard?: Whiteboard[] field to StageRecord in database.ts and included data.stage.whiteboard in saveStageData() in stage-storage.ts. Previously, stage.whiteboard was silently dropped during serialization because StageRecord didn't include this field.

Changes

Whiteboard History Persistence (per-stage)

File Change
lib/store/whiteboard-history.ts Refactored: snapshotssnapshotsByStage, all actions now accept stageId. Added persist middleware (localStorage key: openmaic-whiteboard-history).
components/whiteboard/index.tsx Pass stageId to pushSnapshot() and getSnapshots().
components/whiteboard/whiteboard-history.tsx Pass stageId to getSnapshots() and getSnapshot().
components/whiteboard/whiteboard-canvas.tsx Pass stageId to auto-snapshot pushSnapshot() call.
lib/action/engine.ts Pass stageId to pushSnapshot() in executeWbClear().

Whiteboard Content Persistence (IndexedDB)

File Change
lib/utils/database.ts Added whiteboard?: Whiteboard[] to StageRecord interface.
lib/utils/stage-storage.ts Include data.stage.whiteboard when saving to db.stages.

Testing

  • pnpm tsc --noEmit passes
  • History snapshots persist across page refresh
  • History is isolated per-stage (switching stages shows correct history)
  • Whiteboard content persists across page refresh
  • IndexedDB stages table contains whiteboard field after save
  • localStorage key openmaic-whiteboard-history contains per-stage snapshots

@YizukiAme YizukiAme force-pushed the fix/whiteboard-persistence branch 3 times, most recently from a70c9ba to efccd0d Compare March 19, 2026 17:32
…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
@YizukiAme YizukiAme force-pushed the fix/whiteboard-persistence branch from efccd0d to cea1dbb Compare March 20, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant