Finalize learning algorithm - #4
Conversation
bi-directional confusions, untested (sql logic error)
https://github.com/NeonD00m/quizzy into finalize-learning-algorithm
…D00m/quizzy into finalize-learning-algorithm
automated "Easy" in learn mode
There was a problem hiding this comment.
🟡 Changes recommended
There are several confirmed correctness issues in the new dashboard/stats persistence paths (FSRS timestamping, dashboard query counting/filtering, and INTEGER/REAL score handling) that can produce wrong scheduling or misleading/invalid UI behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR finalizes the app’s learning/study workflow by replacing SM-2 with an FSRS-based scheduler, introducing new study modes (Learn/Test/Cram/Study), revamping stats output accordingly, and adding safer SQLite schema versioning plus bulk import/export commands to support migrations and device transfers.
Changes:
- Introduces an FSRS engine + persistence path for learn sessions, plus a new interactive “Learn Dashboard”.
- Splits prior “learn” behavior into dedicated
Learn(FSRS) andTest(non-FSRS) modes and adds “Cram/Study” flashcard-style mode. - Adds versioned SQLite migrations and new ImportAll/ExportAll commands to improve storage resilience and transfer workflows.
File summaries
| File | Description |
|---|---|
| src/ui/stats.rs | Updates stats UI to display FSRS-oriented labels/fields (stability/difficulty/due). |
| src/ui/learn.rs | Adds Learn dashboard, implements FSRS learn session loop, and renames old learn flow into test mode. |
| src/ui/input.rs | Generalizes input handling with key_input and restores enter_input as a wrapper. |
| src/ui/import.rs | Updates deck creation call signature to new storage API. |
| src/ui/general.rs | Expands deck selection behavior and adds ImportAll/Export/ExportAll commands. |
| src/ui/cards.rs | Makes Cards mode optionally interactive via storage + adds cram mode implementation. |
| src/migrations/002_sm2_to_fsrs.sql | Rebuilds card_stats schema from SM-2 columns to FSRS columns. |
| src/migrations/003_drop_source_hash.sql | Rebuilds decks table to drop unused source_hash. |
| src/migrations/004_add_fsrs_lapses_and_state.sql | Adds FSRS lapses/state tracking fields. |
| src/mcp/server.rs | Updates MCP server output + storage calls to match FSRS/storage API changes. |
| src/main.rs | Adds new CLI commands/modes and wires them into updated UI/core flows. |
| src/core/storage.rs | Adds FSRSStats, dashboard queries, new commit APIs, and migration runner integration. |
| src/core/mod.rs | Exposes new core modules (fsrs, migrations). |
| src/core/migrations.rs | Introduces schema migration runner + embedded migration list. |
| src/core/learn.rs | Replaces legacy session delta format with JSON SessionPayload + unified commit retry. |
| src/core/fsrs.rs | Adds FSRS scheduling engine implementation + tests. |
| src/core/deck.rs | Enhances deck file parsing/writing (JSON includes deck name; names inferred from filename). |
| my_todo.json | Updates local TODO metadata format (tags/files) and completion statuses. |
| benches/mc_bench.rs | Adjusts bench code to new read_deck_from_file signature. |
Review details
Suppressed comments (2)
src/core/storage.rs:711
get_weakest_cardsusesCOALESCE(s.learning_score, 0.0)but then reads the column into ani64. Iflearning_scoreever becomes REAL (or if SQLite returns a REAL due to the literal), this can fail or coerce unexpectedly. Since the schema is INTEGER, coalesce with0(integer).
let mut stmt = self.conn.prepare(
"SELECT c.id, c.term, c.definition, COALESCE(s.learning_score, 0.0) as score
FROM cards c
LEFT JOIN card_stats s ON c.id = s.card_id
WHERE c.deck_id = ?1
src/core/storage.rs:815
- The dashboard query filters out decks with
due_cards == 0, which can makelearn_dashboardreport "No decks found" even when decks exist (just with nothing due/new). The dashboard should likely list all decks and show 0s.
.filter(|res| {
if let Ok(i) = res {
i.due_cards > 0
} else {
- Files reviewed: 19/19 changed files
- Comments generated: 6
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
three new study modes:
test(renamed oldlearnmode),cram/study, and the newlearnmode with FSRS integrated-> revamped stats dashboard accordingly to abandon old SM-2 and bring in FSRS stuff
also upgraded sqlite storage systems to handle versions and migrations better, and added ExportAll and ImportAll commands to import and export all decks in case of a storage update problem where one might reinstall Quizzy or just to transfer in between devices or something