Skip to content

[muse] fix(web): write localStorage values even when the stored blob fails schema decode - #7

Open
kvnloo wants to merge 53 commits into
mainfrom
muse/localstorage-corrupt-blob-write
Open

kvnloo wants to merge 53 commits into
mainfrom
muse/localstorage-corrupt-blob-write

Conversation

@kvnloo

@kvnloo kvnloo commented Sep 28, 2026

Copy link
Copy Markdown
Owner

What Changed

useLocalStorage's setValue no longer reads and decodes the current stored value before a plain-value write — plain values never needed the old blob. Updater-function writes still read it, but now fall back to the initial value on decode failure (matching the read path) instead of turning the write into a silent no-op.

Why

setValue always decoded the stored blob first; a JSON-valid but schema-invalid blob (truncated write from a crash, a schema that gained a required field, a value written by a different build shape) made decode throw, and the catch only logged it. Every later setter call on that key was a silent no-op while the read path kept showing the initial value — an internally inconsistent fail-open/fail-closed split. User-visible: provider-update dismissals, resume-compaction dismissal, sidebar shelf state, and diff-panel file-tree state would snap back and never persist until site storage was cleared manually.

Validation

  • 3 new behavior tests (useLocalStorage.setValue.test.tsx): plain write heals a corrupt blob; updater runs against the initial value on a corrupt blob; normal write/updater paths unchanged.
  • Red on base: the 2 corrupt-blob tests fail on base, the normal-path test passes on both.
  • Existing useLocalStorage.test.ts 6/6 green; apps/web tsc --noEmit clean; vp fmt --check clean.

Checklist

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

Authored with AI assistance (Muse, Meta's Muse Spark) under the contributor's direction.

…fails schema decode

useLocalStorage's setValue always read and decoded the current stored
value first. A JSON-valid but schema-invalid blob (truncated write,
schema gained a required field, value written by a different build
shape) made decode throw, and the catch swallowed it: every later
setter call became a silent no-op while the read path kept showing the
initial value. Toggles and dismissals (provider-update dismissal,
resume-compaction dismissal, sidebar shelf state, diff panel tree)
would snap back and never persist until site storage was cleared.

Plain-value writes no longer touch the stored blob at all. Updater
writes fall back to the initial value on decode failure, matching the
read path, instead of skipping the write.

Tests: 3 new behavior tests in useLocalStorage.setValue.test.tsx
(red-on-base: the 2 corrupt-blob tests fail on base, the normal path
passes on both); existing useLocalStorage.test.ts 6/6 green; apps/web
tsc --noEmit clean.

Authored with AI assistance (Muse, Meta's Muse Spark) under the
contributor's direction.
@github-actions github-actions Bot added size:S vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Sep 28, 2026
juliusmarminge and others added 27 commits October 10, 2026 20:20
…4697)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…tgg#12598)

Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: GPT-6.1-Sol (Codex) <noreply@openai.com>
Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>
…otgg#17938)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…op's end (pingdotgg#14744)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…d reply (pingdotgg#14752)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… partway (pingdotgg#14723)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…Windows desktop (pingdotgg#16869)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Yash Singh <saiansh2525@gmail.com>
…inary (pingdotgg#16838)

Co-authored-by: Yash Singh <saiansh2525@gmail.com>
…to 0% (pingdotgg#16394)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Yash Singh <saiansh2525@gmail.com>
…tgg#17528)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…er hides every skill (pingdotgg#17389)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Yash Singh <saiansh2525@gmail.com>
)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
…yarn group across 1 directory (pingdotgg#16309)

Signed-off-by: dependabot[bot] <support@github.com>
)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Yash Singh <saiansh2525@gmail.com>
whoisaldo and others added 25 commits October 11, 2026 02:40
…op (pingdotgg#16480)

Co-authored-by: Yash Singh <saiansh2525@gmail.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
…tgg#17879)

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
…17050)

Co-authored-by: Julius Marminge <julius0216@outlook.com>
…#17027)

Co-authored-by: Julius Marminge <julius0216@outlook.com>
Retain the existing small fix and original author commits while updating
the integration baseline for fresh T3 CI.

Original fix: Kevin (kvnloo), AI-assisted via Meta Muse Spark.
This merge-only reconciliation introduces no separate behavior change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

keep pr-janitor: never auto-close size:S 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.