From 5aae3eb389b912355ff9584e5427b53017667f2d Mon Sep 17 00:00:00 2001 From: Hikari Date: Fri, 6 Mar 2026 19:18:29 -0800 Subject: [PATCH] feat: show save errors in the UI instead of console MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add syncError state to GameContext. forceSync now catches errors and displays them in the ResourceBar for 5 seconds, replacing the cloud save timestamp with '❌ Save failed'. Signature mismatches are also cleared from localStorage so the next save can proceed. Auto-save silently self-heals bad signatures without surfacing an error. --- apps/web/src/components/ui/ResourceBar.tsx | 10 +++++--- apps/web/src/context/GameContext.tsx | 29 +++++++++++++++++++++- apps/web/src/styles.css | 5 ++++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/apps/web/src/components/ui/ResourceBar.tsx b/apps/web/src/components/ui/ResourceBar.tsx index bb0f329..1bd2d73 100644 --- a/apps/web/src/components/ui/ResourceBar.tsx +++ b/apps/web/src/components/ui/ResourceBar.tsx @@ -33,7 +33,7 @@ export const ResourceBar = ({ isSyncing, onForceSync, }: ResourceBarProps): React.JSX.Element => { - const { formatNumber } = useGame(); + const { formatNumber, syncError } = useGame(); const anyFull = Object.values(resources).some((v) => v >= RESOURCE_CAP); return ( <> @@ -68,11 +68,15 @@ export const ResourceBar = ({ )}
- {lastSavedAt !== null && ( + {syncError !== null ? ( + + ❌ Save failed + + ) : lastSavedAt !== null ? ( ☁️ {formatRelativeTime(lastSavedAt)} - )} + ) : null}