Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/hooks/use-scene-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import type { SceneOutline, PdfImage, ImageMapping } from '@/lib/types/generation';
import type { AgentInfo } from '@/lib/generation/generation-pipeline';
import type { Scene } from '@/lib/types/stage';
import type { Action, SpeechAction } from '@/lib/types/action';

Check warning on line 11 in lib/hooks/use-scene-generator.ts

View workflow job for this annotation

GitHub Actions / Lint & Typecheck

'Action' is defined but never used. Allowed unused vars must match /^_/u
import type { TTSProviderId } from '@/lib/audio/types';

Check warning on line 12 in lib/hooks/use-scene-generator.ts

View workflow job for this annotation

GitHub Actions / Lint & Typecheck

'TTSProviderId' is defined but never used. Allowed unused vars must match /^_/u
import { splitLongSpeechActions } from '@/lib/audio/tts-utils';
import { generateMediaForOutlines } from '@/lib/media/media-orchestrator';
import { createLogger } from '@/lib/logger';
Expand Down Expand Up @@ -403,6 +403,25 @@
if (!abortRef.current && !pausedByFailureOrAbort) {
store.getState().setGenerationStatus('completed');
store.getState().setGeneratingOutlines([]);

// Persist course to server disk so the classroom opens in other browsers
try {
const finalState = store.getState();
const finalStage = finalState.stage;
const finalScenes = finalState.scenes;
if (finalStage && finalScenes.length > 0) {
await fetch('/api/classroom', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ stage: finalStage, scenes: finalScenes }),
});
log.info('Classroom persisted to server disk:', finalStage.id);
}
} catch (persistErr) {
// Non-fatal — generation is complete, disk write failure should not block the user
log.warn('Failed to persist classroom to server disk:', persistErr);
}

options.onComplete?.();
}
} catch (err: unknown) {
Expand Down
Loading