feat: show save errors in the UI instead of console

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.
This commit is contained in:
2026-03-06 19:18:29 -08:00
committed by Naomi Carrigan
parent 50fe905610
commit 5aae3eb389
3 changed files with 40 additions and 4 deletions
+7 -3
View File
@@ -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 = ({
</div>
)}
<div className="profile-buttons">
{lastSavedAt !== null && (
{syncError !== null ? (
<span className="save-status save-error" title={syncError}>
Save failed
</span>
) : lastSavedAt !== null ? (
<span className="save-status" title={new Date(lastSavedAt).toLocaleString()}>
{formatRelativeTime(lastSavedAt)}
</span>
)}
) : null}
<button
className="force-save-button"
disabled={isSyncing}