[codex] Structure web local storage failures#3350
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved This PR adds structured error logging for localStorage operations without changing fallback behavior. Changes are self-contained error handling improvements with comprehensive tests, and the author is a senior contributor. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: codex <codex@users.noreply.github.com>
Dismissing prior approval to re-evaluate ee10b99
Co-authored-by: codex <codex@users.noreply.github.com>
Dismissing prior approval to re-evaluate 287f9de
What Changed
LocalStorageOperationErrorcarrying the operation, storage key, and original causeWhy
Local storage failures were either raw browser/schema exceptions or silently discarded, which lost the operation and key needed to correlate failures. This keeps the original cause chain intact without recording stored values.
Checklist
Validation
vp test apps/web/src/hooks/useLocalStorage.test.ts apps/web/src/clientPersistenceStorage.test.ts apps/web/src/versionSkew.test.ts apps/web/src/providerUpdateDismissal.test.tsvp check(passes with 20 pre-existing warnings)vp run typecheckNote
Low Risk
UI preference and best-effort persistence only; behavior on failure stays the same aside from richer console logging.
Overview
Introduces a schema-backed
LocalStorageOperationError(operation,storageKey,cause) and routes read/decode/encode/write/remove/notify paths inuseLocalStoragethrough it instead of leaking raw browser or schema exceptions.Call sites that already fall back on failure (client settings, dismissal toasts, resizable panel width, file explorer open state) now
console.errorthe structured error while keeping the same defaults.FilePreviewPanelswitches explorer persistence from rawlocalStoragestrings togetLocalStorageItem/setLocalStorageItemwithSchema.Boolean.Adds
useLocalStorage.test.tsand extendsclientPersistenceStorage.test.tsto assert error shape and logging on decode failures.Reviewed by Cursor Bugbot for commit 287f9de. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure localStorage failures into typed
LocalStorageOperationErrorinstances across web storage utilitiesLocalStorageOperationErrorinuseLocalStorage.ts, a tagged error class that captures the operation type (read,decode,encode,write,remove,notify,update) andstorageKeyfor structured error reporting.getLocalStorageItem,setLocalStorageItem,removeLocalStorageItem,dispatchLocalStorageChange) to throwLocalStorageOperationErrorinstead of propagating raw errors.console.errorlogging with structured context toclientPersistenceStorage.ts,providerUpdateDismissal.ts,versionSkew.ts, anduseResizableWidth.tswhere storage failures were previously silent.window.localStoragecalls inFilePreviewPanel.tsxwith schema-validatedgetLocalStorageItem/setLocalStorageItemhelpers.console.erroroutput; theuseLocalStoragehook still returnsinitialValueon failure rather than throwing.Macroscope summarized 287f9de.