Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
UI round 7: live chat numbers with tween, fixed status-line columns, Subagents counts on title row, plain Privacy text, round latest arrow, time-skip never empty
Niko1221e849aef2ae89
diff --git a/apps/host/src/components/ChatToolbar.tsx b/apps/host/src/components/ChatToolbar.tsxindex 610d0ea37..4f21487e5 100644--- a/apps/host/src/components/ChatToolbar.tsx+++ b/apps/host/src/components/ChatToolbar.tsx@@ -39,7 +39,7 @@ export function ChatToolbar({ session, items, selected, onSelect, onClose, onCloreturn <header className="chat-toolbar" style={previews && !expanded && previewWidth ? { gridTemplateColumns: `minmax(0,1fr) ${previewWidth}px` } : undefined} data-timeskip={selected?.startsWith('time-skip:') || undefined} data-preview={previews || undefined} data-expanded={expanded && previews || undefined}><div className="chat-toolbar__conversation"><h1 title={title}>{title}</h1><ChatModelPicker /><button ref={agentsRef} className="chat-agents" title={tr(count ? `${count} subagents running · View overview` : 'View subagent overview')} aria-label={tr(count ? `${count} subagents running — show overview` : 'Subagents — show overview')} aria-haspopup="dialog" aria-expanded={agents} data-working={count > 0 || undefined} onClick={() => setAgents(v => !v)}><Icon name="experts" size={17}/>{tr(count > 0 ? <span className="agent-live-dot"/> : null)}<span className="chat-agents__label">{tr("Subagents")}</span>{tr(session?.agents?.length ? <span className="chat-agents__count">{tr(count || session.agents.length)}</span> : null)}<Icon name="chevron" className={agents ? 'is-open' : ''} size={13}/></button><span className="spacer"/><button ref={menuRef} className="st-btn st-btn--icon" title={tr("Chat options")} aria-label={tr("Chat options")} aria-haspopup="menu" aria-expanded={menu} onClick={() => setMenu(v => !v)}><Icon name="ellipsis"/></button>{tr(!selected && (items.length || extraTabs.length) ? <IconBtn name="panel" title={tr("Open previews")} onClick={() => onSelect(extraTabs.at(-1)?.id ?? items[0].id)}/> : null)}</div>{tr(previews ? <div className="chat-toolbar__previews"><ArtifactTabs extraTabs={extraTabs} onCloseTab={onCloseTab} items={items} selected={selected} onSelect={onSelect}/><div className="preview-window-actions"><div id="preview-file-actions" className="preview-file-actions"/><IconBtn name={expanded ? 'contract' : 'expand'} title={tr(expanded ? 'Exit full screen preview' : 'Full screen preview')} onClick={onExpand}/><IconBtn name="panel" title={tr("Collapse preview sidebar")} onClick={onClose}/></div></div> : null)}- {tr(agents ? <Popover anchor={agentsRef.current} title={tr("Subagents")} width={460} onClose={() => setAgents(false)}>{tr(session?.agents?.length ? <><p className="small muted subagents-overview-summary">{tr(count)}{tr(" running \u00B7 ")}{tr(session.agents.filter(a => a.status === 'completed').length)}{tr(" completed \u00B7 ")}{tr(session.agents.length)}{tr(" total")}</p>{tr(session.agents.map(a => <SubagentRow key={a.id} agent={a} now={now}/>))}</> : <div className="subagents-empty"><Icon name="experts" size={24}/><strong>{tr("No subagents recorded")}</strong><p className="small muted">{tr("Subagents that run in this conversation appear here, with their progress, token usage and elapsed time. Completed runs stay visible.")}</p></div>)}</Popover> : null)}+ {tr(agents ? <Popover anchor={agentsRef.current} title={tr("Subagents")} detail={session?.agents?.length ? <>{tr(count)}{tr(" running \u00B7 ")}{tr(session.agents.filter(a => a.status === 'completed').length)}{tr(" completed \u00B7 ")}{tr(session.agents.length)}{tr(" total")}</> : undefined} width={460} onClose={() => setAgents(false)}>{tr(session?.agents?.length ? <>{tr(session.agents.map(a => <SubagentRow key={a.id} agent={a} now={now}/>))}</> : <div className="subagents-empty"><Icon name="experts" size={24}/><strong>{tr("No subagents recorded")}</strong><p className="small muted">{tr("Subagents that run in this conversation appear here, with their progress, token usage and elapsed time. Completed runs stay visible.")}</p></div>)}</Popover> : null)}{tr(menu ? <FloatingMenu anchor={menuRef.current} title={tr("Chat options")} onClose={() => setMenu(false)}><button role="menuitem" className="menu__item" disabled={!!remote} title={tr(remote ? "API models use their provider’s response settings." : undefined)} onClick={() => { setMenu(false); setSettings(true); }}><Icon name="sliders"/>{tr("Response settings")}</button><button role="menuitem" className="menu__item" disabled={!session} onClick={() => { if (session)downloadSessionLog(session); setMenu(false); }}><Icon name="download"/>{tr("Download session log")}</button></FloatingMenu> : null)}<SamplingDrawer open={settings} onClose={() => setSettings(false)}/>diff --git a/apps/host/src/components/Num.tsx b/apps/host/src/components/Num.tsxnew file mode 100644index 000000000..df64e9531--- /dev/null+++ b/apps/host/src/components/Num.tsx@@ -0,0 +1,29 @@+import { useEffect, useRef, useState } from 'react';+import { tweenValue } from '../lib/tween';++const reduced = () => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;++/** The number a reading is moving towards, shown as it travels there (a short count-up or count-down, 600 ms). Tabular figures keep the width steady. */+export function useTweened(target: number | null, duration = 600): number | null {+ const [shown, setShown] = useState<number | null>(target);+ const from = useRef<number | null>(target);+ const frame = useRef(0);+ useEffect(() => {+ if (target === null || from.current === null || reduced() || target === from.current) { from.current = target; setShown(target); return; }+ const start = performance.now(), origin = from.current;+ cancelAnimationFrame(frame.current);+ const step = (now: number) => {+ const value = tweenValue(origin, target, now - start, duration);+ from.current = value; setShown(value);+ if (now - start < duration) frame.current = requestAnimationFrame(step); else { from.current = target; setShown(target); }+ };+ frame.current = requestAnimationFrame(step);+ return () => cancelAnimationFrame(frame.current);+ }, [target, duration]);+ return shown;+}++export function Num({ value, format, className }: { value: number | null; format: (n: number) => string; className?: string }) {+ const shown = useTweened(value);+ return <span className={`num ${className ?? ''}`.trim()} style={{ fontVariantNumeric: 'tabular-nums' }}>{shown === null ? '—' : format(shown)}</span>;+}diff --git a/apps/host/src/components/Popover.tsx b/apps/host/src/components/Popover.tsxindex 2c787c58c..0d87d94c4 100644--- a/apps/host/src/components/Popover.tsx+++ b/apps/host/src/components/Popover.tsx@@ -3,9 +3,11 @@ import { useLayoutEffect, useRef, useState, type ReactNode } from 'react';import { createPortal } from 'react-dom';import { IconBtn } from './ui';/** Anchored, non-modal surface. Focus and dismissal stay with its own trigger. */-export function Popover({ anchor, title, onClose, children, above = false, width = 360 }: {+export function Popover({ anchor, title, detail, onClose, children, above = false, width = 360 }: {anchor: HTMLElement | null;title: string;+ /** A short line to the right of the title, on the same row (the Subagents list puts its counts here). */+ detail?: ReactNode;onClose: () => void;children: ReactNode;above?: boolean;@@ -35,5 +37,5 @@ export function Popover({ anchor, title, onClose, children, above = false, widthe.stopPropagation();close();}- }}><div className="telepop__head"><strong>{tr(title)}</strong><IconBtn name="x" title={tr("Close {0}", [title.toLowerCase()])} onClick={close}/></div>{tr(children)}</div>, document.body);+ }}><div className="telepop__head"><strong>{tr(title)}</strong>{detail ? <span className="telepop__detail">{detail}</span> : null}<IconBtn name="x" title={tr("Close {0}", [title.toLowerCase()])} onClick={close}/></div>{tr(children)}</div>, document.body);}diff --git a/apps/host/src/components/PrivacyNotes.tsx b/apps/host/src/components/PrivacyNotes.tsxindex 77f1dee50..599cd35c4 100644--- a/apps/host/src/components/PrivacyNotes.tsx+++ b/apps/host/src/components/PrivacyNotes.tsx@@ -1,18 +1,17 @@import { tr } from '../lib/i18n';-import { Icon, type IconName } from './ui';-const NOTES: { icon: IconName; text: string; strong?: boolean }[] = [- { icon: 'shield', text: 'Strata sends no usage telemetry.', strong: true },- { icon: 'file', text: 'Conversations stay in browser storage.' },- { icon: 'link', text: 'When you choose an API model, that conversation and enabled skill instructions are sent to its provider.' },- { icon: 'activity', text: 'The UI request log keeps client, timing and token metadata in memory.' },- { icon: 'memory', text: 'Native API monitoring can retain request content in memory when enabled.' },- { icon: 'tool', text: 'Connected tools access the resources you configure.' },+const NOTES = [+ 'Strata sends no usage telemetry.',+ 'Conversations stay in browser storage.',+ 'When you choose an API model, that conversation and enabled skill instructions are sent to its provider.',+ 'The UI request log keeps client, timing and token metadata in memory.',+ 'Native API monitoring can retain request content in memory when enabled.',+ 'Connected tools access the resources you configure.',];-/** What Strata collects and where things go: short lines across the box, nothing long to read through. */+/** What Strata collects and where things go: plain lines of text, nothing else. */export function PrivacyNotes() {- return <ul className="privacy-notes" aria-label={tr("Collection and logs")}>- {NOTES.map(n => <li key={n.text} data-strong={n.strong || undefined}><Icon name={n.icon} size={15}/><span>{tr(n.text)}</span></li>)}- </ul>;+ return <div className="privacy-notes" aria-label={tr("Collection and logs")}>+ {NOTES.map(text => <p key={text}>{tr(text)}</p>)}+ </div>;}diff --git a/apps/host/src/components/StatusLine.tsx b/apps/host/src/components/StatusLine.tsxindex bff655157..00d1f10a2 100644--- a/apps/host/src/components/StatusLine.tsx+++ b/apps/host/src/components/StatusLine.tsx@@ -25,7 +25,8 @@ export function StatusLine({ sessionId, startedAt, tokens }: { sessionId: stringconst count = frame.tokens ?? tokens;return <div className="live-status" data-phase={frame.phase} aria-live="off"><span className="live-status__pulse" aria-hidden="true"><i/><i/></span>- <span className="live-status__verb" key={playful ? rotation : frame.code + String(frame.args?.target ?? '')}>{statusWords(frame, rotation)}</span>- <span className="live-status__meta">{elapsedText(startedAt, now)}{count ? ` · ${tr('{0} tokens', [count.toLocaleString()])}` : ''}</span>+ <span className="live-status__verb" key={playful ? rotation : frame.code + String(frame.args?.target ?? '')} title={statusWords(frame, rotation)}>{statusWords(frame, rotation)}</span>+ <span className="live-status__time">{elapsedText(startedAt, now)}</span>+ <span className="live-status__tokens">{count ? tr('{0} tokens', [count.toLocaleString()]) : ''}</span></div>;}diff --git a/apps/host/src/components/TelemetryPopover.tsx b/apps/host/src/components/TelemetryPopover.tsxindex f44e1ccf4..a45c0ce06 100644--- a/apps/host/src/components/TelemetryPopover.tsx+++ b/apps/host/src/components/TelemetryPopover.tsx@@ -6,10 +6,13 @@ import { ContextRing } from './ContextRing';import { Popover } from './Popover';import { chatMetrics, compactTokens, elapsed } from '../lib/chat-metrics';import { useStore } from '../lib/store';+import { Num } from './Num';import { useNative } from '../lib/native';import type { Session } from '../lib/types';-function Chip({ icon, visual, label, title, children }: {+function Chip({ icon, visual, label, live, title, children }: {icon?: IconName;+ /** The same words with the number as a moving element (the plain `label` stays for assistive technology). */+ live?: ReactNode;visual?: ReactNode;label: string;title: string;@@ -17,31 +20,12 @@ function Chip({ icon, visual, label, title, children }: {}) {const [open, setOpen] = useState(false);const ref = useRef<HTMLButtonElement>(null);- return <><button ref={ref} className="telemetry__chip" aria-label={tr("{0} \u2014 show details", [title])} aria-description={tr(label)} aria-haspopup="dialog" aria-expanded={open} onClick={() => setOpen(v => !v)}>{tr(visual ?? (icon ? <Icon name={icon} size={14}/> : null))}{tr(label)}</button>{tr(open ? <Popover anchor={ref.current} title={tr(title)} onClose={() => setOpen(false)} above>{tr(children)}</Popover> : null)}</>;+ return <><button ref={ref} className="telemetry__chip" aria-label={tr("{0} \u2014 show details", [title])} aria-description={tr(label)} aria-haspopup="dialog" aria-expanded={open} onClick={() => setOpen(v => !v)}>{tr(visual ?? (icon ? <Icon name={icon} size={14}/> : null))}{live ?? tr(label)}</button>{tr(open ? <Popover anchor={ref.current} title={tr(title)} onClose={() => setOpen(false)} above>{tr(children)}</Popover> : null)}</>;}function Row({ label, value }: {label: string;value: ReactNode;}) { return <div className="telepop__row"><span className="telepop__label">{tr(label)}</span><span className="telepop__value num">{tr(value)}</span></div>; }-/** Refresh once a second; smooth live changes and show exact final measurements. */-function useCalmSpeed(value: number | null, sessionId: string | null, streaming: boolean) {- const latest = useRef(value);- latest.current = value;- const [shown, setShown] = useState(value);- useEffect(() => {- setShown(latest.current);- if (!streaming)- return;- const timer = setInterval(() => setShown(previous => {- const next = latest.current;- if (next === null || previous === null)- return next;- return Math.abs(next - previous) < 1 ? next : previous + (next - previous) * .35;- }), 1000);- return () => clearInterval(timer);- }, [sessionId, streaming]);- return shown;-}export function ChatTelemetry({ session }: {session: Session | null;}) {@@ -51,13 +35,23 @@ export function ChatTelemetry({ session }: {const native = useNative();const running = native?.instances.find(i => i.id === native.defaultId && i.status === 'ready') ?? native?.instances.find(i => i.status === 'ready');const runningContext = running ? Number(running.metrics?.engine?.max_context) || running.context || undefined : undefined;- const m = chatMetrics(session, monitor, runningContext ?? (engine ? contextTokens(engine.beginner.contextLength) : undefined));- const speed = useCalmSpeed(m.speed, session?.id ?? null, m.streaming);+ // While a reply is being written the durations keep counting once a second; the readings come from the Monitor's own stream.+ const [now, setNow] = useState(() => Date.now());+ const working = !!session?.messages.some(x => x.streaming);+ useEffect(() => { if (!working) return; setNow(Date.now()); const t = setInterval(() => setNow(Date.now()), 1000); return () => clearInterval(t); }, [working]);+ const m = chatMetrics(session, monitor, runningContext ?? (engine ? contextTokens(engine.beginner.contextLength) : undefined), now);+ const speed = m.speed;if (!m.hasReplies)return null;+ const int = (n: number) => String(Math.round(n));+ const PLACE = '';+ /** A translated sentence with its number as a moving element: the words around the number keep the language's own order. */+ const around = (template: string, before: string, node: ReactNode) => { const [head, tail = ''] = tr(template, [before, PLACE]).split(PLACE); return <>{head}{node}{tail}</>; };+ const approx = m.estimated ? tr('≈ ') : tr('');+ const dur = (n: number) => elapsed(n);return <div className="telemetry xs muted" aria-label={tr("Chat statistics")}>- <Chip icon="gauge" label={tr("{0}{1} tok/s{2}", [m.estimated ? tr('≈ ') : tr(''), speed === null ? tr('—') : Math.round(speed), m.streaming ? tr('') : tr(' · last reply')])} title={tr("Session statistics")}>{tr(m.estimated ? <p className="xs muted">{tr("Live estimate from response length and elapsed time. Final usage comes from the engine.")}</p> : null)}<Row label={tr("Thinking & writing")} value={elapsed(m.llmMs)}/><Row label={tr("Tool time")} value={elapsed(m.toolMs)}/><Row label={tr("Average time to first token")} value={m.ttft === null ? 'Not reported' : elapsed(m.ttft)}/><Row label={tr("Latest response speed")} value={speed === null ? 'Not reported' : `${Math.round(speed)} tokens/s`}/><Row label={tr("Turns / tool calls")} value={`${m.turns} / ${m.steps}`}/></Chip>- <Chip icon="memory" label={tr("{0}{1} total tokens", [m.estimated ? tr('≈ ') : tr(''), compactTokens(m.total)])} title={tr("Token usage")}><Row label={tr("Total in this chat")} value={compactTokens(m.total)}/><Row label={tr("Input tokens")} value={compactTokens(m.input)}/><Row label={tr("Output tokens")} value={compactTokens(m.output)}/></Chip>- <Chip visual={<ContextRing percent={m.pct}/>} label={tr(m.pct === null ? '—' : `${Math.round(m.pct)}% of context`)} title={tr("Context length")}><Row label={tr("Context used")} value={m.pct === null ? 'Not reported' : `${Math.round(m.pct)}%`}/><div className="context-meter" role="meter" aria-label={tr("Context window used")} aria-valuemin={0} aria-valuemax={100} aria-valuenow={m.pct ?? undefined}><span style={{ width: `${m.pct ?? 0}%` }}/></div><Row label={tr("Current context")} value={compactTokens(m.used)}/><Row label={tr("Context limit")} value={compactTokens(m.max)}/><Row label={tr("Space remaining")} value={m.used !== null && m.max !== null ? compactTokens(Math.max(0, m.max - m.used)) : '—'}/></Chip>+ <Chip icon="gauge" label={tr("{0}{1} tok/s{2}", [approx, speed === null ? tr('—') : Math.round(speed), m.streaming ? tr('') : tr(' · last reply')])} live={around(m.streaming ? "{0}{1} tok/s" : "{0}{1} tok/s · last reply", approx, <Num value={speed} format={int}/>)} title={tr("Session statistics")}>{tr(m.estimated ? <p className="xs muted">{tr("Live estimate from response length and elapsed time. Final usage comes from the engine.")}</p> : null)}<Row label={tr("Thinking time")} value={<Num value={m.thinkMs} format={dur}/>}/><Row label={tr("Writing time")} value={<Num value={m.writeMs} format={dur}/>}/><Row label={tr("Tool time")} value={<Num value={m.toolMs} format={dur}/>}/><Row label={tr("Average time to first token")} value={m.ttft === null ? tr('Not reported') : <Num value={m.ttft} format={dur}/>}/><Row label={tr("Latest response speed")} value={speed === null ? tr('Not reported') : <>{<Num value={speed} format={int}/>}{tr(' tokens/s')}</>}/><Row label={tr("Turns / tool calls")} value={<><Num value={m.turns} format={int}/> / <Num value={m.steps} format={int}/></>}/></Chip>+ <Chip icon="memory" label={tr("{0}{1} total tokens", [approx, compactTokens(m.total)])} live={around("{0}{1} total tokens", approx, <Num value={m.total} format={compactTokens}/>)} title={tr("Token usage")}><Row label={tr("Total in this chat")} value={<Num value={m.total} format={compactTokens}/>}/><Row label={tr("Input tokens")} value={<Num value={m.input} format={compactTokens}/>}/><Row label={tr("Output tokens")} value={<Num value={m.output} format={compactTokens}/>}/></Chip>+ <Chip visual={<ContextRing percent={m.pct}/>} label={tr(m.pct === null ? '—' : `${Math.round(m.pct)}% of context`)} live={m.pct === null ? undefined : <><Num value={m.pct} format={int}/>{tr('% of context')}</>} title={tr("Context length")}><Row label={tr("Context used")} value={m.pct === null ? tr('Not reported') : <><Num value={m.pct} format={int}/>%</>}/><div className="context-meter" role="meter" aria-label={tr("Context window used")} aria-valuemin={0} aria-valuemax={100} aria-valuenow={m.pct ?? undefined}><span style={{ width: `${m.pct ?? 0}%` }}/></div><Row label={tr("Current context")} value={<Num value={m.used} format={compactTokens}/>}/><Row label={tr("Context limit")} value={<Num value={m.max} format={compactTokens}/>}/><Row label={tr("Space remaining")} value={m.used !== null && m.max !== null ? <Num value={Math.max(0, m.max - m.used)} format={compactTokens}/> : '—'}/></Chip></div>;}diff --git a/apps/host/src/components/TimeSkipPanel.tsx b/apps/host/src/components/TimeSkipPanel.tsxindex cba2b8e6f..88c269b04 100644--- a/apps/host/src/components/TimeSkipPanel.tsx+++ b/apps/host/src/components/TimeSkipPanel.tsx@@ -5,6 +5,7 @@ import { plainTimeSkipError, replayTimeSkip, setTimeSkipResult, stopTimeSkip } fimport { realTimeSkipDocuments, timeSkipCheckOutcomes, timeSkipDocumentMarkdown, timeSkipDocuments, timeSkipExample, timeSkipResultState, type TimeSkipDocument, type TimeSkipRun, type TimeSkipVersion } from '../lib/time-skip';import { FloatingMenu } from './FloatingMenu';import { TimeSkipCompare } from './TimeSkipCompare';+import { TimeSkipWorking } from './TimeSkipWorking';import { Btn, Dialog, Icon } from './ui';function VersionTabs({ version, onChange, done }: {version: TimeSkipVersion;@@ -102,6 +103,8 @@ export function TimeSkipPanel({ run, sessionId, inline, expanded, onCompare, onCconst sideBySide = expanded && wide;// A finished real run that changed files: the A versus B view, one window whatever was made. Everything else keeps the older layout.const compareReal = real && frame.done && (run.job?.files?.length ?? 0) > 0;+ const workingReal = real && !frame.done;+ const realEmpty = real && frame.done && !compareReal;useEffect(() => {if (!panel.current)return;@@ -142,7 +145,7 @@ export function TimeSkipPanel({ run, sessionId, inline, expanded, onCompare, onC<div className="ts-content"><div className="ts-heading"><h2 aria-live="polite"><span className="ts-status-icon">{tr(!frame.done ? <span className="ts-activity"/> : <Icon name={kept === 'original' ? 'file' : 'shield'} size={21}/>)}</span><span>{tr(status)}</span></h2></div><p className="ts-caption">{tr(frame.done ? kept === 'original' ? 'The updated result is still available.' : 'The original is always available.' : frame.pass === 2 ? 'Trying one more revision. Your progress is saved.' : 'Improving the saved draft.')}</p>- {tr(compareReal ? <TimeSkipCompare jobId={run.job!.id} files={run.job!.files!} more={run.job!.moreFiles ?? 0}/> : <>+ {tr(workingReal ? <TimeSkipWorking run={run} sessionId={sessionId}/> : compareReal ? <><TimeSkipCompare jobId={run.job!.id} files={run.job!.files!} more={run.job!.moreFiles ?? 0}/></> : realEmpty ? <p className="ts-empty">{tr(frame.done && run.job?.phase && ['failed', 'cancelled', 'interrupted'].includes(run.job.phase) ? 'Nothing was kept from this run. Your files were not changed.' : 'The assistant did not change anything, so there is nothing to compare. Your files were not changed.')}</p> : <>{tr(expanded ? <div className="ts-compare-heading"><h3>{tr("Compare results")}</h3><Btn size="sm" variant="ghost" icon="contract" onClick={() => onCompare(false)}>{tr(inline ? 'Back to chat' : 'Done comparing')}</Btn></div> : null)}<div className="ts-switch-row" data-comparing={expanded || undefined}><VersionTabs version={version} onChange={which => { setVersion(which); setImageCompare(false); }} done={frame.done}/>diff --git a/apps/host/src/lib/chat-metrics.ts b/apps/host/src/lib/chat-metrics.tsindex e59ddd719..03cdaf22f 100644--- a/apps/host/src/lib/chat-metrics.ts+++ b/apps/host/src/lib/chat-metrics.ts@@ -1,11 +1,14 @@import type { MonitorState, Session } from './types';-export function chatMetrics(session:Session|null, monitor:MonitorState|null, configuredContext?:number) {+export function chatMetrics(session:Session|null, monitor:MonitorState|null, configuredContext?:number, now:number=Date.now()) {const messages=session?.messages??[];const replies=messages.filter(m=>m.role==='assistant'&&!m.timeSkipId);const latest=[...replies].reverse().find(m=>m.inputTokens!==undefined);const remote=replies.at(-1)?.remoteModel===true;- const active=!remote&&monitor?.context?.sessionId===session?.id&&!!session;+ const working=replies.some(m=>m.streaming);+ // The Monitor's reading belongs to this chat when it names it, and also while this chat is the one working: a goal or an agent runs under its own+ // session ids, so matching on the chat id alone left the numbers frozen during a goal.+ const active=!remote&&!!session&&!!monitor&&(monitor.context?.sessionId===session.id||(working&&['reading','thinking','generating'].includes(monitor.phase)));// One source: what the context held after the last reply (the engine's own count for that request); the monitor's live figure only while a reply streams.const finished=latest?(latest.contextUsed??latest.inputTokens!+(latest.tokens??0)):null;const liveUsed=active&&Number.isFinite(monitor!.context.usedTokens)&&monitor!.context.usedTokens>0?monitor!.context.usedTokens:null;@@ -16,11 +19,13 @@ export function chatMetrics(session:Session|null, monitor:MonitorState|null, conconst speed=streaming?.tps??[...replies].reverse().find(m=>m.tps!==undefined)?.tps??null;const ttfts=replies.flatMap(m=>m.ttftMs===undefined?[]:[m.ttftMs]);const hasUsage=session?.statsAvailable===true;- return {streaming:!!streaming,estimated:streaming?.usageSource==='estimated',hasReplies:replies.length>0,example:!!session?.showcase||replies.some(m=>m.usageSource==='demo'),+ const llmTotal=replies.reduce((n,m)=>n+(m.durationMs??(m.streaming?Math.max(0,now-(Date.parse(m.at)||now)):0)),0),thinkTotal=replies.reduce((n,m)=>n+(m.reasoningMs??(m.streaming&&m.reasoningStartedAt?Math.max(0,now-m.reasoningStartedAt):0)),0);+ return {streaming:!!streaming,writeMs:Math.max(0,llmTotal-thinkTotal),estimated:streaming?.usageSource==='estimated',hasReplies:replies.length>0,example:!!session?.showcase||replies.some(m=>m.usageSource==='demo'),speed:active&&monitor?.phase==='generating'?monitor.outputTps:speed,total:session?.statsAvailable===false?null:hasUsage?session.tokensIn+session.tokensOut+(streaming?.tokens??0)+(streaming?.inputTokens??0):replies.every(m=>m.inputTokens!==undefined&&m.tokens!==undefined)?replies.reduce((n,m)=>n+m.inputTokens!+m.tokens!,0):null,input:hasUsage?session.tokensIn:null,output:hasUsage?session.tokensOut:null,- llmMs:replies.reduce((n,m)=>n+(m.durationMs??0),0),+ llmMs:replies.reduce((n,m)=>n+(m.durationMs??(m.streaming?Math.max(0,now-(Date.parse(m.at)||now)):0)),0),+ thinkMs:replies.reduce((n,m)=>n+(m.reasoningMs??(m.streaming&&m.reasoningStartedAt?Math.max(0,now-m.reasoningStartedAt):0)),0),toolMs:replies.reduce((n,m)=>n+(m.tools??[]).reduce((v,t)=>v+(t.durationMs??0),0),0),ttft:ttfts.length?ttfts.reduce((n,v)=>n+v,0)/ttfts.length:null,used,max,pct:used!==null&&max?Math.min(100,100*used/max):null,diff --git a/apps/host/src/lib/tween.ts b/apps/host/src/lib/tween.tsnew file mode 100644index 000000000..493db6071--- /dev/null+++ b/apps/host/src/lib/tween.ts@@ -0,0 +1,8 @@+/** Numbers that move: the pure parts of a short count-up / count-down between two readings. */+export const easeOutCubic = (t: number) => 1 - Math.pow(1 - Math.min(1, Math.max(0, t)), 3);++/** The value between `from` and `to` after `elapsed` of `duration` milliseconds. */+export function tweenValue(from: number, to: number, elapsed: number, duration: number): number {+ if (!Number.isFinite(from) || !Number.isFinite(to) || duration <= 0) return to;+ return from + (to - from) * easeOutCubic(elapsed / duration);+}diff --git a/apps/host/src/locales/de.json b/apps/host/src/locales/de.jsonindex 6be5e4389..9b162a823 100644--- a/apps/host/src/locales/de.json+++ b/apps/host/src/locales/de.json@@ -3068,9 +3068,9 @@"s3071": "Die Engine ließ sich mit diesen Einstellungen nicht starten. Es wurde nichts geändert.","s3072": "Die Engine wurde während der Messung beendet. Es wurde nichts geändert.","s3074": "Gespeichert als",- "s3075": "Dauer",- "s3076": "{0} Min.",- "s3077": "Zeigt die Werte Ihrer Optimierung „{0}“.",- "s3078": "Ihre Optimierung „{0}“ setzt",- "s3079": "war {0}"+ "s3075": "Zur neuesten Nachricht scrollen",+ "s3076": "Denkzeit",+ "s3077": "Schreibzeit",+ "s3078": "{0}{1} Tok/s",+ "s3079": "{0}{1} Tok/s · letzte Antwort"}diff --git a/apps/host/src/locales/en.json b/apps/host/src/locales/en.jsonindex c4db95120..1a9cc65a3 100644--- a/apps/host/src/locales/en.json+++ b/apps/host/src/locales/en.json@@ -3068,9 +3068,9 @@"s3071": "The engine could not start with these settings. Nothing was changed.","s3072": "The engine stopped while we were measuring. Nothing was changed.","s3074": "Saved as",- "s3075": "Took",- "s3076": "{0} min",- "s3077": "Showing the values of your tuning '{0}'.",- "s3078": "Your tuning '{0}' sets",- "s3079": "was {0}"+ "s3075": "Scroll to the latest message",+ "s3076": "Thinking time",+ "s3077": "Writing time",+ "s3078": "{0}{1} tok/s",+ "s3079": "{0}{1} tok/s · last reply"}diff --git a/apps/host/src/locales/es.json b/apps/host/src/locales/es.jsonindex b9aec8548..e4bfc1bba 100644--- a/apps/host/src/locales/es.json+++ b/apps/host/src/locales/es.json@@ -3068,9 +3068,9 @@"s3071": "El motor no pudo iniciarse con estos ajustes. No se cambió nada.","s3072": "El motor se detuvo mientras medíamos. No se cambió nada.","s3074": "Guardado como",- "s3075": "Duración",- "s3076": "{0} min",- "s3077": "Mostrando los valores de tu ajuste «{0}».",- "s3078": "Tu ajuste «{0}» establece",- "s3079": "antes {0}"+ "s3075": "Ir al mensaje más reciente",+ "s3076": "Tiempo de razonamiento",+ "s3077": "Tiempo de escritura",+ "s3078": "{0}{1} tok/s",+ "s3079": "{0}{1} tok/s · última respuesta"}diff --git a/apps/host/src/locales/ja.json b/apps/host/src/locales/ja.jsonindex b552c3500..4d1c39d31 100644--- a/apps/host/src/locales/ja.json+++ b/apps/host/src/locales/ja.json@@ -3068,9 +3068,9 @@"s3071": "これらの設定ではエンジンを起動できませんでした。何も変更していません。","s3072": "測定中にエンジンが停止しました。何も変更していません。","s3074": "保存名",- "s3075": "所要時間",- "s3076": "{0} 分",- "s3077": "チューニング「{0}」の値を表示しています。",- "s3078": "チューニング「{0}」の設定",- "s3079": "以前は {0}"+ "s3075": "最新のメッセージへスクロール",+ "s3076": "思考時間",+ "s3077": "執筆時間",+ "s3078": "{0}{1} トークン/秒",+ "s3079": "{0}{1} トークン/秒 · 前回の返信"}diff --git a/apps/host/src/locales/ko.json b/apps/host/src/locales/ko.jsonindex 85b111a44..7168adc15 100644--- a/apps/host/src/locales/ko.json+++ b/apps/host/src/locales/ko.json@@ -3068,9 +3068,9 @@"s3071": "이 설정으로는 엔진을 시작하지 못했습니다. 아무것도 바꾸지 않았습니다.","s3072": "측정 중에 엔진이 멈췄습니다. 아무것도 바꾸지 않았습니다.","s3074": "저장 이름",- "s3075": "소요 시간",- "s3076": "{0}분",- "s3077": "튜닝 '{0}'의 값을 표시하고 있습니다.",- "s3078": "튜닝 '{0}'이(가) 설정하는 값",- "s3079": "이전 {0}"+ "s3075": "최신 메시지로 스크롤",+ "s3076": "생각 시간",+ "s3077": "작성 시간",+ "s3078": "{0}{1} tok/s",+ "s3079": "{0}{1} tok/s · 마지막 응답"}diff --git a/apps/host/src/locales/pt.json b/apps/host/src/locales/pt.jsonindex d9303287d..8d2c49b18 100644--- a/apps/host/src/locales/pt.json+++ b/apps/host/src/locales/pt.json@@ -3068,9 +3068,9 @@"s3071": "O mecanismo não conseguiu iniciar com essas configurações. Nada foi alterado.","s3072": "O mecanismo parou durante a medição. Nada foi alterado.","s3074": "Salvo como",- "s3075": "Duração",- "s3076": "{0} min",- "s3077": "Mostrando os valores do seu ajuste “{0}”.",- "s3078": "Seu ajuste “{0}” define",- "s3079": "era {0}"+ "s3075": "Ir para a mensagem mais recente",+ "s3076": "Tempo de raciocínio",+ "s3077": "Tempo de escrita",+ "s3078": "{0}{1} tok/s",+ "s3079": "{0}{1} tok/s · última resposta"}diff --git a/apps/host/src/locales/ru.json b/apps/host/src/locales/ru.jsonindex fdf35d414..0768709a7 100644--- a/apps/host/src/locales/ru.json+++ b/apps/host/src/locales/ru.json@@ -3068,9 +3068,9 @@"s3071": "Движок не удалось запустить с этими настройками. Ничего не изменено.","s3072": "Движок остановился во время измерения. Ничего не изменено.","s3074": "Сохранено как",- "s3075": "Заняло",- "s3076": "{0} мин",- "s3077": "Показаны значения вашей настройки «{0}».",- "s3078": "Ваша настройка «{0}» задаёт",- "s3079": "было {0}"+ "s3075": "К последнему сообщению",+ "s3076": "Время размышления",+ "s3077": "Время написания",+ "s3078": "{0}{1} ток/с",+ "s3079": "{0}{1} ток/с · последний ответ"}diff --git a/apps/host/src/locales/zh.json b/apps/host/src/locales/zh.jsonindex db9a3371a..b8314e86e 100644--- a/apps/host/src/locales/zh.json+++ b/apps/host/src/locales/zh.json@@ -3068,9 +3068,9 @@"s3071": "引擎无法用这些设置启动。没有做任何更改。","s3072": "测量期间引擎停止了。没有做任何更改。","s3074": "保存为",- "s3075": "用时",- "s3076": "{0} 分钟",- "s3077": "显示你的调优“{0}”的值。",- "s3078": "你的调优“{0}”设置了",- "s3079": "原为 {0}"+ "s3075": "滚动到最新消息",+ "s3076": "思考时间",+ "s3077": "写作时间",+ "s3078": "{0}{1} 词元/秒",+ "s3079": "{0}{1} 词元/秒 · 上次回复"}diff --git a/apps/host/src/screens/Chat.tsx b/apps/host/src/screens/Chat.tsxindex 36bcf3d7e..d4a1c849c 100644--- a/apps/host/src/screens/Chat.tsx+++ b/apps/host/src/screens/Chat.tsx@@ -342,8 +342,8 @@ export function ChatScreen() {<div className="chatsplit" style={splitStyle} data-timeskip={!!selectedRun || undefined} ref={splitRef} data-preview={!!selectedPreview && inlinePreview || undefined} data-expanded={expanded && !!selectedPreview && inlinePreview || undefined}><div className="chatcol"><div className="main__body chat" ref={scroller}>- {tr(awayFromBottom ? (<button type="button" className="jumplatest" data-finished={justFinished || undefined} onClick={() => scrollToLatest()}>- <Icon name="chevron" size={14} style={{ transform: 'rotate(90deg)' }}/>{tr("Latest")}</button>) : null)}+ {tr(awayFromBottom ? (<button type="button" className="jumplatest" data-finished={justFinished || undefined} aria-label={tr("Scroll to the latest message")} title={tr("Scroll to the latest message")} onClick={() => scrollToLatest()}>+ <Icon name="chevron" size={18}/></button>) : null)}<div className="chat__inner"><UsageDashboard loaded={!!loaded}/></div>@@ -376,8 +376,8 @@ export function ChatScreen() {setAwayFromBottom(away);}}>- {tr(awayFromBottom ? (<button type="button" className="jumplatest" data-finished={justFinished || undefined} onClick={() => scrollToLatest()}>- <Icon name="chevron" size={14} style={{ transform: 'rotate(90deg)' }}/>{tr("Latest")}</button>) : null)}+ {tr(awayFromBottom ? (<button type="button" className="jumplatest" data-finished={justFinished || undefined} aria-label={tr("Scroll to the latest message")} title={tr("Scroll to the latest message")} onClick={() => scrollToLatest()}>+ <Icon name="chevron" size={18}/></button>) : null)}<div className="chat__inner">{tr(session.messages.length === 0 ? (session.statsAvailable === false ? <p className="small muted">{tr("Editing from an earlier message. Update the prompt below.")}</p> :<UsageDashboard loaded={!!loaded}/>) : (session.messages.map((m, i) => (<Message key={m.id} message={m} isLast={i === session.messages.length - 1} onEditPrompt={editPrompt} onPreview={openPreview} onOpenTimeSkip={openTimeSkip} timeSkipDone={!!timeSkipRuns.find(r => r.id === m.timeSkipId)?.completedAt} timeSkipReal={!!timeSkipRuns.find(r => r.id === m.timeSkipId)?.job} timeSkipRun={timeSkipRuns.find(r => r.id === m.timeSkipId)} onOpenLink={openLink}/>))))}diff --git a/apps/host/src/styles/app.css b/apps/host/src/styles/app.cssindex 424a2df9a..8d5e7aa1e 100644--- a/apps/host/src/styles/app.css+++ b/apps/host/src/styles/app.css@@ -7142,9 +7142,13 @@ textarea {.tool-summary > div { margin-top: 6px; padding-left: 20px; }/* ---- the live status line ---- */-.live-status { display: flex; align-items: center; gap: 10px; min-height: 28px; margin-top: 6px; color: var(--st-ink-soft); font-size: var(--st-fs-sm); }+.live-status { display: grid; grid-template-columns: 14px minmax(0, 24ch) 6ch minmax(0, auto); align-items: center; column-gap: 10px; min-height: 28px; margin-top: 6px; color: var(--st-ink-soft); font-size: var(--st-fs-sm); }+/* the word has its own area: the timer and the token count stay where they are while the word changes length */+.live-status__verb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+.live-status__time, .live-status__tokens { font-variant-numeric: tabular-nums; color: var(--st-ink-muted); white-space: nowrap; }+.live-status__time { text-align: right; }+@media (max-width: 520px) { .live-status { grid-template-columns: 14px minmax(0, 1fr) 6ch auto; } }.live-status__verb { font-weight: 700; color: var(--st-ink); animation: live-verb .35s ease; }-.live-status__meta { color: var(--st-ink-muted); font-variant-numeric: tabular-nums; }.live-status__pulse { width: 14px; height: 14px; position: relative; flex: none; }.live-status__pulse i { position: absolute; inset: 0; border-radius: 50%; background: var(--st-accent); opacity: .9; animation: live-pulse 1.4s ease-in-out infinite; }.live-status__pulse i:nth-child(2) { animation-delay: .45s; opacity: .5; }@@ -7257,13 +7261,9 @@ textarea {.storage-model__name strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }.storage-model__size { font-variant-numeric: tabular-nums; font-size: var(--st-fs-sm); }-/* ---- About > Privacy ---- */-.privacy-notes { list-style: none; margin: 0; padding: 4px 4px 2px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 28px; }-.privacy-notes li { display: flex; gap: 10px; align-items: flex-start; font-size: var(--st-fs-sm); line-height: 1.45; color: var(--st-ink-soft); }-.privacy-notes li svg { flex: none; margin-top: 2px; color: var(--st-icon); }-.privacy-notes li[data-strong] { grid-column: 1 / -1; color: var(--st-ink); font-weight: 700; }-.privacy-notes li[data-strong] svg { color: var(--st-accent-text); }-@media (max-width: 720px) { .privacy-notes { grid-template-columns: 1fr; } }+/* ---- About > Privacy: plain text ---- */+.privacy-notes { display: flex; flex-direction: column; gap: 8px; padding: 2px 0; }+.privacy-notes p { margin: 0; font-size: var(--st-fs-sm); line-height: 1.5; color: var(--st-ink-soft); }/* ---- an opened task: the name, and a last answer that is easy to read ---- */.task-name { margin: 0 0 2px; font-size: var(--st-fs-xl); letter-spacing: -.02em; }@@ -7323,3 +7323,18 @@ textarea {.native-tuned li { display: flex; gap: 8px; align-items: baseline; }.native-tuned li span { color: var(--st-ink-muted); }@media (max-width: 980px) { .native-model-layout--fit { grid-template-columns: 1fr; } }++/* the Subagents counts sit on the title's row, to its right */+.telepop__head { display: flex; align-items: baseline; gap: 10px; }+.telepop__detail { margin-right: auto; font-size: var(--st-fs-sm); color: var(--st-ink-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }+.telepop__head > .st-btn { align-self: center; margin-left: auto; }+.telepop__detail + .st-btn { margin-left: 0; }++/* the way back to the newest message: a small round arrow, shown only while scrolled up */+.jumplatest { width: 38px; height: 38px; padding: 0; justify-content: center; gap: 0; margin: 10px auto 12px; border-radius: 50%; }+.jumplatest svg { flex: none; }++/* ---- chat statistics: figures that move keep their width ---- */+.telemetry__chip, .telepop__value { font-variant-numeric: tabular-nums; }++.ts-empty { margin: 12px 0; color: var(--st-ink-soft); }diff --git a/apps/host/tests/ui5-live.test.mjs b/apps/host/tests/ui5-live.test.mjsnew file mode 100644index 000000000..bae721baf--- /dev/null+++ b/apps/host/tests/ui5-live.test.mjs@@ -0,0 +1,57 @@+/** Owner round 7: live numbers in chat, a steady status line, the subagents counts on the title row, plain Privacy, a round arrow instead of "Latest". */+import test from 'node:test';+import assert from 'node:assert/strict';+import { readFile } from 'node:fs/promises';+import { build } from 'esbuild';+import { fileURLToPath } from 'node:url';++const src = f => fileURLToPath(new URL(`../src/${f}`, import.meta.url));+const read = f => readFile(src(f), 'utf8');+async function load(file) {+ const result = await build({ entryPoints: [src(`lib/${file}`)], bundle: true, format: 'esm', platform: 'node', write: false, alias: { react: fileURLToPath(new URL('./helpers/react-stub.mjs', import.meta.url)) }, logLevel: 'silent', loader: { '.json': 'json' } });+ return import(`data:text/javascript;base64,${Buffer.from(result.outputFiles[0].text).toString('base64')}`);+}+globalThis.window ??= globalThis; globalThis.localStorage ??= { getItem: () => null, setItem: () => {} };+globalThis.navigator ??= { language: 'en' };+const { tweenValue, easeOutCubic } = await load('tween.ts');+const { chatMetrics } = await load('chat-metrics.ts');++test('item 5: a number travels between two readings in a short ease-out, never past them', () => {+ assert.equal(tweenValue(40, 50, 0, 600), 40);+ assert.equal(tweenValue(40, 50, 600, 600), 50);+ assert.ok(tweenValue(40, 50, 150, 600) > 40 && tweenValue(40, 50, 150, 600) < 50);+ assert.ok(tweenValue(50, 40, 150, 600) < 50 && tweenValue(50, 40, 150, 600) > 40, 'down as well as up');+ assert.equal(tweenValue(NaN, 7, 100, 600), 7); assert.equal(tweenValue(1, 2, 0, 0), 2);+ assert.ok(easeOutCubic(0.5) > 0.5, 'fast at first, settling at the end');+});++const reply = (extra = {}) => ({ role: 'assistant', at: new Date(1_000_000).toISOString(), content: 'x', ...extra });+test('item 5: during a goal the chat follows the Monitor even though the engine names another session', () => {+ const session = { id: 'chat-a', statsAvailable: true, tokensIn: 5000, tokensOut: 400, messages: [{ role: 'user', content: 'goal' }, reply({ inputTokens: 5000, tokens: 400, tps: 41, contextMax: 65536, durationMs: 9000, reasoningMs: 3000 }), reply({ streaming: true, tokens: 120, inputTokens: 5200, reasoningStartedAt: 1_070_000 })] };+ const monitor = { phase: 'generating', outputTps: 47.4, context: { sessionId: 'harness-xyz', usedTokens: 9100, maxTokens: 65536 } };+ const m = chatMetrics(session, monitor, 65536, 1_100_000);+ assert.equal(m.speed, 47.4, 'the live speed comes from the Monitor');+ assert.equal(m.used, 9100, 'and so does the context in use');+ assert.equal(m.llmMs, 9000 + 100_000, 'a reply being written counts its running time');+ assert.equal(m.thinkMs, 3000 + 30_000);+ assert.equal(m.writeMs, 9000 + 100_000 - 33_000);+ assert.equal(m.total, 5000 + 400 + 120 + 5200);+ // an idle engine does not move a finished chat's numbers+ const idle = chatMetrics({ ...session, messages: session.messages.slice(0, 2) }, { phase: 'idle', outputTps: 0, context: { sessionId: 'harness-xyz', usedTokens: 1, maxTokens: 2 } }, 65536, 1_100_000);+ assert.equal(idle.speed, 41); assert.notEqual(idle.used, 1);+});++test('item 10: the status line has fixed columns, so the word changing length moves nothing', async () => {+ const css = await read('styles/app.css'), line = await read('components/StatusLine.tsx');+ assert.match(css, /\.live-status \{ display: grid; grid-template-columns: 14px minmax\(0, 24ch\) 6ch/);+ assert.match(css, /\.live-status__time, \.live-status__tokens \{ font-variant-numeric: tabular-nums/);+ assert.match(line, /live-status__verb/); assert.match(line, /live-status__time/); assert.match(line, /live-status__tokens/);+});++test('items 15, 16, 17: counts on the Subagents title row, Privacy as plain text, a round arrow', async () => {+ const bar = await read('components/ChatToolbar.tsx'), pop = await read('components/Popover.tsx'), privacy = await read('components/PrivacyNotes.tsx'), chat = await read('screens/Chat.tsx');+ assert.match(bar, /title=\{tr\("Subagents"\)\} detail=\{/); assert.ok(!/subagents-overview-summary/.test(bar), 'no second line of counts');+ assert.match(pop, /telepop__detail/);+ assert.ok(!/Icon/.test(privacy), 'no icons in Privacy');+ assert.ok(!/>\{tr\("Latest"\)\}</.test(chat) && (chat.match(/aria-label=\{tr\("Scroll to the latest message"\)\}/g) ?? []).length === 2, 'the Latest button is a round arrow');+});