workbench-store
PURPOSE
Zustand store for transient UI state of the Weapon Workbench screen: which component is currently selected and the library search query string.
OWNS
selectedComponentId: string | null— id of the component currently focused in the workbench (null = nothing selected).librarySearch: string— current search filter applied to the component library panel.selectComponent(id)— setter forselectedComponentId.setLibrarySearch(q)— setter forlibrarySearch.
READS FROM
- Nothing. Store is self-contained; initial values are hardcoded (
null,'').
PUSHES TO
- Any React component in the weapon-workbench screen tree that subscribes via
useWorkbenchStore.
DOES NOT
- Persist to localStorage or any backend.
- Validate that
idcorresponds to a real component. - Cross-reference component data, inventory, or game state.
- Reset on screen unmount (state survives navigation within the React tree’s lifetime).
Signals
selectedComponentIdchange → consumer panels re-render to show component detail.librarySearchchange → library list filters on each keystroke (debouncing, if any, lives in the consumer).
Entry points
useWorkbenchStore— sole export; hook used by every consumer inscreens/weapon-workbench/.
Pattern notes
- Plain
create<State>()factory with no middleware (nopersist, nodevtools, nosubscribeWithSelector). - State + setter colocated in one slice — typical for screen-local UI state.
- ~15 lines total; intentionally minimal. Any persistence, derived state, or cross-screen sharing belongs elsewhere.
EXTRACT-CANDIDATE
- Screen-local zustand stores with
selectedX: string | null+ setter is a recurring shape across workbench-style screens. If a third instance appears, consider acreateSelectionStore<T>()factory in a shared state helper.