Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
fix(web): render the reasoning stream instead of dropping it (#1148)
JustVugg001fcfe02eff
diff --git a/web/src/App.tsx b/web/src/App.tsxindex c2ac567a..f571dfef 100644--- a/web/src/App.tsx+++ b/web/src/App.tsx@@ -232,10 +232,10 @@ export default function App() {setConnected(true)} catch (cause) {if (controller.signal.aborted) {- updateMessages((current) => current.filter((item) => item.id !== assistant.id || item.content))+ updateMessages((current) => current.filter((item) => item.id !== assistant.id || item.content || item.reasoning))} else {setError(cause instanceof Error ? cause.message : "status.generationFailed")- updateMessages((current) => current.filter((item) => item.id !== assistant.id || item.content))+ updateMessages((current) => current.filter((item) => item.id !== assistant.id || item.content || item.reasoning))}} finally {abortRef.current = null@@ -363,7 +363,12 @@ export default function App() {{messages.map((item) => (<article key={item.id} className={cn("message", item.role)}><div className="avatar">{item.role === "user" ? "Y" : <Feather className="size-4" />}</div>- <div><div className="message-meta">{item.role === "user" ? t("chat.you") : t("chat.colibri")}</div><div className="message-body">{item.content+ <div><div className="message-meta">{item.role === "user" ? t("chat.you") : t("chat.colibri")}</div><div className="message-body">{item.reasoning+ ? <details className="reasoning" open={!item.content}>+ <summary>{t("sidebar.reasoning")}</summary>+ <div className="reasoning-body">{item.reasoning}</div>+ </details>+ : null}{item.content? (item.role === "assistant"/* User turns stay literal: the person typed thosecharacters and expects to see them back. Only thediff --git a/web/src/index.css b/web/src/index.cssindex 079655e4..5cf70f62 100644--- a/web/src/index.css+++ b/web/src/index.css@@ -79,6 +79,16 @@ button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-.suggestions { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 38px; }.suggestions button { display: flex; justify-content: space-between; align-items: center; min-height: 62px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 11px; color: #a5b0b4; background: rgba(13,18,21,.75); text-align: left; font-size: 11px; line-height: 1.4; transition: .2s; }.suggestions button:hover { border-color: rgba(78,214,165,.35); color: var(--foreground); transform: translateY(-2px); }.message-list { width: min(820px, calc(100% - 48px)); margin: 0 auto; padding: 44px 0 20px; }.message { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 14px; margin-bottom: 34px; }.avatar { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid var(--border); border-radius: 9px; color: #aeb8bc; background: var(--card); font-size: 11px; font-weight: 700; }.message.assistant .avatar { color: var(--primary); border-color: rgba(78,214,165,.25); background: rgba(78,214,165,.06); }.message-meta { height: 27px; color: #7f8c91; font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }.message-body { color: #d8e0e2; font-size: 14px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }.message.user .message-body { color: #aeb9bd; }+/* Reasoning models stream their thinking before the answer. It is folded away+ once the answer starts arriving (open={!item.content} in App.tsx), so a long+ chain of thought does not push the reply off the screen. */+.reasoning { margin-bottom: 14px; border-left: 2px solid rgba(78,214,165,.28); padding-left: 12px; }+.reasoning > summary { color: #7f8c91; font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; cursor: pointer; list-style: none; }+.reasoning > summary::-webkit-details-marker { display: none; }+.reasoning > summary::before { content: "\25B8 "; display: inline-block; transition: transform .15s; }+.reasoning[open] > summary::before { transform: rotate(90deg); }+.reasoning > summary:hover { color: #aeb9bd; }+.reasoning-body { margin-top: 8px; color: #8d989c; font-size: 13px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }.typing { display: inline-flex; gap: 4px; padding-top: 6px; }.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--primary); animation: pulse 1.1s infinite; }.typing i:nth-child(2) { animation-delay: .15s; }.typing i:nth-child(3) { animation-delay: .3s; }.composer-wrap { padding: 10px 32px 24px; background: linear-gradient(transparent, var(--background) 24%); }.composer { width: min(820px, 100%); margin: 0 auto; overflow: hidden; border: 1px solid #2a353a; border-radius: 15px; background: rgba(13,18,21,.94); box-shadow: 0 18px 55px rgba(0,0,0,.24); }.composer textarea { min-height: 74px; border: 0; }.composer-foot { display: flex; align-items: center; justify-content: space-between; padding: 0 9px 9px 15px; }.composer-foot > span { display: flex; align-items: center; gap: 6px; color: #56646a; font-size: 9px; }.error-banner { width: min(820px, 100%); margin: 0 auto 8px; padding: 9px 12px; border: 1px solid rgba(255,118,111,.25); border-radius: 9px; color: #ff9d98; background: rgba(255,118,111,.07); font-size: 11px; }@keyframes pulse { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }diff --git a/web/src/lib/api.ts b/web/src/lib/api.tsindex 11bb9c5f..b793d6f2 100644--- a/web/src/lib/api.ts+++ b/web/src/lib/api.ts@@ -4,6 +4,10 @@ export interface ChatMessage {id: stringrole: ChatRolecontent: string+ /* Reasoning models stream their thinking on a separate delta field before+ the answer. Kept apart from `content` so it can be rendered as its own+ block and excluded from what is sent back as conversation history. */+ reasoning?: string}interface OpenAIError {@@ -146,6 +150,7 @@ export interface StreamChatOptions {cacheSlot?: numbersignal: AbortSignalonDelta: (text: string) => void+ onReasoning?: (text: string) => void}export async function streamChat(options: StreamChatOptions): Promise<StreamChatResult> {@@ -176,12 +181,14 @@ export async function streamChat(options: StreamChatOptions): Promise<StreamChatconst consume = (data: string) => {if (data === "[DONE]") returnconst event = JSON.parse(data) as {- choices?: Array<{ delta?: { content?: string }; finish_reason?: string | null }>+ choices?: Array<{ delta?: { content?: string; reasoning_content?: string }; finish_reason?: string | null }>usage?: TokenUsage | null}const choice = event.choices?.[0]const text = choice?.delta?.contentif (text) options.onDelta(text)+ const reasoning = choice?.delta?.reasoning_content+ if (reasoning) options.onReasoning?.(reasoning)if (choice?.finish_reason) finishReason = choice.finish_reasonif (event.usage) usage = event.usage}