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): read the pane as a conversation — the terminal runs, and is not shown

rubenluetke10-beepc21e681e4530
diff --git a/jarvis/ui/web/frontend/src/components/chat/ChatStream.tsx b/jarvis/ui/web/frontend/src/components/chat/ChatStream.tsx
new file mode 100644
index 0000000000..4206fcc87c
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/chat/ChatStream.tsx
@@ -0,0 +1,181 @@
+/**
+ * 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.
+ *
+ * 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.
+ */
+import { useEffect, useMemo, useRef, useState } from "react";
+import { ChevronRight, Loader2, TriangleAlert, Users } from "lucide-react";
+
+import { cn } from "@/lib/utils";
+import { readTranscript, subagentsOf, type ChatEvent } from "./chatTranscript";
+
+const POLL_MS = 1000;
+const LINES = 300;
+
+export interface ChatStreamProps {
+ terminal: string;
+ active?: boolean;
+}
+
+export function ChatStream({ terminal, active = true }: ChatStreamProps) {
+ const [lines, setLines] = useState<string[] | null>(null);
+ const [error, setError] = useState<string | null>(null);
+ const bottom = useRef<HTMLDivElement | null>(null);
+ const following = useRef(true);
+
+ 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[] };
+ if (!alive) return;
+ setLines(body.transcript ?? []);
+ setError(null);
+ } catch {
+ if (!alive) return;
+ setError("This agent is no longer running.");
+ }
+ };
+ void tick();
+ const id = window.setInterval(() => void tick(), POLL_MS);
+ return () => {
+ alive = false;
+ window.clearInterval(id);
+ };
+ }, [active, terminal]);
+
+ const events = useMemo(() => readTranscript(lines ?? []), [lines]);
+ const helpers = useMemo(() => subagentsOf(events), [events]);
+
+ useEffect(() => {
+ if (following.current) bottom.current?.scrollIntoView({ block: "end" });
+ }, [events]);
+
+ 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-6"
+ >
+ <div className="mx-auto w-full max-w-3xl space-y-4">
+ {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-sm 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>
+ {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>
+ )}
+ </div>
+ );
+}
+
+function Block({ event }: { event: ChatEvent }) {
+ const [open, setOpen] = useState(false);
+
+ if (event.kind === "user") {
+ return (
+ <div className="flex justify-end">
+ <div className="max-w-[85%] rounded-2xl rounded-br-md bg-secondary/70 px-4 py-2.5 text-sm leading-relaxed">
+ {event.text}
+ </div>
+ </div>
+ );
+ }
+
+ if (event.kind === "status") {
+ return (
+ <div className="flex items-center gap-2 text-xs text-muted-foreground">
+ <Loader2 className="h-3 w-3 animate-spin" aria-hidden />
+ {event.text}
+ </div>
+ );
+ }
+
+ if (event.kind === "step" || event.kind === "subagent") {
+ const long = event.text.length > (event.label?.length ?? 0);
+ return (
+ <button
+ type="button"
+ onClick={() => long && setOpen((v) => !v)}
+ className={cn(
+ "flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left text-xs transition-colors",
+ long && "hover:bg-accent/30",
+ event.kind === "subagent" ? "text-violet-300" : "text-muted-foreground",
+ )}
+ >
+ <ChevronRight
+ className={cn(
+ "mt-0.5 h-3 w-3 shrink-0 transition-transform",
+ open && "rotate-90",
+ !long && "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>
+ </button>
+ );
+ }
+
+ return (
+ <div className="whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground/90">
+ {event.text}
+ </div>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/chat/chatTranscript.test.ts b/jarvis/ui/web/frontend/src/components/chat/chatTranscript.test.ts
new file mode 100644
index 0000000000..683ed44f9b
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/chat/chatTranscript.test.ts
@@ -0,0 +1,90 @@
+/**
+ * Reading a terminal screen as a conversation.
+ *
+ * The properties pinned here are the ones that decide whether a reader can
+ * trust what they see: nothing is invented, nothing recognisable is dropped,
+ * and — the important one — an unrecognised line still reaches the screen.
+ */
+import { describe, expect, test } from "vitest";
+
+import { readTranscript, subagentsOf } from "@/components/chat/chatTranscript";
+
+describe("readTranscript", () => {
+ test("drops the CLI's own banner", () => {
+ // Every conversation would otherwise open on somebody else's logo.
+ const events = readTranscript([
+ "Claude Code v2.1.222",
+ "Opus 5 (1M context) with high effort · Claude Max",
+ // Written with forward slashes on purpose: a Windows path in a TS
+ // string literal needs doubled backslashes, and a fixture that
+ // silently loses them tests the wrong input.
+ "~/Desktop/Personal Jarvis",
+ "2 MCP servers need authentication · run /mcp",
+ "",
+ "Hello there.",
+ ]);
+
+ expect(events).toHaveLength(1);
+ expect(events[0].kind).toBe("assistant");
+ expect(events[0].text).toBe("Hello there.");
+ });
+
+ test("separates what the user said from what the agent answered", () => {
+ const events = readTranscript(["> fix the wake path", "", "Looking at it now."]);
+
+ expect(events.map((e) => e.kind)).toEqual(["user", "assistant"]);
+ expect(events[0].text).toBe("fix the wake path");
+ });
+
+ test("an empty prompt caret is the input box, not something said", () => {
+ expect(readTranscript(["> "])).toEqual([]);
+ });
+
+ test("keeps a line it does not recognise", () => {
+ // The fail-safe direction. A classifier that dropped the unfamiliar would
+ // hide exactly the output that matters the day a CLI changes something.
+ const events = readTranscript(["!!! something entirely new !!!"]);
+
+ expect(events).toHaveLength(1);
+ expect(events[0].text).toContain("something entirely new");
+ });
+
+ test("folds a wrapped paragraph into one block but keeps turns apart", () => {
+ const events = readTranscript([
+ "The wake word never fired because",
+ "the energy gate rejected it.",
+ "",
+ "> thanks",
+ ]);
+
+ expect(events).toHaveLength(2);
+ expect(events[0].text).toBe(
+ "The wake word never fired because\nthe energy gate rejected it.",
+ );
+ expect(events[1].kind).toBe("user");
+ });
+
+ test("recognises steps and names them for a collapsed row", () => {
+ const events = readTranscript(["● Read jarvis/core/config.py (420 lines)"]);
+
+ expect(events[0].kind).toBe("step");
+ expect(events[0].label).toBe("Read jarvis/core/config.py");
+ });
+
+ test("tells a sub-agent apart from an ordinary step", () => {
+ const events = readTranscript([
+ "● Read config.py",
+ "● Spawning agent: audit the wake path",
+ ]);
+
+ expect(events.map((e) => e.kind)).toEqual(["step", "subagent"]);
+ expect(subagentsOf(events)).toHaveLength(1);
+ });
+
+ test("never reorders and never invents a block", () => {
+ const lines = ["> one", "", "two", "", "● three"];
+ const events = readTranscript(lines);
+
+ expect(events.map((e) => e.text)).toEqual(["one", "two", "three"]);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/chat/chatTranscript.ts b/jarvis/ui/web/frontend/src/components/chat/chatTranscript.ts
new file mode 100644
index 0000000000..c71c524809
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/chat/chatTranscript.ts
@@ -0,0 +1,152 @@
+/**
+ * Turning a coding CLI's screen into a conversation.
+ *
+ * The pane behind this chat is real and stays real — a coding agent is only
+ * alive while something is attached to its pseudo-terminal — but nobody should
+ * have to READ a terminal to follow what their agent is doing. The backend
+ * already replays the screen into ordered, decoration-free lines
+ * (`jarvis/agentic_ide/transcript.py`); this classifies those lines into the
+ * four things a reader actually wants to tell apart:
+ *
+ * * what THEY said,
+ * * what the agent said back,
+ * * the steps it took to get there (tools, files, commands),
+ * * and the helpers it spawned to do it.
+ *
+ * ## Why classification and not parsing
+ *
+ * A TUI is a picture, not a protocol. There is no framing to parse and no
+ * guarantee a future release keeps any particular glyph, so this reads SHAPE —
+ * a leading prompt caret, a bullet, an indent — and never a product's exact
+ * wording. An unrecognised line is not dropped and not guessed at: it joins the
+ * current block as prose. That is the fail-safe direction. A classifier that
+ * discarded what it did not recognise would hide exactly the output that
+ * matters on the day a CLI changes something.
+ *
+ * The banner a CLI prints on startup is the one thing removed outright: it is
+ * the same eight lines every time, it is about the tool rather than the work,
+ * and leaving it in means every conversation opens on someone else's logo.
+ */
+
+/** What one block of the rendered conversation is. */
+export type ChatEventKind = "user" | "assistant" | "step" | "subagent" | "status";
+
+export interface ChatEvent {
+ kind: ChatEventKind;
+ /** Body text, already joined and trimmed of trailing blanks. */
+ text: string;
+ /** Short label for a step or sub-agent — the part worth showing collapsed. */
+ label?: string;
+}
+
+/**
+ * Lines a CLI prints about ITSELF rather than about the work.
+ *
+ * Matched loosely and case-insensitively on purpose: these are banners, and a
+ * banner that changes its capitalisation between releases should not start
+ * leaking back into the conversation.
+ */
+const BANNER = [
+ /^[\s│┃|]*claude code\b/i,
+ /^[\s│┃|]*codex\b.*\bv\d/i,
+ /^\s*opus\s|^\s*sonnet\s/i,
+ /^\s*~[\\/]/,
+ /^\s*\d+\s+mcp servers?\b/i,
+ /welcome to/i,
+ /^\s*auto mode (on|off)\b/i,
+ /shift\+tab to cycle/i,
+ /^\s*[←→]\s*\d+\s+agents?\s*$/i,
+ /^\s*for shortcuts\b/i,
+];
+
+/** A line the user typed, as the CLI echoes it back. */
+const USER_ECHO = /^[\s]*[>›❯]\s?(.*)$/;
+
+/**
+ * A step: the agent using a tool, reading a file, running something.
+ *
+ * Shape, not vocabulary — a bullet or a box-drawing lead-in followed by text.
+ * The label is the first clause, which is what a collapsed row shows.
+ */
+const STEP = /^[\s]*(?:[●•⏺✻✽◆▸▪·]|[-*]\s)\s*(.+)$/;
+
+/** A helper the agent started. Recognised by shape plus the ONE word that names it. */
+const SUBAGENT = /\b(sub-?agent|subagent|task tool|spawn(?:ed|ing)?\s+agent)\b/i;
+
+/** Spinner / elapsed-time rows a CLI repaints while it thinks. */
+const STATUS = /^[\s]*[✻✽✢*·]?\s*\w+…?\s*(?:for\s+\d+\s*s|\(\d+s\))/i;
+
+function isBanner(line: string): boolean {
+ return BANNER.some((pattern) => pattern.test(line));
+}
+
+/** First clause of a step, for the collapsed row. Never longer than a line. */
+function labelOf(text: string): string {
+ const cut = text.split(/[(:—]/)[0]?.trim() ?? text;
+ return (cut.length > 72 ? `${cut.slice(0, 72)}…` : cut) || text.slice(0, 72);
+}
+
+/**
+ * Group transcript lines into conversation blocks.
+ *
+ * Consecutive lines of the same kind become ONE block, because a paragraph the
+ * agent printed over four lines is one thing it said, not four. The order of
+ * the input is preserved exactly: this never reorders, and never invents a
+ * block that had no line behind it.
+ */
+export function readTranscript(lines: readonly string[]): ChatEvent[] {
+ const events: ChatEvent[] = [];
+ let current: ChatEvent | null = null;
+
+ const push = (kind: ChatEventKind, text: string, label?: string) => {
+ if (current && current.kind === kind && kind !== "user" && kind !== "step") {
+ current.text += `\n${text}`;
+ return;
+ }
+ current = { kind, text, label };
+ events.push(current);
+ };
+
+ for (const raw of lines) {
+ const line = raw.replace(/\s+$/, "");
+ if (!line.trim()) {
+ // A blank line ends the current block rather than joining it: it is the
+ // only paragraph break a terminal has.
+ current = null;
+ continue;
+ }
+ if (isBanner(line)) continue;
+
+ const echoed = USER_ECHO.exec(line);
+ if (echoed) {
+ const said = echoed[1].trim();
+ // The empty caret is the CLI's input box waiting, not something said.
+ if (said) push("user", said);
+ else current = null;
+ continue;
+ }
+
+ if (STATUS.test(line)) {
+ push("status", line.trim());
+ continue;
+ }
+
+ const step = STEP.exec(line);
+ if (step) {
+ const body = step[1].trim();
+ push(SUBAGENT.test(body) ? "subagent" : "step", body, labelOf(body));
+ continue;
+ }
+
+ // Anything else is the agent talking. Indented continuations join the block
+ // above them, which is what makes a wrapped paragraph read as a paragraph.
+ push("assistant", line.trim());
+ }
+
+ return events.filter((event) => event.text.trim().length > 0);
+}
+
+/** Sub-agents seen in a conversation, newest last — the right-hand panel's list. */
+export function subagentsOf(events: readonly ChatEvent[]): ChatEvent[] {
+ return events.filter((event) => event.kind === "subagent");
+}
diff --git a/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsx b/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsx
index 8435b45e0f..608a902898 100644
--- a/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsx
+++ b/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsx
@@ -31,6 +31,7 @@ import {
startIdeSession,
} from "@/lib/agenticIdeApi";
import { AgenticTerminal } from "@/components/agentic/AgenticTerminal";
+import { ChatStream } from "@/components/chat/ChatStream";
import { VoiceBubble } from "@/components/agentic/VoiceBubble";
import { getWSClient } from "@/hooks/useWebSocket";
import {
@@ -433,17 +434,34 @@ export function ChatWorkspaceView() {
* starts the agent AND shows what it is doing, and it brings the
* years of replay, scroll and resize fixes with it.
*/
- <div className="min-h-0 flex-1 px-4 pb-2">
- <AgenticTerminal
- key={open.chat.terminal}
- name={open.chat.terminal}
- workspaceId={workspaceId ?? undefined}
- displayName={open.chat.agent || "Agent"}
- appearance="dark"
- fontSize={13}
- active
- focused
- />
+ <div className="relative flex min-h-0 flex-1 flex-col">
+ {/*
+ The pane runs, and is not shown.
+
+ A coding agent lives only while something is attached to its
+ pseudo-terminal, so the terminal cannot go away — but nobody
+ should have to READ one to follow their own agent. It is kept
+ mounted underneath at full size (xterm needs real geometry to
+ pick its columns; a display:none pane reports zero and the CLI
+ wraps its output at nothing) and covered by the conversation.
+ Hidden from assistive technology too: the same words are right
+ there in the stream, in a better order.
+ */}
+ <div
+ className="pointer-events-none absolute inset-0 -z-10 overflow-hidden opacity-0"
+ aria-hidden
+ >
+ <AgenticTerminal
+ key={open.chat.terminal}
+ name={open.chat.terminal}
+ workspaceId={workspaceId ?? undefined}
+ displayName={open.chat.agent || "Agent"}
+ appearance="dark"
+ fontSize={13}
+ active
+ />
+ </div>
+ <ChatStream terminal={open.chat.terminal} />
</div>
) : (
<div className="flex min-h-0 flex-1 items-center justify-center overflow-y-auto scrollbar-jarvis px-6">