Add: Frontend

This commit is contained in:
Luc Mcgrady 2025-06-19 22:17:45 +01:00
parent 233c5c19a9
commit b7bd1e05ee
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C
3 changed files with 38 additions and 6 deletions

View file

@ -7,7 +7,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
ComputeRetentionProgress, ComputeRetentionProgress,
type ComputeParamsProgress, type ComputeParamsProgress,
} from "@generated/anki/collection_pb"; } from "@generated/anki/collection_pb";
import { SimulateFsrsReviewRequest } from "@generated/anki/scheduler_pb"; import {
CMRRTarget,
SimulateFsrsReviewRequest,
} from "@generated/anki/scheduler_pb";
import { import {
computeFsrsParams, computeFsrsParams,
evaluateParams, evaluateParams,
@ -94,6 +97,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
newCardsIgnoreReviewLimit: $newCardsIgnoreReviewLimit, newCardsIgnoreReviewLimit: $newCardsIgnoreReviewLimit,
easyDaysPercentages: $config.easyDaysPercentages, easyDaysPercentages: $config.easyDaysPercentages,
reviewOrder: $config.reviewOrder, reviewOrder: $config.reviewOrder,
target: CMRRTarget.memorised,
}); });
const DESIRED_RETENTION_LOW_THRESHOLD = 0.8; const DESIRED_RETENTION_LOW_THRESHOLD = 0.8;

View file

@ -18,21 +18,23 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import { renderSimulationChart } from "../graphs/simulator"; import { renderSimulationChart } from "../graphs/simulator";
import { computeOptimalRetention, simulateFsrsReview } from "@generated/backend"; import { computeOptimalRetention, simulateFsrsReview } from "@generated/backend";
import { runWithBackendProgress } from "@tslib/progress"; import { runWithBackendProgress } from "@tslib/progress";
import type { import {
ComputeOptimalRetentionResponse, CMRRTarget,
SimulateFsrsReviewRequest, type ComputeOptimalRetentionResponse,
SimulateFsrsReviewResponse, type SimulateFsrsReviewRequest,
type SimulateFsrsReviewResponse,
} from "@generated/anki/scheduler_pb"; } from "@generated/anki/scheduler_pb";
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
import SwitchRow from "$lib/components/SwitchRow.svelte"; import SwitchRow from "$lib/components/SwitchRow.svelte";
import GlobalLabel from "./GlobalLabel.svelte"; import GlobalLabel from "./GlobalLabel.svelte";
import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte"; import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte";
import { reviewOrderChoices } from "./choices"; import { CMRRTargetChoices, reviewOrderChoices } from "./choices";
import EnumSelectorRow from "$lib/components/EnumSelectorRow.svelte"; import EnumSelectorRow from "$lib/components/EnumSelectorRow.svelte";
import { DeckConfig_Config_LeechAction } from "@generated/anki/deck_config_pb"; import { DeckConfig_Config_LeechAction } from "@generated/anki/deck_config_pb";
import EasyDaysInput from "./EasyDaysInput.svelte"; import EasyDaysInput from "./EasyDaysInput.svelte";
import Warning from "./Warning.svelte"; import Warning from "./Warning.svelte";
import type { ComputeRetentionProgress } from "@generated/anki/collection_pb"; import type { ComputeRetentionProgress } from "@generated/anki/collection_pb";
import Item from "$lib/components/Item.svelte";
export let shown = false; export let shown = false;
export let state: DeckOptionsState; export let state: DeckOptionsState;
@ -410,6 +412,18 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
{#if computingRetention} {#if computingRetention}
<div>{computeRetentionProgressString}</div> <div>{computeRetentionProgressString}</div>
{/if} {/if}
<Item>
<EnumSelectorRow
choices={CMRRTargetChoices()}
bind:value={simulateFsrsRequest.target}
defaultValue={CMRRTarget.memorised}
>
<SettingTitle>
{"Target: "}
</SettingTitle>
</EnumSelectorRow>
</Item>
</details> </details>
<button <button

View file

@ -11,6 +11,7 @@ import {
DeckConfig_Config_ReviewCardOrder, DeckConfig_Config_ReviewCardOrder,
DeckConfig_Config_ReviewMix, DeckConfig_Config_ReviewMix,
} from "@generated/anki/deck_config_pb"; } from "@generated/anki/deck_config_pb";
import { CMRRTarget } from "@generated/anki/scheduler_pb";
import * as tr from "@generated/ftl"; import * as tr from "@generated/ftl";
import type { Choice } from "$lib/components/EnumSelector.svelte"; import type { Choice } from "$lib/components/EnumSelector.svelte";
@ -199,6 +200,19 @@ export function questionActionChoices(): Choice<DeckConfig_Config_QuestionAction
]; ];
} }
export function CMRRTargetChoices(): Choice<CMRRTarget>[] {
return [
{
label: "Memorized (Default)",
value: CMRRTarget.memorised,
},
{
label: "Stability (Experimental)",
value: CMRRTarget.stability,
},
];
}
function difficultyOrders(fsrs: boolean): Choice<DeckConfig_Config_ReviewCardOrder>[] { function difficultyOrders(fsrs: boolean): Choice<DeckConfig_Config_ReviewCardOrder>[] {
const order = [ const order = [
{ {