fix: clear IndexedDB/localStorage before each query to prevent stale-cache bug#42
Open
koffuxu wants to merge 1 commit into
Open
fix: clear IndexedDB/localStorage before each query to prevent stale-cache bug#42koffuxu wants to merge 1 commit into
koffuxu wants to merge 1 commit into
Conversation
…cache bug NotebookLM persists the full conversation in the browser's IndexedDB. On every run the persistent Chrome profile reloaded the entire accumulated history, causing the answer-detection loop to treat old messages as the current response and either return stale content or spin until timeout. Fix: - Navigate to notebooklm.google.com root first and wipe IndexedDB, localStorage, and sessionStorage via page.evaluate() before loading the target notebook. This ensures the page always starts with 0 messages so the first response that appears is the answer to the current question. - Replace click-based textarea focus with JS focus() to bypass any lingering Material Design overlay backdrops left after UI interactions. - Replace click() with click(force=True) in StealthUtils.human_type() for the same reason. - Simplify response-detection loop: set previous_count = 0 (no pre-snapshot needed) and accept any response where count > 0 or text changed, stable across 3 consecutive polls (~1.5 s). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
NotebookLM persists the full conversation history in the browser's IndexedDB. Because
ask_question.pyuses a persistent Chrome profile (user_data_dir), every run reloaded the entire accumulated history from previous sessions. This caused two failure modes:Fix
scripts/ask_question.pyhttps://notebooklm.google.com/) and wipelocalStorage,sessionStorage, and all IndexedDB databases viapage.evaluate()before loading the target notebook. This ensures the page always starts with 0 messages.previous_count = 0(no pre-snapshot needed) and accept any response wherecount > 0or text changed, stable across 3 consecutive polls (~1.5 s).focus()before typing to bypass any lingering Material Design overlay backdrops that can blockclick()after UI interactions.scripts/browser_utils.pyclick(force=True)inStealthUtils.human_type()to bypass overlay backdrops.Testing
Verified with headless Chromium on macOS. Query "方言识别支持哪几种方言?" returns a correct, on-topic answer in under 5 seconds (3 stable polls).
🤖 Generated with Claude Code