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(chat): draw memory receipts inside the turn's trace, above the reply

rubenluetke10-beep74247dc98798
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsx b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsx
index 7789cb2acb..fb6408f9c9 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsx
@@ -616,9 +616,15 @@ type WorkTraceProps = {
* and coding-pane traces keep the plain node.
*/
companion?: boolean;
+ /**
+ * Steps that belong to this turn's work but are not blocks of it (a
+ * memory receipt posted after the turn). They sit on the trace above the
+ * reply and never below it.
+ */
+ extras?: { key: string; node: ReactNode }[];
};
-function WorkTraceBody({ blocks: rawBlocks, status, startedMs, durationMs, error, onDecide, renderText, className, receipt, completionLabel, conversation = false, companion = false }: WorkTraceProps) {
+function WorkTraceBody({ blocks: rawBlocks, status, startedMs, durationMs, error, onDecide, renderText, className, receipt, completionLabel, conversation = false, companion = false, extras }: WorkTraceProps) {
const t = useT();
const rail = useRail();
const blocks = useMemo(() => withoutQuestionPolls(rawBlocks), [rawBlocks]);
@@ -648,7 +654,7 @@ function WorkTraceBody({ blocks: rawBlocks, status, startedMs, durationMs, error
const restGroups = useMemo(() => fold ? groupConversationTrace(fold.answer) : null, [fold]);
// While a turn runs, its replies and streaming pieces stay live rows; once
// it is done, text before the answer reads as the timeline's narration and
- // anything after the answer follows it.
+ // anything after the answer sits above it too: the answer is always last.
const timeline = useTimeline(rail ? (split ? split.work : blocks) : NO_BLOCKS, status, live);
const afterAnswer = useTimeline(rail && split ? split.after : NO_BLOCKS, status, live);
const answerGroups = useMemo(() => rail && split ? groupConversationTrace(split.answer) : null, [rail, split]);
@@ -698,10 +704,21 @@ function WorkTraceBody({ blocks: rawBlocks, status, startedMs, durationMs, error
: <div className="prose prose-sm max-w-none text-foreground dark:prose-invert [overflow-wrap:anywhere]"><ChatMarkdown text={text} /></div>,
renderDetails: (block) => <ToolDetails block={block} />,
};
+ const work = timelineItems(timeline, renderers);
+ // A live turn's streaming reply is the timeline's tail; extra steps go
+ // above it, as they go above the finished answer.
+ let extraAt = work.length;
+ if (!split) while (extraAt > 0 && !work[extraAt - 1].rail) extraAt--;
+ const extraItems: RailItem[] = (extras ?? []).map((extra) => ({ key: `extra:${extra.key}`, node: extra.node, rail: true }));
const items: RailItem[] = [
- ...timelineItems(timeline, renderers),
- ...(answerGroups ? traceGroupItems({ groups: answerGroups, ...groupProps }) : []),
+ ...work.slice(0, extraAt),
+ ...extraItems,
+ ...work.slice(extraAt),
+ // Work that came after the reply is still work: it goes above the
+ // reply, which is always the last thing the turn shows (maintainer,
+ // 2026-10-03 — nobody should scroll back up to find the answer).
...timelineItems(afterAnswer, renderers),
+ ...(answerGroups ? traceGroupItems({ groups: answerGroups, ...groupProps }) : []),
];
if (visibleError) items.push(errorItem(visibleError, "trace:error"));
items.push(statusItem);
@@ -719,6 +736,7 @@ function WorkTraceBody({ blocks: rawBlocks, status, startedMs, durationMs, error
{classicGroups(groups)}
{foldedError ? <p role="alert" className="py-2 text-sm text-destructive [overflow-wrap:anywhere]">{foldedError}</p> : null}
</ConversationWorkFold> : classicGroups(groups)}
+ {extras?.map((extra) => <Fragment key={`extra:${extra.key}`}>{extra.node}</Fragment>)}
{restGroups ? classicGroups(restGroups) : null}
{visibleError ? <p role="alert" className="py-2 text-sm text-destructive [overflow-wrap:anywhere]">{visibleError}</p> : null}
<div role="status" aria-live="polite" className={cn("flex flex-wrap items-center gap-2 text-xs text-muted-foreground", conversation ? "px-1 pb-2 pt-1" : "border-t border-border pt-3", status === "error" && "text-destructive")}>
@@ -730,7 +748,7 @@ function WorkTraceBody({ blocks: rawBlocks, status, startedMs, durationMs, error
</div>;
}
-export function TurnTrace({ turn, ...props }: { turn: TurnItem; onDecide?: Decide; renderText?: (text: string, id: string) => ReactNode; conversation?: boolean; look?: TraceLook; companion?: boolean }) {
+export function TurnTrace({ turn, ...props }: { turn: TurnItem; onDecide?: Decide; renderText?: (text: string, id: string) => ReactNode; conversation?: boolean; look?: TraceLook; companion?: boolean; extras?: WorkTraceProps["extras"] }) {
const t = useT();
const tokens = outputTokens(turn.usage ?? turn.liveUsage);
const answered = turn.blocks.some(block => block.kind === "text" && block.text.trim());
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx
index b0fa3b4770..de8729e2ff 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx
@@ -1,6 +1,7 @@
import { PairConversationBoundary } from "@/components/agentchat/PairConversation";
import { AgentMessageActivity, ChatActivity, RoutineActivity, routineTask } from "./ChatActivity";
import { MemoryUpdateNotice } from "./MemoryUpdateNotice";
+import { foldMemoryNotices } from "./memoryNotices";
import { mergeOutgoingMessages, useOutgoingMessages } from "@/components/agentchat/useOutgoingMessages";
/**
* The model card's chat column, kept deliberately plain (maintainer,
@@ -653,7 +654,7 @@ function EffortPicker() {
// ---------------------------------------------------------------------------
export function Transcript({
- items,
+ items: rawItems,
agent,
roster,
onDecide,
@@ -665,6 +666,8 @@ export function Transcript({
}) {
const t = useT();
const sessionId = useAgentChat((state) => state.activeSessionId);
+ // Memory receipts are drawn inside the turn they follow, above its reply.
+ const { items, memoryByTurn } = useMemo(() => foldMemoryNotices(rawItems), [rawItems]);
// Follow the newest while the view sits at the end — the rule every
// conversation surface shares (hooks/useStickToBottom). This used to scroll
// a bottom sentinel into view on `[items.length, busy]` only, so a
@@ -706,7 +709,7 @@ export function Transcript({
) : item.type === "user" ? (
<UserBubble item={item} agentId={agent.agentId} sessionId={sessionId ?? agent.chatSessionId ?? undefined} />
) : item.type === "turn" ? (
- <TurnBubble item={item} onDecide={onDecide} />
+ <TurnBubble item={item} memory={memoryByTurn.get(item.id)} onDecide={onDecide} />
) : item.type === "notice" ? (
item.kind === "proposal" ? (
<ProposalCard item={item} />
@@ -964,12 +967,18 @@ export function UserBubble({ item, agentId, sessionId }: { item: UserItem; agent
function TurnBubble({
item,
+ memory,
onDecide,
}: {
item: TurnItem;
+ memory?: NoticeItem[];
onDecide: (approvalId: string, decision: ApprovalDecision) => Promise<void>;
}) {
- return <TurnTrace turn={item} conversation onDecide={onDecide} renderText={(text) => <Prose text={text} />} />;
+ const extras = useMemo(
+ () => memory?.map((notice) => ({ key: notice.id, node: <MemoryUpdateNotice item={notice} inTrace /> })),
+ [memory],
+ );
+ return <TurnTrace turn={item} conversation extras={extras} onDecide={onDecide} renderText={(text) => <Prose text={text} />} />;
}
/**
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/MemoryUpdateNotice.tsx b/jarvis/ui/web/frontend/src/components/society/chat/MemoryUpdateNotice.tsx
index 4b36133477..26df5972d2 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/MemoryUpdateNotice.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/MemoryUpdateNotice.tsx
@@ -1,11 +1,16 @@
import { lazy, Suspense, useState } from "react";
-import { ChevronRight, FileText } from "lucide-react";
+import { ChevronRight, FilePenLine, FileText } from "lucide-react";
import type { NoticeItem } from "@/components/agentchat/reduce";
import { useT } from "@/i18n";
const MemoryFileViewer = lazy(() => import("./MemoryFileViewer").then(module => ({ default: module.MemoryFileViewer })));
-export function MemoryUpdateNotice({ item }: { item: NoticeItem }) {
+/**
+ * The "Memory updated" receipt. Inside a turn (`inTrace`) it is one quiet
+ * step of the reasoning trace, drawn like a tool row; standalone (no turn
+ * before it) it keeps the centred chip.
+ */
+export function MemoryUpdateNotice({ item, inTrace = false }: { item: NoticeItem; inTrace?: boolean }) {
const t = useT();
const [open, setOpen] = useState(false);
const path = typeof item.data.path === "string" ? item.data.path : "";
@@ -13,12 +18,21 @@ export function MemoryUpdateNotice({ item }: { item: NoticeItem }) {
const after = typeof item.data.after === "string" ? item.data.after : undefined;
const patch = Array.isArray(item.data.markdown_diff) && item.data.markdown_diff.every(line => typeof line === "string") ? item.data.markdown_diff as string[] : undefined;
if (!path.startsWith(`society/${item.agentId}/`) || path.split("/").includes("..")) return null;
+ const label = `${t("society.chat.memory_updated")} · ${path.split("/").at(-1)}`;
return <>
- <button type="button" onClick={() => setOpen(true)} className="mx-auto my-3 flex max-w-[min(100%,36rem)] select-none items-center gap-2 rounded-lg bg-secondary px-3 py-2 text-left text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
- <FileText size={14} aria-hidden className="shrink-0" />
- <span className="truncate">{t("society.chat.memory_updated")} · {path.split("/").at(-1)}</span>
- <ChevronRight size={14} aria-hidden className="shrink-0 text-muted-foreground" />
- </button>
+ {inTrace ? (
+ <button type="button" onClick={() => setOpen(true)} data-trace-memory={item.id} className="group/trace flex w-full min-w-0 items-start gap-3 rounded-md py-1 text-left text-sm leading-6 text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
+ <span aria-hidden className="trace-node"><FilePenLine className="h-3.5 w-3.5 shrink-0" /></span>
+ <span className="min-w-0 flex-1 truncate text-foreground-secondary">{label}</span>
+ <ChevronRight aria-hidden className="mt-[5px] h-3.5 w-3.5 shrink-0 opacity-40 transition group-hover/trace:opacity-90" />
+ </button>
+ ) : (
+ <button type="button" onClick={() => setOpen(true)} className="mx-auto my-3 flex max-w-[min(100%,36rem)] select-none items-center gap-2 rounded-lg bg-secondary px-3 py-2 text-left text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
+ <FileText size={14} aria-hidden className="shrink-0" />
+ <span className="truncate">{label}</span>
+ <ChevronRight size={14} aria-hidden className="shrink-0 text-muted-foreground" />
+ </button>
+ )}
{open && <Suspense fallback={null}><MemoryFileViewer path={path} before={before} after={after} patch={patch} onClose={() => setOpen(false)} /></Suspense>}
</>;
}
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/memoryNotices.test.tsx b/jarvis/ui/web/frontend/src/components/society/chat/memoryNotices.test.tsx
new file mode 100644
index 0000000000..5819024e56
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/chat/memoryNotices.test.tsx
@@ -0,0 +1,48 @@
+import { cleanup, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it } from "vitest";
+import { WorkTrace } from "@/components/agentchat/WorkTrace";
+import type { NoticeItem, TimelineItem, TurnBlock, TurnItem } from "@/components/agentchat/reduce";
+import { foldMemoryNotices } from "./memoryNotices";
+
+const turn = (id: string): TurnItem => ({ type: "turn", id, blocks: [], status: "done", startedMs: 1, durationMs: 1 } as unknown as TurnItem);
+const notice = (id: string, kind = "memory_updated"): NoticeItem => ({
+ type: "notice", id, kind, text: "Memory updated", agentName: "Scout", agentId: "scout", status: "done", tsMs: 2, resolved: "", data: {},
+});
+const user = (id: string): TimelineItem => ({ type: "user", id, text: "hi", attachments: [], tsMs: 1 } as unknown as TimelineItem);
+afterEach(cleanup);
+
+describe("memory receipts", () => {
+ it("move into the nearest earlier turn and never stay below it", () => {
+ const items: TimelineItem[] = [user("u1"), turn("t1"), notice("m1"), user("u2"), notice("m2"), turn("t2"), notice("m3"), notice("r", "society_result")];
+ const folded = foldMemoryNotices(items);
+ expect(folded.items.map((item) => item.id)).toEqual(["u1", "t1", "u2", "t2", "r"]);
+ expect(folded.memoryByTurn.get("t1")?.map((n) => n.id)).toEqual(["m1", "m2"]);
+ expect(folded.memoryByTurn.get("t2")?.map((n) => n.id)).toEqual(["m3"]);
+ });
+
+ it("keeps a receipt with no earlier turn where it is", () => {
+ const items: TimelineItem[] = [notice("m0"), user("u1")];
+ expect(foldMemoryNotices(items).items).toEqual(items);
+ expect(foldMemoryNotices([notice("m0"), turn("t1")]).items.map((item) => item.id)).toEqual(["m0", "t1"]);
+ });
+
+ it("draws trace extras above the reply, finished or still streaming", () => {
+ const thought: TurnBlock = { kind: "reasoning", id: "think", text: "Plan.", live: false, durationMs: 1000, startedMs: 1 };
+ const answer: TurnBlock = { kind: "text", id: "answer", text: "Final reply." };
+ const extras = [{ key: "m1", node: <span>MEMORY-STEP</span> }];
+ const order = () => {
+ const html = document.body.innerHTML;
+ return [html.indexOf("Plan."), html.indexOf("MEMORY-STEP"), html.indexOf("Final reply.")];
+ };
+ const { rerender } = render(<WorkTrace conversation blocks={[thought, answer]} status="done" startedMs={1} durationMs={2000} extras={extras} />);
+ expect(screen.getByText("MEMORY-STEP")).toBeTruthy();
+ let [plan, memory, reply] = order();
+ expect(memory).toBeGreaterThan(-1);
+ expect(memory).toBeLessThan(reply);
+ rerender(<WorkTrace conversation blocks={[{ ...thought, live: true }, answer]} status="running" startedMs={1} durationMs={null} extras={extras} />);
+ [plan, memory, reply] = order();
+ expect(memory).toBeGreaterThan(-1);
+ expect(memory).toBeLessThan(reply);
+ expect(plan).toBeLessThan(memory);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/memoryNotices.ts b/jarvis/ui/web/frontend/src/components/society/chat/memoryNotices.ts
new file mode 100644
index 0000000000..a82d606c14
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/chat/memoryNotices.ts
@@ -0,0 +1,35 @@
+import type { NoticeItem, TimelineItem } from "@/components/agentchat/reduce";
+
+const NO_NOTICES: NoticeItem[] = [];
+
+export interface FoldedTimeline {
+ /** The timeline without the memory receipts that moved into a turn. */
+ items: TimelineItem[];
+ /** Turn id → the memory receipts drawn inside that turn's trace. */
+ memoryByTurn: Map<string, NoticeItem[]>;
+}
+
+/**
+ * A memory receipt belongs to the work of the turn before it, never below
+ * the reply (maintainer, 2026-10-03). Background reviews post the receipt as
+ * its own notice, often after the reply has landed, so each `memory_updated`
+ * notice moves into the nearest earlier turn and is drawn in that turn's
+ * trace above its answer. A receipt with no earlier turn stays where it is.
+ */
+export function foldMemoryNotices(items: TimelineItem[]): FoldedTimeline {
+ const memoryByTurn = new Map<string, NoticeItem[]>();
+ if (!items.some((item) => item.type === "notice" && item.kind === "memory_updated")) {
+ return { items, memoryByTurn };
+ }
+ const kept: TimelineItem[] = [];
+ let lastTurnId: string | null = null;
+ for (const item of items) {
+ if (item.type === "turn") lastTurnId = item.id;
+ if (item.type === "notice" && item.kind === "memory_updated" && lastTurnId !== null) {
+ memoryByTurn.set(lastTurnId, [...(memoryByTurn.get(lastTurnId) ?? NO_NOTICES), item]);
+ continue;
+ }
+ kept.push(item);
+ }
+ return { items: kept, memoryByTurn };
+}