Skip to content

fix(storage): local disk persistence for classroom data generated via browser UI flow (#53)#213

Open
AsadAliQuant wants to merge 1 commit intoTHU-MAIC:mainfrom
AsadAliQuant:fix/classroom-disk-persistence
Open

fix(storage): local disk persistence for classroom data generated via browser UI flow (#53)#213
AsadAliQuant wants to merge 1 commit intoTHU-MAIC:mainfrom
AsadAliQuant:fix/classroom-disk-persistence

Conversation

@AsadAliQuant
Copy link
Copy Markdown

Summary

Fixes #53 — classrooms generated via the browser UI are now persisted to data/classrooms/{id}.json on the server disk after generation completes.

Related Issues

Closes #53

Changes

  • lib/hooks/use-scene-generator.ts — added POST /api/classroom call after all scenes finish generating in the browser UI flow, triggering the existing persistClassroom() which writes the classroom JSON to disk atomically

Root Cause

OpenMAIC has two generation flows:

  • API/OpenClaw flow — runs server-side via classroom-generation.ts, already called persistClassroom() correctly
  • Browser UI flow — runs client-side via use-scene-generator.ts, saved to IndexedDB only and never wrote to disk

This meant every classroom created through the normal browser UI was only accessible in the browser that generated it — switching to another browser shows "Classroom not found" because IndexedDB is local to each browser.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Verification

Steps to reproduce / test

  1. Generate a course via the browser UI
  2. Wait for generation to complete
  3. Check that data/classrooms/{id}.json is created on disk
  4. Open the classroom URL in a different browser — should load correctly

What I personally verified

  • Generated course in Chrome — data/classrooms/{id}.json created with full course data
  • Opened same URL in Edge — loaded correctly from disk
  • The call is non-fatal — if it fails, generation completes normally and a warning is logged

Evidence

  • npx tsc --noEmit passes — no new TypeScript errors
  • Manually tested locally

Notes

Zero new dependencies. No schema changes. One file changed.

Opening a persisted course in another browser requires pasting the direct classroom URL (e.g. http://localhost:3000/classroom/{id}). The home page course list still reads from IndexedDB only — showing disk-persisted courses on the home page is a separate improvement.

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.

[Bug] 课程数据未持久化到服务器磁盘

1 participant