Skip to content

fix(notetaker): flush debounced autosave + carry course context to tutor#207

Merged
Jose-Gael-Cruz-Lopez merged 2 commits into
mainfrom
fix/notetaker-data-loss
Jun 12, 2026
Merged

fix(notetaker): flush debounced autosave + carry course context to tutor#207
Jose-Gael-Cruz-Lopez merged 2 commits into
mainfrom
fix/notetaker-data-loss

Conversation

@Jose-Gael-Cruz-Lopez

Copy link
Copy Markdown
Member

What

Fixes two notetaker data-loss bugs from #133:

  1. Dropped debounced autosave. The 800ms-debounced patchNote cleared its pending timer on unmount / note-switch without flushing, so edits typed within the debounce window were silently lost while the footer still read "Saved" — including when clicking Send to tutor / Generate quiz, which router.push and unmount the page.
  2. Lost course context on send-to-tutor. onSendToTutor pushes /learn?topic=…&course=<id>, but LearnInner only read topic/mode/suggest. selectedCourseId stayed "" and the session started with no courseId.

Why

Users lost recent edits when navigating away from a note, and tutor sessions launched from a note silently dropped the note's course, weakening the learning context. Both are correctness/data-integrity issues (P2).

How verified

  • Track the latest pending patch per note alongside its timer; flush it on note-change, on unmount, on pagehide (tab close), and before send-to-tutor / generate-quiz navigation. Pending patches are merged so partial title/body/tags edits aren't lost. The pagehide flush uses a keepalive request so it survives the unload.
  • Footer is now driven by save state (Saved / Unsaved changes / Saving…) so it no longer falsely claims "Saved".
  • LearnInner seeds selectedCourseId from searchParams.get("course"), so the carried-over course flows into startSession and the course selector.
  • cd frontend && npx tsc --noEmit → clean (exit 0).
  • cd frontend && npx vitest run → 5 files, 37 tests passing.

Closes #133

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Jose-Gael-Cruz-Lopez, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 51 minutes and 57 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f188426f-f826-4abf-bc82-e97397662d0a

📥 Commits

Reviewing files that changed from the base of the PR and between 824d7e4 and b54888a.

📒 Files selected for processing (3)
  • frontend/src/app/(shell)/notetaker/page.tsx
  • frontend/src/components/screens/Learn.tsx
  • frontend/src/lib/api.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/notetaker-data-loss

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 12, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
frontend b54888a Commit Preview URL

Branch Preview URL
Jun 12 2026, 05:03 AM

The 800ms-debounced autosave cleared its timer on unmount/note-switch
without firing, so edits typed within the window were lost while the
footer still read Saved. Track the latest pending patch per note and
flush it on note change, on unmount, and before send-to-tutor /
generate-quiz navigation. The tab-close flush uses a keepalive request so
it survives the unload, and the footer now reflects unsaved/saving state.
LearnInner read topic/mode/suggest from the URL but never course, so a
note sent to the tutor lost its course context: selectedCourseId stayed
empty and the session started without a courseId. Seed selectedCourseId
from searchParams.get("course") so the carried-over course flows into
startSession and the course selector.
@Jose-Gael-Cruz-Lopez Jose-Gael-Cruz-Lopez merged commit 7091e6b into main Jun 12, 2026
5 checks passed
@Jose-Gael-Cruz-Lopez Jose-Gael-Cruz-Lopez deleted the fix/notetaker-data-loss branch June 12, 2026 04:54
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.

[P2] Notetaker data loss: dropped debounced autosave + lost course context on send-to-tutor

1 participant