Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(home): reasoning steps like the Claude app, a composer-style Jarvis bar, one recent list

rubenluetke10-beep3d7d96ac6f2c
diff --git a/jarvis/ui/web/frontend/src/components/ChatInput.tsx b/jarvis/ui/web/frontend/src/components/ChatInput.tsx
index 853c6e7694..3e348af607 100644
--- a/jarvis/ui/web/frontend/src/components/ChatInput.tsx
+++ b/jarvis/ui/web/frontend/src/components/ChatInput.tsx
@@ -28,17 +28,10 @@ export function ChatInput() {
// mode is realtime — the same resolver the header and the sidebar use.
const engine = useVoiceEngineDisplay();
const wsWarming = useEventStore((s) => s.wsWarming);
- const chatThinking = useEventStore((s) => s.chatThinking);
+ // The turn's progress is no longer mirrored in the composer — the chat
+ // column renders the live steps (components/home/TurnSteps) as the
+ // in-progress assistant turn. The composer only arms the wait state.
const setChatThinking = useEventStore((s) => s.setChatThinking);
- // Most recent live reasoning step — the pill mirrors what the trace card
- // shows ("Using tool · wiki-recall") instead of a static "thinking…" label.
- // The selector returns a stable object ref while that step is unchanged.
- const activeStep = useEventStore((s) => {
- for (let i = s.thinkingSteps.length - 1; i >= 0; i--) {
- if (s.thinkingSteps[i].status === "active") return s.thinkingSteps[i];
- }
- return undefined;
- });
// Mic-dictation: live transcript streams into the box as the user speaks.
const dictating = useEventStore((s) => s.dictating);
const dictationText = useEventStore((s) => s.dictationText);
@@ -176,23 +169,6 @@ export function ChatInput() {
"focus-within:border-primary/40",
)}
>
- {chatThinking && (
- <div
- className="flex min-w-0 items-center gap-2 rounded-lg border border-primary/30 bg-primary/10 px-3 py-1.5 text-xs text-primary"
- role="status"
- aria-live="polite"
- >
- <span
- aria-hidden
- className="h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-primary/25 border-t-primary"
- />
- <span className="thinking-shimmer min-w-0 truncate font-medium">
- {activeStep
- ? `${t(activeStep.labelKey)}${activeStep.detail ? ` · ${activeStep.detail}` : ""}`
- : t("thinking.label")}
- </span>
- </div>
- )}
{dictating && (
<div
className="flex items-center gap-2 rounded-lg border border-primary/30 bg-primary/10 px-3 py-1.5 text-xs text-primary"
diff --git a/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx b/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx
new file mode 100644
index 0000000000..bdd5858100
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/home/ChatStage.test.tsx
@@ -0,0 +1,157 @@
+import { act, cleanup, render as rtlRender, screen, within } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+import { ChatStage } from "@/components/home/ChatStage";
+import type { ThinkingStep } from "@/lib/thinkingSteps";
+import { useEventStore, type ChatMessage } from "@/store/events";
+
+// The composer inside the stage names the model that will answer (a query),
+// so the stage mounts under a query client like the app.
+function render(ui: React.ReactElement) {
+ const client = new QueryClient({
+ defaultOptions: { queries: { retry: false, staleTime: Infinity } },
+ });
+ return rtlRender(<QueryClientProvider client={client}>{ui}</QueryClientProvider>);
+}
+
+function msg(id: string, role: ChatMessage["role"], content: string): ChatMessage {
+ return { id, role, content, ts: Number(id.replace(/\D/g, "")) || 0 };
+}
+
+function toolStep(id: string, tool: string, status: ThinkingStep["status"] = "done"): ThinkingStep {
+ return {
+ id,
+ kind: "tool",
+ labelKey: "thinking.step_tool",
+ detail: tool,
+ status,
+ startedTs: 0,
+ durationMs: status === "active" ? undefined : 500,
+ };
+}
+
+describe("ChatStage", () => {
+ let scrollTo: ReturnType<typeof vi.fn>;
+
+ beforeEach(() => {
+ // jsdom has no element scrolling; the stage must call the standard API.
+ scrollTo = vi.fn();
+ Object.defineProperty(HTMLElement.prototype, "scrollTo", {
+ configurable: true,
+ writable: true,
+ value: scrollTo,
+ });
+ useEventStore.setState({
+ connected: true,
+ wsWarming: false,
+ messages: [],
+ chatThinking: false,
+ thinkingSteps: [],
+ thinkingStartedTs: null,
+ thinkingTraces: {},
+ activeThreadId: null,
+ assistantName: "Jarvis",
+ });
+ });
+ afterEach(() => {
+ cleanup();
+ vi.useRealTimers();
+ });
+
+ it("shows the empty state with greeting and composer when there is nothing yet", () => {
+ render(<ChatStage />);
+ expect(screen.getByTestId("chat-stage").getAttribute("data-empty")).toBe("true");
+ expect(screen.getByTestId("chat-composer")).toBeTruthy();
+ });
+
+ it("renders the live turn with its steps while the assistant is thinking", () => {
+ useEventStore.setState({
+ messages: [msg("m1", "user", "find my invoices")],
+ chatThinking: true,
+ thinkingStartedTs: Date.now() - 4000,
+ thinkingSteps: [
+ { id: "s1", kind: "brain", labelKey: "thinking.step_brain", status: "done", startedTs: 0, durationMs: 700 },
+ toolStep("s2", "gmail_search", "active"),
+ ],
+ });
+ render(<ChatStage />);
+ const live = screen.getByTestId("chat-turn-live");
+ expect(live.textContent).toContain("Jarvis");
+ const steps = within(live).getByTestId("turn-steps");
+ expect(steps.getAttribute("data-live")).toBe("true");
+ expect(steps.getAttribute("data-open")).toBe("true");
+ const rows = within(steps).getAllByTestId("turn-step");
+ expect(rows).toHaveLength(2);
+ expect(rows[1].textContent).toContain("Gmail · search");
+ expect(within(rows[1]).getByTestId("turn-step-spinner")).toBeTruthy();
+ });
+
+ it("renders a finished trace folded above the answer, tool rows still visible", () => {
+ useEventStore.setState({
+ messages: [msg("m1", "user", "any github issues?"), msg("m2", "assistant", "Three open issues.")],
+ thinkingTraces: {
+ m2: {
+ durationMs: 6_200,
+ steps: [
+ { id: "s1", kind: "brain", labelKey: "thinking.step_brain", status: "done", startedTs: 0, durationMs: 900 },
+ toolStep("s2", "github_issues"),
+ ],
+ },
+ },
+ });
+ render(<ChatStage />);
+ const answer = screen.getByTestId("chat-message-assistant");
+ const steps = within(answer).getByTestId("turn-steps");
+ expect(steps.getAttribute("data-open")).toBe("false");
+ expect(within(steps).getByTestId("turn-steps-toggle").textContent).toContain("6s");
+ const rows = within(steps).getAllByTestId("turn-step");
+ expect(rows).toHaveLength(1);
+ expect(rows[0].textContent).toContain("GitHub · issues");
+ expect(within(rows[0]).getByTestId("turn-step-brand").getAttribute("data-brand-tier")).toBe("logo");
+ // The steps sit above the answer text.
+ expect(answer.textContent!.indexOf("GitHub · issues")).toBeLessThan(
+ answer.textContent!.indexOf("Three open issues."),
+ );
+ });
+
+ it("scrolls a new user message to the top and keeps a spacer under the turn", () => {
+ useEventStore.setState({
+ messages: [msg("m1", "user", "hello"), msg("m2", "assistant", "hi")],
+ });
+ render(<ChatStage />);
+ // Opening a conversation: follow the end, once.
+ expect(scrollTo).toHaveBeenCalledTimes(1);
+ scrollTo.mockClear();
+
+ act(() => {
+ useEventStore.getState().pushMessage(msg("m3", "user", "and now?"));
+ useEventStore.getState().setChatThinking(true);
+ });
+ expect(screen.getByTestId("chat-bottom-spacer")).toBeTruthy();
+ // The user message is brought to the top (one scroll, smooth or instant).
+ expect(scrollTo).toHaveBeenCalledTimes(1);
+ const arg = scrollTo.mock.calls[0][0] as { top: number; behavior: string };
+ expect(arg.top).toBe(0); // jsdom lays everything out at 0 — the top edge
+ expect(["smooth", "auto"]).toContain(arg.behavior);
+ scrollTo.mockClear();
+
+ // The answer landing does NOT move the page.
+ act(() => {
+ useEventStore.getState().finishThinking("m4");
+ useEventStore.getState().pushMessage(msg("m4", "assistant", "here you go"));
+ });
+ expect(scrollTo).not.toHaveBeenCalled();
+ expect(screen.queryByTestId("chat-turn-live")).toBeNull();
+ expect(screen.getAllByTestId("chat-message-assistant")).toHaveLength(2);
+ });
+
+ it("does not render the old thinking card anymore", () => {
+ useEventStore.setState({ messages: [msg("m1", "user", "x")], chatThinking: true, thinkingStartedTs: Date.now() });
+ render(<ChatStage />);
+ // The composer no longer carries a status pill; the live turn does the talking.
+ const composer = screen.getByTestId("chat-composer");
+ expect(within(composer).queryByRole("status")).toBeNull();
+ expect(screen.getByTestId("chat-turn-live")).toBeTruthy();
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/home/ChatStage.tsx b/jarvis/ui/web/frontend/src/components/home/ChatStage.tsx
index 9d1fe26ef1..e76d4a24e1 100644
--- a/jarvis/ui/web/frontend/src/components/home/ChatStage.tsx
+++ b/jarvis/ui/web/frontend/src/components/home/ChatStage.tsx
@@ -1,9 +1,9 @@
-import { useEffect, useRef } from "react";
+import { useEffect, useLayoutEffect, useRef, useState } from "react";
import { useEventStore, type ChatMessage } from "@/store/events";
import { ScrollArea } from "@/components/ui/scroll-area";
import { ChatInput } from "@/components/ChatInput";
-import { ThinkingTrace, ThoughtTraceDisclosure } from "@/components/ThinkingTrace";
+import { TurnSteps } from "@/components/home/TurnSteps";
import { Greeting } from "@/components/home/Greeting";
import { useT } from "@/i18n";
import { cn } from "@/lib/utils";
@@ -20,17 +20,91 @@ import { cn } from "@/lib/utils";
* The composer is the one the classic view used (ChatInput): same send
* path, same dictation, same thread routing. Only the room around it
* changed.
+ *
+ * Scrolling follows the Claude app: when the person sends, their message
+ * is brought to the TOP of the scroll area and the answer grows below it —
+ * the eye stays where the new turn begins instead of chasing the bottom.
+ * A spacer under the last turn makes that possible even when the turn is
+ * short; it shrinks as the answer fills the viewport, so a finished answer
+ * never trails a screen of blank paper. Nothing jumps on assistant output.
*/
export function ChatStage() {
const t = useT();
const messages = useEventStore((s) => s.messages);
const chatThinking = useEventStore((s) => s.chatThinking);
- const endRef = useRef<HTMLDivElement | null>(null);
+ const activeThreadId = useEventStore((s) => s.activeThreadId);
const hasContent = messages.length > 0 || chatThinking;
+ const rootRef = useRef<HTMLDivElement | null>(null);
+ const columnRef = useRef<HTMLDivElement | null>(null);
+ const spacerRef = useRef<HTMLDivElement | null>(null);
+ // The user message pinned to the top of the scroll area for the current
+ // turn. Null until the person sends in this mounted column — opening an
+ // old conversation lands at its end like before, with no spacer.
+ const anchorIdRef = useRef<string | null>(null);
+ const lastMessageIdRef = useRef<string | null>(null);
+ const threadRef = useRef<string | null>(activeThreadId);
+
+ // Refs, not state, on purpose: the spacer must be sized BEFORE the scroll
+ // that relies on it, in the same layout pass — a state round-trip would
+ // scroll first and grow the page afterwards, clamping the scroll short.
+ const applySpacer = () => {
+ const viewport = viewportOf(rootRef.current);
+ const spacer = spacerRef.current;
+ if (!viewport || !spacer) return;
+ const anchor = anchorIdRef.current ? messageElement(viewport, anchorIdRef.current) : null;
+ if (!anchor) {
+ spacer.style.minHeight = "0px";
+ return;
+ }
+ // Everything from the anchored message down to the spacer is the turn.
+ const turnHeight =
+ spacer.getBoundingClientRect().top - anchor.getBoundingClientRect().top;
+ const room = viewport.clientHeight - turnHeight - TURN_BOTTOM_PAD_PX;
+ spacer.style.minHeight = `${Math.max(0, Math.round(room))}px`;
+ };
+
+ // React to the newest message: a user line is the start of a turn and
+ // gets pinned to the top; anything else, with no turn in flight, keeps
+ // the old "follow the end" behaviour (first render of a conversation).
+ // Switching conversations resets the anchor: the new thread is read from
+ // its end, not from wherever the previous turn left the scroll position.
+ useLayoutEffect(() => {
+ if (threadRef.current !== activeThreadId) {
+ threadRef.current = activeThreadId;
+ anchorIdRef.current = null;
+ lastMessageIdRef.current = null;
+ }
+ const viewport = viewportOf(rootRef.current);
+ const last = messages[messages.length - 1];
+ const lastId = last?.id ?? null;
+ const isNew = lastId !== lastMessageIdRef.current;
+ lastMessageIdRef.current = lastId;
+ if (!viewport || !last) return;
+ if (isNew && last.role === "user") {
+ anchorIdRef.current = last.id;
+ applySpacer();
+ scrollMessageToTop(viewport, last.id);
+ return;
+ }
+ applySpacer();
+ if (isNew && anchorIdRef.current === null) scrollToEnd(viewport);
+ // `applySpacer` reads refs only and is recreated per render by design.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [messages, activeThreadId, chatThinking]);
+
+ // The live steps grow without re-rendering this column, so the spacer
+ // also follows the column's size where the platform has ResizeObserver.
useEffect(() => {
- endRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
- }, [messages.length, chatThinking]);
+ const column = columnRef.current;
+ const viewport = viewportOf(rootRef.current);
+ if (!column || !viewport || typeof ResizeObserver === "undefined") return;
+ const ro = new ResizeObserver(() => applySpacer());
+ ro.observe(column);
+ ro.observe(viewport);
+ return () => ro.disconnect();
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [hasContent]);
if (!hasContent) {
return (
@@ -45,13 +119,16 @@ export function ChatStage() {
return (
<div className="flex min-h-0 flex-1 flex-col items-center" data-testid="chat-stage" data-empty="false">
- <ScrollArea className="min-h-0 w-full flex-1">
- <div className="mx-auto flex w-full max-w-[760px] flex-col gap-5 px-6 pb-6 pt-8">
+ <ScrollArea ref={rootRef} className="min-h-0 w-full flex-1">
+ <div
+ ref={columnRef}
+ className="relative mx-auto flex w-full max-w-[760px] flex-col gap-5 px-6 pb-6 pt-8"
+ >
{messages.map((m) => (
<MessageRow key={m.id} message={m} />
))}
- {chatThinking && <ThinkingTrace />}
- <div ref={endRef} />
+ {chatThinking && <LiveTurn />}
+ <div ref={spacerRef} aria-hidden data-testid="chat-bottom-spacer" className="shrink-0" />
</div>
</ScrollArea>
<div className="w-full max-w-[760px] px-6 pb-5 pt-2">
@@ -61,10 +138,93 @@ export function ChatStage() {
);
}
+/** Room kept under the turn so the composer's shadow never kisses the text. */
+const TURN_BOTTOM_PAD_PX = 24;
+
+/** Radix renders the scrolling element as the viewport inside our ScrollArea root. */
+function viewportOf(root: HTMLElement | null): HTMLElement | null {
+ if (!root) return null;
+ return (root.querySelector("[data-radix-scroll-area-viewport]") as HTMLElement | null) ?? root;
+}
+
+function messageElement(viewport: HTMLElement, id: string): HTMLElement | null {
+ // Attribute compare instead of a selector: message ids carry characters
+ // (":" , "." ) a CSS selector would need escaping for.
+ for (const el of Array.from(viewport.querySelectorAll<HTMLElement>("[data-message-id]"))) {
+ if (el.dataset.messageId === id) return el;
+ }
+ return null;
+}
+
+function prefersReducedMotion(): boolean {
+ return typeof window !== "undefined" && typeof window.matchMedia === "function"
+ ? window.matchMedia("(prefers-reduced-motion: reduce)").matches
+ : false;
+}
+
+function scrollViewport(viewport: HTMLElement, top: number) {
+ const behavior: ScrollBehavior = prefersReducedMotion() ? "auto" : "smooth";
+ if (typeof viewport.scrollTo === "function") viewport.scrollTo({ top, behavior });
+ else viewport.scrollTop = top;
+}
+
+/** Bring the message with `id` to the top edge of the viewport (plus a breath of padding). */
+function scrollMessageToTop(viewport: HTMLElement, id: string) {
+ const el = messageElement(viewport, id);
+ if (!el) return;
+ const top =
+ el.getBoundingClientRect().top - viewport.getBoundingClientRect().top + viewport.scrollTop - 12;
+ scrollViewport(viewport, Math.max(0, top));
+}
+
+function scrollToEnd(viewport: HTMLElement) {
+ scrollViewport(viewport, viewport.scrollHeight);
+}
+
+/** Elapsed wall-clock since `startedTs`, ticking once a second while set. */
+function useElapsedMs(startedTs: number | null): number {
+ const [now, setNow] = useState(() => Date.now());
+ useEffect(() => {
+ if (startedTs === null) return;
+ setNow(Date.now());
+ const id = window.setInterval(() => setNow(Date.now()), 1000);
+ return () => window.clearInterval(id);
+ }, [startedTs]);
+ return startedTs === null ? 0 : Math.max(0, now - startedTs);
+}
+
+/**
+ * The assistant turn still in progress: byline plus the live steps. Reads
+ * the store itself so the column does not re-render on every step event —
+ * only this block does.
+ */
+function LiveTurn() {
+ const assistantName = useEventStore((s) => s.assistantName);
+ const steps = useEventStore((s) => s.thinkingSteps);
+ const startedTs = useEventStore((s) => s.thinkingStartedTs);
+ const elapsed = useElapsedMs(startedTs);
+ return (
+ <div className="flex flex-col gap-1.5 px-1" data-testid="chat-turn-live">
+ <Byline name={assistantName} />
+ <TurnSteps steps={steps} live durationMs={elapsed} />
+ </div>
+ );
+}
+
+function Byline({ name }: { name: string }) {
+ return (
+ <div className="flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.14em] text-primary">
+ <span className="h-1 w-1 rounded-full bg-primary" aria-hidden />
+ {name}
+ </div>
+ );
+}
+
/**
* One message in the column. The person's lines sit right in a quiet
* bubble; the assistant's run flush-left with a byline and, when there is
- * one, the "Thought for Ns" disclosure — prose on the page, not a bubble.
+ * one, the turn's steps ("Thought for Ns" + tool calls) above the answer —
+ * prose on the page, not a bubble.
*/
function MessageRow({ message }: { message: ChatMessage }) {
const assistantName = useEventStore((s) => s.assistantName);
@@ -73,7 +233,10 @@ function MessageRow({ message }: { message: ChatMessage }) {
if (message.role === "system") {
return (
- <div className="mx-auto max-w-[85%] rounded-lg border border-border bg-secondary/50 px-3 py-2 text-center text-xs italic text-muted-foreground">
+ <div
+ data-message-id={message.id}
+ className="mx-auto max-w-[85%] rounded-lg border border-border bg-secondary/50 px-3 py-2 text-center text-xs italic text-muted-foreground"
+ >
{message.content}
</div>
);
@@ -81,7 +244,10 @@ function MessageRow({ message }: { message: ChatMessage }) {
if (message.role === "preamble") {
return (
- <div className="flex flex-col gap-1 text-xs italic leading-relaxed text-muted-foreground">
+ <div
+ data-message-id={message.id}
+ className="flex flex-col gap-1 text-xs italic leading-relaxed text-muted-foreground"
+ >
<span className="font-mono text-[10px] not-italic uppercase tracking-[0.14em] text-muted-foreground">
{assistantName} · pre-ack
</span>
@@ -92,7 +258,7 @@ function MessageRow({ message }: { message: ChatMessage }) {
if (isUser) {
return (
- <div className="flex justify-end" data-testid="chat-message-user">
+ <div className="flex justify-end" data-testid="chat-message-user" data-message-id={message.id}>
<div className="max-w-[78%] rounded-2xl rounded-br-md border border-border bg-secondary px-4 py-2.5 text-[15px] leading-relaxed text-foreground">
<div className="whitespace-pre-wrap">{message.content}</div>
</div>
@@ -101,12 +267,13 @@ function MessageRow({ message }: { message: ChatMessage }) {
}
return (
- <div className="flex flex-col gap-1.5 px-1" data-testid="chat-message-assistant">
- <div className="flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.14em] text-primary">
- <span className="h-1 w-1 rounded-full bg-primary" aria-hidden />
- {assistantName}
- </div>
- {trace && <ThoughtTraceDisclosure trace={trace} />}
+ <div
+ className="flex flex-col gap-1.5 px-1"
+ data-testid="chat-message-assistant"
+ data-message-id={message.id}
+ >
+ <Byline name={assistantName} />
+ {trace && <TurnSteps steps={trace.steps} durationMs={trace.durationMs} className="mb-1" />}
<div className={cn("whitespace-pre-wrap text-[15px] leading-relaxed text-foreground")}>
{message.content}
</div>
diff --git a/jarvis/ui/web/frontend/src/components/home/JarvisBar.tsx b/jarvis/ui/web/frontend/src/components/home/JarvisBar.tsx
new file mode 100644
index 0000000000..bb19d77371
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/home/JarvisBar.tsx
@@ -0,0 +1,170 @@
+import { useCallback, type KeyboardEvent, type MouseEvent } from "react";
+import { PhoneOff } from "lucide-react";
+
+import { useEventStore, type VoiceState } from "@/store/events";
+import { VoiceWaveform, type WaveformPhase } from "@/components/overlay/VoiceWaveform";
+import { voiceInputLevelRef } from "@/lib/voiceInputLevel";
+import { useVoiceCall } from "@/components/agentic/useVoiceCall";
+import { useVoiceReadiness } from "@/hooks/useVoiceReadiness";
+import { useVoiceEngineDisplay } from "@/hooks/useVoiceEngineDisplay";
+import { useT } from "@/i18n";
+import { cn } from "@/lib/utils";
+
+/** Bars across the card — wide enough to read as a waveform, not a meter. */
+const BAR_COUNT = 40;
+
+/**
+ * The Jarvis bar — the front page's one voice control, drawn as a card in
+ * the chat composer's language (components/ChatInput.tsx: rounded-2xl,
+ * bg-card, a hairline border, the same soft shadow) so the two surfaces
+ * read as siblings.
+ *
+ * Top row: the live waveform, large. Bottom row: the state (dot + word) on
+ * the left; on the right the engine pill — provider and model, click to
+ * change it — and, only while a conversation is running, an End button.
+ * The whole card is the start/stop control (maintainer, 2026-08-23: no
+ * microphone button — you tap the bar or say the wake word); the pills stop
+ * the click from reaching the card so changing the model never starts a
+ * call by accident.
+ *
+ * A `div` with the button role rather than a `<button>`: a button may not
+ * contain the two inner buttons, and nesting them is how a screen reader
+ * would announce one control three times.
+ */
+export function JarvisBar({ phase }: { phase: WaveformPhase }) {
+ const t = useT();
+ const voiceState = useEventStore((s) => s.voiceState);
+ const setActiveSection = useEventStore((s) => s.setActiveSection);
+ const { connected } = useVoiceReadiness();
+ const engine = useVoiceEngineDisplay();
+ const { active: callActive, busy: callBusy, connecting, toggleCall } = useVoiceCall();
+
+ const disabled = callBusy || connecting || !connected;
+ const label = callActive ? t("home.bar_stop") : t("home.bar_start");
+ const stateWord = t(`voice_state.${stateKey(voiceState, connecting, connected)}`);
+
+ const onCardClick = useCallback(() => {
+ if (disabled) return;
+ void toggleCall();
+ }, [disabled, toggleCall]);
+
+ const onCardKey = useCallback(
+ (ev: KeyboardEvent<HTMLDivElement>) => {
+ if (ev.target !== ev.currentTarget) return; // a pill has its own keys
+ if (ev.key === "Enter" || ev.key === " ") {
+ ev.preventDefault();
+ onCardClick();
+ }
+ },
+ [onCardClick],
+ );
+
+ const onEngineClick = useCallback(
+ (ev: MouseEvent<HTMLButtonElement>) => {
+ ev.stopPropagation();
+ setActiveSection("apikeys");
+ },
+ [setActiveSection],
+ );
+
+ const onEndClick = useCallback(
+ (ev: MouseEvent<HTMLButtonElement>) => {
+ ev.stopPropagation();
+ if (callBusy) return;
+ void toggleCall();
+ },
+ [callBusy, toggleCall],
+ );
+
+ return (
+ <div
+ role="button"
+ tabIndex={disabled ? -1 : 0}
+ aria-disabled={disabled || undefined}
+ aria-label={label}
+ title={label}
+ onClick={onCardClick}
+ onKeyDown={onCardKey}
+ data-testid="jarvis-bar"
+ data-phase={phase}
+ data-active={callActive || undefined}
+ className={cn(
+ "group flex w-full cursor-pointer select-none flex-col gap-2 rounded-2xl border border-border bg-card p-3 text-left",
+ "shadow-[0_1px_2px_rgb(var(--scrim-rgb)/0.05),0_8px_24px_rgb(var(--scrim-rgb)/0.06)] transition-[border-color,box-shadow]",
+ "hover:border-primary/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
+ "aria-disabled:cursor-default aria-disabled:opacity-80 aria-disabled:hover:border-border",
+ callActive && "border-primary/50",
+ )}
+ >
+ <VoiceWaveform
+ levelRef={voiceInputLevelRef}
+ phase={phase}
+ count={BAR_COUNT}
+ frame={false}
+ className="h-14 w-full"
+ />
+ <div className="flex items-center gap-1.5">
+ <span
+ className={cn(
+ "flex min-w-0 items-center gap-2 px-1 font-mono text-[10px] uppercase tracking-[0.16em]",
+ callActive ? "text-primary" : "text-muted-foreground",
+ )}
+ data-testid="jarvis-bar-state"
+ >
+ <span
+ aria-hidden
+ className={cn(
+ "h-2 w-2 shrink-0 rounded-full",
+ voiceState === "error"
+ ? "bg-destructive"
+ : callActive
+ ? "bg-primary animate-jarvis-pulse"
+ : "bg-muted-foreground/40",
+ )}
+ />
+ <span className="truncate">{stateWord}</span>
+ </span>
+ <span className="flex-1" />
+ <button
+ type="button"
+ onClick={onEngineClick}
+ title={t("home.model_hint")}
+ data-testid="jarvis-bar-engine"
+ className="inline-flex h-8 max-w-[280px] items-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ <span className="truncate font-medium text-foreground">{engine.providerLabel}</span>
+ {engine.model && (
+ <span className="hidden truncate font-mono text-[10px] text-muted-foreground sm:inline">
+ {engine.model}
+ </span>
+ )}
+ </button>
+ {callActive && (
+ <button
+ type="button"
+ onClick={onEndClick}
+ disabled={callBusy}
+ aria-label={t("home.bar_end")}
+ title={t("home.bar_end")}
+ data-testid="jarvis-bar-end"
+ className="inline-flex h-8 items-center gap-1.5 rounded-lg border border-destructive/30 bg-destructive/10 px-2.5 text-xs font-medium text-destructive transition-colors hover:bg-destructive/20 disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ <PhoneOff className="h-3.5 w-3.5" aria-hidden />
+ {t("home.bar_end")}
+ </button>
+ )}
+ </div>
+ </div>
+ );
+}
+
+/**
+ * Which `voice_state.*` word the bar shows. Offline wins over whatever the
+ * store last heard; the call being negotiated wins over the stale state
+ * before it.
+ */
+export function stateKey(state: VoiceState, connecting: boolean, connected: boolean): string {
+ if (!connected) return "offline";
+ if (connecting) return "connecting";
+ return state;
+}
diff --git a/jarvis/ui/web/frontend/src/components/home/RecentRuns.tsx b/jarvis/ui/web/frontend/src/components/home/RecentRuns.tsx
deleted file mode 100644
index 942b150ecd..0000000000
--- a/jarvis/ui/web/frontend/src/components/home/RecentRuns.tsx
+++ /dev/null
@@ -1,126 +0,0 @@
-import { useState } from "react";
-
-import { useRuns } from "@/hooks/useRuns";
-import { OutcomeDot } from "@/components/runs/OutcomeBadge";
-import type { RunListItem } from "@/components/runs/types";
-import { useEventStore } from "@/store/events";
-import { useRunFocusStore } from "@/store/runFocus";
-import { fill, useT } from "@/i18n";
-import { cn } from "@/lib/utils";
-import { SidebarGroup } from "@/components/home/SidebarGroup";
-
-/** How many runs the block shows folded. The sketch says three. */
-export const RECENT_RUNS_FOLDED = 3;
-/** How many it shows unfolded — enough to scan, never a second inspector. */
-export const RECENT_RUNS_UNFOLDED = 12;
-
-/**
- * The last runs, at a glance, from the sidebar (maintainer sketch,
- * 2026-08-23): outcome dot, what was said, when, and how long. A row opens
- * the Run Inspector on that run. Reads the same query the inspector uses, so
- * there is one fetch and one cache for both.
- */
-export function RecentRuns() {
- const t = useT();
- const { data: runs } = useRuns();
- const [open, setOpen] = useState(false);
- const setActive = useEventStore((s) => s.setActiveSection);
- const focus = useRunFocusStore((s) => s.focus);
-
- const all = runs ?? [];
- const shown = all.slice(0, open ? RECENT_RUNS_UNFOLDED : RECENT_RUNS_FOLDED);
- const canExpand = all.length > RECENT_RUNS_FOLDED;
-
- return (
- <SidebarGroup
- title={t("sidebar.recent_runs")}
- action={
- canExpand
- ? {
- label: open ? t("sidebar.show_less") : t("sidebar.show_all"),
- onClick: () => setOpen((v) => !v),
- expanded: open,
- }
- : undefined
- }
- testId="recent-runs"
- >
- {shown.length === 0 ? (
- <p className="px-2 py-1 text-[11px] text-muted-foreground/70">{t("sidebar.no_runs")}</p>
- ) : (
- <ul className="space-y-px">
- {shown.map((run) => (
- <RunRow
- key={run.session_id}
- run={run}
- onOpen={() => {
- focus(run.session_id);
- setActive("run_inspector");
- }}
- />
- ))}
- </ul>
- )}
- </SidebarGroup>
- );
-}
-
-function RunRow({ run, onOpen }: { run: RunListItem; onOpen: () => void }) {
- const t = useT();
- const live = run.ended_ms === null;
- const title = run.preview || run.session_id.slice(0, 8);
- const meta = live
- ? t("sidebar.run_live")
- : fill(t("sidebar.run_meta"), {
- turns: run.turn_count,
- duration: formatDuration(run.duration_s),
- });
- return (
- <li>
- <button
- type="button"
- onClick={onOpen}
- title={title}
- data-testid="recent-run-row"
- className={cn(
- "group grid w-full grid-cols-[auto_1fr_auto] items-center gap-x-2 rounded-lg px-2 py-1.5 text-left transition-colors",
- "hover:bg-background/60 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
- )}
- >
- <OutcomeDot
- outcome={live ? "live" : run.outcome}
- className={cn(live && "bg-primary animate-jarvis-pulse")}
- />
- <span className="truncate text-xs text-foreground">{title}</span>
- <span className="font-mono text-[10px] tabular-nums text-muted-foreground">
- {formatClock(run.started_ms)}
- </span>
- <span className="col-start-2 truncate font-mono text-[10px] text-muted-foreground/80">
- {meta}
- </span>
- </button>
- </li>
- );
-}
-
-function formatDuration(seconds: number | null): string {
- if (seconds === null || !Number.isFinite(seconds)) return "—";
- const s = Math.max(0, Math.round(seconds));
- if (s < 60) return `${s}s`;
- const m = Math.floor(s / 60);
- const rest = s % 60;
- if (m < 60) return rest ? `${m}m ${rest}s` : `${m}m`;
- const h = Math.floor(m / 60);
- return `${h}h ${m % 60}m`;
-}
-
-function formatClock(ms: number): string {
- if (!ms) return "";
- const d = new Date(ms);
- const today = new Date();
- today.setHours(0, 0, 0, 0);
- if (d.getTime() >= today.getTime()) {
- return d.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });
- }
- return d.toLocaleDateString(undefined, { month: "short", day: "numeric" });
-}
diff --git a/jarvis/ui/web/frontend/src/components/home/TurnSteps.test.tsx b/jarvis/ui/web/frontend/src/components/home/TurnSteps.test.tsx
new file mode 100644
index 0000000000..e107d7b5c8
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/home/TurnSteps.test.tsx
@@ -0,0 +1,108 @@
+import { cleanup, fireEvent, render, screen, within } from "@testing-library/react";
+import { afterEach, describe, expect, it } from "vitest";
+
+import { TurnSteps, formatThoughtDuration } from "@/components/home/TurnSteps";
+import type { ThinkingStep } from "@/lib/thinkingSteps";
+
+function step(over: Partial<ThinkingStep> & Pick<ThinkingStep, "id" | "kind">): ThinkingStep {
+ return {
+ labelKey: over.kind === "tool" ? "thinking.step_tool" : "thinking.step_brain",
+ status: "done",
+ startedTs: 0,
+ durationMs: 1200,
+ ...over,
+ };
+}
+
+const FINISHED: ThinkingStep[] = [
+ step({ id: "a", kind: "brain", detail: "openai · gpt-5" }),
+ step({ id: "b", kind: "tool", detail: "gmail_search", durationMs: 820 }),
+ step({ id: "c", kind: "tool", detail: "run_shell", status: "error", durationMs: 300 }),
+ step({ id: "d", kind: "note", labelKey: "thinking.step_update", detail: "Found 3 mails" }),
+];
+
+describe("TurnSteps", () => {
+ afterEach(() => cleanup());
+
+ it("renders nothing for a finished turn without steps, but a live header with none", () => {
+ const { container, rerender } = render(<TurnSteps steps={[]} />);
+ expect(container.querySelector('[data-testid="turn-steps"]')).toBeNull();
+ rerender(<TurnSteps steps={[]} live durationMs={3000} />);
+ const root = screen.getByTestId("turn-steps");
+ expect(root.getAttribute("data-live")).toBe("true");
+ expect(screen.getByTestId("turn-steps-toggle").textContent).toContain("Thinking");
+ expect(screen.getByTestId("turn-steps-toggle").textContent).toContain("3s");
+ });
+
+ it("starts folded when finished: header with the duration, tool rows still visible", () => {
+ render(<TurnSteps steps={FINISHED} durationMs={10_400} />);
+ const toggle = screen.getByTestId("turn-steps-toggle");
+ expect(toggle.getAttribute("aria-expanded")).toBe("false");
+ expect(toggle.textContent).toContain("10s");
+
+ const list = screen.getByTestId("turn-steps-list");
+ expect(list.getAttribute("data-folded")).toBe("true");
+ const rows = within(list).getAllByTestId("turn-step");
+ expect(rows.map((r) => r.getAttribute("data-kind"))).toEqual(["tool", "tool"]);
+ // Non-tool rows are behind the fold (labels resolve through the real EN locale).
+ expect(screen.queryByText("Reasoning")).toBeNull();
+ });
+
+ it("unfolds to every row and folds back", () => {
+ render(<TurnSteps steps={FINISHED} durationMs={10_400} />);
+ fireEvent.click(screen.getByTestId("turn-steps-toggle"));
+ expect(screen.getByTestId("turn-steps-toggle").getAttribute("aria-expanded")).toBe("true");
+ expect(screen.getAllByTestId("turn-step")).toHaveLength(4);
+ expect(screen.getByText("Reasoning")).toBeTruthy();
+ expect(screen.getByText("Found 3 mails")).toBeTruthy();
+
+ fireEvent.click(screen.getByTestId("turn-steps-toggle"));
+ expect(screen.getAllByTestId("turn-step")).toHaveLength(2);
+ });
+
+ it("renders tool rows with the brand tile, the humanised label and the raw tool name", () => {
+ render(<TurnSteps steps={FINISHED} durationMs={10_400} />);
+ const [gmail, shell] = screen.getAllByTestId("turn-step");
+
+ const gmailTile = within(gmail).getByTestId("turn-step-brand");
+ expect(gmailTile.getAttribute("data-brand-tier")).toBe("logo");
+ expect(gmailTile.querySelector("img")?.getAttribute("src")).toMatch(/svg/);
+ expect(gmail.textContent).toContain("Gmail · search");
+ expect(gmail.textContent).toContain("gmail_search");
+ expect(gmail.textContent).toContain("0.8s");
+
+ const shellTile = within(shell).getByTestId("turn-step-brand");
+ expect(shellTile.getAttribute("data-brand-tier")).toBe("monogram");
+ expect(shellTile.textContent).toBe("RS");
+ expect(shell.getAttribute("data-status")).toBe("error");
+ // The key may or may not be in the locale yet; both forms contain "failed".
+ expect(shell.textContent).toMatch(/failed/i);
+ });
+
+ it("is open in live mode and spins on the active row", () => {
+ const live: ThinkingStep[] = [
+ step({ id: "a", kind: "brain", durationMs: 900 }),
+ step({ id: "b", kind: "tool", detail: "github_issues", status: "active", durationMs: undefined }),
+ ];
+ render(<TurnSteps steps={live} live durationMs={2_500} />);
+ expect(screen.getByTestId("turn-steps-toggle").getAttribute("aria-expanded")).toBe("true");
+ const rows = screen.getAllByTestId("turn-step");
+ expect(rows).toHaveLength(2);
+ expect(within(rows[1]).getByTestId("turn-step-spinner")).toBeTruthy();
+ expect(within(rows[0]).queryByTestId("turn-step-spinner")).toBeNull();
+ });
+
+ it("honours defaultOpen over the mode default", () => {
+ render(<TurnSteps steps={FINISHED} durationMs={1000} defaultOpen />);
+ expect(screen.getAllByTestId("turn-step")).toHaveLength(4);
+ });
+});
+
+describe("formatThoughtDuration", () => {
+ it("rounds to whole seconds and never shows 0s for a real turn", () => {
+ expect(formatThoughtDuration(0)).toBe("0s");
+ expect(formatThoughtDuration(400)).toBe("1s");
+ expect(formatThoughtDuration(10_400)).toBe("10s");
+ expect(formatThoughtDuration(65_000)).toBe("1m 05s");
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/home/TurnSteps.tsx b/jarvis/ui/web/frontend/src/components/home/TurnSteps.tsx
new file mode 100644
index 0000000000..641655008c
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/home/TurnSteps.tsx
@@ -0,0 +1,338 @@
+/**
+ * The reasoning steps of one turn, the way the Claude desktop app shows
+ * them: a muted "Thought for 10s" line that folds and unfolds the list, rows
+ * hung on a thin vertical connector, and tool calls as rows carrying the
+ * service's brand mark in a small tile. Not the model's thinking text — the
+ * maintainer asked for the steps and the tool calls, nothing more.
+ *
+ * Two modes share one renderer:
+ * live — the turn is still running; the list is open, the active row
+ * spins, the header counts the seconds.
+ * finished — folded to the header by default, BUT the tool rows stay
+ * visible under it: what the assistant reached for is the part
+ * worth seeing without a click. Unfolding shows every row.
+ *
+ * Presentational only: steps come in as props (the store keeps the live
+ * list and the per-message snapshots), time comes in as `durationMs` — the
+ * caller ticks. That keeps this usable from the chat column and the voice
+ * lane alike, and testable without a store.
+ */
+import { useId, useState } from "react";
+import {
+ Bot,
+ Brain,
+ ChevronRight,
+ CircleAlert,
+ Clock,
+ Info,
+ MonitorDot,
+ type LucideIcon,
+} from "lucide-react";
+
+import type { ThinkingStep, ThinkingStepKind } from "@/lib/thinkingSteps";
+import { resolveToolBrand } from "@/lib/toolBrand";
+import { fill, useT } from "@/i18n";
+import { cn } from "@/lib/utils";
+
+export interface TurnStepsProps {
+ steps: ThinkingStep[];
+ /** The turn is still running — the last active step shows a live spinner. */
+ live?: boolean;
+ /** Total thinking time (finished: of the turn; live: elapsed so far), for the header. */
+ durationMs?: number;
+ /** Tighter rows (the voice lane). */
+ compact?: boolean;
+ /** Finished traces start folded; live ones start open. */
+ defaultOpen?: boolean;
+ className?: string;
+}
+
+/** Whole seconds like the Claude app: "10s", "1m 05s"; never "0s" for a real turn. */
+export function formatThoughtDuration(ms: number): string {
+ const total = Math.max(0, Math.round(ms / 1000));
+ if (total < 60) return `${Math.max(total, ms > 0 ? 1 : 0)}s`;
+ const m = Math.floor(total / 60);
+ const s = total % 60;
+ return `${m}m ${String(s).padStart(2, "0")}s`;
+}
+
+/** Per-row durations keep tenths under ten seconds — a 0.4s tool call is not "0s". */
+function formatStepDuration(ms: number): string {
+ if (ms < 10_000) return `${(ms / 1000).toFixed(1)}s`;
+ return formatThoughtDuration(ms);
+}
+
+const KIND_ICON: Record<Exclude<ThinkingStepKind, "tool">, LucideIcon> = {
+ brain: Brain,
+ computer: MonitorDot,
+ worker: Bot,
+ note: Info,
+};
+
+/**
+ * The small spinner shown on an active row. A plain ring instead of an
+ * animated SVG so it stays crisp at 14px; under reduced motion it stands
+ * still as a ring, which still reads as "open".
+ */
+function Spinner({ className }: { className?: string }) {
+ return (
+ <span
+ aria-hidden
+ data-testid="turn-step-spinner"
+ className={cn(
+ "inline-block rounded-full border-2 border-primary/25 border-t-primary motion-safe:animate-spin",
+ className,
+ )}
+ />
+ );
+}
+
+/** The tile at the left of a tool row: the brand SVG, or a two-letter monogram. */
+function BrandTile({
+ logoUrl,
+ monogram,
+ label,
+ compact,
+}: {
+ logoUrl?: string;
+ monogram: string;
+ label: string;
+ compact: boolean;
+}) {
+ const [failed, setFailed] = useState(false);
+ const showLogo = Boolean(logoUrl) && !failed;
+ return (
+ <span
+ data-testid="turn-step-brand"
+ data-brand-tier={showLogo ? "logo" : "monogram"}
+ title={label}
+ className={cn(
+ // Opaque page background first, so the tile masks the connector line
+ // behind it; the tint is a translucent plate on top of that.
+ "relative z-10 grid shrink-0 place-items-center overflow-hidden rounded-md bg-background",
+ compact ? "h-[18px] w-[18px]" : "h-5 w-5",
+ )}
+ >
+ <span
+ aria-hidden
+ className={cn(
+ "absolute inset-0 rounded-md border",
+ // A full-colour mark sits on a light plate (its own colours carry the
+ // brand); the monogram sits on the page's own secondary surface.
+ showLogo ? "border-sheen/10 bg-sheen/[0.07]" : "border-border/70 bg-secondary",
+ )}
+ />
+ {showLogo ? (
+ <img
+ src={logoUrl}
+ alt=""
+ className={cn("relative", compact ? "h-3 w-3" : "h-3.5 w-3.5")}
+ loading="lazy"
+ onError={() => setFailed(true)}
+ />
+ ) : (
+ <span className="relative font-mono text-[8px] font-semibold leading-none text-muted-foreground">
+ {monogram}
+ </span>
+ )}
+ </span>
+ );
+}
+
+/** The gutter mark of a non-tool row: spinner while active, the kind's icon otherwise. */
+function KindMark({ step, compact }: { step: ThinkingStep; compact: boolean }) {
+ const size = compact ? "h-3 w-3" : "h-3.5 w-3.5";
+ const box = cn(
+ "relative z-10 grid shrink-0 place-items-center bg-background",
+ compact ? "h-[18px] w-[18px]" : "h-5 w-5",
+ );
+ if (step.status === "active") {
+ return (
+ <span className={box}>
+ <Spinner className={size} />
+ </span>
+ );
+ }
+ if (step.status === "error") {
+ return (
+ <span className={box}>
+ <CircleAlert aria-hidden className={cn(size, "text-destructive")} />
+ </span>
+ );
+ }
+ const Icon = KIND_ICON[step.kind as Exclude<ThinkingStepKind, "tool">] ?? Info;
+ return (
+ <span className={box}>
+ <Icon aria-hidden className={cn(size, "text-muted-foreground/70")} />
+ </span>
+ );
+}
+
+function StepRow({ step, compact }: { step: ThinkingStep; compact: boolean }) {
+ const t = useT();
+ const isTool = step.kind === "tool";
+ const active = step.status === "active";
+ const error = step.status === "error";
+ const brand = isTool ? resolveToolBrand(step.detail ?? "") : null;
+
+ return (
+ <li
+ data-testid="turn-step"
+ data-kind={step.kind}
+ data-status={step.status}
+ className={cn(
+ "relative flex min-w-0 items-center",
+ compact ? "gap-2 py-[3px]" : "gap-2.5 py-1",
+ )}
+ >
+ {isTool && brand ? (
+ <BrandTile
+ logoUrl={brand.logoUrl}
+ monogram={brand.monogram}
+ label={brand.label}
+ compact={compact}
+ />
+ ) : (
+ <KindMark step={step} compact={compact} />
+ )}
+
+ <span
+ className={cn(
+ "min-w-0 flex-1 truncate leading-5",
+ compact ? "text-xs" : "text-[13px]",
+ error ? "text-destructive" : isTool ? "text-foreground/85" : "text-muted-foreground",
+ active && !isTool && "thinking-shimmer font-medium",
+ )}
+ >
+ {isTool && brand ? (
+ <>
+ {brand.label}
+ {step.detail && (
+ <span className="ml-2 font-mono text-[10px] text-muted-foreground/70">
+ {step.detail}
+ </span>
+ )}
+ </>
+ ) : (
+ <>
+ {t(step.labelKey)}
+ {step.detail && (
+ <span className="ml-1.5 font-normal text-muted-foreground/80">{step.detail}</span>
+ )}
+ </>
+ )}
+ </span>
+
+ {isTool && active && <Spinner className={compact ? "h-3 w-3" : "h-3.5 w-3.5"} />}
+ {error && (
+ <span className="shrink-0 text-[10px] uppercase tracking-[0.08em] text-destructive/80">
+ {t("turn_steps.failed")}
+ </span>
+ )}
+ {!active && step.durationMs !== undefined && step.durationMs > 0 && (
+ <span className="shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/60">
+ {formatStepDuration(step.durationMs)}
+ </span>
+ )}
+ </li>
+ );
+}
+
+export function TurnSteps({
+ steps,
+ live = false,
+ durationMs,
+ compact = false,
+ defaultOpen,
+ className,
+}: TurnStepsProps) {
+ const t = useT();
+ const listId = useId();
+ const [open, setOpen] = useState<boolean>(defaultOpen ?? live);
+
+ // A finished turn with nothing observed has nothing to say; a live one
+ // still shows its header so the person sees the assistant is working.
+ if (!live && steps.length === 0) return null;
+
+ const toolRows = steps.filter((s) => s.kind === "tool");
+ const visible = open ? steps : toolRows;
+ const headerText = live
+ ? t("thinking.label")
+ : thoughtFor(t("turn_steps.thought_for"), formatThoughtDuration(durationMs ?? 0));
+ const elapsed = live && durationMs !== undefined ? formatThoughtDuration(durationMs) : null;
+
+ return (
+ <div
+ data-testid="turn-steps"
+ data-live={live ? "true" : "false"}
+ data-open={open ? "true" : "false"}
+ className={cn("flex min-w-0 flex-col", className)}
+ role={live ? "status" : undefined}
+ aria-live={live ? "polite" : undefined}
+ >
+ <button
+ type="button"
+ onClick={() => setOpen((v) => !v)}
+ aria-expanded={open}
+ aria-controls={listId}
+ data-testid="turn-steps-toggle"
+ className={cn(
+ "group -ml-1 flex w-fit max-w-full items-center gap-1.5 rounded-md px-1 text-left text-muted-foreground transition-colors hover:text-foreground",
+ compact ? "py-0.5 text-xs" : "py-1 text-[13px]",
+ )}
+ >
+ {live ? (
+ <Spinner className={compact ? "h-3 w-3" : "h-3.5 w-3.5"} />
+ ) : (
+ <Clock aria-hidden className={cn("shrink-0", compact ? "h-3 w-3" : "h-3.5 w-3.5")} />
+ )}
+ <span className={cn("truncate", live && "thinking-shimmer font-medium")}>{headerText}</span>
+ {elapsed && (
+ <span className="shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground/70">
+ {elapsed}
+ </span>
+ )}
+ <ChevronRight
+ aria-hidden
+ className={cn(
+ "h-3 w-3 shrink-0 opacity-60 transition-transform duration-200 motion-reduce:transition-none group-hover:opacity-100",
+ open && "rotate-90",
+ )}
+ />
+ </button>
+
+ {visible.length > 0 && (
+ <ol
+ id={listId}
+ data-testid="turn-steps-list"
+ data-folded={open ? "false" : "true"}
+ className={cn("relative", compact ? "ml-0.5 mt-0.5" : "ml-0.5 mt-1")}
+ >
+ {/* The connector: one thin line behind the gutter marks, which mask
+ it with their own background so it reads as joining them. */}
+ <span
+ aria-hidden
+ className={cn(
+ "absolute bottom-2 top-2 w-px bg-border",
+ compact ? "left-[8.5px]" : "left-[9.5px]",
+ )}
+ />
+ {visible.map((s) => (
+ <StepRow key={s.id} step={s} compact={compact} />
+ ))}
+ </ol>
+ )}
+ </div>
+ );
+}
+
+/**
+ * "Thought for {duration}" — the locale decides the word order. Should a
+ * locale (or an un-hydrated test) hand back a template without the token,
+ * the duration is still appended so the number is never lost.
+ */
+function thoughtFor(template: string, duration: string): string {
+ return template.includes("{duration}")
+ ? fill(template, { duration })
+ : `${template} ${duration}`;
+}
diff --git a/jarvis/ui/web/frontend/src/components/home/VoiceStage.test.tsx b/jarvis/ui/web/frontend/src/components/home/VoiceStage.test.tsx
index db903474d8..d99d12f446 100644
--- a/jarvis/ui/web/frontend/src/components/home/VoiceStage.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/home/VoiceStage.test.tsx
@@ -1,12 +1,13 @@
import { describe, expect, it } from "vitest";
import { hintFor, recentLines, waveformPhase } from "@/components/home/VoiceStage";
+import { stateKey } from "@/components/home/JarvisBar";
import { greetingKey } from "@/components/home/Greeting";
-import { reduceTranscript, type TranscriptLine } from "@/lib/homeTranscript";
+import type { TranscriptTextLine } from "@/lib/homeTranscript";
const t = (key: string) => key;
-function line(who: TranscriptLine["who"], text: string, i: number): TranscriptLine {
+function line(who: TranscriptTextLine["who"], text: string, i: number): TranscriptTextLine {
return { id: `m${i}`, who, text, ts: i };
}
@@ -50,34 +51,11 @@ describe("VoiceStage helpers", () => {
});
});
-describe("homeTranscript reducer", () => {
- it("turns heard words and spoken answers into lines, joining the answer's pieces", () => {
- let lines: TranscriptLine[] = [];
- lines = reduceTranscript(lines, "TranscriptFinal", { transcript: { text: " what time is it " } }, 1000);
- // The final TranscriptionUpdate of the same utterance is not a second line.
- lines = reduceTranscript(lines, "TranscriptionUpdate", { text: "what time is it", is_final: true }, 1200);
- lines = reduceTranscript(lines, "TranscriptionUpdate", { text: "what time", is_final: false }, 1300);
- lines = reduceTranscript(lines, "SpeechSpoken", { text: "It is ten past nine." }, 2000);
- lines = reduceTranscript(lines, "SpeechSpoken", { text: "Shall I set a timer?" }, 3000);
- expect(lines.map((l) => [l.who, l.text])).toEqual([
- ["user", "what time is it"],
- ["assistant", "It is ten past nine. Shall I set a timer?"],
- ]);
- });
-
- it("takes typed turns from MessageSent and ignores everything else", () => {
- let lines: TranscriptLine[] = [];
- const same = lines;
- lines = reduceTranscript(lines, "BrainTurnCompleted", { tokens_in: 1 }, 1);
- expect(lines).toBe(same);
- lines = reduceTranscript(lines, "MessageSent", { role: "user", text: "hello" }, 10);
- lines = reduceTranscript(lines, "MessageSent", { role: "system", text: "note" }, 11);
- lines = reduceTranscript(lines, "MessageSent", { role: "assistant", text: "hi there" }, 12);
- // A reply that is also spoken is one line, not two.
- lines = reduceTranscript(lines, "SpeechSpoken", { text: "hi there" }, 13);
- expect(lines.map((l) => [l.who, l.text])).toEqual([
- ["user", "hello"],
- ["assistant", "hi there"],
- ]);
+describe("JarvisBar state word", () => {
+ it("says offline before anything else, connecting over a stale state", () => {
+ expect(stateKey("speaking", false, false)).toBe("offline");
+ expect(stateKey("idle", true, true)).toBe("connecting");
+ expect(stateKey("listening", false, true)).toBe("listening");
+ expect(stateKey("speaking", false, true)).toBe("speaking");
});
});
diff --git a/jarvis/ui/web/frontend/src/components/home/VoiceStage.tsx b/jarvis/ui/web/frontend/src/components/home/VoiceStage.tsx
index e2d5550481..06821217bf 100644
--- a/jarvis/ui/web/frontend/src/components/home/VoiceStage.tsx
+++ b/jarvis/ui/web/frontend/src/components/home/VoiceStage.tsx
@@ -3,18 +3,18 @@ import { useEffect, useMemo, useRef } from "react";
import { useEventStore, type VoiceState } from "@/store/events";
import { useHomeStore } from "@/store/home";
import type { TranscriptLine as TranscriptEntry } from "@/lib/homeTranscript";
-import { VoiceWaveform, type WaveformPhase } from "@/components/overlay/VoiceWaveform";
-import { voiceInputLevelRef } from "@/lib/voiceInputLevel";
+import type { WaveformPhase } from "@/components/overlay/VoiceWaveform";
import { useVoiceCall } from "@/components/agentic/useVoiceCall";
import { useVoiceReadiness } from "@/hooks/useVoiceReadiness";
-import { useVoiceEngineDisplay } from "@/hooks/useVoiceEngineDisplay";
import { useWakeWord } from "@/hooks/useWakeWord";
import { fill, useT } from "@/i18n";
import { cn } from "@/lib/utils";
import { Greeting } from "@/components/home/Greeting";
+import { JarvisBar } from "@/components/home/JarvisBar";
+import { TurnSteps } from "@/components/home/TurnSteps";
/** How many finished lines the lane keeps above the bar. */
-const TRANSCRIPT_LINES = 6;
+const TRANSCRIPT_LINES = 8;
/**
* The voice stage — what the front page opens on.
@@ -26,10 +26,13 @@ const TRANSCRIPT_LINES = 6;
* the IDE's voice bubble uses, so there is exactly one way voice begins.
*
* The transcript lane reads the home store's transcript (lib/homeTranscript:
- * heard words, spoken answers and typed turns merged into one list) plus the
- * live, not-yet-final transcription, so what you are saying appears while
- * you say it. Older lines scroll away; this is the live turn, not an archive
- * — the archive is one click away in the sidebar's recent chats.
+ * heard words, the turn's reasoning steps, spoken answers and typed turns
+ * merged into one list) plus the live, not-yet-final transcription, so what
+ * you are saying appears while you say it. A turn's steps render between
+ * your words and the answer — live while the turn runs, folded afterwards
+ * (components/home/TurnSteps). Older lines scroll away; this is the live
+ * turn, not an archive — the archive is one click away in the sidebar's
+ * recent chats.
*/
export function VoiceStage() {
const t = useT();
@@ -39,23 +42,22 @@ export function VoiceStage() {
const transcription = useEventStore((s) => s.transcription);
const transcriptionFinal = useEventStore((s) => s.transcriptionFinal);
const { connected, warming } = useVoiceReadiness();
- const engine = useVoiceEngineDisplay();
- const { active: callActive, busy: callBusy, connecting, toggleCall } = useVoiceCall();
+ const { connecting } = useVoiceCall();
const { config: wakeConfig } = useWakeWord();
const wakePhrase = wakeConfig?.phrase.trim() || "";
const lines = useMemo(() => recentLines(transcript, TRANSCRIPT_LINES), [transcript]);
const liveLine = transcription && !transcriptionFinal ? transcription : "";
+ // A live turn keeps the lane pinned to its end as steps arrive.
+ const liveSteps = lines.some((m) => m.who === "steps" && m.live);
const laneEnd = useRef<HTMLDivElement | null>(null);
useEffect(() => {
laneEnd.current?.scrollIntoView({ block: "end" });
- }, [lines.length, liveLine]);
+ }, [lines, liveLine, liveSteps]);
const phase = waveformPhase(voiceState, connected);
- const pressDisabled = callBusy || connecting || !connected;
const hint = hintFor({ connected, warming, connecting, voiceState, wakePhrase, t });
- const barLabel = callActive ? t("home.bar_stop") : t("home.bar_start");
return (
<div className="flex min-h-0 flex-1 flex-col items-center overflow-hidden" data-testid="voice-stage">
@@ -63,18 +65,30 @@ export function VoiceStage() {
<Greeting subtitle={t("home.voice_subtitle")} muted={lines.length > 0 || Boolean(liveLine)} />
<div
- className="flex max-h-[40vh] min-h-[96px] flex-col justify-end gap-3 overflow-y-auto px-1 scrollbar-jarvis"
+ className="flex max-h-[44vh] min-h-[96px] flex-col justify-end gap-3 overflow-y-auto px-1 scrollbar-jarvis"
data-testid="voice-transcript"
aria-live="polite"
>
- {lines.map((m) => (
- <TranscriptLine
- key={m.id}
- who={m.who === "user" ? t("home.transcript_you") : assistantName}
- text={m.text}
- user={m.who === "user"}
- />
- ))}
+ {lines.map((m) =>
+ m.who === "steps" ? (
+ <div key={m.id} className="pl-[80px]" data-testid="transcript-steps">
+ <TurnSteps
+ steps={m.steps}
+ live={m.live}
+ durationMs={m.durationMs}
+ compact
+ defaultOpen={m.live}
+ />
+ </div>
+ ) : (
+ <TranscriptLine
+ key={m.id}
+ who={m.who === "user" ? t("home.transcript_you") : assistantName}
+ text={m.text}
+ user={m.who === "user"}
+ />
+ ),
+ )}
{liveLine && (
<TranscriptLine who={t("home.transcript_you")} text={liveLine} user live />
)}
@@ -82,47 +96,7 @@ export function VoiceStage() {
</div>
<div className="flex flex-col items-center gap-3">
- <button
- type="button"
- onClick={() => void toggleCall()}
- disabled={pressDisabled}
- aria-label={barLabel}
- title={barLabel}
- data-testid="jarvis-bar"
- data-phase={phase}
- className={cn(
- "group relative flex h-16 w-full items-center gap-4 rounded-full border border-border bg-card pl-5 pr-3 text-left shadow-[0_1px_2px_rgb(var(--scrim-rgb)/0.06),0_12px_32px_rgb(var(--scrim-rgb)/0.08)] transition-[box-shadow,border-color]",
- "hover:border-primary/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
- "disabled:cursor-default disabled:opacity-80",
- callActive && "border-primary/50",
- )}
- >
- <span
- className={cn(
- "flex shrink-0 items-center gap-2 font-mono text-[10px] uppercase tracking-[0.16em]",
- callActive ? "text-primary" : "text-muted-foreground",
- )}
- >
- <span
- aria-hidden
- className={cn(
- "h-2 w-2 rounded-full",
- callActive ? "bg-primary animate-jarvis-pulse" : "bg-muted-foreground/40",
- )}
- />
- {t(`voice_state.${connecting ? "connecting" : voiceState}`)}
- </span>
- <VoiceWaveform
- levelRef={voiceInputLevelRef}
- phase={phase}
- count={32}
- frame={false}
- className="h-14 min-w-0 flex-1"
- />
- <span className="hidden shrink-0 items-center gap-1.5 rounded-full border border-border bg-secondary/60 px-2.5 py-1 font-mono text-[10px] uppercase tracking-[0.12em] text-muted-foreground sm:flex">
- {engine.providerLabel}
- </span>
- </button>
+ <JarvisBar phase={phase} />
<p
className="font-mono text-[11px] tracking-[0.04em] text-muted-foreground"
data-testid="voice-hint"
diff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
index 0d19547865..61aed88694 100644
--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
@@ -22,7 +22,6 @@ import { useMemo, useState } from "react";
import { useT } from "@/i18n";
import { BrowserRealtimeControl } from "@/components/voice/BrowserRealtimeControl";
import { SurfaceSwitch } from "@/components/home/SurfaceSwitch";
-import { RecentRuns } from "@/components/home/RecentRuns";
import { RecentChats } from "@/components/home/RecentChats";
import { useConversations } from "@/hooks/useConversations";
import { useHomeStore } from "@/store/home";
@@ -69,8 +68,10 @@ export interface SidebarProps {
onToggleCollapsed?: () => void;
}
-/** Width the sidebar was designed at, and the one a double-click restores. */
-export const SIDEBAR_DEFAULT_WIDTH = 280;
+/** Width the sidebar was designed at, and the one a double-click restores.
+ * 320 since 2026-08-23: the front page's controls live in this column now
+ * and the maintainer dragged it wider on first use — that is the default. */
+export const SIDEBAR_DEFAULT_WIDTH = 320;
/**
* Narrowest the sidebar goes: the nav icons, and nothing else.
@@ -329,7 +330,9 @@ export function Sidebar({
<DockRail className="min-h-0 flex-1" />
) : (
<nav className="flex-1 overflow-y-auto scrollbar-jarvis p-2">
- <RecentRuns />
+ {/* One list, not two: a voice session IS a run, and showing it as
+ "recent run" and "recent chat" read as a duplicate (maintainer,
+ 2026-08-23). The Run Inspector keeps the run view. */}
<RecentChats />
<div className="mx-1 mb-1 mt-2 border-t border-border/60" aria-hidden />
{NAV_GROUPS.map((group, groupIndex) => (
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 41967deab4..7c73b09887 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -452,19 +452,15 @@
"indicator_label": "Sprachstatus"
},
"sidebar": {
- "collapse": "Navigation einklappen",
"surface_voice": "Voice",
"surface_chat": "Chat",
"surface_hint": "Startseite zwischen Sprache und getipptem Chat umschalten",
"new_chat": "Neuer Chat",
- "recent_runs": "Letzte Runs",
"recent_chats": "Letzte Chats",
"show_all": "Alle anzeigen",
"show_less": "Weniger anzeigen",
- "no_runs": "Noch keine Runs",
"no_chats": "Noch keine Unterhaltungen",
- "run_meta": "{turns} Turns · {duration}",
- "run_live": "live",
+ "collapse": "Navigation einklappen",
"expand": "Navigation ausklappen",
"wake_hint": "Sag dein Wake-Word…",
"brain_label": "Brain",
@@ -506,7 +502,10 @@
"subscription_or_api": "Subscription-Login oder API-Key",
"local": "Lokal, kein Key nötig"
},
- "chats_view": {
+ "turn_steps": {
+ "thought_for": "{duration} nachgedacht",
+ "failed": "fehlgeschlagen"
+ },
"home": {
"greeting_morning": "Guten Morgen{name_part}",
"greeting_afternoon": "Guten Tag{name_part}",
@@ -525,6 +524,7 @@
"hint_error": "Voice hat ein Problem — tippe auf die Leiste, um es erneut zu versuchen",
"bar_start": "Tippen, um die Unterhaltung zu starten",
"bar_stop": "Tippen, um die Unterhaltung zu beenden",
+ "bar_end": "Beenden",
"chat_empty_title": "Wie kann ich helfen?",
"composer_hint": "Enter sendet · Shift+Enter für eine neue Zeile",
"model_hint": "Verwendetes Modell — zum Ändern klicken",
@@ -535,6 +535,7 @@
"background_wallpaper": "Hintergrundbild",
"background_hint": "Die App zeichnet standardmäßig auf einer einfarbigen Fläche. Wähle unten ein Bild, um es als Hintergrund zu nutzen; „Einfarbig“ bringt die schlichte Fläche zurück."
},
+ "chats_view": {
"title": "Chat",
"subtitle": "Rede mit deinem Assistenten oder schreibe — beides landet im selben Event-Bus.",
"thinking_aria": "Dein Assistent denkt nach",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 2c00c9556f..bf8940b912 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -452,19 +452,15 @@
"indicator_label": "Voice state"
},
"sidebar": {
- "collapse": "Collapse the navigation",
"surface_voice": "Voice",
"surface_chat": "Chat",
"surface_hint": "Switch the front page between voice and typed chat",
"new_chat": "New chat",
- "recent_runs": "Recent runs",
"recent_chats": "Recent chats",
"show_all": "Show all",
"show_less": "Show less",
- "no_runs": "No runs yet",
"no_chats": "No conversations yet",
- "run_meta": "{turns} turns · {duration}",
- "run_live": "live",
+ "collapse": "Collapse the navigation",
"expand": "Expand the navigation",
"wake_hint": "Say your wake word…",
"brain_label": "Brain",
@@ -506,7 +502,10 @@
"subscription_or_api": "Subscription login or API key",
"local": "Local, no key needed"
},
- "chats_view": {
+ "turn_steps": {
+ "thought_for": "Thought for {duration}",
+ "failed": "failed"
+ },
"home": {
"greeting_morning": "Good morning{name_part}",
"greeting_afternoon": "Good afternoon{name_part}",
@@ -525,6 +524,7 @@
"hint_error": "Voice ran into a problem — tap the bar to try again",
"bar_start": "Tap to start the conversation",
"bar_stop": "Tap to end the conversation",
+ "bar_end": "End",
"chat_empty_title": "How can I help?",
"composer_hint": "Enter to send · Shift+Enter for a new line",
"model_hint": "Model in use — click to change it",
@@ -535,6 +535,7 @@
"background_wallpaper": "Wallpaper",
"background_hint": "The app paints on a plain colour by default. Pick a picture below to use it as your wallpaper; “Solid colour” brings the plain ground back."
},
+ "chats_view": {
"title": "Chat",
"subtitle": "Talk to your assistant or type — both go through the same event bus.",
"thinking_aria": "Your assistant is thinking",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 99203de95b..d4c56e7798 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -452,19 +452,15 @@
"indicator_label": "Estado de voz"
},
"sidebar": {
- "collapse": "Contraer la navegación",
"surface_voice": "Voz",
"surface_chat": "Chat",
"surface_hint": "Cambiar la página de inicio entre voz y chat escrito",
"new_chat": "Nuevo chat",
- "recent_runs": "Últimas ejecuciones",
"recent_chats": "Chats recientes",
"show_all": "Mostrar todo",
"show_less": "Mostrar menos",
- "no_runs": "Aún no hay ejecuciones",
"no_chats": "Aún no hay conversaciones",
- "run_meta": "{turns} turnos · {duration}",
- "run_live": "en vivo",
+ "collapse": "Contraer la navegación",
"expand": "Expandir la navegación",
"wake_hint": "Di tu palabra de activación…",
"brain_label": "Cerebro",
@@ -506,7 +502,10 @@
"subscription_or_api": "Inicio de sesión con suscripción o clave API",
"local": "Local, no necesita clave"
},
- "chats_view": {
+ "turn_steps": {
+ "thought_for": "Pensó durante {duration}",
+ "failed": "falló"
+ },
"home": {
"greeting_morning": "Buenos días{name_part}",
"greeting_afternoon": "Buenas tardes{name_part}",
@@ -525,6 +524,7 @@
"hint_error": "La voz tuvo un problema — toca la barra para intentarlo de nuevo",
"bar_start": "Toca para iniciar la conversación",
"bar_stop": "Toca para terminar la conversación",
+ "bar_end": "Terminar",
"chat_empty_title": "¿En qué puedo ayudar?",
"composer_hint": "Enter envía · Shift+Enter para una nueva línea",
"model_hint": "Modelo en uso — haz clic para cambiarlo",
@@ -535,6 +535,7 @@
"background_wallpaper": "Fondo de pantalla",
"background_hint": "La app se dibuja sobre un color liso por defecto. Elige una imagen abajo para usarla de fondo; «Color sólido» devuelve la superficie lisa."
},
+ "chats_view": {
"title": "Chat",
"subtitle": "Habla con tu asistente o escribe — ambos pasan por el mismo bus de eventos.",
"thinking_aria": "Tu asistente está pensando",
diff --git a/jarvis/ui/web/frontend/src/lib/homeTranscript.test.ts b/jarvis/ui/web/frontend/src/lib/homeTranscript.test.ts
new file mode 100644
index 0000000000..10cd6b4713
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/homeTranscript.test.ts
@@ -0,0 +1,220 @@
+import { describe, expect, it } from "vitest";
+
+import {
+ LATE_ATTACH_MS,
+ STALE_TURN_MS,
+ reduceTranscript,
+ type TranscriptLine,
+ type TranscriptStepsLine,
+} from "@/lib/homeTranscript";
+import { MAX_THINKING_STEPS } from "@/lib/thinkingSteps";
+
+type Step = [name: string, payload: unknown, ts: number];
+
+function run(steps: Step[], start: TranscriptLine[] = []): TranscriptLine[] {
+ return steps.reduce((lines, [name, payload, ts]) => reduceTranscript(lines, name, payload, ts), start);
+}
+
+function shape(lines: TranscriptLine[]): unknown[] {
+ return lines.map((l) =>
+ l.who === "steps"
+ ? ["steps", l.steps.map((s) => `${s.kind}:${s.detail ?? ""}:${s.status}`), l.live ? "live" : "done"]
+ : [l.who, l.text],
+ );
+}
+
+function stepsLine(lines: TranscriptLine[]): TranscriptStepsLine {
+ const found = lines.find((l): l is TranscriptStepsLine => l.who === "steps");
+ if (!found) throw new Error("no steps line");
+ return found;
+}
+
+describe("homeTranscript reducer — text", () => {
+ it("turns heard words and spoken answers into lines, joining the answer's pieces", () => {
+ const lines = run([
+ ["TranscriptFinal", { transcript: { text: " what time is it " } }, 1000],
+ // The final TranscriptionUpdate of the same utterance is not a second line.
+ ["TranscriptionUpdate", { text: "what time is it", is_final: true }, 1200],
+ ["TranscriptionUpdate", { text: "what time", is_final: false }, 1300],
+ ["SpeechSpoken", { text: "It is ten past nine." }, 2000],
+ ["SpeechSpoken", { text: "Shall I set a timer?" }, 3000],
+ ]);
+ expect(shape(lines)).toEqual([
+ ["user", "what time is it"],
+ ["assistant", "It is ten past nine. Shall I set a timer?"],
+ ]);
+ });
+
+ it("takes typed turns from MessageSent and ignores everything else", () => {
+ let lines: TranscriptLine[] = [];
+ const same = lines;
+ lines = reduceTranscript(lines, "BrainTurnCompleted", { tokens_in: 1 }, 1);
+ expect(lines).toBe(same);
+ lines = reduceTranscript(lines, "SystemStateChanged", { new_state: "LISTENING" }, 2);
+ expect(lines).toBe(same);
+ lines = run(
+ [
+ ["MessageSent", { role: "user", text: "hello" }, 10],
+ ["MessageSent", { role: "system", text: "note" }, 11],
+ ["MessageSent", { role: "assistant", text: "hi there" }, 12],
+ // A reply that is also spoken is one line, not two.
+ ["SpeechSpoken", { text: "hi there" }, 13],
+ ],
+ lines,
+ );
+ expect(shape(lines)).toEqual([
+ ["user", "hello"],
+ ["assistant", "hi there"],
+ ]);
+ });
+});
+
+describe("homeTranscript reducer — steps per turn", () => {
+ it("collects a tool call into the turn between the words and the answer", () => {
+ const lines = run([
+ ["TranscriptFinal", { transcript: { text: "search my mail for the invoice" } }, 1000],
+ ["BrainTurnStarted", { provider: "openai", model: "gpt-5" }, 1400],
+ ["ActionProposed", { tool_name: "gmail_search", tier: "safe" }, 1500],
+ ["ActionExecuted", { tool_name: "gmail_search", success: true, duration_ms: 820 }, 2320],
+ ["SpeechSpoken", { text: "Found it — sent on Tuesday.", spoken_kind: "reply" }, 3000],
+ ["BrainTurnCompleted", { provider: "openai", model: "gpt-5" }, 3100],
+ ]);
+ expect(shape(lines)).toEqual([
+ ["user", "search my mail for the invoice"],
+ ["steps", ["brain:openai · gpt-5:done", "tool:gmail_search:done"], "done"],
+ ["assistant", "Found it — sent on Tuesday."],
+ ]);
+ const turn = stepsLine(lines);
+ // The reply closed the turn; the brain's late Completed attached quietly.
+ expect(turn.live).toBe(false);
+ // Thinking time runs from the user's words, not from the first step.
+ expect(turn.startedTs).toBe(1000);
+ expect(turn.durationMs).toBe(2000);
+ expect(turn.steps[1].durationMs).toBe(820);
+ });
+
+ it("is live while the turn runs and shows the active tool", () => {
+ const open = run([
+ ["TranscriptFinal", { transcript: { text: "open the calendar" } }, 1000],
+ ["ActionProposed", { tool_name: "computer_use" }, 1500],
+ ]);
+ const turn = stepsLine(open);
+ expect(turn.live).toBe(true);
+ expect(turn.durationMs).toBeUndefined();
+ expect(turn.steps.map((s) => s.status)).toEqual(["active"]);
+ });
+
+ it("handles the classic pipeline order: tools first, brain events together, then speech", () => {
+ const lines = run([
+ ["TranscriptFinal", { transcript: { text: "what is on my calendar" } }, 1000],
+ ["ActionProposed", { tool_name: "calendar_list" }, 1600],
+ ["ActionExecuted", { tool_name: "calendar_list", success: true }, 2100],
+ // The pipeline publishes both only after the brain call succeeded.
+ ["BrainTurnStarted", { provider: "anthropic", model: "claude" }, 4000],
+ ["BrainTurnCompleted", { provider: "anthropic", model: "claude" }, 4001],
+ ["SpeechSpoken", { text: "Two meetings.", spoken_kind: "reply" }, 4500],
+ ]);
+ expect(shape(lines)).toEqual([
+ ["user", "what is on my calendar"],
+ ["steps", ["tool:calendar_list:done", "brain:anthropic · claude:done"], "done"],
+ ["assistant", "Two meetings."],
+ ]);
+ const turn = stepsLine(lines);
+ // The brain step is backdated to the tool's end, not a 1 ms blip.
+ expect(turn.steps[1].startedTs).toBe(2100);
+ expect(turn.steps[1].durationMs).toBe(1901);
+ expect(turn.durationMs).toBe(3001);
+ });
+
+ it("keeps a tool-only turn that never speaks", () => {
+ const lines = run([
+ ["TranscriptFinal", { transcript: { text: "mute the music" } }, 1000],
+ ["ActionProposed", { tool_name: "media_control" }, 1300],
+ ["ActionExecuted", { tool_name: "media_control", success: true }, 1400],
+ ["BrainTurnStarted", { provider: "x", model: "y" }, 1500],
+ ["BrainTurnCompleted", { provider: "x", model: "y" }, 1500],
+ // The floor comes back without a word being said.
+ ["SystemStateChanged", { new_state: "LISTENING", previous: "THINKING" }, 1600],
+ ]);
+ expect(shape(lines)).toEqual([
+ ["user", "mute the music"],
+ ["steps", ["tool:media_control:done", "brain:x · y:done"], "done"],
+ ]);
+ expect(stepsLine(lines).live).toBe(false);
+ });
+
+ it("lets a preamble be spoken mid-turn without closing it, and a late step join", () => {
+ const lines = run([
+ ["TranscriptFinal", { transcript: { text: "book the table" } }, 1000],
+ ["ActionProposed", { tool_name: "browser" }, 1200],
+ ["SpeechSpoken", { text: "One moment.", spoken_kind: "preamble" }, 1300],
+ ["ActionExecuted", { tool_name: "browser", success: true }, 5000],
+ ["BrainTurnCompleted", {}, 5100],
+ ["SpeechSpoken", { text: "Done, eight o'clock.", spoken_kind: "reply" }, 5500],
+ // A trailing tool report still lands on the same turn (the turn's last
+ // event was the brain completing at 5100).
+ ["ActionExecuted", { tool_name: "notify", success: false }, 5100 + LATE_ATTACH_MS - 1],
+ ]);
+ expect(shape(lines)).toEqual([
+ ["user", "book the table"],
+ ["steps", ["tool:browser:done", "tool:notify:error"], "done"],
+ ["assistant", "One moment."],
+ ["assistant", "Done, eight o'clock."],
+ ]);
+ });
+
+ it("opens a fresh turn for steps long after the last one and closes a stale turn", () => {
+ const lines = run([
+ ["TranscriptFinal", { transcript: { text: "start the report" } }, 1000],
+ ["JarvisAgentTaskStarted", { utterance: "start the report" }, 1500],
+ // Nothing for a long time — the worker never reported back.
+ ["ActionExecuted", { tool_name: "notify", success: true }, 1500 + STALE_TURN_MS + 1],
+ ]);
+ expect(shape(lines)).toEqual([
+ ["user", "start the report"],
+ ["steps", ["worker:start the report:done"], "done"],
+ ["steps", ["tool:notify:done"], "done"],
+ ]);
+ const [first, second] = lines.filter((l): l is TranscriptStepsLine => l.who === "steps");
+ // Closed when it went quiet, not two minutes later.
+ expect(first.durationMs).toBe(500);
+ expect(second.startedTs).toBe(1500 + STALE_TURN_MS + 1);
+ });
+
+ it("closes the open turn when the user speaks again", () => {
+ const lines = run([
+ ["TranscriptFinal", { transcript: { text: "first" } }, 1000],
+ ["ActionProposed", { tool_name: "slow_tool" }, 1200],
+ ["TranscriptFinal", { transcript: { text: "never mind" } }, 3000],
+ ]);
+ expect(shape(lines)).toEqual([
+ ["user", "first"],
+ ["steps", ["tool:slow_tool:done"], "done"],
+ ["user", "never mind"],
+ ]);
+ });
+
+ it("returns the same array for events that change nothing", () => {
+ const lines = run([
+ ["TranscriptFinal", { transcript: { text: "hi" } }, 1000],
+ ["ActionProposed", { tool_name: "t" }, 1100],
+ ]);
+ expect(reduceTranscript(lines, "AudioLevel", { input: 0.2 }, 1200)).toBe(lines);
+ // Completing a worker that never started touches nothing.
+ expect(reduceTranscript(lines, "JarvisAgentTaskCompleted", { success: true }, 1200)).toBe(lines);
+ // A realtime BrainTurnCompleted with no brain step still ends the turn.
+ const closed = reduceTranscript(lines, "BrainTurnCompleted", { finish_reason: "realtime_usage" }, 1300);
+ expect(closed).not.toBe(lines);
+ expect(stepsLine(closed).live).toBe(false);
+ expect(stepsLine(closed).steps[0].status).toBe("done");
+ });
+
+ it("caps the steps of one turn", () => {
+ const events: Step[] = [["TranscriptFinal", { transcript: { text: "many" } }, 1000]];
+ for (let i = 0; i < MAX_THINKING_STEPS + 10; i++) {
+ events.push(["ActionExecuted", { tool_name: `tool_${i}`, success: true }, 1100 + i]);
+ }
+ const lines = run(events);
+ expect(stepsLine(lines).steps.length).toBe(MAX_THINKING_STEPS);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/lib/homeTranscript.ts b/jarvis/ui/web/frontend/src/lib/homeTranscript.ts
index 784839ff41..51844ee8a8 100644
--- a/jarvis/ui/web/frontend/src/lib/homeTranscript.ts
+++ b/jarvis/ui/web/frontend/src/lib/homeTranscript.ts
@@ -1,6 +1,6 @@
/**
- * The live transcript the voice stage shows: what was said to the assistant
- * and what it answered, as lines, newest last.
+ * The live transcript the voice stage shows: what was said to the assistant,
+ * what it did on the way, and what it answered — as lines, newest last.
*
* Why its own reducer and not `messages`: a SPOKEN turn does not travel as
* `MessageSent`. The pipeline publishes the heard words as `TranscriptFinal`
@@ -9,25 +9,117 @@
* usually in sentence-sized pieces. Typed turns DO come as `MessageSent`.
* The lane merges the two so it reads the same whether you spoke or typed.
*
+ * Steps (2026-08-23): the event store collects reasoning steps only for TYPED
+ * turns (`chatThinking`), so a spoken "search my mail" showed the answer and
+ * nothing of the tool call that produced it. Here every turn carries its own
+ * steps as a third line kind, `who: "steps"`, sitting between the user's
+ * words and the answer. The step model itself is `lib/thinkingSteps.ts` —
+ * the same reducer the chat uses, so both stages read the same events the
+ * same way; this module only decides WHICH turn an event belongs to and when
+ * a turn is over.
+ *
+ * Turn boundaries, in order of evidence:
+ * - open on `BrainTurnStarted` or on the first tool / worker / computer-use
+ * event (the classic pipeline publishes BrainTurnStarted+Completed
+ * together AFTER the tools ran, so a tool event is often the first sign);
+ * - close on `BrainTurnCompleted`, `VoiceTurnCompleted`, a turn-ending
+ * `SpeechSpoken` (a reply, not a preamble or progress nudge), the next
+ * user utterance, the session going idle or back to listening after
+ * speech, or staleness — a turn with no event for STALE_TURN_MS is over
+ * whatever the backend forgot to say.
+ * Steps that arrive shortly after a close (a late ActionExecuted, the
+ * pipeline's BrainTurnStarted after its tools) still join that turn.
+ *
* Pure: (lines, event) → lines, and the same array back for every event it
* does not read, so the store can skip the update.
*/
-export type TranscriptWho = "user" | "assistant";
+import {
+ finalizeThinkingSteps,
+ reduceThinkingSteps,
+ type ThinkingStep,
+} from "@/lib/thinkingSteps";
+
+export type TranscriptWho = "user" | "assistant" | "steps";
-export interface TranscriptLine {
+interface TranscriptLineBase {
id: string;
ts: number;
who: TranscriptWho;
text: string;
}
+/** Heard words (user) or a spoken / typed answer (assistant). */
+export interface TranscriptTextLine extends TranscriptLineBase {
+ who: "user" | "assistant";
+ /**
+ * The spoken kind (`SpeechSpoken.spoken_kind`) when the line was said out
+ * loud — "reply", "preamble", … Pieces of one answer join only when their
+ * kinds agree, so a "One moment" preamble never melts into the reply that
+ * follows the tool call.
+ */
+ kind?: string;
+}
+
+/** The reasoning steps of one turn — tools, workers, the brain call. */
+export interface TranscriptStepsLine extends TranscriptLineBase {
+ who: "steps";
+ /** Always empty; kept so every line has the same shape. */
+ text: "";
+ steps: ThinkingStep[];
+ /** The turn is still running — steps may still arrive. */
+ live: boolean;
+ /** When the turn began (the user's words, or the first step). */
+ startedTs: number;
+ /** Last event that touched this turn; drives the late-attach window. */
+ lastTs: number;
+ /** Thinking time once the turn is closed. */
+ durationMs?: number;
+}
+
+export type TranscriptLine = TranscriptTextLine | TranscriptStepsLine;
+
/** How many lines are kept. The lane shows the tail; this bounds memory. */
export const TRANSCRIPT_MAX = 40;
/** Consecutive spoken pieces of one answer are joined when this close. */
const JOIN_WITHIN_MS = 6_000;
/** A repeat of the same words within this window is the same utterance. */
const DUPLICATE_WITHIN_MS = 12_000;
+/**
+ * A step event arriving this soon after a turn closed still belongs to it.
+ * The classic pipeline publishes BrainTurnStarted+Completed back to back
+ * AFTER its tools, and a late ActionExecuted can trail the reply by a
+ * moment; anything later than this is a new (tool-only) turn.
+ */
+export const LATE_ATTACH_MS = 15_000;
+/**
+ * A turn that saw no event for this long is closed the next time anything
+ * arrives. Generous on purpose — the brain timeout is 60 s in the composer
+ * and a desktop action can run longer — but finite, so a turn whose closing
+ * event never came does not spin forever.
+ */
+export const STALE_TURN_MS = 120_000;
+/**
+ * The user's words are the honest start of a turn: the brain starts working
+ * the moment they end. Only when they were said this recently, though —
+ * a tool-only turn minutes later is not a reaction to them.
+ */
+const USER_TURN_WITHIN_MS = 60_000;
+
+/**
+ * Spoken kinds that happen INSIDE a turn and must not close it. Everything
+ * else (reply, clarify, timeout, unavailable, action_done, …) is the
+ * assistant's last word on the matter. Mirrors SPOKEN_KIND_* in
+ * jarvis/sessions/constants.py.
+ */
+const MID_TURN_SPOKEN_KINDS: ReadonlySet<string> = new Set([
+ "preamble",
+ "progress",
+ "backchannel",
+ "announcement",
+ "completion",
+ "subagent",
+]);
let counter = 0;
function nextId(ts: number): string {
@@ -39,7 +131,16 @@ function clean(text: unknown): string {
return typeof text === "string" ? text.replace(/\s+/g, " ").trim() : "";
}
-function isDuplicate(lines: TranscriptLine[], who: TranscriptWho, text: string, ts: number): boolean {
+function str(v: unknown): string {
+ return typeof v === "string" ? v : "";
+}
+
+function isDuplicate(
+ lines: TranscriptLine[],
+ who: "user" | "assistant",
+ text: string,
+ ts: number,
+): boolean {
for (let i = lines.length - 1; i >= 0; i--) {
const line = lines[i];
if (ts - line.ts > DUPLICATE_WITHIN_MS) return false;
@@ -48,9 +149,181 @@ function isDuplicate(lines: TranscriptLine[], who: TranscriptWho, text: string,
return false;
}
-function push(lines: TranscriptLine[], who: TranscriptWho, text: string, ts: number): TranscriptLine[] {
- const next = [...lines, { id: nextId(ts), ts, who, text }];
- return next.length > TRANSCRIPT_MAX ? next.slice(next.length - TRANSCRIPT_MAX) : next;
+function cap(lines: TranscriptLine[]): TranscriptLine[] {
+ return lines.length > TRANSCRIPT_MAX ? lines.slice(lines.length - TRANSCRIPT_MAX) : lines;
+}
+
+function push(
+ lines: TranscriptLine[],
+ who: "user" | "assistant",
+ text: string,
+ ts: number,
+ kind?: string,
+): TranscriptLine[] {
+ const line: TranscriptTextLine = { id: nextId(ts), ts, who, text };
+ if (kind) line.kind = kind;
+ return cap([...lines, line]);
+}
+
+/** Index of the last steps line, or -1. */
+function lastStepsIndex(lines: TranscriptLine[]): number {
+ for (let i = lines.length - 1; i >= 0; i--) {
+ if (lines[i].who === "steps") return i;
+ }
+ return -1;
+}
+
+/** True when no user line sits after index `i` — the turn is still current. */
+function isCurrentTurn(lines: TranscriptLine[], i: number): boolean {
+ for (let j = i + 1; j < lines.length; j++) {
+ if (lines[j].who === "user") return false;
+ }
+ return true;
+}
+
+function replaceAt(lines: TranscriptLine[], i: number, line: TranscriptLine): TranscriptLine[] {
+ const next = [...lines];
+ next[i] = line;
+ return next;
+}
+
+function closeTurn(line: TranscriptStepsLine, tsMs: number): TranscriptStepsLine {
+ return {
+ ...line,
+ live: false,
+ steps: finalizeThinkingSteps(line.steps, tsMs),
+ lastTs: Math.max(line.lastTs, tsMs),
+ durationMs: Math.max(0, tsMs - line.startedTs),
+ };
+}
+
+/** Close the open turn, if any. Same array back when there is none. */
+function closeOpenTurn(lines: TranscriptLine[], tsMs: number): TranscriptLine[] {
+ const i = lastStepsIndex(lines);
+ if (i === -1) return lines;
+ const line = lines[i] as TranscriptStepsLine;
+ if (!line.live) return lines;
+ return replaceAt(lines, i, closeTurn(line, tsMs));
+}
+
+/**
+ * Close a turn nobody closed: the open turn is older than STALE_TURN_MS.
+ * Cheap — one look at the last steps line — so it runs on every event.
+ */
+function closeStaleTurn(lines: TranscriptLine[], tsMs: number): TranscriptLine[] {
+ const i = lastStepsIndex(lines);
+ if (i === -1) return lines;
+ const line = lines[i] as TranscriptStepsLine;
+ if (!line.live || tsMs - line.lastTs < STALE_TURN_MS) return lines;
+ // Closed at the moment it went quiet, not now: the duration must not
+ // count the two minutes nobody was working.
+ return replaceAt(lines, i, closeTurn(line, line.lastTs));
+}
+
+/**
+ * Where a step event goes: the open turn, or — within the late-attach
+ * window and before any newer user utterance — the turn that just closed.
+ */
+function stepsTarget(lines: TranscriptLine[], tsMs: number): number {
+ const i = lastStepsIndex(lines);
+ if (i === -1) return -1;
+ const line = lines[i] as TranscriptStepsLine;
+ if (line.live) return i;
+ if (isCurrentTurn(lines, i) && tsMs - line.lastTs <= LATE_ATTACH_MS) return i;
+ return -1;
+}
+
+/** The start of a fresh turn: the user's recent words, else right now. */
+function turnStart(lines: TranscriptLine[], tsMs: number): number {
+ const last = lines[lines.length - 1];
+ if (last && last.who === "user" && tsMs - last.ts <= USER_TURN_WITHIN_MS) return last.ts;
+ return tsMs;
+}
+
+/**
+ * The classic pipeline publishes BrainTurnStarted only once the brain call
+ * has SUCCEEDED, immediately followed by BrainTurnCompleted — so the brain
+ * step would always read "0 ms". Backdate it to the last thing we know the
+ * turn was doing (the previous step, or the user's words): that span is the
+ * time the brain was demonstrably busy. A realtime BrainTurnStarted arriving
+ * mid-turn gets the same treatment, which is equally honest there.
+ */
+function backdateBrainStep(
+ steps: ThinkingStep[],
+ previous: ThinkingStep[],
+ sinceTs: number,
+): ThinkingStep[] {
+ const last = steps[steps.length - 1];
+ if (!last || last.kind !== "brain" || last.status !== "active") return steps;
+ if (previous.length && previous[previous.length - 1] === last) return steps;
+ if (last.startedTs <= sinceTs) return steps;
+ const next = [...steps];
+ next[next.length - 1] = { ...last, startedTs: sinceTs };
+ return next;
+}
+
+function reduceSteps(
+ lines: TranscriptLine[],
+ name: string,
+ payload: unknown,
+ tsMs: number,
+): TranscriptLine[] {
+ const target = stepsTarget(lines, tsMs);
+ if (target !== -1) {
+ const line = lines[target] as TranscriptStepsLine;
+ const reduced = reduceThinkingSteps(line.steps, name, payload, tsMs);
+ if (!reduced) {
+ // The event meant nothing to the steps — but a completion still ends
+ // the turn (a realtime turn has no BrainTurnStarted, so its
+ // BrainTurnCompleted finds no brain step to complete).
+ if (name === "BrainTurnCompleted" && line.live) {
+ return replaceAt(lines, target, closeTurn(line, tsMs));
+ }
+ return lines;
+ }
+ const sinceTs = line.steps.length
+ ? Math.max(line.startedTs, line.lastTs)
+ : line.startedTs;
+ const steps =
+ name === "BrainTurnStarted" ? backdateBrainStep(reduced, line.steps, sinceTs) : reduced;
+ // A late ACTIVE step (a tool starting after the reply) reopens the turn;
+ // the next closing event ends it again. A late finished step is just
+ // one more row on a closed turn.
+ const reopened = !line.live && steps.some((s) => s.status === "active");
+ const updated: TranscriptStepsLine = {
+ ...line,
+ steps,
+ lastTs: tsMs,
+ live: line.live || reopened,
+ };
+ if (name === "BrainTurnCompleted") {
+ return replaceAt(lines, target, closeTurn(updated, tsMs));
+ }
+ // No duration while it runs again — the old one would lie.
+ if (reopened) delete updated.durationMs;
+ return replaceAt(lines, target, updated);
+ }
+
+ // No turn to join: does this event open one?
+ const opened = reduceThinkingSteps([], name, payload, tsMs);
+ if (!opened || !opened.length) return lines;
+ const startedTs = turnStart(lines, tsMs);
+ const steps =
+ name === "BrainTurnStarted" ? backdateBrainStep(opened, [], startedTs) : opened;
+ const line: TranscriptStepsLine = {
+ id: nextId(tsMs),
+ ts: tsMs,
+ who: "steps",
+ text: "",
+ steps,
+ // A turn born from an already-finished step (ActionExecuted with no
+ // Proposed before it) is not running — it is a record.
+ live: steps.some((s) => s.status === "active"),
+ startedTs,
+ lastTs: tsMs,
+ };
+ if (!line.live) line.durationMs = Math.max(0, tsMs - startedTs);
+ return cap([...lines, line]);
}
export function reduceTranscript(
@@ -60,40 +333,64 @@ export function reduceTranscript(
tsMs: number,
): TranscriptLine[] {
const p = (payload ?? {}) as Record<string, unknown>;
+ lines = closeStaleTurn(lines, tsMs);
switch (name) {
case "TranscriptFinal": {
const transcript = (p.transcript ?? {}) as Record<string, unknown>;
const text = clean(transcript.text);
if (!text || isDuplicate(lines, "user", text, tsMs)) return lines;
- return push(lines, "user", text, tsMs);
+ return push(closeOpenTurn(lines, tsMs), "user", text, tsMs);
}
case "TranscriptionUpdate": {
if (p.is_final !== true) return lines;
const text = clean(p.text);
if (!text || isDuplicate(lines, "user", text, tsMs)) return lines;
- return push(lines, "user", text, tsMs);
+ return push(closeOpenTurn(lines, tsMs), "user", text, tsMs);
}
case "SpeechSpoken": {
const text = clean(p.text);
if (!text || isDuplicate(lines, "assistant", text, tsMs)) return lines;
- const last = lines[lines.length - 1];
- if (last && last.who === "assistant" && tsMs - last.ts < JOIN_WITHIN_MS) {
+ // The assistant's last word closes the turn; a preamble or a progress
+ // nudge is said WHILE the turn runs and leaves it open.
+ const kind = str(p.spoken_kind);
+ const base = MID_TURN_SPOKEN_KINDS.has(kind) ? lines : closeOpenTurn(lines, tsMs);
+ const last = base[base.length - 1];
+ if (
+ last &&
+ last.who === "assistant" &&
+ tsMs - last.ts < JOIN_WITHIN_MS &&
+ (!last.kind || !kind || last.kind === kind)
+ ) {
// One answer, said in pieces: grow the line instead of stacking pieces.
- const joined = [...lines];
- joined[joined.length - 1] = { ...last, ts: tsMs, text: `${last.text} ${text}` };
- return joined;
+ return replaceAt(base, base.length - 1, {
+ ...last,
+ ts: tsMs,
+ text: `${last.text} ${text}`,
+ });
}
- return push(lines, "assistant", text, tsMs);
+ return push(base, "assistant", text, tsMs, kind);
}
case "MessageSent": {
const role = p.role;
if (role !== "user" && role !== "assistant") return lines;
const text = clean(p.text);
if (!text || isDuplicate(lines, role, text, tsMs)) return lines;
- return push(lines, role, text, tsMs);
+ return push(role === "user" ? closeOpenTurn(lines, tsMs) : lines, role, text, tsMs);
}
- default:
+ case "VoiceTurnCompleted":
+ return closeOpenTurn(lines, tsMs);
+ case "SystemStateChanged": {
+ // The session went idle, or the floor came back to the user after the
+ // assistant spoke: whatever the turn was doing, it is over.
+ const next = str(p.new_state).toLowerCase();
+ const previous = str(p.previous).toLowerCase();
+ if (next === "idle" || (next === "listening" && previous === "speaking")) {
+ return closeOpenTurn(lines, tsMs);
+ }
return lines;
+ }
+ default:
+ return reduceSteps(lines, name, payload, tsMs);
}
}
diff --git a/jarvis/ui/web/frontend/src/lib/toolBrand.test.ts b/jarvis/ui/web/frontend/src/lib/toolBrand.test.ts
new file mode 100644
index 0000000000..52501caf90
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/toolBrand.test.ts
@@ -0,0 +1,68 @@
+import { describe, expect, it } from "vitest";
+
+import { monogramFor, resolveToolBrand, tokenizeToolName } from "@/lib/toolBrand";
+
+describe("resolveToolBrand", () => {
+ it("maps a prefixed tool name to the brand and humanises the action", () => {
+ const b = resolveToolBrand("gmail_search");
+ expect(b.brandId).toBe("gmail");
+ expect(b.label).toBe("Gmail · search");
+ // Vite inlines small SVGs as data URLs, so only "some svg" is stable.
+ expect(b.logoUrl).toMatch(/svg/);
+ expect(b.monogram).toBe("GM");
+ });
+
+ it("normalises dashes and drops the wrapper word", () => {
+ const b = resolveToolBrand("plugin-gmail");
+ expect(b.brandId).toBe("gmail");
+ expect(b.label).toBe("Gmail");
+ });
+
+ it("prefers the most specific brand (google_calendar over anything shorter)", () => {
+ const b = resolveToolBrand("google_calendar_list");
+ expect(b.brandId).toBe("google_calendar");
+ expect(b.label).toBe("Google Calendar · list");
+ expect(b.logoUrl).toMatch(/svg/);
+ expect(b.monogram).toBe("GC");
+ });
+
+ it("matches whole tokens only, never substrings", () => {
+ expect(resolveToolBrand("linear_issues").brandId).toBe("linear");
+ expect(resolveToolBrand("nonlinear_solver").brandId).toBeUndefined();
+ });
+
+ it("uses the display name for brands whose file stem reads wrong", () => {
+ expect(resolveToolBrand("github_issues").label).toBe("GitHub · issues");
+ expect(resolveToolBrand("cal_com_bookings").label).toBe("Cal.com · bookings");
+ expect(resolveToolBrand("home_assistant_toggle").label).toBe("Home Assistant · toggle");
+ });
+
+ it("falls back to a humanised label and a monogram for unknown tools", () => {
+ const shell = resolveToolBrand("run_shell");
+ expect(shell.brandId).toBeUndefined();
+ expect(shell.logoUrl).toBeUndefined();
+ expect(shell.label).toBe("run shell");
+ expect(shell.monogram).toBe("RS");
+
+ const nav = resolveToolBrand("navigate");
+ expect(nav.label).toBe("navigate");
+ expect(nav.monogram).toBe("NA");
+ });
+
+ it("survives an empty name", () => {
+ expect(resolveToolBrand("").label).toBe("?");
+ expect(resolveToolBrand("").monogram).toBe("??");
+ });
+});
+
+describe("helpers", () => {
+ it("tokenizes on any non-alphanumeric run, lower-cased", () => {
+ expect(tokenizeToolName("Plugin-Gmail.Search v2")).toEqual(["plugin", "gmail", "search", "v2"]);
+ });
+
+ it("builds two-letter monograms from initials or the first two letters", () => {
+ expect(monogramFor("Google Drive")).toBe("GD");
+ expect(monogramFor("Notion")).toBe("NO");
+ expect(monogramFor("Gmail · search")).toBe("GS");
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/lib/toolBrand.ts b/jarvis/ui/web/frontend/src/lib/toolBrand.ts
new file mode 100644
index 0000000000..18d3961606
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/toolBrand.ts
@@ -0,0 +1,144 @@
+/**
+ * Tool name → brand mark, for the reasoning steps of a turn.
+ *
+ * A tool step only knows the tool's registry name ("gmail_search",
+ * "plugin-gmail", "google_calendar_list", "run_shell"). The turn view wants
+ * what the Claude app shows for a tool call: the service's mark in a small
+ * tile and a readable label. This module is the pure mapping — no React, no
+ * store — so the rule ("which brand does this tool belong to?") is unit-
+ * testable on its own and identical wherever a tool name is rendered.
+ *
+ * The brand set is derived from the SVGs bundled under `src/assets/brands`
+ * (the same files the Plugins store and UltraWiki use), so adding a mark
+ * there lights it up here too — nothing to register. Matching is on
+ * underscore-separated TOKENS, never raw substrings: "linear_issues" is
+ * Linear, "nonlinear_solver" is not. Multi-token brands ("google_calendar",
+ * "cal_com") are tried before single-token ones so the most specific brand
+ * wins.
+ */
+
+const BUNDLED_BRAND_LOGOS = import.meta.glob("../assets/brands/*.svg", {
+ eager: true,
+ query: "?url",
+ import: "default",
+}) as Record<string, string>;
+
+/** Display names where the file id's auto-humanised form would be wrong. */
+const BRAND_DISPLAY_NAMES: Record<string, string> = {
+ cal_com: "Cal.com",
+ clickup: "ClickUp",
+ github: "GitHub",
+ gmail: "Gmail",
+ google_calendar: "Google Calendar",
+ google_drive: "Google Drive",
+ home_assistant: "Home Assistant",
+ youtube_music: "YouTube Music",
+};
+
+/** Tokens that name a wrapper, not an action — dropped from the label. */
+const NOISE_TOKENS = new Set(["plugin", "tool", "mcp"]);
+
+interface Brand {
+ id: string;
+ tokens: string[];
+ label: string;
+ logoUrl: string;
+}
+
+function humanise(tokens: string[]): string {
+ return tokens
+ .filter(Boolean)
+ .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
+ .join(" ");
+}
+
+/** Every bundled brand, most specific (most tokens, then longest) first. */
+const BRANDS: Brand[] = Object.entries(BUNDLED_BRAND_LOGOS)
+ .map(([path, logoUrl]) => {
+ const id = path.replace(/^.*\//, "").replace(/\.svg$/, "");
+ const tokens = id.split("_");
+ return {
+ id,
+ tokens,
+ label: BRAND_DISPLAY_NAMES[id] ?? humanise(tokens),
+ logoUrl,
+ };
+ })
+ .sort(
+ (a, b) => b.tokens.length - a.tokens.length || b.id.length - a.id.length,
+ );
+
+export interface ToolBrand {
+ /** Readable label: "Gmail · search", "Google Calendar · list", "run shell". */
+ label: string;
+ /** Bundled SVG for the brand tile, when the tool belongs to a known brand. */
+ logoUrl?: string;
+ /** Two-letter fallback for the tile when there is no logo. */
+ monogram: string;
+ /** The brand id (asset file stem) the tool resolved to, if any. */
+ brandId?: string;
+}
+
+/** "plugin-gmail" → ["plugin", "gmail"]; "Google.Calendar list" → ["google", "calendar", "list"]. */
+export function tokenizeToolName(toolName: string): string[] {
+ return toolName
+ .toLowerCase()
+ .split(/[^a-z0-9]+/)
+ .filter(Boolean);
+}
+
+/** Index at which `needle` occurs as a contiguous run inside `hay`, or -1. */
+function indexOfRun(hay: string[], needle: string[]): number {
+ outer: for (let i = 0; i + needle.length <= hay.length; i++) {
+ for (let j = 0; j < needle.length; j++) {
+ if (hay[i + j] !== needle[j]) continue outer;
+ }
+ return i;
+ }
+ return -1;
+}
+
+/** Two letters: initials of a multi-word label, else its first two letters. */
+export function monogramFor(label: string): string {
+ const words = label.split(/[\s·]+/).filter(Boolean);
+ if (words.length === 0) return "??";
+ const raw =
+ words.length >= 2
+ ? words[0].charAt(0) + words[1].charAt(0)
+ : words[0].slice(0, 2);
+ return raw.toUpperCase().padEnd(2, "·");
+}
+
+/**
+ * Resolve a tool name to its brand mark and a readable label.
+ *
+ * Known brand: the remaining tokens (minus wrapper words like "plugin")
+ * become the action — "gmail_search" → "Gmail · search", "plugin-gmail" →
+ * "Gmail". Unknown tool: the tokens joined with spaces — "run_shell" →
+ * "run shell" — and a monogram instead of a logo.
+ */
+export function resolveToolBrand(toolName: string): ToolBrand {
+ const tokens = tokenizeToolName(toolName ?? "");
+ if (tokens.length === 0) {
+ return { label: (toolName ?? "").trim() || "?", monogram: "??" };
+ }
+
+ for (const brand of BRANDS) {
+ const at = indexOfRun(tokens, brand.tokens);
+ if (at === -1) continue;
+ const rest = [...tokens.slice(0, at), ...tokens.slice(at + brand.tokens.length)].filter(
+ (w) => !NOISE_TOKENS.has(w),
+ );
+ const label = rest.length ? `${brand.label} · ${rest.join(" ")}` : brand.label;
+ return {
+ label,
+ logoUrl: brand.logoUrl,
+ monogram: monogramFor(brand.label),
+ brandId: brand.id,
+ };
+ }
+
+ const plain = tokens.filter((w) => !NOISE_TOKENS.has(w));
+ const label = (plain.length ? plain : tokens).join(" ");
+ return { label, monogram: monogramFor(label) };
+}
diff --git a/jarvis/ui/web/frontend/src/store/runFocus.ts b/jarvis/ui/web/frontend/src/store/runFocus.ts
deleted file mode 100644
index a87b0c1892..0000000000
--- a/jarvis/ui/web/frontend/src/store/runFocus.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { create } from "zustand";
-
-/**
- * A one-shot hand-off: "open the Run Inspector ON this run".
- *
- * The sidebar's recent-runs block lives outside the inspector, whose
- * selection is local state. Setting the focus here and switching sections
- * lets the inspector pick that run up on mount and clear the hand-off, so a
- * later visit starts on the newest run as before.
- */
-interface RunFocusStore {
- sessionId: string | null;
- focus: (sessionId: string) => void;
- /** Take the pending hand-off (and clear it). Null when nothing is pending. */
- take: () => string | null;
-}
-
-export const useRunFocusStore = create<RunFocusStore>((set, get) => ({
- sessionId: null,
- focus: (sessionId) => set({ sessionId }),
- take: () => {
- const id = get().sessionId;
- if (id !== null) set({ sessionId: null });
- return id;
- },
-}));
diff --git a/jarvis/ui/web/frontend/src/views/RunInspectorView.tsx b/jarvis/ui/web/frontend/src/views/RunInspectorView.tsx
index 84b5af52bf..7bb7bce84c 100644
--- a/jarvis/ui/web/frontend/src/views/RunInspectorView.tsx
+++ b/jarvis/ui/web/frontend/src/views/RunInspectorView.tsx
@@ -3,16 +3,11 @@ import { useT } from "@/i18n";
import { useRuns } from "@/hooks/useRuns";
import { RunList } from "@/components/runs/RunList";
import { RunDetail } from "@/components/runs/RunDetail";
-import { useRunFocusStore } from "@/store/runFocus";
export function RunInspectorView() {
const t = useT();
const { data: runs, isError } = useRuns();
- // A run handed over from elsewhere (the sidebar's recent-runs block) is
- // the first pick; otherwise the newest run, as before.
- const [selected, setSelected] = useState<string | null>(() =>
- useRunFocusStore.getState().take(),
- );
+ const [selected, setSelected] = useState<string | null>(null);
useEffect(() => {
if (selected === null && runs && runs.length > 0) setSelected(runs[0].session_id);