Skip to content

Conversation

@bfulton
Copy link
Owner

@bfulton bfulton commented Dec 29, 2025

Unify disk state, React state, and XState machine into a single Zustand store with automatic Electron IPC sync.

Document the plan to unify disk state, React state, and XState machine
into a single Zustand store with automatic Electron IPC sync.
Implements the foundation for unifying disk state, React state, and XState
into a single reactive store as described in docs/roadmap/reactive-state-management.md.

Key additions:
- Zustand store with typed slices for config, auth, runner, jobs, github, update, and UI state
- YAML persistence middleware with debounced atomic writes
- XState synchronization middleware to sync runner machine state to store
- Zubridge integration for automatic main→renderer state sync
- Renderer hooks (useStore, useDispatch, convenience hooks for each slice)

The store infrastructure runs alongside the existing Context providers.
Next step is to migrate each Context to use the Zustand store as its
backing state, eventually removing the Contexts entirely.

Dependencies added:
- zustand: Core state management
- @zubridge/electron: Electron IPC state synchronization
- Add zubridge mock for renderer tests
- Update AppConfigContext to read from Zustand store when synced
- Use fallback state (from IPC) until zubridge is ready
- Add settings IPC handler updates to sync with Zustand store
- Configure webpack fallbacks for Node.js modules in renderer
- Add userFilter mode validation when loading settings
Both contexts now follow the same pattern as AppConfigContext:
- Read state from Zustand store when zubridge has synced
- Use fallback state (from IPC) until zubridge is ready
- Actions continue to call IPC, which updates the main store
- zubridge automatically syncs changes back to renderer
@bfulton bfulton changed the title Add reactive state management design doc Reactive state management Dec 29, 2025
@bfulton bfulton merged commit eb8ed88 into main Dec 29, 2025
4 checks passed
@bfulton bfulton deleted the claude/plan-reactive-state-T3tq5 branch December 29, 2025 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants