Zustand State Store
One Zustand store is the main-window brain: nav, settings, download queue, gallery list, and hero metadata.
useRuforgeStore in ruforgeStore.ts merges slices into a single create() call. createDownloadQueueSlice owns jobs, focus row, enqueue/pause/finish handlers, and legacy hero fields (url, videoInfo, metadataLoading). Gallery state holds entries, galleryLoading, and scan revision counters.
Components subscribe with selectors (useRuforgeStore(s => s.activeTab)) to avoid rerendering the whole tree when unrelated fields change. Player scrub hover, open menus, and transient downloader UI stay in local useState on purpose.
Persistence uses ruforgePersistStorage.ts: flat localStorage keys for settings and output paths so older builds and mini-player readers stay compatible. Download jobs also persist to survive restarts mid-queue. Gallery entries reload from disk via fetchEntries after boot.
Zustand does not cross webviews. Mini player keeps its own playback state and syncs through Tauri events. When debugging playback handoff, check both surfaces.
In the repo
Where it shows up
-
src/store/ruforgeStore.tsmain store composition -
src/store/downloadQueueSlice.tsqueue CRUD, finish handler, hero clear -
ruforgePersistStorage.tsflat key mapping - Not persisted: transient player UI, explorer shimmer, modal open flags