Skip to content

Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦

C

fix(web): auto-connect in useEffect, atlas from engine origin, drop inert ternary

JustVugg6c630912a160
diff --git a/web/src/App.tsx b/web/src/App.tsx
index 6b89423f..c2ac567a 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -168,10 +168,16 @@ export default function App() {
}
}
- if (servedByEngine && !autoConnected.current && !connected) {
- autoConnected.current = true
- setTimeout(() => connect(), 0)
- }
+ // Auto-connect once when the UI is served by the engine itself. In an
+ // effect, not in the render body: a side effect during render breaks under
+ // StrictMode double-rendering and concurrent re-renders.
+ useEffect(() => {
+ if (servedByEngine && !autoConnected.current && !connected) {
+ autoConnected.current = true
+ connect()
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [servedByEngine, connected])
const canSend = useMemo(() => draft.trim() && model && !loading, [draft, loading, model])
@@ -209,7 +215,7 @@ export default function App() {
if (firstToken) { setTtft(performance.now() - t0); setStreamStart(performance.now()); firstToken = false }
count++
setTokenCount(count)
- const elapsed = (performance.now() - (firstToken ? t0 : t0)) / 1000
+ const elapsed = (performance.now() - t0) / 1000
if (elapsed > 0.3) setTokPerSec(count / ((performance.now() - t0) / 1000))
updateMessages((current) => current.map((item) =>
item.id === assistant.id ? { ...item, content: item.content + delta } : item,
diff --git a/web/src/Brain.tsx b/web/src/Brain.tsx
index e67310b3..bea0aa6b 100644
--- a/web/src/Brain.tsx
+++ b/web/src/Brain.tsx
@@ -35,10 +35,16 @@ export function Brain({ baseUrl, apiKey, connected }: { baseUrl: string; apiKey:
// load the expert atlas if published (measured topic affinity, #175)
useEffect(() => {
- fetch("/experts.json").then(r => r.ok ? r.json() : null).then(d => {
- if (d?.experts) setAtlas(d.experts)
- }).catch(() => {})
- }, [])
+ // The atlas lives next to the engine's /experts endpoint, not on the page
+ // origin: when the UI is hosted elsewhere (dev server, static hosting) a
+ // root-relative fetch pointed at the wrong server and the atlas never
+ // loaded. Same base + auth as the live expert map above.
+ const base = baseUrl.replace(/\/v1\/?$/, "")
+ fetch(endpoint(base, "/experts.json"), { headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : {} })
+ .then(r => r.ok ? r.json() : null).then(d => {
+ if (d?.experts) setAtlas(d.experts)
+ }).catch(() => {})
+ }, [baseUrl, apiKey])
// track container size for responsive cell sizing
useEffect(() => {