agent: lumotia-rebrand — localStorage keys + event channels migration
Some checks failed
check / cargo check (macos-latest) (push) Has been cancelled
check / cargo check (ubuntu-22.04) (push) Has been cancelled
check / cargo check (windows-latest) (push) Has been cancelled
check / svelte build + lint (push) Has been cancelled

Phase 7 of the rebrand cascade. Persisted UI state + inter-window event
channels migrated from magnotia to lumotia naming, with one-shot
localStorage key migration so dogfooded UI state survives the rename.

src/lib/utils/localStorageMigration.ts (new):
- migrateLocalStorageKey(old, new): idempotent + crash-safe shim.
  - If new key exists, removes old (lumotia value is authoritative).
  - If only old exists, copies value to new key, removes old.
  - If neither, no-op.
- migrateLocalStorageKeys(pairs): batch wrapper.

src/lib/stores/page.svelte.ts:
- 4 key constants renamed to lumotia_settings / lumotia_profiles /
  lumotia_task_lists / lumotia_templates.
- BroadcastChannel name renamed to lumotia_task_lists.
- migrateLocalStorageKeys() called at module load before any read.

src/lib/stores/focusTimer.svelte.ts:
- STORAGE_KEY renamed to lumotia.focusTimer.v1.
- migrateLocalStorageKey() called at module load.

Event channels (magnotia: -> lumotia:) renamed across frontend + Rust:
- magnotia:toggle-recording (src/routes/+layout.svelte)
- magnotia:hotkey-pressed / -released (src-tauri/src/commands/hotkey.rs +
  consumers)
- magnotia:open-wind-down (src-tauri/src/tray.rs + consumer)
- magnotia:llm-download-progress (src-tauri/src/commands/llm.rs)
- magnotia:preferences-changed (src/lib/stores/preferences.svelte.ts +
  consumers)
- magnotia:start-timer (nudgeBus + dispatch sites)
- magnotia:focus-timer-{complete,cancelled} (focusTimer + nudgeBus)
- magnotia:microstep-generated (nudgeBus + dispatch sites)
- magnotia:step-completed (nudgeBus + dispatch sites)
- magnotia:task-{completed,uncompleted,deleted} (page.svelte.ts +
  nudgeBus + consumers)

Storage-event filters in src/routes/{float,viewer,preview}/+layout@.svelte
updated to filter on lumotia_settings.

User-facing toast strings still say "Magnotia" — deferred to Phase 8
(frontend strings).

npm run check: 0 errors / 0 warnings (3958 files).
cargo test --workspace: 339 pass / 0 fail.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-13 12:10:50 +01:00
parent 14313cfa84
commit 16081095e0
21 changed files with 122 additions and 58 deletions

View File

@@ -0,0 +1,48 @@
/**
* Phase 7 of the magnotia -> lumotia rebrand cascade. Persisted UI state
* survives the rename via one-shot key migrations run at module-load
* inside the stores that own each key.
*
* `migrateLocalStorageKey` is idempotent and crash-safe:
* - If the new key already exists, the old key (if any) is removed
* silently — the lumotia value is authoritative.
* - If only the old key exists, its value is copied to the new key and
* the old key is removed.
* - If neither exists, this is a no-op.
*/
const STORAGE_NS = "lumotia-rebrand-migration";
export function migrateLocalStorageKey(oldKey: string, newKey: string): void {
if (typeof localStorage === "undefined") return;
try {
const newValue = localStorage.getItem(newKey);
if (newValue !== null) {
if (localStorage.getItem(oldKey) !== null) {
localStorage.removeItem(oldKey);
}
return;
}
const oldValue = localStorage.getItem(oldKey);
if (oldValue === null) return;
localStorage.setItem(newKey, oldValue);
localStorage.removeItem(oldKey);
} catch (err) {
// Quota / disabled-storage / DOMException — silently no-op. The store
// will fall back to the old key on next read (or fail there with a
// visible error). Logging is intentionally silent to avoid polluting
// dev-console output on every page in the multi-window flow.
void err;
}
}
/**
* Run a batch of migrations. Used by stores that own multiple keys.
*/
export function migrateLocalStorageKeys(pairs: Array<[string, string]>): void {
for (const [oldKey, newKey] of pairs) {
migrateLocalStorageKey(oldKey, newKey);
}
}
void STORAGE_NS;

View File

@@ -1,7 +1,7 @@
/**
* Forward-compatible, versioned settings migration.
*
* Historically, `localStorage["magnotia_settings"]` was a bare JSON object
* Historically, `localStorage["lumotia_settings"]` was a bare JSON object
* (whatever `SettingsState` looked like at write time). That shape
* tolerates new fields cleanly — spread over `defaults` — but does not
* survive: