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(chat): render the conversation, stop transcribing the screen

rubenluetke10-beep0af4e184324c
diff --git a/jarvis/ui/web/frontend/src/components/chat/ChatStream.tsx b/jarvis/ui/web/frontend/src/components/chat/ChatStream.tsx
index 2849422e67..3e385f21b4 100644
--- a/jarvis/ui/web/frontend/src/components/chat/ChatStream.tsx
+++ b/jarvis/ui/web/frontend/src/components/chat/ChatStream.tsx
@@ -1,51 +1,95 @@
/**
* The conversation, as a conversation.
*
- * Reads the pane's transcript and renders it the way a chat client does: what
- * you said on one side, what the agent said on the other, and the work it did
- * in between as quiet, collapsible steps rather than as terminal output. The
- * terminal is still there and still running — it is simply not the thing you
- * are asked to read.
+ * ## Where this reads from, and why it changed
*
- * Sub-agents get their own column on the right the moment one appears, because
- * "what are the helpers doing" is a different question from "what is the main
- * agent saying", and interleaving the two makes both unreadable.
+ * It used to read the pane's SCREEN and classify the lines back into a chat.
+ * That cannot be made to work, because a TUI is a picture rather than a
+ * protocol: it repaints rows in place, wraps to whatever width it happened to
+ * have, draws its own logo, and prints spinners. The first version of this view
+ * showed a half-rendered ASCII banner, a raw `$ cd … && git diff` line and
+ * `Churned for 5s` — all of them faithfully transcribed, none of them anything
+ * a person wants to read.
+ *
+ * So it reads the record the CLI keeps in order to resume itself
+ * (`/terminals/{name}/conversation`). There, roles are declared and tool calls
+ * carry their name and arguments, so this component renders rather than guesses:
+ * prose as Markdown, work as quiet collapsible steps, and nothing at all for
+ * the banner — because the banner was never in the conversation to begin with.
+ *
+ * ## Two sources, on purpose
+ *
+ * The file says what was SAID; it is written as turns complete. The pane says
+ * what is happening RIGHT NOW. So the live status line at the bottom still
+ * comes from the pane, and a CLI that keeps no readable record falls back to
+ * the pane entirely — honestly, with the terminal offered rather than an error.
*/
-import { useEffect, useMemo, useRef, useState } from "react";
-import { ChevronRight, Loader2, TriangleAlert, Users } from "lucide-react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { ChevronRight, Loader2, TriangleAlert } from "lucide-react";
+import ReactMarkdown from "react-markdown";
import { cn } from "@/lib/utils";
-import { readTranscript, subagentsOf, type ChatEvent } from "./chatTranscript";
+import {
+ fetchConversation,
+ type AgentStep,
+ type AgentTurn,
+} from "@/lib/agentConversationApi";
-const POLL_MS = 1000;
-const LINES = 300;
+/**
+ * How often the conversation is re-read.
+ *
+ * Slower than the pane's own poll: this file changes when a turn COMPLETES, not
+ * while it is being typed, so asking four times a second would be four times
+ * the disk for the same answer. The live line below it is what moves quickly.
+ */
+const POLL_MS = 1500;
export interface ChatStreamProps {
terminal: string;
active?: boolean;
+ /**
+ * Show the raw pane instead. Called when this CLI keeps no readable record —
+ * the surface has the terminal and should mount it rather than leave the
+ * reader with an empty column.
+ */
+ onUnavailable?: () => void;
}
-export function ChatStream({ terminal, active = true }: ChatStreamProps) {
- const [lines, setLines] = useState<string[] | null>(null);
+export function ChatStream({ terminal, active = true, onUnavailable }: ChatStreamProps) {
+ const [turns, setTurns] = useState<AgentTurn[] | null>(null);
const [error, setError] = useState<string | null>(null);
const bottom = useRef<HTMLDivElement | null>(null);
+ /*
+ * Follow the tail only while the reader IS at the tail. Scrolling up is a
+ * deliberate act — somebody is reading what already happened — and yanking
+ * them back down on every poll makes the history unreadable.
+ */
const following = useRef(true);
+ const reportedUnavailable = useRef(false);
+
+ const notifyUnavailable = useCallback(() => {
+ if (reportedUnavailable.current) return;
+ reportedUnavailable.current = true;
+ onUnavailable?.();
+ }, [onUnavailable]);
useEffect(() => {
if (!active) return;
let alive = true;
const tick = async () => {
try {
- const response = await fetch(
- `/api/agentic-ide/terminals/${encodeURIComponent(terminal)}/report?lines=${LINES}`,
- );
- if (!response.ok) throw new Error(String(response.status));
- const body = (await response.json()) as { transcript?: string[] };
+ const body = await fetchConversation(terminal);
if (!alive) return;
- setLines(body.transcript ?? []);
+ if (!body.available) {
+ notifyUnavailable();
+ return;
+ }
+ setTurns(body.turns);
setError(null);
} catch {
if (!alive) return;
+ // A pane that has gone away is a state, not a crash. Said once, in the
+ // reader's language of "this stopped", not as a status code.
setError("This agent is no longer running.");
}
};
@@ -55,127 +99,160 @@ export function ChatStream({ terminal, active = true }: ChatStreamProps) {
alive = false;
window.clearInterval(id);
};
- }, [active, terminal]);
+ }, [active, notifyUnavailable, terminal]);
- const events = useMemo(() => readTranscript(lines ?? []), [lines]);
- const helpers = useMemo(() => subagentsOf(events), [events]);
+ // Keyed on the turn count and the last turn's length: the tail grows both by
+ // gaining turns and by the open turn getting longer, and only those two mean
+ // "there is new text below".
+ const tailKey = useMemo(() => {
+ const last = turns?.[turns.length - 1];
+ return `${turns?.length ?? 0}:${last?.text.length ?? 0}:${last?.steps.length ?? 0}`;
+ }, [turns]);
useEffect(() => {
if (following.current) bottom.current?.scrollIntoView({ block: "end" });
- }, [events]);
+ }, [tailKey]);
return (
- <div className="flex min-h-0 flex-1">
- <div
- onScroll={(event) => {
- const node = event.currentTarget;
- following.current = node.scrollHeight - node.scrollTop - node.clientHeight < 64;
- }}
- data-testid="chat-stream"
- className="min-h-0 flex-1 overflow-y-auto scrollbar-jarvis px-8 py-10"
- >
- <div className="mx-auto w-full max-w-[46rem] space-y-6">
- {error && (
- <div className="flex items-center gap-2 rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-300">
- <TriangleAlert className="h-4 w-4 shrink-0" aria-hidden />
- {error}
- </div>
- )}
- {lines === null && !error && (
- <div className="flex items-center gap-2 text-sm text-muted-foreground">
- <Loader2 className="h-4 w-4 animate-spin" aria-hidden />
- Waking the agent…
- </div>
- )}
- {lines !== null && events.length === 0 && !error && (
- <p className="text-[15px] text-muted-foreground">
- The agent is ready. Say what you want done.
- </p>
- )}
- {events.map((event, index) => (
- <Block key={`${event.kind}-${index}`} event={event} />
- ))}
- <div ref={bottom} />
- </div>
- </div>
-
- {helpers.length > 0 && (
- <aside className="w-64 shrink-0 overflow-y-auto scrollbar-jarvis border-l border-border/60 px-3 py-4">
- <div className="mb-2 flex items-center gap-2 text-[11px] font-medium uppercase tracking-wider text-muted-foreground">
- <Users className="h-3.5 w-3.5" aria-hidden />
- Sub-agents
+ <div
+ onScroll={(event) => {
+ const node = event.currentTarget;
+ following.current = node.scrollHeight - node.scrollTop - node.clientHeight < 64;
+ }}
+ data-testid="chat-stream"
+ className="min-h-0 flex-1 overflow-y-auto scrollbar-jarvis px-8 py-8"
+ >
+ <div className="mx-auto flex w-full max-w-[46rem] flex-col gap-7">
+ {error && (
+ <div className="flex items-center gap-2 rounded-xl border border-amber-500/25 bg-amber-500/[0.06] px-4 py-3 text-sm text-amber-300">
+ <TriangleAlert className="h-4 w-4 shrink-0" aria-hidden />
+ {error}
</div>
- {helpers.map((helper, index) => (
- <div
- key={index}
- className="mb-1.5 rounded-lg border border-border/60 bg-card/40 px-2.5 py-2 text-[11px] leading-snug"
- >
- {helper.label ?? helper.text}
- </div>
- ))}
- </aside>
- )}
+ )}
+ {turns === null && !error && (
+ <div className="flex items-center gap-2 text-sm text-muted-foreground">
+ <Loader2 className="h-4 w-4 animate-spin" aria-hidden />
+ Reading the conversation…
+ </div>
+ )}
+ {turns !== null && turns.length === 0 && !error && (
+ <p className="text-[15px] text-muted-foreground">
+ The agent is ready. Say what you want done.
+ </p>
+ )}
+ {(turns ?? []).map((turn, index) => (
+ <TurnBlock key={index} turn={turn} />
+ ))}
+ <div ref={bottom} />
+ </div>
</div>
);
}
-function Block({ event }: { event: ChatEvent }) {
- const [open, setOpen] = useState(false);
-
- if (event.kind === "user") {
+function TurnBlock({ turn }: { turn: AgentTurn }) {
+ if (turn.role === "user") {
return (
<div className="flex justify-end">
- <div className="max-w-[80%] whitespace-pre-wrap break-words rounded-3xl bg-secondary/60 px-5 py-3 text-[15px] leading-[1.65]">
- {event.text}
+ <div className="max-w-[80%] whitespace-pre-wrap break-words rounded-2xl bg-foreground/[0.07] px-4 py-2.5 text-[15px] leading-[1.6]">
+ {turn.text}
</div>
</div>
);
}
- if (event.kind === "status") {
- return (
- <div className="flex items-center gap-2 text-[13px] text-muted-foreground">
- <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />
- {event.text}
- </div>
- );
- }
+ return (
+ <div className="flex flex-col gap-3">
+ {turn.text && <Prose text={turn.text} />}
+ {turn.steps.length > 0 && (
+ <div className="flex flex-col gap-0.5">
+ {turn.steps.map((step, index) => (
+ <StepRow key={index} step={step} />
+ ))}
+ </div>
+ )}
+ </div>
+ );
+}
- if (event.kind === "step" || event.kind === "subagent") {
- const long = event.text.length > (event.label?.length ?? 0);
- return (
+/**
+ * The agent's own words, rendered as the Markdown they are.
+ *
+ * A coding agent writes in Markdown — headings, lists, fenced code — and
+ * showing that as preformatted text was half of why the old view looked like a
+ * log file. The type scale is a reading scale rather than a terminal one: this
+ * is prose, and it is the only thing on this surface anybody reads end to end.
+ */
+function Prose({ text }: { text: string }) {
+ return (
+ <div
+ className={cn(
+ "text-[15.5px] leading-[1.7] tracking-[-0.003em] text-foreground/90",
+ "[&_p]:my-2 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0",
+ "[&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-5",
+ "[&_li]:my-0.5",
+ "[&_h1]:mb-2 [&_h1]:mt-4 [&_h1]:text-[17px] [&_h1]:font-semibold",
+ "[&_h2]:mb-2 [&_h2]:mt-4 [&_h2]:text-[16px] [&_h2]:font-semibold",
+ "[&_h3]:mb-1.5 [&_h3]:mt-3 [&_h3]:text-[15px] [&_h3]:font-semibold",
+ "[&_strong]:font-semibold [&_strong]:text-foreground",
+ "[&_code]:rounded [&_code]:bg-foreground/[0.07] [&_code]:px-1 [&_code]:py-0.5",
+ "[&_code]:font-mono [&_code]:text-[13px]",
+ "[&_pre]:my-3 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:bg-foreground/[0.05]",
+ "[&_pre]:p-3 [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-[12.5px]",
+ "[&_a]:underline [&_a]:underline-offset-2",
+ "[&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-3",
+ "[&_blockquote]:text-muted-foreground",
+ )}
+ >
+ <ReactMarkdown>{text}</ReactMarkdown>
+ </div>
+ );
+}
+
+/**
+ * One tool call, at the weight of a footnote.
+ *
+ * The name the CLI gave the tool and the one argument worth seeing — a path, a
+ * command — on a single line that does not wrap. Everything else is behind the
+ * disclosure, because the reason to show steps at all is "I can see what it
+ * touched", and that question is answered by forty short lines, never by forty
+ * pretty-printed JSON objects.
+ */
+function StepRow({ step }: { step: AgentStep }) {
+ const [open, setOpen] = useState(false);
+ const expandable = Boolean(step.detail);
+
+ return (
+ <div>
<button
type="button"
- onClick={() => long && setOpen((v) => !v)}
+ onClick={() => expandable && setOpen((v) => !v)}
+ aria-expanded={expandable ? open : undefined}
className={cn(
- "flex w-full items-start gap-2.5 rounded-lg px-2 py-1.5 text-left text-[13px] transition-colors",
- long && "hover:bg-accent/30",
- event.kind === "subagent" ? "text-violet-300" : "text-muted-foreground",
+ "flex w-full items-center gap-2 rounded-md px-1.5 py-1 text-left text-[12.5px]",
+ "text-muted-foreground transition-colors",
+ expandable && "hover:bg-foreground/[0.05] hover:text-foreground/80",
)}
>
<ChevronRight
className={cn(
- "mt-0.5 h-3 w-3 shrink-0 transition-transform",
+ "h-3 w-3 shrink-0 transition-transform",
open && "rotate-90",
- !long && "opacity-0",
+ !expandable && "opacity-0",
)}
aria-hidden
/>
- <span className="min-w-0 flex-1">
- <span className="block truncate font-medium">{event.label ?? event.text}</span>
- {open && (
- <span className="mt-1 block whitespace-pre-wrap break-words font-mono text-[11px] text-muted-foreground/80">
- {event.text}
- </span>
- )}
- </span>
+ <span className="shrink-0 font-medium text-foreground/70">{step.tool}</span>
+ {step.target && (
+ <span className="min-w-0 flex-1 truncate font-mono text-[11.5px] text-muted-foreground/80">
+ {step.target}
+ </span>
+ )}
</button>
- );
- }
-
- return (
- <div className="whitespace-pre-wrap break-words text-[16px] leading-[1.75] tracking-[-0.003em] text-foreground/95">
- {event.text}
+ {open && step.detail && (
+ <pre className="ml-6 mt-1 max-h-72 overflow-auto scrollbar-jarvis whitespace-pre-wrap break-words rounded-md bg-foreground/[0.04] p-2.5 font-mono text-[11.5px] leading-relaxed text-muted-foreground">
+ {step.detail}
+ </pre>
+ )}
</div>
);
}
diff --git a/jarvis/ui/web/frontend/src/lib/agentConversationApi.ts b/jarvis/ui/web/frontend/src/lib/agentConversationApi.ts
new file mode 100644
index 0000000000..eb732b2cc2
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/agentConversationApi.ts
@@ -0,0 +1,49 @@
+/**
+ * A pane's conversation, as the coding CLI itself recorded it.
+ *
+ * The counterpart of `/report`, and the reason it exists: `/report` answers
+ * with the pane's SCREEN — the picture a TUI drew, banners and spinners and
+ * all — while this answers with the file the CLI keeps in order to be able to
+ * resume itself. Roles are declared there, tool calls carry their arguments,
+ * and prose is prose, so nothing downstream has to guess what a line was.
+ *
+ * `available: false` is a normal answer and the caller must handle it: a CLI
+ * that keeps no readable record, or a pane whose conversation has not been
+ * written yet. Watching the live pane is the honest fallback — never an error
+ * message, because nothing is wrong.
+ */
+
+/** One thing the agent did between two things it said. */
+export interface AgentStep {
+ /** The CLI's own name for the tool — shown as-is, never translated. */
+ tool: string;
+ /** The one argument worth reading at a glance: a path, a command. */
+ target: string;
+ /** Everything else about the call, for a reader who opens the step. */
+ detail: string;
+}
+
+export interface AgentTurn {
+ role: "user" | "assistant";
+ text: string;
+ steps: AgentStep[];
+}
+
+export interface AgentConversation {
+ terminal: string;
+ agent: string;
+ available: boolean;
+ turns: AgentTurn[];
+}
+
+export async function fetchConversation(
+ terminal: string,
+ signal?: AbortSignal,
+): Promise<AgentConversation> {
+ const response = await fetch(
+ `/api/agentic-ide/terminals/${encodeURIComponent(terminal)}/conversation`,
+ { signal },
+ );
+ if (!response.ok) throw new Error(String(response.status));
+ return (await response.json()) as AgentConversation;
+}
diff --git a/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsx b/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsx
index ec58d3f398..9c85cfbded 100644
--- a/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsx
+++ b/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsx
@@ -14,7 +14,14 @@
* two states, never a menu of things to click instead.
*/
import { useCallback, useEffect, useMemo, useState } from "react";
-import { FolderOpen, LayoutGrid, Loader2, SquareTerminal, X } from "lucide-react";
+import {
+ FolderOpen,
+ LayoutGrid,
+ Loader2,
+ MessagesSquare,
+ SquareTerminal,
+ X,
+} from "lucide-react";
import { AgentMark } from "@/components/agentic/AgentMark";
import { ChatComposer, type ComposerAgent } from "@/components/chat/ChatComposer";
@@ -81,6 +88,15 @@ export function ChatWorkspaceView() {
// a bubble mounted inside a component that re-renders per keystroke would
// reset the orb mid-sentence.
const [talking, setTalking] = useState(false);
+ /*
+ * Show the raw pane instead of the conversation.
+ *
+ * Set by the reader who wants the terminal, and set for them when this CLI
+ * keeps no record a conversation can be read from. Reset per chat: it answers
+ * "how am I looking at THIS agent", and a CLI without a transcript must not
+ * decide how the next one is shown.
+ */
+ const [rawPane, setRawPane] = useState(false);
const [agents, setAgents] = useState<ComposerAgent[]>([]);
const [agentId, setAgentId] = useState("");
@@ -123,6 +139,13 @@ export function ChatWorkspaceView() {
};
}, []);
+ // A different chat is a different agent, possibly a different CLI. Whether
+ // the LAST one had a readable transcript says nothing about this one.
+ const openChatId = open?.chat.id ?? null;
+ useEffect(() => {
+ setRawPane(false);
+ }, [openChatId]);
+
const activeProject = open?.project ?? lastProject;
const addProject = useCallback(async () => {
@@ -435,13 +458,32 @@ export function ChatWorkspaceView() {
</span>
)}
<div className="flex-1" />
+ {/* Which of the two views of the same running agent is on screen.
+ The pane is always there and always running; this only decides
+ whether you read its conversation or watch it work. */}
+ {open?.chat.terminal && (
+ <button
+ type="button"
+ data-testid="toggle-raw-pane"
+ onClick={() => setRawPane((v) => !v)}
+ title={rawPane ? "Read the conversation" : "Watch the terminal"}
+ className="flex h-7 items-center gap-1.5 rounded-md px-2 text-[11px] text-muted-foreground transition-colors hover:bg-foreground/[0.06] hover:text-foreground"
+ >
+ {rawPane ? (
+ <MessagesSquare className="h-3.5 w-3.5" aria-hidden />
+ ) : (
+ <SquareTerminal className="h-3.5 w-3.5" aria-hidden />
+ )}
+ {rawPane ? "Conversation" : "Terminal"}
+ </button>
+ )}
{open && (
<button
type="button"
onClick={() => setOpen(null)}
title="Close this chat"
aria-label="Close this chat"
- className="flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground"
+ className="flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-foreground/[0.06] hover:text-foreground"
>
<X className="h-3.5 w-3.5" aria-hidden />
</button>
@@ -485,8 +527,12 @@ export function ChatWorkspaceView() {
there in the stream, in a better order.
*/}
<div
- className="pointer-events-none absolute inset-0 -z-10 overflow-hidden opacity-0"
- aria-hidden
+ className={
+ rawPane
+ ? "absolute inset-0 overflow-hidden px-4 pb-2"
+ : "pointer-events-none absolute inset-0 -z-10 overflow-hidden opacity-0"
+ }
+ aria-hidden={!rawPane}
>
<AgenticTerminal
key={open.chat.terminal}
@@ -496,9 +542,21 @@ export function ChatWorkspaceView() {
appearance="dark"
fontSize={13}
active
+ focused={rawPane}
/>
</div>
- <ChatStream terminal={open.chat.terminal} />
+ {!rawPane && (
+ <ChatStream
+ terminal={open.chat.terminal}
+ /*
+ * Not every CLI keeps a conversation anyone can read. When
+ * this one does not, the pane it is already running becomes
+ * the view — which is the honest answer, and never an empty
+ * column with an apology in it (CLAUDE.md §3).
+ */
+ onUnavailable={() => setRawPane(true)}
+ />
+ )}
</div>
) : (
<div className="flex min-h-0 flex-1 items-center justify-center overflow-y-auto scrollbar-jarvis px-6">