Skip to content

[codex] Structure web local storage failures#3350

Merged
juliusmarminge merged 3 commits into
mainfrom
codex/web-local-storage-errors
Jun 20, 2026
Merged

[codex] Structure web local storage failures#3350
juliusmarminge merged 3 commits into
mainfrom
codex/web-local-storage-errors

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

What Changed

  • added a schema-backed LocalStorageOperationError carrying the operation, storage key, and original cause
  • applied it at local storage read/decode/encode/update/write/remove/notification boundaries
  • retained best-effort settings and dismissal fallbacks while reporting their structured failures
  • added focused coverage for storage operation context and the client-settings fallback

Why

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

  • This PR is small and focused
  • I explained what changed and why
  • No UI changes

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.ts
  • vp check (passes with 20 pre-existing warnings)
  • vp run typecheck

Note

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 in useLocalStorage through 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.error the structured error while keeping the same defaults. FilePreviewPanel switches explorer persistence from raw localStorage strings to getLocalStorageItem / setLocalStorageItem with Schema.Boolean.

Adds useLocalStorage.test.ts and extends clientPersistenceStorage.test.ts to 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 LocalStorageOperationError instances across web storage utilities

  • Introduces LocalStorageOperationError in useLocalStorage.ts, a tagged error class that captures the operation type (read, decode, encode, write, remove, notify, update) and storageKey for structured error reporting.
  • Updates all localStorage helpers (getLocalStorageItem, setLocalStorageItem, removeLocalStorageItem, dispatchLocalStorageChange) to throw LocalStorageOperationError instead of propagating raw errors.
  • Adds console.error logging with structured context to clientPersistenceStorage.ts, providerUpdateDismissal.ts, versionSkew.ts, and useResizableWidth.ts where storage failures were previously silent.
  • Replaces direct window.localStorage calls in FilePreviewPanel.tsx with schema-validated getLocalStorageItem/setLocalStorageItem helpers.
  • Behavioral Change: previously silent localStorage failures now emit console.error output; the useLocalStorage hook still returns initialValue on failure rather than throwing.

Macroscope summarized 287f9de.

Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 676da97e-4fa5-464b-9148-2551430b2d79

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/web-local-storage-errors

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jun 20, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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>
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 13:01

Dismissing prior approval to re-evaluate ee10b99

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
@macroscopeapp macroscopeapp Bot dismissed their stale review June 20, 2026 13:18

Dismissing prior approval to re-evaluate 287f9de

@juliusmarminge juliusmarminge merged commit 9a78c6f into main Jun 20, 2026
16 checks passed
@juliusmarminge juliusmarminge deleted the codex/web-local-storage-errors branch June 20, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant