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.

fix(trace): stop the bounce and keep agent replies inside the turn

rubenluetke10-beep801a076ddbfe
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/AgentTimeline.tsx b/jarvis/ui/web/frontend/src/components/agentchat/AgentTimeline.tsx
index 75017ca51f..f387670b2d 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/AgentTimeline.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentchat/AgentTimeline.tsx
@@ -1,4 +1,4 @@
-import { Fragment, memo } from "react";
+import { Fragment, memo, useMemo } from "react";
import { ChatMarkdown, MediaPreview, mediaKind } from "@/components/agentchat/ChatMarkdown";
import { CircleAlert, FileText, ImageIcon } from "lucide-react";
import { InternalMessageBubble, type InternalParticipant } from "./InternalMessageBubble";
@@ -7,6 +7,8 @@ import { ProviderLogo } from "@/components/providers/ProviderLogo";
import { effortLabel } from "./AgentComposer";
import { TurnTrace, type Decide, type TraceLook } from "./WorkTrace";
import type { TimelineItem, TurnItem, TextBlock } from "./reduce";
+import { TraceMessageLine } from "./TraceTimeline";
+import { attachTurnMessages, type TraceMessage } from "./turnMessages";
import { useT } from "@/i18n";
import { cn } from "@/lib/utils";
@@ -44,10 +46,16 @@ export function AgentTimeline({
traceCompanion?: boolean;
}) {
const t = useT();
- const stamps = bubbles ? timeStamps(items) : null;
+ // On the rail look an agent's answer to a working turn is a quiet line in
+ // that turn's trace, so the reply stays the last thing in the chat.
+ const { items: shown, messagesByTurn } = useMemo(
+ () => traceLook === "rail" ? attachTurnMessages(items) : { items, messagesByTurn: NO_MESSAGES },
+ [items, traceLook],
+ );
+ const stamps = bubbles ? timeStamps(shown) : null;
return (
<>
- {items.map((item) => {
+ {shown.map((item) => {
const stamp = stamps?.get(item.id);
const node = renderItem(item);
return stamp ? (
@@ -200,6 +208,7 @@ export function AgentTimeline({
bubbles={bubbles}
traceLook={traceLook}
traceCompanion={traceCompanion}
+ messages={messagesByTurn.get(item.id)}
/>
);
}
@@ -240,10 +249,18 @@ function stampLabel(at: Date, now: Date): string {
return `${date}, ${time}`;
}
-const Turn = memo(function Turn({ turn, assistantName, providerLabel, onDecide, bubbles = false, traceLook, traceCompanion = false }: {
+const NO_MESSAGES = new Map<string, TraceMessage[]>();
+
+const Turn = memo(function Turn({ turn, assistantName, providerLabel, onDecide, bubbles = false, traceLook, traceCompanion = false, messages }: {
turn: TurnItem; assistantName: string; providerLabel: string; onDecide: Decide; bubbles?: boolean; traceLook: TraceLook; traceCompanion?: boolean;
+ /** Agent messages that arrived while this turn worked. */
+ messages?: TraceMessage[];
}) {
const t = useT();
+ const extras = useMemo(
+ () => messages?.map((message) => ({ key: message.id, node: <TraceMessageLine message={message} /> })),
+ [messages],
+ );
return <div className="flex min-w-0 flex-col gap-3" data-testid="agent-turn" data-message-id={turn.id} data-status={turn.status}>
{!bubbles && (
<div className="flex flex-wrap items-center gap-2 text-xs text-muted-foreground">
@@ -253,7 +270,7 @@ const Turn = memo(function Turn({ turn, assistantName, providerLabel, onDecide,
{turn.effort ? <span>{effortLabel(turn.effort, t)}</span> : null}
</div>
)}
- <TurnTrace turn={turn} look={traceLook} companion={traceCompanion} onDecide={onDecide} renderText={(text, id) => <Prose block={{ kind: "text", text, id }} />} />
+ <TurnTrace turn={turn} look={traceLook} companion={traceCompanion} extras={extras} onDecide={onDecide} renderText={(text, id) => <Prose block={{ kind: "text", text, id }} />} />
</div>;
});
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/TraceTimeline.test.tsx b/jarvis/ui/web/frontend/src/components/agentchat/TraceTimeline.test.tsx
index 848fd325a5..30f46fcf4f 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/TraceTimeline.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentchat/TraceTimeline.test.tsx
@@ -44,3 +44,25 @@ it("draws nothing for a turn whose only step is the brain call", () => {
render(<VoiceWorkTrace steps={[step({ id: "b", kind: "brain", labelKey: "thinking.step_brain", detail: "m" })]} durationMs={0} />);
expect(screen.queryByTestId("conversation-work-fold")).toBeNull();
});
+
+it("keeps a stretch at one line while its calls run, so the chat never jumps", async () => {
+ const { WorkTrace } = await import("./WorkTrace");
+ const call = (id: string, output: string | null) => ({
+ kind: "tool" as const, callId: id, name: "Bash", input: { command: `step ${id}` }, output,
+ isError: false, durationMs: output === null ? null : 100, approval: null, startedMs: 0,
+ });
+ const lines = () => document.querySelectorAll("[data-trace-entry='activity'] > *").length;
+ const { rerender } = render(<WorkTrace status="running" startedMs={0} durationMs={null} blocks={[call("a", null)]} />);
+ expect(lines()).toBe(1);
+ rerender(<WorkTrace status="running" startedMs={0} durationMs={null} blocks={[call("a", "ok"), call("b", null)]} />);
+ // The running call takes the stretch's one line; it is not added below it.
+ expect(lines()).toBe(1);
+ expect(document.querySelector(".trace-shimmer")?.textContent).toBe("step b");
+ rerender(<WorkTrace status="running" startedMs={0} durationMs={null} blocks={[call("a", "ok"), call("b", "ok")]} />);
+ expect(lines()).toBe(1);
+ expect(screen.getByRole("button", { name: /^Ran commands/ })).toBeTruthy();
+ // A failure says why on the same line.
+ rerender(<WorkTrace status="running" startedMs={0} durationMs={null} blocks={[{ ...call("a", "Exit code 1"), isError: true }]} />);
+ expect(lines()).toBe(1);
+ expect(screen.getByRole("button", { name: /step a.*Failed: Exit code 1/ })).toBeTruthy();
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/TraceTimeline.tsx b/jarvis/ui/web/frontend/src/components/agentchat/TraceTimeline.tsx
index 464503a2e1..ca55576aed 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/TraceTimeline.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentchat/TraceTimeline.tsx
@@ -1,5 +1,5 @@
import { useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react";
-import { ChevronRight, FilePlus2, FileText, FolderOpen, Globe, Image, Pencil, Search, SquareTerminal, Wrench } from "lucide-react";
+import { ChevronRight, FilePlus2, FileText, FolderOpen, Globe, Image, MessagesSquare, Pencil, Search, SquareTerminal, Wrench } from "lucide-react";
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
import { useT } from "@/i18n";
@@ -9,8 +9,9 @@ import { ToolChoiceIcon } from "./ToolChoiceChips";
import type { ToolChoice } from "./toolChoices";
import { toolIdentity, toolIdentityStyle } from "./toolIdentity";
import { traceToolIdentity } from "./traceActivity";
+import type { TraceMessage } from "./turnMessages";
import {
- buildTimeline, readableOutput, summarize, traceDuration, tr,
+ buildTimeline, readableOutput, traceDuration, tr,
type ActivityEntry, type Call, type ProseEntry, type Timeline,
} from "./traceEntries";
@@ -158,22 +159,26 @@ function Chevron({ open }: { open: boolean }) {
}
function ActivityView({ entry, renderers }: { entry: ActivityEntry; renderers: TimelineRenderers }) {
- const t = useT();
const [open, setOpen] = useState(false);
- const running = entry.calls.filter((call) => call.status === "running");
- const settled = entry.calls.filter((call) => call.status !== "running");
- if (entry.calls.length === 1) return <CallLine call={entry.calls[0]} renderers={renderers} />;
- const lang = t("trace_report.locale");
+ // A stretch is always exactly ONE line, as in the Codex app. While a call
+ // runs, that line IS the running call; when it settles, the line becomes
+ // the summary again. Drawing the running call as an extra line made the
+ // whole chat grow and shrink by a line on every call (the bounce bug).
+ const current = [...entry.calls].reverse().find((call) => call.status === "running");
+ if (entry.calls.length === 1 || current) {
+ return <div className="min-w-0" data-trace-entry="activity">
+ <CallLine call={current ?? entry.calls[0]} renderers={renderers} />
+ </div>;
+ }
return <div className="min-w-0" data-trace-entry="activity">
- {settled.length ? <button type="button" className={lineButton} aria-expanded={open} onClick={() => setOpen(!open)}>
- <StretchMark calls={settled} />
- <span className="min-w-0 truncate">{settled.length === entry.calls.length ? entry.summary : summarize(settled, t, lang)}</span>
+ <button type="button" className={lineButton} aria-expanded={open} onClick={() => setOpen(!open)}>
+ <StretchMark calls={entry.calls} />
+ <span className="min-w-0 truncate">{entry.summary}</span>
<Chevron open={open} />
- </button> : null}
+ </button>
{open ? <div className="mb-1 ml-[7px] min-w-0 border-l border-border pl-4">
- {settled.map((call) => <CallLine key={call.id} call={call} renderers={renderers} />)}
+ {entry.calls.map((call) => <CallLine key={call.id} call={call} renderers={renderers} />)}
</div> : null}
- {running.map((call) => <CallLine key={call.id} call={call} renderers={renderers} />)}
</div>;
}
@@ -192,11 +197,13 @@ function CallLine({ call, renderers }: { call: Call; renderers: TimelineRenderer
{call.added || call.removed ? <span className="shrink-0 font-mono text-xs tabular-nums">
<span className="diff-count-add">+{call.added}</span>{" "}<span className="diff-count-del">−{call.removed}</span>
</span> : null}
- {problem || quiet ? <span className={cn("shrink-0", problem ? "text-destructive" : "text-muted-foreground")}>{tr(t, `state.${call.status}`)}</span> : null}
+ {/* Why it failed reads on the same line: a line of its own would come
+ and go with the call and make the chat jump. */}
+ {problem || quiet ? <span className={cn("min-w-0 truncate", problem ? "text-destructive" : "text-muted-foreground")}
+ title={call.reason || undefined}>{tr(t, `state.${call.status}`)}{problem && call.reason ? `: ${call.reason}` : ""}</span> : null}
{!running ? <Chevron open={open} /> : null}
</button>
{/* Why a call failed reads without opening anything. */}
- {problem && call.reason && !open ? <p data-trace-reason className="-mt-1 mb-1 truncate pl-[26px] text-[13px] leading-5 text-destructive" title={call.reason}>{call.reason}</p> : null}
{open ? <div className="mb-2 ml-[7px] min-w-0 border-l border-border pl-4 pt-0.5"><CallDetails call={call} renderers={renderers} /></div> : null}
</div>;
}
@@ -228,3 +235,28 @@ function CallDetails({ call, renderers }: { call: Call; renderers: TimelineRende
{took}
</div>;
}
+
+/**
+ * An agent's message inside the turn that asked for it: one quiet line —
+ * who, then the first words — that opens to the whole message. The full
+ * text never stands in the chat as a card of its own.
+ */
+export function TraceMessageLine({ message }: { message: TraceMessage }) {
+ const t = useT();
+ const [open, setOpen] = useState(false);
+ const preview = message.text.replace(/[`*_#>]/g, "").replace(/\s+/g, " ").trim();
+ return <div className="min-w-0" data-trace-entry="message" data-outgoing={message.outgoing ? "" : undefined}>
+ <button type="button" className={lineButton} aria-expanded={open} onClick={() => setOpen(!open)}>
+ <MessagesSquare aria-hidden className={glyph} strokeWidth={1.75} />
+ <span className="shrink-0 text-foreground-secondary">{message.outgoing ? `→ ${message.name}` : message.name}</span>
+ <span className="min-w-0 flex-1 basis-0 truncate text-muted-foreground/70">{preview}</span>
+ {message.failed ? <span className="shrink-0 text-destructive">{tr(t, "state.failed")}</span> : null}
+ <Chevron open={open} />
+ </button>
+ {open ? <div className="mb-2 ml-[7px] min-w-0 border-l border-border pl-4 pt-0.5">
+ <div className="prose max-h-96 max-w-none overflow-auto trace-text text-muted-foreground dark:prose-invert [overflow-wrap:anywhere] prose-p:my-1 prose-p:text-muted-foreground prose-li:text-muted-foreground prose-strong:text-foreground-secondary [&>:first-child]:mt-0">
+ <ReactMarkdown remarkPlugins={[remarkGfm]}>{message.text}</ReactMarkdown>
+ </div>
+ </div> : null}
+ </div>;
+}
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.test.tsx b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.test.tsx
index d48e07cf1f..e899d62ec0 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.test.tsx
@@ -103,7 +103,7 @@ describe("work trace", () => {
// One quiet line for the stretch; the failure opens with it.
fireEvent.click(screen.getByRole("button", { name: /^Read files/ }));
fireEvent.click(screen.getByRole("button", { name: /^Read err\.ts.*Failed/ }));
- expect(screen.getByText("Failed: Permission denied")).toBeTruthy();
+ expect(screen.getAllByText("Failed: Permission denied").length).toBeGreaterThan(0);
expect(screen.getByRole("button", { name: "Approve" })).toBeTruthy();
});
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/turnMessages.test.tsx b/jarvis/ui/web/frontend/src/components/agentchat/turnMessages.test.tsx
new file mode 100644
index 0000000000..564f532f03
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentchat/turnMessages.test.tsx
@@ -0,0 +1,63 @@
+import { cleanup, fireEvent, render } from "@testing-library/react";
+import { afterEach, describe, expect, it } from "vitest";
+import type { AgentChatEvent } from "@/lib/agentChatApi";
+import { AgentTimeline } from "./AgentTimeline";
+import { EMPTY_TIMELINE, reduceEvents } from "./reduce";
+import { attachTurnMessages } from "./turnMessages";
+
+let seq = 0;
+const ev = (kind: string, payload: Record<string, unknown>, tsMs: number): AgentChatEvent =>
+ ({ seq: ++seq, ts_ms: tsMs, kind, payload }) as AgentChatEvent;
+afterEach(() => { cleanup(); seq = 0; });
+
+/** The shape of the 2026-10-03 audit turn: each reply arrived as an echo notice
+ * plus the message, a wrap-up repeated them, and the answer came last. */
+function auditTurn(): AgentChatEvent[] {
+ return [
+ ev("user_message", { text: "Run a new audit" }, 1000),
+ ev("turn_started", { turn_id: "t1", provider: "claude-api", model: "m", runner: "claude-cli", surface: "jarvis" }, 1001),
+ ev("tool_call", { turn_id: "t1", call_id: "c1", name: "mcp__jarvis__society_status", input: {} }, 1100),
+ ev("tool_result", { turn_id: "t1", call_id: "c1", output: "{}" }, 1200),
+ ev("notice", { kind: "society_message", agent_name: "X markring", status: "done", text: "Reply for Ruben, as of 3 Oct 2026" }, 2000),
+ ev("agent_message", { message_id: "m1", sender_name: "X markring", sender_kind: "agent", text: "Reply for Ruben, as of 3 Oct 2026", status: "queued" }, 2001),
+ ev("agent_message_status", { message_id: "m1", status: "delivered" }, 2002),
+ ev("assistant_text", { turn_id: "t1", message_id: "a1", text: "Two agents have answered so far." }, 3000),
+ ev("notice", { kind: "delegation_report", turn_id: "t1", agent_name: "X markring", status: "done", text: "Reply for Ruben, as of 3 Oct 2026" }, 4000),
+ ev("notice", { kind: "delegation_report", turn_id: "t1", agent_name: "Jarvis-Scout", status: "done", text: "Scout audit, read-only" }, 4001),
+ ev("assistant_text", { turn_id: "t1", message_id: "a2", text: "All agents have answered." }, 5000),
+ ev("turn_finished", { turn_id: "t1", status: "done", duration_ms: 4100, usage: {} }, 5100),
+ ];
+}
+
+describe("agent messages inside the turn that asked for them", () => {
+ it("moves each answer into its turn once, dropping the echo notices", () => {
+ const { items, messagesByTurn } = attachTurnMessages(reduceEvents(EMPTY_TIMELINE, auditTurn()).items);
+ expect(items.map((item) => item.type)).toEqual(["user", "turn"]);
+ expect(messagesByTurn.get(items[1].id)?.map((m) => m.name)).toEqual(["X markring", "Jarvis-Scout"]);
+ });
+
+ it("keeps a message outside any turn where it is, still without its echo", () => {
+ const { items } = attachTurnMessages(reduceEvents(EMPTY_TIMELINE, [
+ ev("notice", { kind: "society_message", agent_name: "Scout", status: "done", text: "Hi" }, 100),
+ ev("agent_message", { message_id: "m9", sender_name: "Scout", sender_kind: "agent", text: "Hi", status: "delivered" }, 101),
+ ]).items);
+ expect(items.map((item) => item.type)).toEqual(["internal"]);
+ });
+
+ it("draws the answers as quiet trace lines and keeps Jarvis's reply last", () => {
+ const { container } = render(<AgentTimeline items={reduceEvents(EMPTY_TIMELINE, auditTurn()).items} assistantName="Jarvis"
+ providerLabel={(id) => id} onDecide={() => undefined} bubbles traceLook="rail" />);
+ // No full-text cards: one line per answer, inside the turn.
+ const lines = Array.from(container.querySelectorAll<HTMLElement>("[data-trace-entry='message']"));
+ expect(lines.map((line) => line.textContent)).toEqual([
+ expect.stringContaining("X markring"), expect.stringContaining("Jarvis-Scout"),
+ ]);
+ expect(container.querySelector("[data-testid='agent-turn'] [data-trace-entry='message']")).toBeTruthy();
+ // The reply is the last words of the turn.
+ const turnText = container.querySelector("[data-testid='agent-turn']")!.textContent!;
+ expect(turnText.lastIndexOf("All agents have answered.")).toBeGreaterThan(turnText.lastIndexOf("Jarvis-Scout"));
+ // The whole message is one tap away.
+ fireEvent.click(lines[1].querySelector("button")!);
+ expect(lines[1].querySelector(".prose")?.textContent).toContain("Scout audit, read-only");
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/turnMessages.ts b/jarvis/ui/web/frontend/src/components/agentchat/turnMessages.ts
new file mode 100644
index 0000000000..9758276995
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentchat/turnMessages.ts
@@ -0,0 +1,105 @@
+import type { InternalMessageItem, NoticeItem, TimelineItem } from "./reduce";
+
+/** One agent message drawn inside a turn's trace. */
+export interface TraceMessage {
+ id: string;
+ /** Who wrote it — or, for a message Jarvis sent, who it went to. */
+ name: string;
+ /** True when Jarvis sent it ("→ X"); false when an agent wrote back. */
+ outgoing: boolean;
+ text: string;
+ failed: boolean;
+}
+
+export interface AttachedTimeline {
+ /** The timeline without the messages that moved into a turn. */
+ items: TimelineItem[];
+ /** Turn id → the messages drawn quietly inside that turn's trace. */
+ messagesByTurn: Map<string, TraceMessage[]>;
+}
+
+/** Notice kinds that only repeat what an agent message already carries. */
+const ECHO_KINDS = new Set(["society_message", "delegation_report"]);
+/** How close a society_message notice and its agent_message arrive. */
+const ECHO_WINDOW_MS = 5_000;
+/** Grace after a turn's last moment in which a reply still belongs to it. */
+const TURN_GRACE_MS = 2_000;
+
+function messageOf(item: InternalMessageItem): TraceMessage {
+ return {
+ id: item.id,
+ name: item.outgoing ? item.outgoing.recipientName : item.message.sender_name,
+ outgoing: Boolean(item.outgoing),
+ text: item.message.text,
+ failed: item.message.status === "failed",
+ };
+}
+
+function noticeMessage(item: NoticeItem): TraceMessage {
+ return { id: item.id, name: item.agentName, outgoing: false, text: item.text, failed: item.status === "blocked" };
+}
+
+/**
+ * Agents answering Jarvis belong to the work of the turn that asked them,
+ * not below its reply (maintainer, 2026-10-03: "the output of Jarvis is
+ * always at the bottom"). Every reply used to arrive twice — a
+ * `society_message` notice with the full text plus the agent message itself
+ * — and once more as a `delegation_report` when the turn wrapped up, each as
+ * its own block after the whole turn, so the answer sat above a wall of
+ * cards and had to be scrolled back to.
+ *
+ * Here each message that arrives while a turn is working moves into that
+ * turn (drawn as one quiet trace line that opens to the full text), and the
+ * echo notices that only repeat a message are dropped. A message outside any
+ * turn stays where it is, still without its echo.
+ */
+export function attachTurnMessages(items: TimelineItem[]): AttachedTimeline {
+ const messagesByTurn = new Map<string, TraceMessage[]>();
+ if (!items.some((item) => item.type === "internal" || (item.type === "notice" && ECHO_KINDS.has(item.kind)))) {
+ return { items, messagesByTurn };
+ }
+ const internals = items.filter((item): item is InternalMessageItem => item.type === "internal");
+ const isEcho = (notice: NoticeItem) => notice.kind === "society_message" && internals.some((item) =>
+ !item.outgoing && item.message.sender_name === notice.agentName && Math.abs(item.tsMs - notice.tsMs) <= ECHO_WINDOW_MS);
+
+ const kept: TimelineItem[] = [];
+ let turn: { id: string; endsMs: number } | null = null;
+ const attach = (turnId: string, message: TraceMessage) => {
+ const list = messagesByTurn.get(turnId) ?? [];
+ messagesByTurn.set(turnId, [...list, message]);
+ };
+ for (const item of items) {
+ if (item.type === "turn") {
+ turn = {
+ id: item.id,
+ endsMs: item.status === "running" || item.durationMs === null ? Number.POSITIVE_INFINITY : item.startedMs + item.durationMs + TURN_GRACE_MS,
+ };
+ kept.push(item);
+ continue;
+ }
+ if (item.type === "user") turn = null;
+ const inTurn = turn !== null && item.type !== "user" && "tsMs" in item && item.tsMs <= turn.endsMs;
+ if (item.type === "notice" && ECHO_KINDS.has(item.kind)) {
+ if (isEcho(item)) continue;
+ if (item.kind === "delegation_report" && turn !== null && inTurn) {
+ // The wrap-up repeats each agent's answer; keep it only for an agent
+ // whose answer did not arrive as a message of its own.
+ const already = messagesByTurn.get(turn.id)?.some((m) => m.name === item.agentName && !m.outgoing);
+ if (!already) attach(turn.id, noticeMessage(item));
+ continue;
+ }
+ if (turn !== null && inTurn) {
+ attach(turn.id, noticeMessage(item));
+ continue;
+ }
+ kept.push(item);
+ continue;
+ }
+ if (item.type === "internal" && turn !== null && inTurn) {
+ attach(turn.id, messageOf(item));
+ continue;
+ }
+ kept.push(item);
+ }
+ return { items: kept, messagesByTurn };
+}
diff --git a/jarvis/ui/web/frontend/src/components/home/TurnSteps.test.tsx b/jarvis/ui/web/frontend/src/components/home/TurnSteps.test.tsx
index eaf9c6e7c2..441b3c8642 100644
--- a/jarvis/ui/web/frontend/src/components/home/TurnSteps.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/home/TurnSteps.test.tsx
@@ -8,7 +8,7 @@ it("keeps brief voice errors visible", () => {
expect(traceWorthShowing(steps, 20, false)).toBe(true);
render(<TurnSteps steps={steps} durationMs={20} />);
// A failed step says why under its own line.
- expect(screen.getByText("Connection lost")).toBeTruthy();
+ expect(screen.getByText(/Connection lost/)).toBeTruthy();
});
it("does not hide live work with no events", () => {
const { rerender, container } = render(<TurnSteps steps={[]} />);
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/ChatActivity.test.tsx b/jarvis/ui/web/frontend/src/components/society/chat/ChatActivity.test.tsx
index 3db7d5baa4..63a6e9ce6e 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/ChatActivity.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/ChatActivity.test.tsx
@@ -61,11 +61,11 @@ it("keeps live and interrupted conversation tools in the left lane", () => {
{ kind: "text", id: "reply", text: "I will send the mail next." },
live,
]} />);
- // Like the Codex app, nothing folds: the model's words, the reply and the
- // call that never returned all stay in view, in order.
+ // Like the Codex app, nothing folds: the model's words, the call that
+ // never returned and the reply all stay in view — the reply last.
const text = screen.getByTestId("work-trace").textContent!;
- expect(text.indexOf("Inspect archive.")).toBeLessThan(text.indexOf("I will send the mail next."));
- expect(text.indexOf("I will send the mail next.")).toBeLessThan(text.indexOf("Searched for archive"));
+ expect(text.indexOf("Inspect archive.")).toBeLessThan(text.indexOf("Searched for archive"));
+ expect(text.indexOf("Searched for archive")).toBeLessThan(text.indexOf("I will send the mail next."));
expect(text).toContain("Stopped");
expect(container.querySelectorAll(".mx-auto")).toHaveLength(0);
expect(screen.getByTestId("work-trace").className).toMatch(/self-start/);
@@ -83,7 +83,7 @@ it("keeps a failure in view beside the reply, its reason under its line", () =>
// One quiet line for the stretch; it opens to the calls, and the failed
// one says why under its own line.
fireEvent.click(screen.getByRole("button", { name: /^Read files$/ }));
- expect(screen.getByText("Upload failed")).toBeTruthy();
+ expect(screen.getByText(/: Upload failed/)).toBeTruthy();
// The raw output stays one tap further, under the call.
expect(screen.queryByText("Report contents")).toBeNull();
fireEvent.click(screen.getAllByRole("button", { name: /^Read report\.csv/ })[0]);
@@ -97,7 +97,7 @@ it("keeps a pending approval actionable in the conversation style", () => {
{ ...base, callId: "approval", isError: false, output: null, approval: { approvalId: "ap", summary: "Send this message?", decision: null } },
]} onDecide={() => undefined} />);
// The failed call says why on its own line; the approval needs a tap.
- expect(screen.getByText("Delivery failed")).toBeTruthy();
+ expect(screen.getByText(/: Delivery failed/)).toBeTruthy();
expect(screen.getByText("Send this message?")).toBeTruthy();
expect(screen.getByRole("button", { name: "Approve" })).toBeTruthy();
});
@@ -114,7 +114,7 @@ it("shows agent message direction and truthful delivery state without preview cl
expect(screen.getByRole("alert").textContent).toBe("Connection closed");
});
-it("keeps work after the reply after it, without reordering the conversation", () => {
+it("keeps the reply last, even when work followed it", () => {
const tool: ToolBlock = { kind: "tool", callId: "a", name: "read_file", input: { path: "report.csv" }, output: "Report contents", isError: false, durationMs: 100, approval: null, startedMs: 0 };
const blocks = [tool, { ...tool, callId: "b", name: "write_file" }, { kind: "text" as const, id: "reply", text: "Your report is ready." }, { ...tool, callId: "error", isError: true, output: "Upload failed" }];
const { rerender } = render(<WorkTrace conversation status="running" startedMs={0} durationMs={null} blocks={blocks} />);
@@ -123,10 +123,11 @@ it("keeps work after the reply after it, without reordering the conversation", (
rerender(<WorkTrace conversation status="done" startedMs={0} durationMs={1000} blocks={blocks} />);
const text = screen.getByTestId("work-trace").textContent ?? "";
expect(text.indexOf("Read a file, created a file")).toBeLessThan(text.indexOf("Your report is ready."));
- expect(text.indexOf("Your report is ready.")).toBeLessThan(text.indexOf("Read report.csv"));
+ // The call after the reply is drawn above it: nobody scrolls back up for the answer.
+ expect(text.indexOf("Read report.csv")).toBeLessThan(text.indexOf("Your report is ready."));
expect(screen.getAllByText("Your report is ready.")).toHaveLength(1);
// The call after the reply failed and says why without opening anything.
- expect(screen.getByText("Upload failed")).toBeTruthy();
+ expect(screen.getByText(/: Upload failed/)).toBeTruthy();
// Each stretch opens to its calls, and closes again.
const stretch = screen.getByRole("button", { name: /^Read a file, created a file/ });
fireEvent.click(stretch);