Completes persistence story and crash recovery hardening.
Nav store persistence:
- Wraps nav store with zustand persist middleware
- Persists activeView to localStorage under "mc-nav-store"
- Remembers which view you were on across sessions
Bridge tmp file cleanup (src-tauri/src/data/bridge.rs):
- New cleanup_tmp_files() method removes orphaned .json.tmp files
- Called on startup to clean up from crashes during save_map()
- Logs cleaned files for debugging
- Returns count of files removed
The atomic write pattern (write to .tmp, then rename) can leave
orphan files if the app crashes between write and rename. This
cleanup ensures we don't accumulate stale tmp files over time.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Wraps the focus store with zustand/middleware persist to maintain
queue state across page refreshes and app restarts.
Persists:
- current: The currently focused item
- queue: Remaining items in the work queue
Not persisted (transient state):
- isLoading: Reset on mount
- error: Reset on mount
Storage key: "mc-focus-store"
This prevents losing your place in the queue when the app restarts
or the page refreshes during development.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements the frontend state management layer using Zustand. Each store
is single-purpose and testable in isolation.
Focus Store (focus-store.ts):
- Tracks current focused item (THE ONE THING)
- Manages the queue of remaining items
- Actions: setItems, act (start/defer/skip), setFocus, reorderQueue
- Advancing through items removes from queue, promotes next to current
Navigation Store (nav-store.ts):
- Simple view routing: focus | queue | inbox
- No URL-based routing needed for native app
- Default view is "focus"
Capture Store (capture-store.ts):
- Manages quick capture overlay state
- Tracks submission status and errors
- Opens via global shortcut event listener
Batch Store (batch-store.ts):
- Manages batch processing mode for rapid item completion
- Tracks items, their statuses (pending/done/skipped), and current index
- Derives counts: completedCount, skippedCount, isFinished
- Used for "knock out all code reviews" workflow
State design principles:
- No derived state stored; computed on access
- Actions are pure mutations with logging
- Loading/error states colocated with data
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>