refactor(configurator): shape-guard localStorage, migrate lucide-svelte (SL-015/018/019/021/022/025) - #479
Conversation
…e-svelte, document preview singleton
SL-019: reuse savedThemes.ts's isStringRecord() shape guard in
persistence.ts's loadInitialOverrides() instead of trusting
JSON.parse(local) as Record<string,string> unchecked — malformed or
wrong-shaped localStorage now falls back to {} instead of passing through.
SL-021: verified already resolved (no motion dependency or imports remain).
SL-022: migrate lucide-svelte -> @lucide/svelte across all 9 importing
files (import-source only, no icon renames needed — verified via tsc/
svelte-check/build after the full migration).
SL-025: document why previewResolver.svelte.ts's previewVersion is a
deliberate module-level singleton rather than component-scoped state.
SL-018 and SL-015 were investigated but required no changes: SL-018's
'error' saveState and its StudioHeader render branch were already fully
implemented in an earlier batch; SL-015's premise (two competing
`overrides` membership idioms to unify) doesn't hold in this codebase —
only the `in` idiom is used, consistently, across ~120 call sites in ~15
files, well beyond the ~15-site estimate in the remediation plan.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoConfigurator: validate localStorage overrides and migrate to @lucide/svelte
AI Description
Diagram
High-Level Assessment
Files changed (14)
|
PR4 (codec.ts types) and PR6 (preview debounce) merged into the integration branch after this branch diverged, both touching import blocks adjacent to PR5's lucide-svelte migration in App.svelte and CheatsheetPanel.svelte. Resolved by keeping both sides: the @lucide/svelte import source (PR5) plus the ApiIndex/SlashedClass type imports (PR4). PreviewPanel.svelte's lucide import (PR5) and its rAF-coalescing effect bodies (PR6) merged cleanly with no conflict. Verified post-merge: tsc/svelte-check clean, 73/73 unit tests + 17/17 component tests pass, full vite build succeeds.
b5e7e76
into
claude/pr-469-audit-rebase-ggp0e4
Summary
Fifth themed PR from the SLASHED technical-debt audit (PR #469), covering the configurator correctness/UX/dependency-cleanup group. Targets the long-lived integration branch
claude/pr-469-audit-rebase-ggp0e4(parallel-safe with PR4 per the remediation plan — both touchApp.svelte/CheatsheetPanel.sveltebut on non-overlapping lines).persistence.ts'sloadInitialOverrides()now reusessavedThemes.ts's existingisStringRecord()shape guard (exported for this purpose) instead of trustingJSON.parse(local)asRecord<string, string>unchecked. Malformed or wrong-shapedlocalStoragecontent now falls back to{}instead of passing through as-is. Updated the two existingtests/persistence.test.jscases that pinned the old (unguarded) behavior, and added a case for a record with a non-string value.lucide-svelte→@lucide/svelteacross all 9 importing files (import-source only — no icon name changes were needed; verified withtsc/svelte-check/a fullvite buildafter the migration). Removedlucide-sveltefromconfigurator/package.json, rannpm installto update the lockfile, and rerannpm run check:versionper CLAUDE.md's rule for touchingconfigurator/package.json.previewResolver.svelte.ts'spreviewVersionexplaining why it's deliberately a module-level singleton (one shared preview iframe for the whole app) rather than component-scoped state.'error'saveState, the catch-handler wiring, and theStudioHeaderrender branch for it were already fully implemented in an earlier batch.name in overridesvsoverrides[name] !== undefined) that need unifying into a helper. Only theinidiom actually exists in this codebase, consistently, across ~120 call sites in ~15 panel files (well beyond the plan's ~15-site/4-file estimate). There's nothing to reconcile, andkey in overridesis already a clear, terse, standard idiom — introducing a helper would add indirection across ~120 sites for no correctness or readability gain. Confirmed with the repo owner before skipping.motiondependency or imports remain in the configurator).Test plan
npx tsc --noEmit— cleannpx svelte-check --tsconfig ./tsconfig.json— 0 errors, 0 warningsnpm run test:unit— 73/73 passednpm run test:components— 17/17 passednpm run build(full vite build) — succeeds with the new icon packagenpm audit— 0 vulnerabilitiesnpm run check:version(root) — all references in sync after touchingconfigurator/package.jsontests-e2e/shell.spec.js) against a real built preview server — 5/6 passing; the 1 failure is a pre-existing/favicon.ico404 console error unrelated to this PR (index.htmlnever referenced a favicon, confirmed independent of this diff)Generated by Claude Code