feat: cache demo edits in localStorage with Loaded-from-cache banner#18
Merged
Conversation
- Call flemsInstance.onchange(fn) instead of assigning it; the Flems API exposes onchange as a registrar, so assignment left autosave dead. - Recompute cache key + reload files reactively on same-route demo navigation (component is reused; only data updates). - Show the 'Loaded from cache' banner only when actually restored from cache, not after a fresh-edit autosave. - Clear pending save timer on demo switch and component destroy; save under the key captured at edit time. - NaN/negative-safe debounce parsing (allows 0); guard localStorage writes and drop the unused savedAt field. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
NivGreenstein
previously approved these changes
Jul 21, 2026
NivGreenstein
approved these changes
Jul 21, 2026
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.
Summary
localStorage(namespaced key perclient/name), auto-saved on change with a configurable debounce.cache.debounceMs→ ConfigMapPUBLIC_CACHE_DEBOUNCE_MS→$env/dynamic/public→ client (500ms fallback).Changes
src/lib/cache/demoCache.ts— localStorage util (cacheKey/loadCache/saveCache/clearCache), SSR-safe, best-effort writes.src/lib/components/flems.svelte—onChangeprop; registers Flemsonchangehandler (registrar call, not property assignment).src/routes/demo/[client]/[name]/+page.svelte— reactive cache key (survives same-route demo switches), post-mount load, debounced save, clear-with-confirm, amber banner.helm/values.yaml,helm/templates/configmap.yaml,.env.example— debounce config plumbing.Test Plan
npm run check— 0 errors / 0 warningsnpm run build— cleanPUBLIC_CACHE_DEBOUNCE_MS🤖 Generated with Claude Code