Skip to content

Validate stored inspector prefs and persist containerMaxWidth#57

Merged
abewheel merged 1 commit into
mainfrom
abewheel/inspector-prefs-followup
May 2, 2026
Merged

Validate stored inspector prefs and persist containerMaxWidth#57
abewheel merged 1 commit into
mainfrom
abewheel/inspector-prefs-followup

Conversation

@abewheel
Copy link
Copy Markdown
Contributor

@abewheel abewheel commented May 2, 2026

Summary

  • Sanitize the JSON in readStoredPrefs per-field so a corrupt or stale sunpeak-inspector-prefs entry (older sunpeak version, manual edit) can't seed an unknown theme, displayMode, platform, or screenWidth into inspector state.
  • Add containerMaxWidth to the persisted preferences alongside containerMaxHeight — both are user-editable in the sidebar and should behave the same on refresh.
  • Add a Map-backed localStorage shim to src/test/setup.ts. Node 22+ ships a stubbed globalThis.localStorage with no methods, and happy-dom doesn't replace it, so any test touching localStorage would crash.

Follows up on #56.

Test plan

  • pnpm --filter sunpeak test -- --run (367 passing, 5 new tests for restore / sanitize / corrupt-JSON fallback / autoRun bypass / URL precedence)
  • pnpm --filter sunpeak typecheck
  • pnpm --filter sunpeak lint

Sanitize the parsed JSON one field at a time in readStoredPrefs so a
corrupt or stale localStorage entry can't seed bad values like an
unknown theme or platform into state. Add containerMaxWidth to the
persisted preferences so manual sidebar widths survive a refresh, like
containerMaxHeight already does.

Install a Map-backed localStorage shim in the test setup. Node 22+
ships a stubbed globalThis.localStorage that lacks setItem/getItem,
and happy-dom doesn't override it.
@abewheel abewheel merged commit 3671085 into main May 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant