MCPcopy Create free account
hub / github.com/debpalash/VoiceStudio / WizardLibrary

Function WizardLibrary

frontend/src/components/WizardLibrary.jsx:235–482  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

233}
234
235export default function WizardLibrary() {
236 const { t } = useTranslation();
237 const modelsQuery = useModels();
238 const installMutation = useInstallModel();
239 const { data: engineInventory } = useEngines();
240 const selectMutation = useSelectEngine();
241 const engines = engineInventory?.tts ?? null;
242 const [progress, setProgress] = useState({}); // { repo_id: { phase, files } }
243 const [showTail, setShowTail] = useState(false);
244 const [switching, setSwitching] = useState(null);
245 const esRef = useRef(null);
246
247 const models = useMemo(() => {
248 const list = modelsQuery.data;
249 return Array.isArray(list) ? list : (list?.models ?? []);
250 }, [modelsQuery.data]);
251
252 // Host platform tags (e.g. ['darwin', 'darwin-arm64']) so we can surface the
253 // models tuned for THIS machine by default instead of burying them.
254 const platformTags = useMemo(() => {
255 const d = modelsQuery.data;
256 return Array.isArray(d) ? [] : (d?.platform_tags ?? []);
257 }, [modelsQuery.data]);
258
259 // One SSE stream for all rows (same channel the Settings store uses).
260 useEffect(() => {
261 const es = new EventSource(setupDownloadStreamUrl());
262 esRef.current = es;
263 es.onmessage = (evt) => {
264 try {
265 const ev = JSON.parse(evt.data);
266 if (!ev?.repo_id) return;
267 // Refetch the list once the repo finishes so the row flips to installed.
268 // (The reducer is pure — the side-effect stays here.)
269 if (ev.phase === 'install_done') modelsQuery.refetch();
270 // Pure reducer (exported for tests). Full phase taxonomy:
271 // SetupProgressEvent in api/setup.ts. install_error now PERSISTS with
272 // its message instead of the row silently vanishing (P1-A).
273 setProgress((prev) => reduceWizardDownloadEvent(prev, ev));
274 } catch {
275 /* keepalive */
276 }
277 };
278 return () => es.close();
279 // eslint-disable-next-line react-hooks/exhaustive-deps
280 }, []);
281
282 const install = (repoId) => {
283 const key = `local\u0000${repoId}`;
284 setProgress((p) => ({ ...p, [key]: { phase: 'active', files: {} } }));
285 installMutation.mutate(repoId, {
286 onError: (e) => {
287 toast.error(e?.message || 'install failed');
288 setProgress((p) => {
289 const n = { ...p };
290 delete n[key];
291 return n;
292 });

Callers

nothing calls this directly

Calls 15

useModelsFunction · 0.90
useInstallModelFunction · 0.90
useEnginesFunction · 0.90
useSelectEngineFunction · 0.90
setupDownloadStreamUrlFunction · 0.90
isRecommendedPickFunction · 0.85
modelRowFunction · 0.85
useEngineFunction · 0.85
mirrorBlockedReposFunction · 0.85
installFunction · 0.70
tFunction · 0.50

Tested by

no test coverage detected