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): show outgoing agent replies in their own timeline

rubenluetke10-beep5685edee1ee3
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/InternalMessageBubble.tsx b/jarvis/ui/web/frontend/src/components/agentchat/InternalMessageBubble.tsx
index bea14c714d..538a15e7fd 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/InternalMessageBubble.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentchat/InternalMessageBubble.tsx
@@ -99,9 +99,13 @@ export function InternalMessageBubble({
const shown = !foldable || open;
const senderName = sender?.name || item.message.sender_name;
- const toName = recipient?.name || recipientName || "";
+ const toName = item.outgoing?.recipientName || recipient?.name || recipientName || "";
+ const counterpart = item.outgoing
+ ? { id: item.outgoing.recipientId, name: toName }
+ : { id: item.message.sender_id, name: senderName };
const status = item.message.status;
- const statusLabel = t(`agent_chat.delivery_${status}`);
+ const statusLabel = item.outgoing && status !== "failed"
+ ? t("agent_chat.delivery_sent") : t(`agent_chat.delivery_${status}`);
const statusTone =
status === "failed"
? "text-destructive"
@@ -118,7 +122,7 @@ export function InternalMessageBubble({
>
<button
type="button"
- onClick={() => canOpenPair ? openPair?.({ id: item.message.sender_id, name: senderName }) : foldable && setOpen((v) => !v)}
+ onClick={() => canOpenPair ? openPair?.(counterpart) : foldable && setOpen((v) => !v)}
aria-expanded={!canOpenPair && foldable ? open : undefined}
aria-label={
canOpenPair ? t("agent_chat.pair_open") : foldable
@@ -172,7 +176,7 @@ export function InternalMessageBubble({
) : null}
</span>
</button>
- <div className="px-3 pb-2.5 pl-[30px]" onClick={canOpenPair ? () => openPair?.({ id: item.message.sender_id, name: senderName }) : undefined} style={canOpenPair ? { cursor: "pointer" } : undefined}>
+ <div className="px-3 pb-2.5 pl-[30px]" onClick={canOpenPair ? () => openPair?.(counterpart) : undefined} style={canOpenPair ? { cursor: "pointer" } : undefined}>
{shown ? (
<div data-testid="agent-message-internal-full" className="whitespace-pre-wrap text-sm leading-relaxed text-foreground [overflow-wrap:anywhere]">
<ChatMarkdown text={text} />
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/reduce.ts b/jarvis/ui/web/frontend/src/components/agentchat/reduce.ts
index afba5e88eb..9622b04d51 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/reduce.ts
+++ b/jarvis/ui/web/frontend/src/components/agentchat/reduce.ts
@@ -146,6 +146,8 @@ export interface InternalMessageItem {
id: string;
message: InternalMessage;
tsMs: number;
+ /** Board-backed outbound receipt; it is never input to the receiving model. */
+ outgoing?: { recipientId: string; recipientName: string };
}
export type TimelineItem = UserItem | TurnItem | ErrorItem | NoticeItem | InternalMessageItem;
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/useOutgoingMessages.test.tsx b/jarvis/ui/web/frontend/src/components/agentchat/useOutgoingMessages.test.tsx
new file mode 100644
index 0000000000..d3285bc62b
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentchat/useOutgoingMessages.test.tsx
@@ -0,0 +1,82 @@
+import { act, cleanup, fireEvent, render, renderHook, screen, waitFor, within } from "@testing-library/react";
+import { afterEach, expect, it, vi } from "vitest";
+import type { SocietyEnvelope } from "@/lib/societyApi";
+import { collectOutgoing, mergeOutgoingMessages, useOutgoingMessages } from "./useOutgoingMessages";
+import { InternalMessageBubble } from "./InternalMessageBubble";
+import { PairConversationBoundary } from "./PairConversation";
+import type { InternalMessageItem, TimelineItem } from "./reduce";
+
+vi.mock("@/i18n", () => ({ useT: () => (key: string) => key }));
+vi.mock("@/hooks/useStickToBottom", () => ({ useStickToBottom: () => ({ rootRef: { current: null }, contentRef: { current: null }, atEnd: true, jumpToEnd: () => {}, follow: () => {} }) }));
+const names = new Map([["jarvis", "Jarvis"], ["nala", "Nala"], ["scout", "Scout"]]);
+function row(seq: number, from = "nala", to: string | null = "jarvis", kind: SocietyEnvelope["msg_type"] = "ANSWER"): SocietyEnvelope {
+ return { seq, event_id: `m${seq}`, msg_type: kind, from_agent: from, to_agent: to,
+ trace_id: "t", parent_event_id: null, ts_ms: seq * 1000, cost_usd: 0, payload: { text: `Reply ${seq}` } };
+}
+afterEach(() => { cleanup(); vi.unstubAllGlobals(); vi.useRealTimers(); });
+
+it.each(["nala", "scout"])("shows %s's outgoing replies in chronological order without duplicates", (id) => {
+ const original: TimelineItem[] = [{ type: "user", id: "u", text: "Hello", tsMs: 500, attachments: [] },
+ { type: "notice", id: "n", kind: "done", text: "Done", agentId: id, agentName: id, status: "done", tsMs: 3000, data: {}, resolved: "" }];
+ const events = collectOutgoing([], [row(1, id), row(2, id, "jarvis", "SAY"), row(3, "unrelated"), row(4, id, null), row(5, id, "jarvis", "RESULT")], id);
+ const items = mergeOutgoingMessages(original, events, id, names.get(id)!, names);
+ expect(items.map((item) => item.id)).toEqual(["u", "m1", "m2", "n"]);
+ expect((items[1] as InternalMessageItem).outgoing).toEqual({ recipientId: "jarvis", recipientName: "Jarvis" });
+ expect(mergeOutgoingMessages(items, events, id, id, names)).toBe(items);
+ expect(original).toHaveLength(2);
+});
+
+it("updates an outgoing receipt on a delivery veto without inventing delivered status", () => {
+ const sent = collectOutgoing([], [row(1)], "nala");
+ const veto = { ...row(2, "scheduler", "nala", "VETO"), parent_event_id: "m1", payload: { text: "Target paused" } };
+ const events = collectOutgoing(sent, [veto], "nala");
+ const item = mergeOutgoingMessages([], events, "nala", "Nala", names)[0] as InternalMessageItem;
+ expect(item.message.status).toBe("failed");
+ render(<InternalMessageBubble item={item} />);
+ expect(screen.getByText("Target paused")).toBeTruthy();
+ expect(screen.getByText("agent_chat.delivery_failed")).toBeTruthy();
+});
+
+it("opens the recipient conversation from an outgoing card and preserves the draft", async () => {
+ vi.stubGlobal("fetch", async () => ({ ok: true, json: async () => ({ events: [row(1)] }) }));
+ const item = mergeOutgoingMessages([], [row(1)], "nala", "Nala", names)[0] as InternalMessageItem;
+ render(<PairConversationBoundary recipient={{ id: "nala", name: "Nala" }}>
+ <InternalMessageBubble item={item} /><input aria-label="Draft" defaultValue="Keep this" />
+ </PairConversationBoundary>);
+ expect(screen.getByText("Nala")).toBeTruthy();
+ expect(screen.getByText("Jarvis")).toBeTruthy();
+ expect(screen.getByText("agent_chat.delivery_sent")).toBeTruthy();
+ expect(screen.queryByText("agent_chat.delivery_delivered")).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: "agent_chat.pair_open" }));
+ const conversation = await screen.findByTestId("agent-pair-conversation");
+ await within(conversation).findByText("Reply 1");
+ fireEvent.click(screen.getAllByRole("button", { name: "agent_chat.pair_close" })[0]);
+ expect((screen.getByRole("textbox") as HTMLInputElement).value).toBe("Keep this");
+});
+
+it("pages the archive, polls new replies, and ignores late data from a previous agent", async () => {
+ const calls: string[] = [];
+ let late: ((value: unknown) => void) | undefined;
+ vi.stubGlobal("fetch", async (url: string) => {
+ calls.push(url);
+ if (calls.length === 3) return new Promise((resolve) => { late = resolve; });
+ return { ok: true, json: async () => ({ events: url.includes("after_seq=0&")
+ ? Array.from({ length: 1000 }, (_, index) => row(index + 1, index === 0 ? "nala" : "other"))
+ : [row(1001)] }) };
+ });
+ const { result, rerender } = renderHook(({ id }) => useOutgoingMessages(id), { initialProps: { id: "nala" } });
+ await waitFor(() => expect(result.current).toHaveLength(2));
+ expect(calls[1]).toContain("after_seq=1000&");
+ vi.useFakeTimers();
+ // The first poll was scheduled with real timers; changing agent starts a new read.
+ rerender({ id: "scout" });
+ expect(result.current).toEqual([]);
+ rerender({ id: "nala" });
+ await act(async () => {
+ late?.({ ok: true, json: async () => ({ events: [row(2000, "scout")] }) });
+ });
+ expect(result.current.every((event) => event.from_agent === "nala")).toBe(true);
+ await act(async () => { await vi.advanceTimersByTimeAsync(5000); });
+ expect(calls.at(-1)).toContain("after_seq=1001&");
+ expect(result.current.map((event) => event.event_id)).toEqual(["m1", "m1001"]);
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/useOutgoingMessages.ts b/jarvis/ui/web/frontend/src/components/agentchat/useOutgoingMessages.ts
new file mode 100644
index 0000000000..5607d32973
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentchat/useOutgoingMessages.ts
@@ -0,0 +1,85 @@
+import { useEffect, useMemo, useState } from "react";
+import type { SocietyEnvelope } from "@/lib/societyApi";
+import type { InternalMessageItem, TimelineItem } from "./reduce";
+
+const MESSAGE_TYPES = new Set(["SAY", "QUERY", "ANSWER", "PROPOSE"]);
+const EMPTY_EVENTS: SocietyEnvelope[] = [];
+
+/** Retain outgoing messages and their delivery vetoes, never unrelated board activity. */
+export function collectOutgoing(
+ previous: SocietyEnvelope[], rows: SocietyEnvelope[], agentId: string,
+): SocietyEnvelope[] {
+ const messages = new Map(previous.map((row) => [row.event_id, row]));
+ for (const row of rows) {
+ if (row.from_agent === agentId && row.to_agent && row.to_agent !== agentId
+ && row.to_agent !== "user" && MESSAGE_TYPES.has(row.msg_type)
+ && typeof row.payload.text === "string" && row.payload.text.trim()) {
+ messages.set(row.event_id, row);
+ } else if (row.msg_type === "VETO" && row.parent_event_id && messages.has(row.parent_event_id)) {
+ messages.set(row.event_id, row);
+ }
+ }
+ return messages.size === previous.length ? previous : [...messages.values()];
+}
+
+/** The board is durable, so reopening a chat recovers replies sent via tools OR the CLI. */
+export function mergeOutgoingMessages(
+ items: TimelineItem[], events: SocietyEnvelope[], agentId: string, agentName: string,
+ names: ReadonlyMap<string, string>,
+): TimelineItem[] {
+ const seen = new Set(items.filter((item) => item.type === "internal").map((item) => item.id));
+ const failures = new Map(events.filter((row) => row.msg_type === "VETO")
+ .map((row) => [row.parent_event_id, String(row.payload.text ?? "")]));
+ const outgoing: InternalMessageItem[] = events.filter((row) => row.from_agent === agentId
+ && MESSAGE_TYPES.has(row.msg_type) && row.to_agent && !seen.has(row.event_id)).map((row) => ({
+ type: "internal", id: row.event_id, tsMs: row.ts_ms,
+ outgoing: { recipientId: row.to_agent!, recipientName: names.get(row.to_agent!) ?? row.to_agent! },
+ message: {
+ message_id: row.event_id, sender_id: agentId, sender_name: agentName,
+ sender_kind: "agent", text: String(row.payload.text), prompt: "", trace_id: row.trace_id,
+ // The board proves submission, not delivery. The bubble labels this as sent.
+ status: failures.has(row.event_id) ? "failed" : "queued", error: failures.get(row.event_id) ?? "", turn_id: "",
+ },
+ }));
+ if (!outgoing.length) return items;
+ const time = (item: TimelineItem) => item.type === "turn" ? item.startedMs : item.tsMs;
+ return [...items, ...outgoing].sort((a, b) => time(a) - time(b));
+}
+
+export function useOutgoingMessages(agentId: string | null): SocietyEnvelope[] {
+ const [state, setState] = useState({ agentId, events: EMPTY_EVENTS });
+ useEffect(() => {
+ if (!agentId) return;
+ const controller = new AbortController();
+ let cursor = 0;
+ let timer: ReturnType<typeof setTimeout>;
+ // Read ascending pages: the agent-filtered endpoint returns the newest page
+ // and cannot recover a complete archive. Retain only this agent's outbox.
+ const read = async () => {
+ try {
+ if (document.hidden) return;
+ let more = true;
+ while (more && !controller.signal.aborted) {
+ const response = await fetch(`/api/society/events?after_seq=${cursor}&limit=1000`, { signal: controller.signal });
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
+ const data: { events: SocietyEnvelope[] } = await response.json();
+ if (controller.signal.aborted) return;
+ setState((previous) => {
+ const events = collectOutgoing(previous.agentId === agentId ? previous.events : EMPTY_EVENTS, data.events, agentId);
+ return previous.agentId === agentId && previous.events === events ? previous : { agentId, events };
+ });
+ const next = data.events.at(-1)?.seq ?? cursor;
+ more = data.events.length === 1000 && next > cursor;
+ cursor = next;
+ }
+ } catch (cause) {
+ if (!controller.signal.aborted) console.warn("Could not load outgoing agent messages", cause);
+ } finally {
+ if (!controller.signal.aborted) timer = setTimeout(() => void read(), 3000 + Math.random() * 2000);
+ }
+ };
+ void read();
+ return () => { controller.abort(); clearTimeout(timer); };
+ }, [agentId]);
+ return useMemo(() => state.agentId === agentId ? state.events : EMPTY_EVENTS, [agentId, state]);
+}
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 96c6df174c..514fb5755c 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx
@@ -1,5 +1,6 @@
import { PairConversationBoundary } from "@/components/agentchat/PairConversation";
import { InternalMessageBubble } from "@/components/agentchat/InternalMessageBubble";
+import { mergeOutgoingMessages, useOutgoingMessages } from "@/components/agentchat/useOutgoingMessages";
/**
* The model card's chat column, kept deliberately plain (maintainer,
* 2026-09-02): bubbles, a time stamp, one pill-shaped composer with a "+"
@@ -181,7 +182,12 @@ function SpecialistChat({ agent, roster }: AgentChatPanelProps) {
const sessionId = agent.chatSessionId;
const sessionReady = Boolean(sessionId) && activeSessionId === sessionId;
const visibleItems = itemsForOpenSession(sessionId, activeSessionId, items);
- const view = useTranscriptView(sessionReady ? sessionId : null, visibleItems);
+ const outgoing = useOutgoingMessages(sessionReady ? agent.agentId : null);
+ const allItems = useMemo(() => mergeOutgoingMessages(
+ visibleItems, outgoing, agent.agentId, agent.name,
+ new Map(roster.map((member) => [member.agentId, member.name])),
+ ), [visibleItems, outgoing, agent.agentId, agent.name, roster]);
+ const view = useTranscriptView(sessionReady ? sessionId : null, allItems);
// Open the agent's own session before the browser paints. Waiting on bind /
// catalog / sessions left the previous specialist's transcript on screen
@@ -642,7 +648,7 @@ export function Transcript({
<InternalMessageBubble
item={item}
sender={roster.find((a) => a.agentId === item.message.sender_id) ?? null}
- recipient={agent}
+ recipient={item.outgoing ? roster.find((a) => a.agentId === item.outgoing?.recipientId) : agent}
/>
) : item.type === "user" ? (
<UserBubble item={item} />
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 0173c387be..f04f168d96 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -612,6 +612,7 @@
"internal_expand": "Ganze Nachricht zeigen",
"internal_collapse": "Weniger anzeigen",
"delivery_queued": "Eingereiht",
+ "delivery_sent": "Gesendet",
"delivery_delivered": "Zugestellt",
"delivery_failed": "Fehlgeschlagen",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index f2b1873373..4677411599 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -612,6 +612,7 @@
"internal_expand": "Show the full message",
"internal_collapse": "Show less",
"delivery_queued": "Queued",
+ "delivery_sent": "Sent",
"delivery_delivered": "Delivered",
"delivery_failed": "Failed",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 9879d6cdb6..2fd2ac6b0e 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -612,6 +612,7 @@
"internal_expand": "Mostrar el mensaje completo",
"internal_collapse": "Mostrar menos",
"delivery_queued": "En cola",
+ "delivery_sent": "Enviado",
"delivery_delivered": "Entregado",
"delivery_failed": "Error",