From 8d17ec65831c4faeb0b518c335819839816e2ad0 Mon Sep 17 00:00:00 2001 From: Amruth Pillai Date: Sat, 4 Jul 2026 21:46:50 +0200 Subject: [PATCH] =?UTF-8?q?refactor(web):=20finding=208=20=E2=80=94=20drop?= =?UTF-8?q?=20localStorage=20migration=20sentinel,=20use=20null-check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Number(null) === 0 caused the old code to use a separate :initialized key as a migration sentinel. A plain null check on localStorage.getItem() is sufficient and removes the sentinel key entirely. Claude-Session: https://claude.ai/code/session_012Bnvt1MghwHj4qQRxuQUGa --- apps/web/src/routes/agent/$threadId.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/apps/web/src/routes/agent/$threadId.tsx b/apps/web/src/routes/agent/$threadId.tsx index 5b888c77d..1f008e56a 100644 --- a/apps/web/src/routes/agent/$threadId.tsx +++ b/apps/web/src/routes/agent/$threadId.tsx @@ -46,7 +46,6 @@ export const Route = createFileRoute("/agent/$threadId")({ }); const AGENT_PREVIEW_ZOOM_STORAGE_KEY = "reactive-resume:agent-preview-zoom:v3"; -const AGENT_PREVIEW_ZOOM_MIGRATION_KEY = `${AGENT_PREVIEW_ZOOM_STORAGE_KEY}:initialized`; const MIN_PREVIEW_ZOOM = 0.4; const MAX_PREVIEW_ZOOM = 1.5; const PREVIEW_ZOOM_STEP = 0.05; @@ -58,14 +57,10 @@ function clampPreviewZoom(value: number) { function getInitialPreviewZoom() { if (typeof window === "undefined") return DEFAULT_PREVIEW_ZOOM; - - if (!window.localStorage.getItem(AGENT_PREVIEW_ZOOM_MIGRATION_KEY)) { - window.localStorage.setItem(AGENT_PREVIEW_ZOOM_STORAGE_KEY, String(DEFAULT_PREVIEW_ZOOM)); - window.localStorage.setItem(AGENT_PREVIEW_ZOOM_MIGRATION_KEY, "true"); - return DEFAULT_PREVIEW_ZOOM; - } - - const stored = Number(window.localStorage.getItem(AGENT_PREVIEW_ZOOM_STORAGE_KEY)); + // ponytail: Number(null) === 0, so guard with a null-check before parsing + const raw = window.localStorage.getItem(AGENT_PREVIEW_ZOOM_STORAGE_KEY); + if (raw === null) return DEFAULT_PREVIEW_ZOOM; + const stored = Number(raw); return Number.isFinite(stored) ? clampPreviewZoom(stored) : DEFAULT_PREVIEW_ZOOM; }