From bd98315fe31bf8ea8d2f387a07f25f8498650936 Mon Sep 17 00:00:00 2001 From: "claude (blind_chess)" Date: Mon, 18 May 2026 20:27:25 -0400 Subject: [PATCH] fix(client): guard phantom-store mutations against unset game and no-op move Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/client/src/lib/stores/phantoms.svelte.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/client/src/lib/stores/phantoms.svelte.ts b/packages/client/src/lib/stores/phantoms.svelte.ts index a2e6ecf..e351e93 100644 --- a/packages/client/src/lib/stores/phantoms.svelte.ts +++ b/packages/client/src/lib/stores/phantoms.svelte.ts @@ -38,11 +38,13 @@ function makeStore() { } function place(sq: Square, type: PieceType) { + if (!gameId) return; state.phantoms = { ...state.phantoms, [sq]: { color: oppColor, type } }; persist(); } function move(from: Square, to: Square) { + if (!gameId || from === to) return; const p = state.phantoms[from]; if (!p) return; const next = { ...state.phantoms }; @@ -53,6 +55,7 @@ function makeStore() { } function remove(sq: Square) { + if (!gameId) return; const next = { ...state.phantoms }; delete next[sq]; state.phantoms = next;