Commit Graph

4 Commits

Author SHA1 Message Date
teernisse
087b588d71 feat: add Tauri state persistence and BvCli trait
- Add Tauri storage adapter for Zustand (tauri-storage.ts)
- Add read_state, write_state, clear_state Tauri commands
- Wire focus-store and nav-store to use Tauri persistence
- Add BvCli trait for bv CLI mocking with response types
- Add BvError and McError conversion for bv errors
- Add cleanup_tmp_files tests for bridge
- Fix linter-introduced tauri_specta::command issues

Closes bd-2x6, bd-gil, bd-3px

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-26 10:06:57 -05:00
teernisse
5059eb008a feat: add nav store persistence and tmp file cleanup
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>
2026-02-26 09:56:24 -05:00
teernisse
6c04c2efe7 feat: add localStorage persistence to focus store
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>
2026-02-26 09:56:09 -05:00
teernisse
259f751f45 feat: add Zustand stores for focus, navigation, capture, and batch
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>
2026-02-26 09:54:34 -05:00