Skip to content

Real-time study queue updates#12

Merged
bootuz merged 5 commits into
mainfrom
feature/realtime-due-queue
Jun 4, 2026
Merged

Real-time study queue updates#12
bootuz merged 5 commits into
mainfrom
feature/realtime-due-queue

Conversation

@bootuz
Copy link
Copy Markdown
Owner

@bootuz bootuz commented Jun 4, 2026

Summary

The study-queue surfaces computed card "dueness" as fsrsDue <= now() inside a combine { } block, which only re-runs when an upstream Flow emits. A card becoming due is pure wall-clock time crossing a threshold — no data changes at that instant — so the counts went stale until some unrelated event (an edit, a sync, or re-subscription) forced a recompute. This PR makes time itself a reactive input so the queue refreshes the exact moment a card becomes due, with no data change, navigation, or restart.

  • New operator core/domain/fsrs/DueTicker.ktFlow<List<Card>>.withDueTicks(now): pairs each card list with a now timestamp re-emitted precisely at the soonest future fsrsDue (event-driven via flatMapLatest + delay). Reschedules on card changes; idles (no busy-wait) when nothing is future-due; flatMapLatest cancels the pending wait when WhileSubscribed unsubscribes (zero background wakeups).
  • StudyQueueViewModel (Today/Queue home) and DeckDetailViewModel (deck Due/New stats + the Study ↔ "You're all caught up!" slot) now feed their cards flow through the operator and consume the reactive nowMillis.

Out of scope: the active study session stays a fixed snapshot; studiedToday midnight rollover; OS background/notification refresh.

Test plan

  • DueTickerTest (6 JVM tests, Turbine + virtual time): immediate emit + idle on no-future-due; re-emit exactly when a future Review card becomes due; soonest-then-next ordering; Learning-state watched; deleted card ignored; restart on card-list change.
  • StudyQueueViewModelTest + LibraryAndDeckDetailViewModelTest: a near-future card starts uncounted, then appears in dueCount/readyCount after virtual time advances past its due moment.
  • Full unit-test suite green; :app:assembleDebug BUILD SUCCESSFUL.
  • Manual smoke (pending emulator): leave the Today/deck screen open with a card due shortly — count rises and the action slot flips at the due moment, no navigation; backgrounding past the due moment and returning shows correct counts immediately.

🤖 Generated with Claude Code

@bootuz bootuz merged commit 2978b53 into main Jun 4, 2026
1 check passed
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