web: reset checker state on navigation to avoid stale enabled/options

When switching between checkers via the sidebar, plan.enabled retained
the previous checker's values because the guard condition prevented
re-initialization. Reset all derived state eagerly on checkerId change
and always repopulate plan.enabled from fresh status.
This commit is contained in:
nemunaire 2026-05-20 16:30:32 +08:00
commit 0a120a6d97

View file

@ -78,10 +78,19 @@
});
let scheduleCard = $state<{ save: () => Promise<void> } | undefined>(undefined);
$effect(() => {
// Reset state when switching checkers
checkerId;
plan = { enabled: {} };
resolvedStatus = null;
optionValues = {};
inheritedValues = {};
});
$effect(() => {
checkStatusPromise.then((status) => {
resolvedStatus = status;
if (status?.rules && Object.keys(plan.enabled ?? {}).length === 0) {
if (status?.rules) {
const enabled: Record<string, boolean> = {};
for (const rule of status.rules) {
if (rule.name) enabled[rule.name] = true;