Repository navigation
Persisted state store with migrations, export and import - #23
Merged
Merged
Conversation
Versioned root state saved to one localStorage key with debounced writes and a flush on pagehide. Older versions migrate step by step; newer or unreadable data is never overwritten and can be exported as it is. Storage that is missing or full falls back to memory with a warning. The Settings tab gets Export and Import buttons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying lsos with
|
| Latest commit: |
baa1986
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8ea4638d.lsos-2qs.pages.dev |
| Branch Preview URL: | https://claude-issue-1-5sz08c.lsos-2qs.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Adds the one place where all user state lives: a versioned root state saved to a single
localStoragekey (lsos:state). Writes are debounced (500 ms) and flushed onpagehide. Older versions migrate step by step on load. Newer or unreadable stored data is never overwritten: a warning shows and the data can be exported as it is. If storage is missing or full, LSOS keeps working in memory and shows a warning. The Settings tab gets Export and Import buttons, and imports are validated with clear error messages.src/lib/state.ts:AppState(no sections yet),parseState,migrate,exportFileNamesrc/lib/persistence.ts: storage, debounce with an injected scheduler, status (saved / memory / blocked)src/lib/store.svelte.ts: thin Svelte 5 wiring ($statestore,$effect→ save,pagehide)src/components/Settings.svelte,src/components/SaveStatus.svelteFollow-up: #22 (two open tabs overwrite each other's saves).
Closes #1
How to check it
lsos-backup-<date>.jsoncontaining{"version":1}.{"hello":1}→ "Could not import …: it has no valid version number."localStorage.setItem('lsos:state', '{"version":99}')and reload → orange warning; Export gives back exactly that text; the stored value stays untouched. Importing a valid file (after the confirm dialog) replaces it and the warning goes away.Checklist
npm run verifypasses🤖 Generated with Claude Code
Generated by Claude Code