From d159aaa7041e2417f18ffeab86a4abdc2d28a506 Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Tue, 8 Jul 2025 17:40:17 +0800 Subject: [PATCH] Add historical retention field to FSRS review request and update related logic - Added `historical_retention` field to `SimulateFsrsReviewRequest` in `scheduler.proto`. - Updated `simulator.rs` to use `req.historical_retention` instead of the removed `desired_retention`. - Modified `FsrsOptions.svelte` to include `historicalRetention` in the options passed to the component. --- proto/anki/scheduler.proto | 1 + rslib/src/scheduler/fsrs/simulator.rs | 3 +-- ts/routes/deck-options/FsrsOptions.svelte | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/proto/anki/scheduler.proto b/proto/anki/scheduler.proto index 01f092a39..1294b4543 100644 --- a/proto/anki/scheduler.proto +++ b/proto/anki/scheduler.proto @@ -404,6 +404,7 @@ message SimulateFsrsReviewRequest { repeated float easy_days_percentages = 10; deck_config.DeckConfig.Config.ReviewCardOrder review_order = 11; optional uint32 suspend_after_lapse_count = 12; + float historical_retention = 13; } message SimulateFsrsReviewResponse { diff --git a/rslib/src/scheduler/fsrs/simulator.rs b/rslib/src/scheduler/fsrs/simulator.rs index 2d43cc4a7..4e0907eb3 100644 --- a/rslib/src/scheduler/fsrs/simulator.rs +++ b/rslib/src/scheduler/fsrs/simulator.rs @@ -146,7 +146,6 @@ impl Collection { let new_cards = cards.iter().filter(|c| c.queue == CardQueue::New).count() + req.deck_size as usize; let fsrs = FSRS::new(Some(&req.params))?; - let historical_retention = req.desired_retention; let mut converted_cards = cards .into_iter() .filter(is_included_card) @@ -157,7 +156,7 @@ impl Collection { .memory_state_from_sm2( c.ease_factor(), c.interval as f32, - historical_retention, + req.historical_retention, ) .ok()? .into(), diff --git a/ts/routes/deck-options/FsrsOptions.svelte b/ts/routes/deck-options/FsrsOptions.svelte index 706407889..cfdea341c 100644 --- a/ts/routes/deck-options/FsrsOptions.svelte +++ b/ts/routes/deck-options/FsrsOptions.svelte @@ -95,6 +95,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html newCardsIgnoreReviewLimit: $newCardsIgnoreReviewLimit, easyDaysPercentages: $config.easyDaysPercentages, reviewOrder: $config.reviewOrder, + historicalRetention: $config.historicalRetention, }); const DESIRED_RETENTION_LOW_THRESHOLD = 0.8;