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

feat(web): show Continue only on an incomplete assistant turn

eni6923b7d334f8
diff --git a/web/src/App.tsx b/web/src/App.tsx
index 7e7d018e..d3934e43 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -70,6 +70,12 @@ export default function App() {
const [health, setHealth] = useState<HealthResponse | null>(null)
const [healthError, setHealthError] = useState("")
const [lastRun, setLastRun] = useState<StreamChatResult | null>(null)
+ /* How the last turn ended, for deciding whether it can be continued: "length"
+ (hit max_tokens) and "aborted" (stopped by hand) are open and continuable;
+ "stop" (the model closed the turn) is complete, and continuing it only makes
+ the model re-emit its stop and add nothing. null before any turn / after a
+ reset. Tracked apart from lastRun because an abort never sets a result. */
+ const [lastFinish, setLastFinish] = useState<string | null>(null)
const [draft, setDraft] = useState("")
const [loading, setLoading] = useState(false)
const [streamStart, setStreamStart] = useState<number | null>(null)
@@ -151,7 +157,7 @@ export default function App() {
}, [cacheSlot, kvSlots])
// EFFECT #6
- useEffect(() => { setLastRun(null) }, [cacheSlot])
+ useEffect(() => { setLastRun(null); setLastFinish(null) }, [cacheSlot])
// EFFECT #7
useEffect(() => { bottomRef.current?.scrollIntoView({ behavior: "smooth" }) }, [messages])
@@ -277,12 +283,14 @@ export default function App() {
completion: prev.completion + (result.usage?.completion_tokens || 0),
}))
setLastRun(result)
+ setLastFinish(result.finishReason)
setConnected(true)
} catch (cause) {
/* Drop the target bubble only if it is empty -- a first turn that never got
a token. A continued turn already carries the client's opening, so the
`|| item.content` keeps it on the screen through an abort or an error. */
if (controller.signal.aborted) {
+ setLastFinish("aborted")
updateMessages((current) => current.filter((item) => item.id !== targetId || item.content || item.reasoning))
} else {
setError(cause instanceof Error ? cause.message : "status.generationFailed")
@@ -329,7 +337,7 @@ export default function App() {
}
const openSettings = (page = "general") => { setSettingsPage(page); setView("settings") }
- const clearChat = () => { updateMessages([]); setLastRun(null); setTokPerSec(null); setTtft(null); setTokenCount(0); setTotalTokens({ prompt: 0, completion: 0 }); setError("") }
+ const clearChat = () => { updateMessages([]); setLastRun(null); setLastFinish(null); setTokPerSec(null); setTtft(null); setTokenCount(0); setTotalTokens({ prompt: 0, completion: 0 }); setError("") }
const newChat = () => {
if (loading) return
if (messages.length) setArchives(items => [{ id: message("system", "").id, slot: cacheSlot, messages: [...messages] }, ...items])
@@ -347,7 +355,7 @@ export default function App() {
const slot = entry.slot < kvSlots ? entry.slot : cacheSlot
const currentMessages = conversations[slot] || []
setArchives(items => [...(currentMessages.length ? [{ id: message("system", "").id, slot, messages: currentMessages }] : []), ...items.filter(item => item.id !== entry.id)])
- setConversations(items => ({ ...items, [slot]: entry.messages })); setCacheSlot(slot); setView("chat"); setHistoryOpen(false); setLastRun(null); setError(""); setDraft("")
+ setConversations(items => ({ ...items, [slot]: entry.messages })); setCacheSlot(slot); setView("chat"); setHistoryOpen(false); setLastRun(null); setLastFinish(null); setError(""); setDraft("")
}
const empty = messages.length === 0
const connectionControls = (<fieldset disabled={loading}><section className="side-section">
@@ -463,7 +471,7 @@ export default function App() {
<div className="reasoning-body">{item.reasoning}</div>
</details>
: null}{item.content ? (item.role === "assistant" ? <Markdown text={item.content} /> : item.content) : <span className="typing" aria-label={t("ui.generating")}><i /><i /><i /></span>}</div>
- {item.role === "assistant" && item.content && <div className="message-actions"><button className="icon-action" aria-label={t("ui.copy")} title={t("ui.copy")} onClick={() => void copyMessage(item)}><Copy /></button>{copied === item.id && <span role="status">{t("ui.copied")}</span>}{index === messages.length - 1 && !loading && <button className="icon-action" aria-label={t("ui.regenerate")} title={t("ui.regenerate")} onClick={() => { const retry = resendFrom(messages, index); if (retry) void send(retry.text, retry.previous, retry.pictures, false) }}><RefreshCw /></button>}{index === messages.length - 1 && !loading && <button className="icon-action" aria-label={t("ui.continue")} title={t("ui.continue")} onClick={() => void continueTurn()}><StepForward /></button>}</div>}
+ {item.role === "assistant" && item.content && <div className="message-actions"><button className="icon-action" aria-label={t("ui.copy")} title={t("ui.copy")} onClick={() => void copyMessage(item)}><Copy /></button>{copied === item.id && <span role="status">{t("ui.copied")}</span>}{index === messages.length - 1 && !loading && <button className="icon-action" aria-label={t("ui.regenerate")} title={t("ui.regenerate")} onClick={() => { const retry = resendFrom(messages, index); if (retry) void send(retry.text, retry.previous, retry.pictures, false) }}><RefreshCw /></button>}{index === messages.length - 1 && !loading && (lastFinish === "length" || lastFinish === "aborted") && <button className="icon-action" aria-label={t("ui.continue")} title={t("ui.continue")} onClick={() => void continueTurn()}><StepForward /></button>}</div>}
</article>)}<div ref={bottomRef} /></div>
</div>}
<div className="composer-wrap">