Skip to content

Fix response detection and add notebook title sync - #48

Open
ajagjivan-celonis wants to merge 1 commit into
PleasePrompto:masterfrom
ajagjivan-celonis:fix/response-detection-and-title-sync
Open

Fix response detection and add notebook title sync#48
ajagjivan-celonis wants to merge 1 commit into
PleasePrompto:masterfrom
ajagjivan-celonis:fix/response-detection-and-title-sync

Conversation

@ajagjivan-celonis

Copy link
Copy Markdown

Summary

  • Fix stale/cached responses being returned instead of actual answers
  • Add automatic notebook title sync from NotebookLM UI to local library
  • Improve typing resilience against DOM re-renders

Problem 1: Stale Responses

The ask_question.py script was returning cached responses from chat history instead of the actual answer. NotebookLM's DOM inserts new responses at arbitrary positions (not always at the end), and the original code captured baselines before async history loaded.

Problem 2: Notebook Names Out of Sync

Local library.json stored names at add-time but never updated them when users renamed notebooks in NotebookLM's web UI.

Solution

  • Resilient typing: Replace element.type() with page.fill() to prevent DOM detachment errors during React re-renders
  • Hash-based detection: Capture hashes of all existing responses before submitting, then identify new responses by checking which element's hash isn't in the baseline set
  • Title sync: Extract notebook name from page.title() and auto-update library.json when names differ

Test plan

  • Simple math questions return correct fresh answers
  • Complex multi-part queries work correctly
  • New notebooks auto-detect title on add
  • Title sync triggers when names differ

🤖 Generated with Claude Code

- Replace character-by-character typing with page.fill() to prevent
  DOM detachment errors during React re-renders
- Wait for chat history to fully load before capturing baseline
- Use hash-based detection to find new responses (NotebookLM inserts
  them at arbitrary DOM positions, not always at the end)
- Add question verification after typing
- Auto-detect notebook title from page.title() and sync with local
  library.json when names differ

Fixes stale/cached responses being returned instead of actual answers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

1 participant