Skip to content

fix: quality-adjusted SM-2 first intervals and review UX freeze#10

Merged
prithaxdev merged 1 commit into
mainfrom
sprint-3/fix-review-scheduling-and-ux
Apr 30, 2026
Merged

fix: quality-adjusted SM-2 first intervals and review UX freeze#10
prithaxdev merged 1 commit into
mainfrom
sprint-3/fix-review-scheduling-and-ux

Conversation

@prithaxdev
Copy link
Copy Markdown
Owner

@prithaxdev prithaxdev commented Apr 30, 2026

  • sm2.py: first review now gives 4-day interval for Easy (quality>=4) and 2-day for Hard (quality==3) instead of always 1; Forgot unchanged
  • test_sm2.py: replace fixed-interval test with separate Easy/Hard cases
  • use-review.ts: fix query key mismatch — invalidate snippetKeys.due with clerkId to match useDueSnippets, not Supabase UUID; keep supabaseUserId for review log invalidation
  • review-session.tsx: track submittingRating (1|3|5|null) per click; wrap mutateAsync in try/catch so errors show an inline banner instead of silently freezing
  • review-card.tsx: spinner replaces label on the active rating button while request is in-flight; idle buttons dim to 40% (not 50%)

Summary by CodeRabbit

Release Notes

  • New Features

    • Quality-based scheduling for initial reviews: high-confidence ratings now schedule 4 days ahead, while moderate-confidence ratings schedule 2 days ahead.
  • Improvements

    • Enhanced review interface with visual feedback indicating which rating is being submitted, including a loading animation.
    • Added error handling and user-facing messages for failed review submissions.

- sm2.py: first review now gives 4-day interval for Easy (quality>=4)
  and 2-day for Hard (quality==3) instead of always 1; Forgot unchanged
- test_sm2.py: replace fixed-interval test with separate Easy/Hard cases
- use-review.ts: fix query key mismatch — invalidate snippetKeys.due with
  clerkId to match useDueSnippets, not Supabase UUID; keep supabaseUserId
  for review log invalidation
- review-session.tsx: track submittingRating (1|3|5|null) per click;
  wrap mutateAsync in try/catch so errors show an inline banner instead
  of silently freezing
- review-card.tsx: spinner replaces label on the active rating button
  while request is in-flight; idle buttons dim to 40% (not 50%)
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 6d625fe2-7543-40d9-b5c5-3546eaa44335

📥 Commits

Reviewing files that changed from the base of the PR and between 6349c5b and e9675ec.

📒 Files selected for processing (5)
  • apps/api/app/algorithms/sm2.py
  • apps/api/tests/test_sm2.py
  • apps/web/components/review-card.tsx
  • apps/web/components/review-session.tsx
  • apps/web/hooks/use-review.ts

📝 Walkthrough

Walkthrough

Changes update the SM-2 spaced repetition algorithm to use quality-based scheduling on first-memory success, update corresponding tests, and enhance the review card UI to display which rating is being submitted with improved error handling in the submission flow.

Changes

Cohort / File(s) Summary
SM-2 Algorithm and Tests
apps/api/app/algorithms/sm2.py, apps/api/tests/test_sm2.py
Updated SM-2 first-success scheduling to use quality-conditioned intervals: quality ≥ 4 schedules 4 days, quality [3, 4) schedules 2 days (previously fixed to 1 day). Tests updated to assert new interval expectations for Easy and Hard quality ratings on first review.
Review Card UI Enhancements
apps/web/components/review-card.tsx, apps/web/components/review-session.tsx
Replaced boolean isSubmitting with submittingRating to track which specific rating is being processed. Active rating button shows spinning loader and "Saving…" text; inactive ratings show normal text with reduced opacity. Added error handling to display error banner when submission fails, with state reset on completion.
Review Hook Authentication
apps/web/hooks/use-review.ts
Changed query invalidation to use Clerk's clerkId for due-snippet queries instead of Supabase user id; added separate Supabase id retrieval with conditional invalidation to prevent calls with undefined identifiers.

Sequence Diagram

sequenceDiagram
    participant User
    participant ReviewSession
    participant ReviewCard
    participant API as API/Mutation

    User->>ReviewSession: Click rating button
    activate ReviewSession
    ReviewSession->>ReviewSession: Set submittingRating state
    ReviewSession->>ReviewCard: Pass submittingRating prop
    activate ReviewCard
    ReviewCard->>ReviewCard: Render loader for active rating<br/>Show "Saving…" text
    ReviewCard-->>ReviewSession: (visual feedback)
    deactivate ReviewCard
    ReviewSession->>API: mutateAsync (submit review)
    activate API
    alt Success
        API-->>ReviewSession: Success response
        ReviewSession->>ReviewSession: Advance session index/done
    else Failure
        API-->>ReviewSession: Error response
        ReviewSession->>ReviewSession: Store submitError message
        ReviewSession->>ReviewCard: Error banner renders
    end
    ReviewSession->>ReviewSession: Reset submittingRating (finally)
    deactivate API
    deactivate ReviewSession
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 The spacing grows with wisdom's might,
First memories now pace just right—
Two days or four, by quality's call,
While rating buttons dance through all,
With loaders spinning, errors caught,
A smoother flow our review has wrought!


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Review rate limit: 2/3 reviews remaining, refill in 20 minutes.

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

@prithaxdev prithaxdev merged commit d01d5e4 into main Apr 30, 2026
1 of 2 checks passed
@railway-app railway-app Bot temporarily deployed to awake-fascination / production April 30, 2026 08:03 Inactive
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