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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(voice): the transcript keeps the whole conversation and scrolls like a document
rubenluetke10-beep3c2642cf2185
diff --git a/jarvis/ui/web/frontend/src/components/home/VoiceStage.test.tsx b/jarvis/ui/web/frontend/src/components/home/VoiceStage.test.tsxindex d99d12f446..ffe2104cbc 100644--- a/jarvis/ui/web/frontend/src/components/home/VoiceStage.test.tsx+++ b/jarvis/ui/web/frontend/src/components/home/VoiceStage.test.tsx@@ -1,21 +1,178 @@-import { describe, expect, it } from "vitest";+import { act, cleanup, fireEvent, render as rtlRender, screen } from "@testing-library/react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { afterEach, describe, expect, it, vi } from "vitest";-import { hintFor, recentLines, waveformPhase } from "@/components/home/VoiceStage";+import { NEAR_END_PX, VoiceStage, hintFor, isNearEnd, waveformPhase } from "@/components/home/VoiceStage";import { stateKey } from "@/components/home/JarvisBar";import { greetingKey } from "@/components/home/Greeting";-import type { TranscriptTextLine } from "@/lib/homeTranscript";+import { useHomeStore } from "@/store/home";+import { useEventStore } from "@/store/events";+import type { TranscriptLine } from "@/lib/homeTranscript";const t = (key: string) => key;-function line(who: TranscriptTextLine["who"], text: string, i: number): TranscriptTextLine {+// The bar owns a canvas waveform and two hooks of its own; the stage's+// scrolling is what these tests are about, so it stands in as a marker.+vi.mock("@/components/home/JarvisBar", async () => {+ const actual = await vi.importActual<typeof import("@/components/home/JarvisBar")>(+ "@/components/home/JarvisBar",+ );+ return { ...actual, JarvisBar: () => <div data-testid="jarvis-bar" /> };+});+vi.mock("@/components/agentic/useVoiceCall", () => ({+ useVoiceCall: () => ({ active: false, busy: false, connecting: false, toggleCall: () => {} }),+}));+vi.mock("@/hooks/useVoiceReadiness", () => ({+ useVoiceReadiness: () => ({+ connected: true,+ warming: false,+ ready: true,+ voiceWarming: false,+ bootWarming: false,+ }),+}));+vi.mock("@/hooks/useWakeWord", () => ({+ useWakeWord: () => ({ config: { phrase: "Hey George" }, loading: false, error: null }),+}));++class NoopResizeObserver {+ observe() {}+ unobserve() {}+ disconnect() {}+}+if (typeof globalThis.ResizeObserver === "undefined") {+ globalThis.ResizeObserver = NoopResizeObserver as unknown as typeof ResizeObserver;+}++/** The greeting reads the profile name (a query), so the stage mounts like the app. */+function render() {+ const client = new QueryClient({+ defaultOptions: { queries: { retry: false, staleTime: Infinity } },+ });+ return rtlRender(+ <QueryClientProvider client={client}>+ <VoiceStage />+ </QueryClientProvider>,+ );+}++function said(who: "user" | "assistant", text: string, i: number): TranscriptLine {return { id: `m${i}`, who, text, ts: i };}+/** jsdom lays nothing out, so the viewport is told how tall it "is". */+function fakeMetrics(viewport: HTMLElement, scrollTop: number, scrollHeight: number, clientHeight: number) {+ Object.defineProperty(viewport, "scrollHeight", { value: scrollHeight, configurable: true });+ Object.defineProperty(viewport, "clientHeight", { value: clientHeight, configurable: true });+ viewport.scrollTop = scrollTop;+}++function viewport(): HTMLElement {+ const el = document.querySelector("[data-radix-scroll-area-viewport]");+ if (!el) throw new Error("no scroll viewport");+ return el as HTMLElement;+}++afterEach(() => {+ cleanup();+ useHomeStore.getState().resetTranscript();+});++describe("VoiceStage transcript", () => {+ it("renders the WHOLE conversation, not a window onto its last lines", () => {+ // The regression this guards: the lane used to cut to the last 8 entries+ // before rendering, so older turns were absent from the DOM and no amount+ // of scrolling could bring them back.+ const lines = Array.from({ length: 30 }, (_, i) =>+ said(i % 2 === 0 ? "user" : "assistant", `line ${i}`, i),+ );+ act(() => useHomeStore.getState().seedTranscript(lines));+ render();++ expect(screen.getAllByTestId("transcript-line")).toHaveLength(30);+ expect(screen.getByText("line 0")).toBeTruthy();+ expect(screen.getByText("line 29")).toBeTruthy();+ // And it lives in a scrolling viewport, not a clipped lane.+ expect(document.querySelector("[data-radix-scroll-area-viewport]")).toBeTruthy();+ });++ it("offers the way back only once the view has been scrolled off the end", () => {+ act(() =>+ useHomeStore+ .getState()+ .seedTranscript(Array.from({ length: 20 }, (_, i) => said("user", `line ${i}`, i))),+ );+ render();++ expect(screen.queryByTestId("voice-scroll-end")).toBeNull();++ const vp = viewport();+ fakeMetrics(vp, 0, 4000, 500);+ act(() => {+ fireEvent.scroll(vp);+ });+ expect(screen.getByTestId("voice-scroll-end")).toBeTruthy();++ // Back at the end, the button goes away and following resumes.+ fakeMetrics(vp, 3500, 4000, 500);+ act(() => {+ fireEvent.scroll(vp);+ });+ expect(screen.queryByTestId("voice-scroll-end")).toBeNull();+ });++ it("keeps the reader's place when new lines arrive after scrolling up", () => {+ act(() =>+ useHomeStore+ .getState()+ .seedTranscript(Array.from({ length: 20 }, (_, i) => said("user", `line ${i}`, i))),+ );+ render();++ const vp = viewport();+ fakeMetrics(vp, 120, 4000, 500);+ act(() => {+ fireEvent.scroll(vp);+ });++ act(() =>+ useHomeStore.getState().seedTranscript([+ ...Array.from({ length: 20 }, (_, i) => said("user", `line ${i}`, i)),+ said("assistant", "a fresh answer", 99),+ ]),+ );++ expect(screen.getByText("a fresh answer")).toBeTruthy();+ expect(vp.scrollTop).toBe(120);+ });++ it("is one centred column with no lane before anything is said", () => {+ render();+ expect(screen.getByTestId("voice-stage").dataset.empty).toBe("true");+ expect(document.querySelector("[data-radix-scroll-area-viewport]")).toBeNull();+ expect(screen.getByTestId("jarvis-bar")).toBeTruthy();+ });++ it("shows the words still being said under the finished ones", () => {+ act(() => useHomeStore.getState().seedTranscript([said("assistant", "settled", 1)]));+ act(() => useEventStore.setState({ transcription: "still talking", transcriptionFinal: false }));+ render();++ expect(screen.getByTestId("transcript-live").textContent).toContain("still talking");+ act(() => useEventStore.setState({ transcription: "", transcriptionFinal: true }));+ });+});+describe("VoiceStage helpers", () => {- it("keeps only the last lines, in order", () => {- const all = [line("user", "one", 1), line("assistant", "two", 2), line("user", "three", 3)];- expect(recentLines(all, 2).map((m) => m.text)).toEqual(["two", "three"]);- expect(recentLines(all, 10).map((m) => m.text)).toEqual(["one", "two", "three"]);+ it("follows new output only while the view is at the end", () => {+ // Exactly at the bottom, and a hair short of it: still following.+ expect(isNearEnd(900, 1000, 100)).toBe(true);+ expect(isNearEnd(900 - NEAR_END_PX, 1000, 100)).toBe(true);+ // Scrolled up to read something: the view stays put.+ expect(isNearEnd(900 - NEAR_END_PX - 1, 1000, 100)).toBe(false);+ expect(isNearEnd(0, 1000, 100)).toBe(false);+ // A conversation shorter than the viewport is always at its end.+ expect(isNearEnd(0, 100, 400)).toBe(true);});it("maps the voice state onto the waveform phases, idle when offline", () => {diff --git a/jarvis/ui/web/frontend/src/components/home/VoiceStage.tsx b/jarvis/ui/web/frontend/src/components/home/VoiceStage.tsxindex aaa7ac6d20..4e5b13ac9c 100644--- a/jarvis/ui/web/frontend/src/components/home/VoiceStage.tsx+++ b/jarvis/ui/web/frontend/src/components/home/VoiceStage.tsx@@ -1,39 +1,46 @@-import { useEffect, useMemo, useRef } from "react";+import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";+import { ArrowDown } from "lucide-react";import { useEventStore, type VoiceState } from "@/store/events";import { useHomeStore } from "@/store/home";-import type { TranscriptLine as TranscriptEntry } from "@/lib/homeTranscript";import type { WaveformPhase } from "@/components/overlay/VoiceWaveform";import { useVoiceCall } from "@/components/agentic/useVoiceCall";import { useVoiceReadiness } from "@/hooks/useVoiceReadiness";import { useWakeWord } from "@/hooks/useWakeWord";import { fill, useT } from "@/i18n";import { cn } from "@/lib/utils";+import { ScrollArea } from "@/components/ui/scroll-area";import { Greeting } from "@/components/home/Greeting";import { JarvisBar } from "@/components/home/JarvisBar";import { TurnSteps, traceWorthShowing } from "@/components/home/TurnSteps";import { traceModel } from "@/lib/thinkingSteps";-/** How many finished lines the lane keeps above the bar. */-const TRANSCRIPT_LINES = 8;-/*** The voice stage — what the front page opens on.*- * Vertically centred, one column: the greeting, the last few lines of the- * conversation, the Jarvis bar, and one quiet line that says what to do- * next. No microphone button (maintainer, 2026-08-23): you tap the bar, or- * you say the wake word. The bar IS the control — the same start/stop path- * the IDE's voice bubble uses, so there is exactly one way voice begins.+ * Empty, it is one centred column: the greeting, the Jarvis bar, and one+ * quiet line that says what to do next. No microphone button (maintainer,+ * 2026-08-23): you tap the bar, or you say the wake word. The bar IS the+ * control — the same start/stop path the IDE's voice bubble uses, so there+ * is exactly one way voice begins.+ *+ * Once anything has been said the page becomes a document, the way the chat+ * stage next door already is: the whole conversation scrolls in its own+ * viewport and the bar docks to the bottom. WHOLE, not a window onto the+ * last few turns — until 2026-08-24 the lane rendered only the last 8 lines,+ * so anything that scrolled off was gone from the DOM and could not be+ * scrolled back to. The lane reads the home store's transcript+ * (lib/homeTranscript: 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).*- * The transcript lane reads the home store's transcript (lib/homeTranscript:- * 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.+ * Scrolling follows the Claude app. New output pulls the view along ONLY+ * while the view is already at the end; scrolled up to read something, you+ * keep your place while the conversation goes on below, and a button over+ * the bar takes you back to the end. Nothing yanks the page out from under+ * someone mid-sentence.*/export function VoiceStage() {const t = useT();@@ -49,15 +56,11 @@ export function VoiceStage() {const wakePhrase = wakeConfig?.phrase.trim() || "";// Steps blocks with nothing to show (a sub-second brain call, no tools)- // are dropped BEFORE the lane is cut to its last lines, so an empty block- // never takes a slot — or leaves a blank gap — in the lane.+ // are dropped so an empty block never leaves a blank gap in the lane.const lines = useMemo(() =>- recentLines(- transcript.filter(- (m) => m.who !== "steps" || traceWorthShowing(m.steps, m.durationMs, m.live),- ),- TRANSCRIPT_LINES,+ transcript.filter(+ (m) => m.who !== "steps" || traceWorthShowing(m.steps, m.durationMs, m.live),),[transcript],);@@ -70,27 +73,96 @@ export function VoiceStage() {liveReply && !(lastLine?.who === "assistant" && lastLine.text.startsWith(liveReply))? liveReply: "";- // A live turn keeps the lane pinned to its end as steps arrive.- const liveSteps = lines.some((m) => m.who === "steps" && m.live);+ const hasLines = lines.length > 0 || Boolean(liveLine) || Boolean(liveAnswer);++ const rootRef = useRef<HTMLDivElement | null>(null);+ const columnRef = useRef<HTMLDivElement | null>(null);+ // Whether new output pulls the view along. A ref, not state: the auto-scroll+ // below runs in a layout effect and must read the CURRENT answer, not the+ // one a re-render would deliver a frame later. `atEnd` mirrors it for the+ // button, which only has to be right by the next paint.+ const stickRef = useRef(true);+ const [atEnd, setAtEnd] = useState(true);++ const jumpToEnd = useCallback(() => {+ const viewport = viewportOf(rootRef.current);+ if (!viewport) return;+ stickRef.current = true;+ setAtEnd(true);+ if (!prefersReducedMotion() && typeof viewport.scrollTo === "function") {+ viewport.scrollTo({ top: viewport.scrollHeight, behavior: "smooth" });+ } else {+ viewport.scrollTop = viewport.scrollHeight;+ }+ }, []);- const laneEnd = useRef<HTMLDivElement | null>(null);+ // One listener answers both questions: does new output pull the view along,+ // and is the "back to the end" button needed.useEffect(() => {- laneEnd.current?.scrollIntoView({ block: "end" });- }, [lines, liveLine, liveAnswer, liveSteps]);+ const viewport = viewportOf(rootRef.current);+ if (!viewport) return;+ const read = () => {+ const near = isNearEnd(viewport.scrollTop, viewport.scrollHeight, viewport.clientHeight);+ stickRef.current = near;+ setAtEnd(near);+ };+ read();+ viewport.addEventListener("scroll", read, { passive: true });+ return () => viewport.removeEventListener("scroll", read);+ }, [hasLines]);++ useLayoutEffect(() => {+ const viewport = viewportOf(rootRef.current);+ if (!viewport || !stickRef.current) return;+ viewport.scrollTop = viewport.scrollHeight;+ }, [lines, liveLine, liveAnswer]);++ // An answer and its steps grow WITHOUT a new line arriving, so the effect+ // above never fires for them; the column's own size is the honest signal+ // where the platform has ResizeObserver.+ useEffect(() => {+ const column = columnRef.current;+ const viewport = viewportOf(rootRef.current);+ if (!column || !viewport || typeof ResizeObserver === "undefined") return;+ const ro = new ResizeObserver(() => {+ if (stickRef.current) viewport.scrollTop = viewport.scrollHeight;+ });+ ro.observe(column);+ return () => ro.disconnect();+ }, [hasLines]);const phase = waveformPhase(voiceState, connected);const hint = hintFor({ connected, warming, connecting, voiceState, wakePhrase, t });- return (- <div className="flex min-h-0 flex-1 flex-col items-center overflow-hidden" data-testid="voice-stage">- <div className="flex min-h-0 w-full max-w-[760px] flex-1 flex-col justify-center gap-7 px-6 pb-14 pt-6">- <Greeting subtitle={t("home.voice_subtitle")} muted={lines.length > 0 || Boolean(liveLine)} />+ if (!hasLines) {+ return (+ <div+ className="flex min-h-0 flex-1 flex-col items-center overflow-hidden"+ data-testid="voice-stage"+ data-empty="true"+ >+ <div className="flex w-full max-w-[760px] flex-1 flex-col justify-center gap-8 px-6 pb-14">+ <Greeting subtitle={t("home.voice_subtitle")} />+ <JarvisBar phase={phase} hint={hint} />+ </div>+ </div>+ );+ }+ return (+ <div+ className="flex min-h-0 flex-1 flex-col items-center overflow-hidden"+ data-testid="voice-stage"+ data-empty="false"+ >+ <ScrollArea ref={rootRef} className="min-h-0 w-full flex-1" data-testid="voice-transcript"><div- 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"+ ref={columnRef}+ className="mx-auto flex w-full max-w-[760px] flex-col gap-3 px-6 pb-4 pt-6"aria-live="polite">+ <Greeting subtitle={t("home.voice_subtitle")} muted />+ <div className="h-2 shrink-0" aria-hidden />{lines.map((m) =>m.who === "steps" ? (<div key={m.id} className="pl-[80px]" data-testid="transcript-steps">@@ -112,21 +184,58 @@ export function VoiceStage() {/>),)}- {liveLine && (- <TranscriptLine who={t("home.transcript_you")} text={liveLine} user live />- )}- {liveAnswer && (- <TranscriptLine who={assistantName} text={liveAnswer} user={false} live />- )}- <div ref={laneEnd} />+ {liveLine && <TranscriptLine who={t("home.transcript_you")} text={liveLine} user live />}+ {liveAnswer && <TranscriptLine who={assistantName} text={liveAnswer} user={false} live />}</div>+ </ScrollArea>+ <div className="relative w-full max-w-[760px] px-6 pb-6 pt-2">+ {!atEnd && (+ <button+ type="button"+ onClick={jumpToEnd}+ data-testid="voice-scroll-end"+ aria-label={t("home.transcript_to_end")}+ title={t("home.transcript_to_end")}+ className={cn(+ "absolute -top-3 left-1/2 z-10 flex h-8 w-8 -translate-x-1/2 items-center justify-center",+ "rounded-full border border-border bg-card/95 text-muted-foreground shadow-md backdrop-blur",+ "transition-colors hover:border-primary/40 hover:text-foreground",+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",+ )}+ >+ <ArrowDown aria-hidden className="h-4 w-4" />+ </button>+ )}<JarvisBar phase={phase} hint={hint} /></div></div>);}+/**+ * Within this many pixels of the bottom counts as "at the end", so sub-pixel+ * rounding — or the half line a growing answer adds between two frames —+ * never reads as "they scrolled away".+ */+export const NEAR_END_PX = 72;++export function isNearEnd(scrollTop: number, scrollHeight: number, clientHeight: number): boolean {+ return scrollHeight - scrollTop - clientHeight <= NEAR_END_PX;+}++/** 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 prefersReducedMotion(): boolean {+ return typeof window !== "undefined" && typeof window.matchMedia === "function"+ ? window.matchMedia("(prefers-reduced-motion: reduce)").matches+ : false;+}+/*** One line of the lane. A LIVE line (words still being said, an answer still* being produced) is muted and italic with a cursor; the finished line it@@ -166,18 +275,16 @@ function TranscriptLine({>{text}{live && (- <span className="ml-0.5 inline-block h-[1em] w-0.5 translate-y-0.5 animate-pulse bg-primary motion-reduce:animate-none" aria-hidden />+ <span+ className="ml-0.5 inline-block h-[1em] w-0.5 translate-y-0.5 animate-pulse bg-primary motion-reduce:animate-none"+ aria-hidden+ />)}</span></div>);}-/** The last N lines of the transcript, oldest first. */-export function recentLines(lines: TranscriptEntry[], limit: number): TranscriptEntry[] {- return lines.length > limit ? lines.slice(lines.length - limit) : lines;-}-export function waveformPhase(state: VoiceState, connected: boolean): WaveformPhase {if (!connected) return "idle";switch (state) {diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 4519cbd40e..2e849ab8e4 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -541,6 +541,7 @@"greeting_evening": "Guten Abend{name_part}","voice_subtitle": "Sag dein Wake‑Wort oder tippe auf die Leiste — die Unterhaltung erscheint hier.","transcript_you": "Du",+ "transcript_to_end": "Zum Neuesten springen","hint_idle": "Sag „{wake}“ oder tippe auf die Leiste","hint_idle_nowake": "Tippe auf die Leiste, um zu starten","hint_listening": "Ich höre zu…",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 8fe43e98ac..31067b476e 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -541,6 +541,7 @@"greeting_evening": "Good evening{name_part}","voice_subtitle": "Say your wake word or tap the bar — the conversation shows up here.","transcript_you": "You",+ "transcript_to_end": "Jump to the newest","hint_idle": "Say “{wake}” or tap the bar to start","hint_idle_nowake": "Tap the bar to start","hint_listening": "Listening…",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex e8262bf7eb..463cd1ebc3 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -541,6 +541,7 @@"greeting_evening": "Buenas noches{name_part}","voice_subtitle": "Di tu palabra de activación o toca la barra — la conversación aparece aquí.","transcript_you": "Tú",+ "transcript_to_end": "Ir a lo más reciente","hint_idle": "Di «{wake}» o toca la barra para empezar","hint_idle_nowake": "Toca la barra para empezar","hint_listening": "Escuchando…",diff --git a/jarvis/ui/web/frontend/src/lib/homeTranscript.ts b/jarvis/ui/web/frontend/src/lib/homeTranscript.tsindex 82c825c79d..d025724025 100644--- a/jarvis/ui/web/frontend/src/lib/homeTranscript.ts+++ b/jarvis/ui/web/frontend/src/lib/homeTranscript.ts@@ -79,8 +79,14 @@ export interface TranscriptStepsLine extends TranscriptLineBase {export type TranscriptLine = TranscriptTextLine | TranscriptStepsLine;-/** How many lines are kept. The lane shows the tail; this bounds memory. */-export const TRANSCRIPT_MAX = 40;+/**+ * How many lines are kept. Since the lane scrolls through ALL of them+ * (components/home/VoiceStage) rather than showing a window onto the last+ * few, this number is what a person can actually scroll back to — long+ * enough for a whole sitting, and still nothing on the heap: a few hundred+ * short strings.+ */+export const TRANSCRIPT_MAX = 300;/** 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. */