Skip to content

feat: Validate and fix blocked localstorage - #500

Open
Bohreromir wants to merge 2 commits into
mainfrom
fix-379-blocked-localstorage
Open

Bohreromir wants to merge 2 commits into
mainfrom
fix-379-blocked-localstorage

Conversation

@Bohreromir

@Bohreromir Bohreromir commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Description

When the browser blocks localStorage the whole app crashed.

This introduces an interface for all localStorage acces which guards and validates contents.

  • All storage access goes through $lib/client/local-storage and an ESLint rule enforces their use.
  • Stored JSON is only read through a zod schema. Data that doesn't match, e.g. from an older release, falls back to defaults instead of breaking at runtime.
  • If we need to migrate any content in the future we will do so with a lightweights version prefix

#498 will be stacked on top of this PR.

closes #379

Docs

Release note

Checklist

Author

  • AI review done, findings addressed
  • Tests added or updated
  • Changelog updated (if the repo keeps one)

Reviewer

  • Useful comments and logging
  • Docs added or updated per the style guide

Acceptance

  • Check for release notes and docs

Reading localStorage throws a SecurityError when site data is blocked.
ThemeToggle and the app layout did so during hydration, which took down
the whole app.

- Access storage only through $lib/client/local-storage, whose helpers
  fail silently; enforced by an ESLint rule.
- Read stored JSON only through a zod schema, so data from older
  releases falls back to defaults instead of breaking at runtime.
- Guard the inline theme script in app.html.
- Say that tabs can't be saved instead of blaming the content size.
- Document how to handle stored data and shape changes in AGENTS.md.
The helpers detect the browser by window instead of $app/environment,
so they don't depend on SvelteKit and generic ui/ components can
persist their own state through them.
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 68.32% 9365 / 13706
🔵 Statements 67.28% 12569 / 18680
🔵 Functions 69.08% 3023 / 4376
🔵 Branches 58.6% 5311 / 9062
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/lib/client/local-storage.ts 96.66% 92.85% 100% 100% 28
src/lib/components/Pagination.svelte 62.16% 48.88% 57.14% 65.67% 73, 105
src/lib/components/layout/header/ThemeToggle.svelte 92.85% 85.71% 100% 100% 10, 25
src/lib/components/layout/sidebar/Sidebar.svelte 0% 0% 0% 0% 102-274
src/lib/components/storage/sidebar/resizable-panel.svelte.ts 35% 36.36% 50% 37.83% 24, 29-30, 39-66, 74-75
src/lib/components/trino/StatementResult.svelte 0% 0% 0% 0% 28-281
src/lib/editor/completion/completion-history.ts 71.42% 58.33% 87.5% 73.8% 39-50, 62-63, 74
src/lib/storage/operations.svelte.ts 92.35% 89.83% 90.24% 93.28% 13, 163-167, 208, 235, 255-258
src/lib/storage/persistence.ts 100% 100% 100% 100%
src/lib/storage/tabs.svelte.ts 85.29% 79.02% 93.33% 88.23% 142, 222, 256, 268, 270, 283, 288, 303, 309, 343-344, 366, 386, 398-402, 410, 446-457, 495-496, 499, 504
src/lib/stores/tab-store.svelte.ts 91.37% 78.18% 94.59% 95.78% 64, 69, 73-79, 95, 104, 121, 179, 209
src/lib/types/pagination.ts 100% 75% 100% 100%
src/routes/(app)/+layout.svelte 0% 0% 0% 0% 11-96
src/routes/(app)/storage/+page.svelte 0% 0% 0% 0% 25-165
src/routes/(app)/trino/+page.svelte 0% 0% 0% 0% 396-812
Generated in workflow #1357 for commit 149492c by the Vitest Coverage Report Action

@Bohreromir
Bohreromir added this pull request to stack #501 November 26, 2026 09:24
@Bohreromir
Bohreromir marked this pull request as ready for review November 26, 2026 09:39
@Bohreromir Bohreromir self-assigned this Nov 26, 2026
@Bohreromir Bohreromir moved this to Development: Waiting for Review in Stackable Engineering Nov 26, 2026
@Bohreromir Bohreromir changed the title Validate and fix blocked localstorage feat: Validate and fix blocked localstorage Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development: Waiting for Review

Development

Successfully merging this pull request may close these issues.

localStorage Interface

1 participant