From c2530549165a5185b19d355d505fe2dd27e66af6 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 10 Jun 2026 23:57:27 +0530 Subject: [PATCH] refactor: Make persisted() values raw state The getter handed out a deep $state proxy, so in-place mutation of a persisted array/record would update the UI while silently never being written to localStorage. All consumers already replace .value wholesale; $state.raw makes that the only semantics and drops the per-read proxy overhead. Co-Authored-By: Claude Fable 5 --- src/lib/util/persist.svelte.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/util/persist.svelte.ts b/src/lib/util/persist.svelte.ts index a8c8e0fb..34b092a2 100644 --- a/src/lib/util/persist.svelte.ts +++ b/src/lib/util/persist.svelte.ts @@ -37,8 +37,10 @@ export interface Persisted { } // A localStorage-backed reactive value. Reads on init, writes on every set. +// Raw state: replace `value` wholesale to change it. With a deep proxy, +// in-place mutation would update the UI without ever being persisted. export const persisted = (key: string, initial: T): Persisted => { - let value = $state(readJSON(key, initial)); + let value = $state.raw(readJSON(key, initial)); return { get value() { return value;