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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(chat): simplify agent conversations and collapse completed activity
rubenluetke10-beepbe2183807060
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsx b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsxindex 14cba745b4..2adf22a0c9 100644--- a/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsx+++ b/jarvis/ui/web/frontend/src/components/agentchat/WorkTrace.tsx@@ -58,6 +58,18 @@ export function groupTrace(blocks: TurnBlock[]): Group[] {return groups;}+/** Fold adjacent work between replies, keeping failures and decisions in view. */+export function groupConversationTrace(blocks: TurnBlock[]): Group[] {+ const groups: Group[] = [];+ for (const block of blocks) {+ const family = block.kind !== "text" && !(block.kind === "tool" && attention(block)) ? "activity" : null;+ const previous = groups.at(-1);+ if (family && previous?.family === family) previous.blocks.push(block);+ else groups.push({ id: block.kind === "tool" ? block.callId : block.id, blocks: [block], family });+ }+ return groups;+}+function pretty(value: unknown): string {if (typeof value === "string") return value;return JSON.stringify(value, null, 2) ?? "";@@ -66,19 +78,20 @@ function pretty(value: unknown): string {const rowButton = "flex w-full min-w-0 items-start gap-2.5 rounded-sm py-2 text-left text-sm leading-5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground";const iconClass = "mt-0.5 h-4 w-4 shrink-0";-function Disclosure({ label, children, forced = false, initiallyOpen = false, icon, trailing, tone, summary }: {+function Disclosure({ label, children, forced = false, initiallyOpen = false, icon, trailing, tone, summary, resetKey = "" }: {label: ReactNode; children?: ReactNode; forced?: boolean; initiallyOpen?: boolean;- icon: ReactNode; trailing?: ReactNode; tone?: string; summary?: ReactNode;+ icon: ReactNode; trailing?: ReactNode; tone?: string; summary?: ReactNode; resetKey?: string;}) {const id = useId();// A manual choice during a live turn must not prevent completion folding.- const [choice, setChoice] = useState<{ phase: boolean; open: boolean } | null>(null);- const open = forced || (choice?.phase === initiallyOpen ? choice.open : initiallyOpen);+ const phase = `${initiallyOpen}:${resetKey}`;+ const [choice, setChoice] = useState<{ phase: string; open: boolean } | null>(null);+ const open = forced || (choice?.phase === phase ? choice.open : initiallyOpen);return (<div className={cn("min-w-0 text-muted-foreground", tone)}><button type="button" className={rowButton} aria-expanded={children ? open : undefined}aria-controls={children ? id : undefined} disabled={!children || forced}- onClick={() => setChoice({ phase: initiallyOpen, open: !open })}>+ onClick={() => setChoice({ phase, open: !open })}>{icon}<span className="min-w-0 flex-1 [overflow-wrap:anywhere]">{label}</span>{trailing ? <span className="shrink-0 text-xs tabular-nums">{trailing}</span> : null}@@ -90,7 +103,7 @@ function Disclosure({ label, children, forced = false, initiallyOpen = false, ic);}-export function ReasoningTrace({ block, turnLive }: { block: ReasoningBlock; turnLive: boolean }) {+export function ReasoningTrace({ block, turnLive, compact = false }: { block: ReasoningBlock; turnLive: boolean; compact?: boolean }) {const t = useT();const live = turnLive && block.live;const elapsed = useClock(block.startedMs, live);@@ -100,8 +113,9 @@ export function ReasoningTrace({ block, turnLive }: { block: ReasoningBlock; tur: t(live ? "work_trace.thinking_for" : "work_trace.thought_for").replace("{duration}", traceDuration(duration));const gist = text.replace(/```[\s\S]*?```/g, " ").replace(/[`*_#>~]/g, "").replace(/\s+/g, " ").trim();return <Disclosure label={label} icon={<Brain aria-hidden className={cn(iconClass, live && "motion-safe:animate-pulse")} />}- forced={live} initiallyOpen={turnLive}- summary={!turnLive && gist ? <p className="mb-2 ml-6 line-clamp-2 text-xs leading-5">{gist.slice(0, 240)}</p> : undefined}>+ forced={live} initiallyOpen={compact ? live : turnLive}+ resetKey={compact ? String(turnLive) : ""}+ summary={!compact && !turnLive && gist ? <p className="mb-2 ml-6 line-clamp-2 text-xs leading-5">{gist.slice(0, 240)}</p> : undefined}>{text ? <div className="prose prose-sm max-h-64 max-w-none overflow-auto text-xs leading-6 text-muted-foreground dark:prose-invert [overflow-wrap:anywhere] prose-p:my-1 prose-pre:overflow-auto"><ReactMarkdown remarkPlugins={[remarkGfm]}>{text}</ReactMarkdown></div> : undefined}@@ -186,48 +200,57 @@ export const TraceTool = memo(function TraceTool({ block, status, onDecide }: {</div>;});-export function WorkTrace({ blocks, status, startedMs, durationMs, error, onDecide, renderText, className, receipt, completionLabel }: {+export function WorkTrace({ blocks, status, startedMs, durationMs, error, onDecide, renderText, className, receipt, completionLabel, conversation = false }: {blocks: TurnBlock[]; status: TurnStatus; startedMs: number; durationMs: number | null; error?: string | null;onDecide?: Decide; renderText?: (text: string, id: string) => ReactNode; className?: string;- receipt?: ReactNode; completionLabel?: string;+ receipt?: ReactNode; completionLabel?: string; conversation?: boolean;}) {const t = useT();const live = status === "running";const elapsed = useClock(startedMs, live);- const groups = useMemo(() => groupTrace(blocks), [blocks]);+ const groups = useMemo(() => conversation ? groupConversationTrace(blocks) : groupTrace(blocks), [blocks, conversation]);const pending = blocks.some(block => block.kind === "tool" && block.approval?.decision === null);const outcome = pending ? "approval" : live ? "working" : status === "error" ? "failed" : status === "cancelled" ? "stopped" : "done";const Icon = pending ? ShieldQuestion : live ? CircleDashed : status === "error" ? CircleAlert : Check;return <div className={cn("min-w-0 space-y-0.5", className)} data-testid="work-trace" data-state={status}>{groups.map(group => {const first = group.blocks[0];+ if (conversation && group.family === "activity" && group.blocks.length > 1) return <div key={group.id} className="mx-auto w-full max-w-xl py-1 [&_button]:text-xs">+ <Disclosure label={t("society.chat.activity_trace").replace("{count}", String(group.blocks.length))}+ icon={<Wrench aria-hidden className={iconClass} />} initiallyOpen={live}+ forced={live && group.blocks.some(block => block.kind === "reasoning" && block.live)}>+ {group.blocks.map(block => block.kind === "tool"+ ? <TraceTool key={block.callId} block={block} status={status} onDecide={onDecide} />+ : block.kind === "reasoning" ? <ReasoningTrace key={block.id} block={block} turnLive={live} compact /> : null)}+ </Disclosure>+ </div>;if (group.blocks.length > 1) return <Disclosure key={group.id}label={t(`work_trace.group_${group.family}`).replace("{count}", String(group.blocks.length))}icon={<Check aria-hidden className={iconClass} />} initiallyOpen={live}>{group.blocks.map(block => <TraceTool key={(block as ToolBlock).callId} block={block as ToolBlock} status={status} onDecide={onDecide} />)}</Disclosure>;- if (first.kind === "tool") return <TraceTool key={group.id} block={first} status={status} onDecide={onDecide} />;- if (first.kind === "reasoning") return <ReasoningTrace key={group.id} block={first} turnLive={live} />;- return first.text.trim() ? <div key={group.id} className="min-w-0 py-2">{renderText ? renderText(first.text, first.id) : <div className="prose prose-sm max-w-none text-foreground dark:prose-invert [overflow-wrap:anywhere]"><ChatMarkdown text={first.text} /></div>}</div> : null;+ if (first.kind === "tool") return <div key={group.id} className={conversation ? "mx-auto w-full max-w-xl py-1 text-xs [&_button]:text-xs" : undefined}><TraceTool block={first} status={status} onDecide={onDecide} /></div>;+ if (first.kind === "reasoning") return <div key={group.id} className={conversation ? "max-w-xl text-xs [&_button]:text-xs" : undefined}><ReasoningTrace block={first} turnLive={live} compact={conversation} /></div>;+ return first.text.trim() ? <div key={group.id} className={cn("min-w-0 py-2", conversation && "w-fit max-w-[min(85%,42rem)] rounded-2xl rounded-bl-md bg-secondary px-4 py-2.5")}>{renderText ? renderText(first.text, first.id) : <div className="prose prose-sm max-w-none text-foreground dark:prose-invert [overflow-wrap:anywhere]"><ChatMarkdown text={first.text} /></div>}</div> : null;})}{error ? <p role="alert" className="py-2 text-sm text-destructive [overflow-wrap:anywhere]">{error}</p> : null}- <div role="status" aria-live="polite" className={cn("flex flex-wrap items-center gap-2 border-t border-border pt-3 text-xs text-muted-foreground", status === "error" && "text-destructive")}>+ <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")}><Icon aria-hidden className={cn("h-3.5 w-3.5", live && !pending && "motion-safe:animate-spin")} /><span>{outcome === "done" && completionLabel ? completionLabel : t(`work_trace.${outcome}`)}</span>{(live || durationMs !== null) ? <span aria-live="off" className="tabular-nums">{traceDuration(live ? elapsed : durationMs ?? 0)}</span> : null}- {receipt}+ {receipt ? conversation ? <details className="ml-1"><summary className="cursor-pointer rounded-sm focus-visible:ring-2 focus-visible:ring-ring">{t("society.chat.activity_details")}</summary><div className="flex flex-wrap gap-2 py-1">{receipt}</div></details> : receipt : null}</div></div>;}-export function TurnTrace({ turn, ...props }: { turn: TurnItem; onDecide?: Decide; renderText?: (text: string, id: string) => ReactNode }) {+export function TurnTrace({ turn, ...props }: { turn: TurnItem; onDecide?: Decide; renderText?: (text: string, id: string) => ReactNode; conversation?: boolean }) {const t = useT();const tokens = outputTokens(turn.usage ?? turn.liveUsage);const answered = turn.blocks.some(block => block.kind === "text" && block.text.trim());return <WorkTrace {...props} blocks={turn.blocks} status={turn.status} startedMs={turn.startedMs} durationMs={turn.durationMs} error={turn.error}completionLabel={!answered ? t("agent_chat.turn_no_answer") : undefined}- receipt={<>+ receipt={tokens !== null && tokens > 0 || turn.costUsd !== null && turn.costUsd > 0 ? <>{tokens !== null && tokens > 0 ? <span aria-live="off" className="tabular-nums">{formatTokens(tokens)} {t("agent_chat.tokens")}</span> : null}{turn.costUsd !== null && turn.costUsd > 0 ? <span className="tabular-nums">${turn.costUsd.toFixed(4)}</span> : null}- </>} />;+ </> : undefined} />;}diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsxindex e479b1bc2e..ed39f10086 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,5 @@import { PairConversationBoundary } from "@/components/agentchat/PairConversation";-import { InternalMessageBubble } from "@/components/agentchat/InternalMessageBubble";+import { AgentMessageActivity, ChatActivity, RoutineActivity, routineTask } from "./ChatActivity";import { mergeOutgoingMessages, useOutgoingMessages } from "@/components/agentchat/useOutgoingMessages";/*** The model card's chat column, kept deliberately plain (maintainer,@@ -74,12 +74,10 @@ import {const STAMP_GAP_MS = 30 * 60_000;/**- * The chat owns six eighths of the agent card, which is far wider than a line- * of prose should ever be. Transcript and composer share this one measure so- * the column reads like a chat instead of a stretched log; the panes, borders- * and scrollbars still span the full width.+ * Messages use the full conversation lane; each bubble limits its own prose+ * width. The composer follows the lane so replies read left to right.*/-const CHAT_MEASURE = "mx-auto w-full max-w-[820px]";+const CHAT_MEASURE = "mx-auto w-full min-w-0";/** The line appended to a message that names an agent; Jarvis delegates on it. */const DELEGATE_MARK = "[to jarvis]";@@ -226,17 +224,11 @@ function SpecialistChat({ agent, roster }: AgentChatPanelProps) {return (<div- className="flex h-full min-h-0 flex-col"+ className="flex h-full min-h-0 flex-col bg-background"data-testid="society-chat"data-session-id={sessionId ?? ""}data-session-ready={sessionReady ? "true" : "false"}>- <div className="flex shrink-0 items-center gap-2 border-b border-border px-3 py-2 text-xs text-muted-foreground">- {agent.provider ? <ProviderLogo providerId={agent.provider} label={agent.providerLabel} size="sm" /> : null}- <span className="truncate text-foreground">{agent.providerLabel || t("society.chat.model_default")}</span>- {agent.model ? <span className="truncate font-mono">{agent.model}</span> : null}- {agent.effort ? <span className="ml-auto rounded-full border border-border px-2 py-0.5">{agent.effort}</span> : null}- </div><Transcript key={`${sessionId ?? agent.agentId}:${view.boundaryId}`} items={view.items} agent={agent} roster={roster} onDecide={decide} />{lastError && sessionReady ? (<p role="alert" className="px-4 pb-1 text-xs text-destructive">@@ -370,7 +362,7 @@ function JarvisChat({ agent, roster }: AgentChatPanelProps) {);return (- <div className="flex h-full min-h-0 flex-col" data-testid="society-chat" data-mode="chat">+ <div className="flex h-full min-h-0 flex-col bg-background" data-testid="society-chat" data-mode="chat">{header}<Transcript key={`${activeSessionId ?? ""}:${view.boundaryId}`} items={view.items} agent={agent} roster={roster} onDecide={decide} />{lastError ? (@@ -639,21 +631,17 @@ export function Transcript({let lastStamp = 0;return (<div className="relative flex min-h-0 flex-1 flex-col">- <div ref={rootRef} className="min-h-0 flex-1 overflow-y-auto px-4 py-3" data-testid="society-transcript">- <div ref={contentRef} className={cn(CHAT_MEASURE, "flex flex-col gap-2")}>+ <div ref={rootRef} className="min-h-0 flex-1 overflow-y-auto px-4 py-5 sm:px-6" data-testid="society-transcript">+ <div ref={contentRef} className={cn(CHAT_MEASURE, "flex flex-col gap-3")}>{items.map((item) => {- const ts = item.type === "user" || item.type === "internal" ? item.tsMs : item.type === "turn" ? item.startedMs : 0;+ const ts = item.type === "turn" ? item.startedMs : item.tsMs;const stamp = ts && ts - lastStamp > STAMP_GAP_MS ? ts : 0;if (stamp) lastStamp = ts;return (<div key={item.id} className="flex flex-col gap-2">{stamp ? <TimeStamp ms={stamp} /> : null}{item.type === "internal" ? (- <InternalMessageBubble- item={item}- sender={roster.find((a) => a.agentId === item.message.sender_id) ?? null}- recipient={item.outgoing ? roster.find((a) => a.agentId === item.outgoing?.recipientId) : agent}- />+ <AgentMessageActivity item={item} roster={roster} />) : item.type === "user" ? (<UserBubble item={item} />) : item.type === "turn" ? (@@ -683,7 +671,7 @@ function TimeStamp({ ms }: { ms: number }) {const today = new Date().toDateString() === date.toDateString();const time = date.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });const day = today ? t("society.chat.today") : date.toLocaleDateString(undefined, { day: "2-digit", month: "short" });- return <p className="my-1 text-center text-xs text-muted-foreground">{`${day} ${time}`}</p>;+ return <p className="my-4 text-center text-[11px] text-muted-foreground">{`${day} ${time}`}</p>;}/**@@ -701,10 +689,9 @@ function NoticeLine({ item }: { item: NoticeItem }) {): item.agentName;return (- <div className="flex max-w-[85%] flex-col gap-0.5 self-start rounded-2xl rounded-bl-md border border-border bg-card px-3.5 py-2 text-xs">- {headline ? <p className="font-medium text-foreground">{headline}</p> : null}- {item.text ? <ChatMarkdown text={item.text} className="leading-relaxed text-muted-foreground" /> : null}- </div>+ <ChatActivity label={headline || item.text.split("\n")[0]} failed={item.status === "blocked" || item.resolved === "failed"}>+ {item.text ? <ChatMarkdown text={item.text} className="leading-relaxed" /> : null}+ </ChatActivity>);}@@ -783,6 +770,12 @@ function ProposalCard({ item }: { item: NoticeItem }) {: item.resolved? t("society.chat.proposal_failed"): "";+ if (item.resolved && item.resolved !== "failed") return <ChatActivity+ label={<>{resolvedLabel} · {kind ? t(`society.chat.proposal_kind_${kind}`) : ""} · {summary}</>}>+ <p className="whitespace-pre-wrap">{detail || summary}</p>+ {reason ? <p className="mt-2">{reason}</p> : null}+ {outcome ? <p className="mt-2">{outcome}</p> : null}+ </ChatActivity>;return (<divclassName={cn(@@ -880,9 +873,11 @@ function visibleUserText(text: string): string {export function UserBubble({ item }: { item: UserItem }) {const choices = messageChoices(item);const text = visibleUserText(item.text);+ const task = routineTask(item.text);+ if (task !== null && item.attachments.length === 0) return <RoutineActivity task={task} original={item.text} />;return (- <div className="flex max-w-[85%] flex-col items-end gap-1 self-end">- <div className="rounded-2xl rounded-br-md bg-secondary px-3.5 py-2 text-sm leading-relaxed text-foreground">+ <div className="flex min-w-0 max-w-[min(85%,42rem)] flex-col items-end gap-1 self-end">+ <div className="min-w-0 rounded-2xl rounded-br-md bg-secondary px-4 py-2.5 text-sm leading-relaxed text-foreground [overflow-wrap:anywhere]"><MessageWithChips text={text} choices={choices} /></div>{item.attachments.length > 0 ? (@@ -905,7 +900,7 @@ function TurnBubble({item: TurnItem;onDecide: (approvalId: string, decision: ApprovalDecision) => Promise<void>;}) {- return <TurnTrace turn={item} onDecide={onDecide} renderText={(text) => <Prose text={text} />} />;+ return <TurnTrace turn={item} conversation onDecide={onDecide} renderText={(text) => <Prose text={text} />} />;}/**@@ -926,10 +921,10 @@ function Prose({ text, muted }: { text: string; muted?: boolean }) {"prose-headings:my-2 prose-headings:text-[1em] prose-headings:font-semibold prose-headings:text-foreground","prose-strong:font-semibold prose-strong:text-foreground","prose-ul:my-1.5 prose-ol:my-1.5 prose-li:my-0.5",- "prose-a:text-foreground prose-a:underline prose-a:underline-offset-2",+ "prose-a:text-primary prose-a:underline prose-a:underline-offset-2","prose-code:rounded prose-code:bg-secondary prose-code:px-1 prose-code:py-0.5 prose-code:font-mono","prose-code:text-[0.9em] prose-code:font-normal prose-code:before:hidden prose-code:after:hidden",- "prose-pre:my-2 prose-pre:rounded-xl prose-pre:bg-secondary prose-pre:p-3 prose-pre:text-xs",+ "prose-pre:my-2 prose-pre:rounded-xl prose-pre:bg-background prose-pre:p-3 prose-pre:text-xs prose-pre:text-foreground","prose-hr:my-3 prose-blockquote:border-l-2 prose-blockquote:pl-3 prose-blockquote:not-italic",)}>@@ -1107,7 +1102,7 @@ export function Composer({ agent, mentionable, busy, sessionId, cwd, provider, sconst pickerOpen = mentionOpen;return (- <div className="shrink-0 border-t border-border px-3 pb-3 pt-2">+ <div className="shrink-0 px-4 pb-4 pt-2 sm:px-6">{problem ? <p className="mb-1 px-1 text-xs text-destructive">{problem}</p> : null}{mentionOpen && codingError ? <button type="button" className="mb-1 text-xs text-destructive underline" onClick={() => setCodingRetry((n) => n + 1)}>{t("society.chat.coding_retry")}</button> : null}{mentionOpen && capabilities.inventoryError ? <button type="button" className="mb-1 text-xs text-destructive underline" onClick={capabilities.retryInventory}>{t("common.retry")}</button> : null}@@ -1128,7 +1123,7 @@ export function Composer({ agent, mentionable, busy, sessionId, cwd, provider, sref={composerRef}className={cn(CHAT_MEASURE,- "relative flex items-end gap-1 rounded-[22px] border border-border bg-background px-1.5 py-1",+ "relative flex items-end gap-1 rounded-[24px] border border-border bg-secondary px-2 py-1.5 focus-within:border-border-strong",attachments.dragging && "border-border-strong",// The whole composer reads as armed while the mic is open, not just// the 32px button someone has to go looking for.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.tsxnew file mode 100644index 0000000000..60b807eb17--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/chat/ChatActivity.test.tsx@@ -0,0 +1,83 @@+import { cleanup, fireEvent, render, screen } from "@testing-library/react";+import { afterEach, beforeAll, expect, it } from "vitest";+import { loadLocaleChunk } from "@/i18n";+import { AgentMessageActivity, RoutineActivity, routineTask } from "./ChatActivity";+import { ReasoningTrace, WorkTrace } from "@/components/agentchat/WorkTrace";+import type { InternalMessageItem, ReasoningBlock, ToolBlock } from "@/components/agentchat/reduce";++beforeAll(() => loadLocaleChunk("society"));+afterEach(cleanup);++const envelope = "Scheduled routine task-123. Follow your CURRENT standing instructions and permissions.\nUse your memory and conversation archive for prior results. For information watches, check sources and dates, remember last-seen items, and report only meaningful new findings.\n\n";++it("folds only a full scheduler envelope, preserving ordinary user messages", () => {+ expect(routineTask(envelope + "Check the inbox.\nSummarize changes.")).toBe("Check the inbox.\nSummarize changes.");+ expect(routineTask("Scheduled routine task-123. Please explain this.")).toBeNull();+ expect(routineTask("Please quote:\n" + envelope)).toBeNull();+ render(<RoutineActivity task={"Check the inbox.\nSummarize changes."} original={envelope + "Check the inbox.\nSummarize changes."} />);+ expect(screen.queryByText("Summarize changes.")).toBeNull();+ fireEvent.click(screen.getByRole("button", { name: "Routine check · Check the inbox." }));+ expect(screen.getAllByText(/Summarize changes\./, { selector: "p" }).length).toBeGreaterThan(0);+});++it("shows live reasoning, hides it as soon as thinking finishes, and permits reopening", () => {+ const block: ReasoningBlock = { kind: "reasoning", id: "r", text: "Inspect the inbox first.", live: true, startedMs: Date.now(), durationMs: null };+ const { rerender } = render(<ReasoningTrace block={block} turnLive compact />);+ expect(screen.getByText(block.text)).toBeTruthy();+ rerender(<ReasoningTrace block={{ ...block, live: false, durationMs: 3000 }} turnLive compact />);+ expect(screen.queryByText(block.text)).toBeNull();+ fireEvent.click(screen.getByRole("button", { name: "Thought for 3.0s" }));+ expect(screen.getByText(block.text)).toBeTruthy();+ rerender(<ReasoningTrace block={{ ...block, live: false, durationMs: 3000 }} turnLive={false} compact />);+ expect(screen.queryByText(block.text)).toBeNull();+});++it("folds a live manual choice on completion even when the provider never ends reasoning", () => {+ const block: ReasoningBlock = { kind: "reasoning", id: "r", text: "Inspect the inbox first.", live: true, startedMs: Date.now(), durationMs: null };+ const { rerender } = render(<ReasoningTrace block={block} turnLive compact />);+ rerender(<ReasoningTrace block={block} turnLive={false} compact />);+ expect(screen.queryByText(block.text)).toBeNull();+ fireEvent.click(screen.getByRole("button", { name: "Thought" }));+ expect(screen.getByText(block.text)).toBeTruthy();+});++it("keeps failures and approvals visible in the conversation style", () => {+ const base: ToolBlock = { kind: "tool", callId: "failure", name: "send_message", input: {}, output: "Delivery failed", isError: true, durationMs: 100, approval: null, startedMs: 0 };+ render(<WorkTrace conversation status="done" startedMs={0} durationMs={1000} blocks={[+ base,+ { ...base, callId: "approval", isError: false, output: null, approval: { approvalId: "ap", summary: "Send this message?", decision: null } },+ ]} onDecide={() => undefined} />);+ expect(screen.getByText("Delivery failed")).toBeTruthy();+ expect(screen.getByText("Send this message?")).toBeTruthy();+ expect(screen.getByRole("button", { name: "Approve" })).toBeTruthy();+});++it("shows agent message direction and truthful delivery state without preview clutter", () => {+ const item: InternalMessageItem = { type: "internal", id: "m", tsMs: 0, outgoing: { recipientId: "scout", recipientName: "Scout" }, message: { message_id: "m", sender_id: "lead", sender_name: "Lead", sender_kind: "agent", text: "Please check the report.", prompt: "", trace_id: "trace", turn_id: "turn", status: "queued", error: "" } };+ const { rerender } = render(<AgentMessageActivity item={item} roster={[]} />);+ expect(screen.getByRole("button", { name: /Message to Scout.*Queued/ })).toBeTruthy();+ expect(screen.queryByText(item.message.text)).toBeNull();+ fireEvent.click(screen.getByRole("button"));+ expect(screen.getByText(item.message.text)).toBeTruthy();+ rerender(<AgentMessageActivity item={{ ...item, message: { ...item.message, status: "failed", error: "Connection closed" } }} roster={[]} />);+ expect(screen.getByRole("button", { name: /Message failed Scout/ })).toBeTruthy();+ expect(screen.getByRole("alert").textContent).toBe("Connection closed");+});++it("folds successful work between replies without swallowing an error or reordering the conversation", () => {+ 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} />);+ const activity = screen.getByRole("button", { name: "Activity · 2 steps" });+ expect(activity.getAttribute("aria-expanded")).toBe("true");+ fireEvent.click(activity);+ fireEvent.click(activity);+ rerender(<WorkTrace conversation status="done" startedMs={0} durationMs={1000} blocks={blocks} />);+ expect(activity.getAttribute("aria-expanded")).toBe("false");+ expect(screen.queryByRole("button", { name: /Write file/ })).toBeNull();+ expect(screen.getByText("Your report is ready.")).toBeTruthy();+ expect(screen.getByText("Upload failed")).toBeTruthy();+ fireEvent.click(activity);+ fireEvent.click(screen.getByRole("button", { name: /Write file/ }));+ expect(screen.getByText("Report contents")).toBeTruthy();+});diff --git a/jarvis/ui/web/frontend/src/components/society/chat/ChatActivity.tsx b/jarvis/ui/web/frontend/src/components/society/chat/ChatActivity.tsxnew file mode 100644index 0000000000..12d3232003--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/chat/ChatActivity.tsx@@ -0,0 +1,59 @@+import { useId, useState, type ReactNode } from "react";+import { ArrowDownLeft, ArrowUpRight, ChevronRight, Clock3 } from "lucide-react";+import { ChatMarkdown } from "@/components/agentchat/ChatMarkdown";+import { useOpenPairConversation } from "@/components/agentchat/PairConversation";+import type { InternalMessageItem } from "@/components/agentchat/reduce";+import { useT } from "@/i18n";+import { cn } from "@/lib/utils";+import { AgentSwatch } from "../AgentSwatch";+import type { SocietyAgent } from "../data";++/** A quiet event in the conversation; details remain keyboard accessible. */+export function ChatActivity({ label, icon, children, failed = false }: {+ label: ReactNode; icon?: ReactNode; children: ReactNode; failed?: boolean;+}) {+ const [open, setOpen] = useState(false);+ const id = useId();+ return <div className="my-3 w-full min-w-0 text-xs text-muted-foreground">+ <button type="button" aria-expanded={open} aria-controls={id} onClick={() => setOpen(!open)}+ className={cn("mx-auto flex max-w-[min(100%,36rem)] items-center justify-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", failed && "text-destructive")}>+ {icon}<span className="min-w-0 truncate">{label}</span>+ <ChevronRight aria-hidden className={cn("h-3 w-3 shrink-0 transition-transform", open && "rotate-90")} />+ </button>+ {open ? <div id={id} className="mx-auto mt-2 max-w-xl rounded-xl bg-secondary px-4 py-3 text-sm leading-relaxed [overflow-wrap:anywhere]">{children}</div> : null}+ </div>;+}++/** Recognize only the scheduler's complete envelope; ordinary messages stay intact. */+export function routineTask(text: string): string | null {+ const envelope = /^Scheduled routine [^\s.]+\. Follow your CURRENT standing instructions and permissions\.\r?\nUse your memory and conversation archive for prior results\. For information watches, check sources and dates, remember last-seen items, and report only meaningful new findings\.\r?\n\r?\n/;+ const match = envelope.exec(text);+ return match ? text.slice(match[0].length).trim() : null;+}++export function RoutineActivity({ task, original }: { task: string; original: string }) {+ const t = useT();+ return <ChatActivity label={<>{t("society.chat.routine_check")} · {task.split(/\r?\n/)[0]}</>} icon={<Clock3 aria-hidden className="h-3.5 w-3.5 shrink-0" />}>+ <ChatMarkdown text={task} />+ <details className="mt-2 text-xs"><summary className="cursor-pointer">{t("society.chat.activity_details")}</summary><p className="mt-2 whitespace-pre-wrap">{original}</p></details>+ </ChatActivity>;+}++export function AgentMessageActivity({ item, roster }: { item: InternalMessageItem; roster: SocietyAgent[] }) {+ const t = useT();+ const openPair = useOpenPairConversation();+ const outgoing = Boolean(item.outgoing);+ const id = item.outgoing?.recipientId ?? item.message.sender_id;+ const participant = roster.find(agent => agent.agentId === id);+ const name = participant?.name || item.outgoing?.recipientName || item.message.sender_name;+ const status = item.message.status;+ const failed = status === "failed";+ const canOpenPair = Boolean(openPair && id && id !== "user" && item.message.sender_kind !== "user");+ const label = t(failed ? "society.chat.message_failed" : outgoing ? "society.chat.message_to" : "society.chat.message_from");+ return <ChatActivity failed={failed} icon={outgoing ? <ArrowUpRight aria-hidden className="h-3.5 w-3.5 shrink-0" /> : <ArrowDownLeft aria-hidden className="h-3.5 w-3.5 shrink-0" />}+ label={<span className="inline-flex max-w-full items-center gap-2"><span>{label}</span>{participant ? <AgentSwatch agent={participant} size={18} /> : null}<span className="truncate">{name}</span>{status === "queued" ? <span>· {t("agent_chat.delivery_queued")}</span> : null}</span>}>+ <ChatMarkdown text={item.message.text} />+ {item.message.error ? <p role="alert" className="mt-2 text-destructive">{item.message.error}</p> : null}+ {canOpenPair ? <button type="button" onClick={() => openPair?.({ id, name })} className="mt-3 rounded-sm text-xs underline underline-offset-4 focus-visible:ring-2 focus-visible:ring-ring">{t("agent_chat.pair_open")}</button> : null}+ </ChatActivity>;+}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json b/jarvis/ui/web/frontend/src/i18n/locales/society/de.jsonindex 7d6343fab4..862190a257 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/de.json@@ -1,6 +1,12 @@{"society": {"chat": {+ "activity_details": "Details",+ "activity_trace": "Aktivität · {count} Schritte",+ "routine_check": "Routine-Prüfung",+ "message_to": "Nachricht an",+ "message_from": "Nachricht von",+ "message_failed": "Nachricht fehlgeschlagen","model_search": "Modelle suchen","model_show_more": "Weitere Modelle anzeigen","model_show_fewer": "Weniger Modelle anzeigen",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json b/jarvis/ui/web/frontend/src/i18n/locales/society/en.jsonindex f95ce5d558..c5013f9c46 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/en.json@@ -1,6 +1,12 @@{"society": {"chat": {+ "activity_details": "Details",+ "activity_trace": "Activity · {count} steps",+ "routine_check": "Routine check",+ "message_to": "Message to",+ "message_from": "Message from",+ "message_failed": "Message failed","model_search": "Search models","model_show_more": "Show more models","model_show_fewer": "Show fewer models",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json b/jarvis/ui/web/frontend/src/i18n/locales/society/es.jsonindex d078e5c29d..2a40fff8f5 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/es.json@@ -1,6 +1,12 @@{"society": {"chat": {+ "activity_details": "Detalles",+ "activity_trace": "Actividad · {count} pasos",+ "routine_check": "Comprobación de rutina",+ "message_to": "Mensaje a",+ "message_from": "Mensaje de",+ "message_failed": "Error al enviar mensaje","model_search": "Buscar modelos","model_show_more": "Mostrar más modelos","model_show_fewer": "Mostrar menos modelos",