fix: clean up stale generationSession on failure#194
fix: clean up stale generationSession on failure#194YizukiAme wants to merge 2 commits intoTHU-MAIC:mainfrom
Conversation
ce5128f to
4227c6f
Compare
Closes THU-MAIC#185 When generation fails, the session was left in sessionStorage, causing stale settings (e.g. webSearch: true) to replay on page refresh. Now sessionStorage.removeItem('generationSession') is called in the catch block so failed sessions are cleaned up.
4227c6f to
977eb4a
Compare
|
Thanks for the fix. One question before merging: In the normal user flow, if someone goes back to the homepage and reconfigures (e.g. disables web search), Could you clarify the exact reproduction path where a user disables web search but still hits the stale session? I might be missing something. The cleanup itself is good hygiene regardless — just want to make sure the issue description matches the actual bug. |
Thanks for the thorough review!! I originally ran into this during development — I was getting an unexpected Tavily error even though I hadn't configured or enabled web search at all, and after digging through DevTools I found that manually clearing generationSession from sessionStorage resolved it. It happened a few more times after that, so I suspected it was caused by a previously Tavily-enabled session lingering around. 🤔 The reproduction steps in the issue may not be fully accurate — the root cause might be tied to development-specific scenarios that I can't pinpoint exactly right now...? But after applying this one-line fix, I haven't run into the issue again, and the change is minimal. If you'd like, I can try to track down and reproduce the exact trigger more rigorously. 🙃 |
Summary
Fixes stale
generationSessioninsessionStoragecausing false Tavily error on retry.Problem
When generation fails (e.g. missing Tavily API key), the
generationSessioninsessionStorageis not cleaned up. On page refresh, the old session withwebSearch: trueis reloaded and the web search step is re-triggered, producing a confusing Tavily error even if web search was disabled for the new attempt.Fix
Added
sessionStorage.removeItem('generationSession')in thecatchblock ofstartGeneration(), so failed sessions are cleaned up and don't replay stale settings.Testing
tsc --noEmitpassesCloses #185