-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Bug Description
When a classroom generation fails on the /generation-preview page (e.g., due to a missing Tavily API key), the stale generationSession in sessionStorage is not cleaned up.
If the user then refreshes the page or navigates back to /generation-preview, the old session (with webSearch: true) is reloaded and the web search step is re-triggered — even if the user didn't enable web search this time. This produces a confusing error:
Tavily API key is not configured. Set it in Settings → Web Search or set TAVILY_API_KEY env var.
Root Cause
In app/generation-preview/page.tsx, the catch block (line ~727) does not call sessionStorage.removeItem('generationSession'). The session is only cleaned up on success (line 724) or when the user clicks "Back" (line 747).
Steps to Reproduce
- Enable "Web Search" in generation settings (without configuring a Tavily API key)
- Start classroom generation → it will fail with the Tavily error
- Go back to the homepage, disable "Web Search", and start a new generation
- Refresh the
/generation-previewpage → the old session withwebSearch: trueis loaded → same Tavily error appears
Expected Behavior
Failed generation sessions should be cleaned up so that refreshing /generation-preview doesn't replay stale settings.
Suggested Fix
Add sessionStorage.removeItem('generationSession') in the catch block of startGeneration():
} catch (err) {
if (err instanceof DOMException && err.name === 'AbortError') {
log.info('[GenerationPreview] Generation aborted');
return;
}
+ sessionStorage.removeItem('generationSession');
setError(err instanceof Error ? err.message : String(err));
}Deployment Method
Local development (pnpm dev)
Browser
Chrome
Note: This is a one-line fix — just add sessionStorage.removeItem('generationSession') in the catch block.