Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(views): revamp execution log — virtualized, readable, two-tier header (#5890)
Naiyuan Qing00e658401ba1
diff --git a/packages/core/agents/stores/index.ts b/packages/core/agents/stores/index.tsindex 4d3eeb9d8e..f1d401560b 100644--- a/packages/core/agents/stores/index.ts+++ b/packages/core/agents/stores/index.ts@@ -13,6 +13,7 @@ export {} from "./view-store";export {useTranscriptViewStore,+ type TranscriptDetailDensity,type TranscriptFilterKey,type TranscriptSortDirection,} from "./transcript-view-store";diff --git a/packages/core/agents/stores/transcript-view-store.test.ts b/packages/core/agents/stores/transcript-view-store.test.tsindex 6bf21f35d2..1a0c3f725e 100644--- a/packages/core/agents/stores/transcript-view-store.test.ts+++ b/packages/core/agents/stores/transcript-view-store.test.ts@@ -4,18 +4,16 @@ import { useTranscriptViewStore } from "./transcript-view-store";beforeEach(() => {useTranscriptViewStore.setState({sortDirection: "chronological",- preserveFilters: false,selectedFilterKeys: [],- defaultExpanded: false,+ density: "smart",});});describe("useTranscriptViewStore", () => {- it("defaults to chronological, unfiltered, and collapsed", () => {+ it("defaults to chronological, unfiltered, and smart density", () => {expect(useTranscriptViewStore.getState().sortDirection).toBe("chronological");- expect(useTranscriptViewStore.getState().preserveFilters).toBe(false);expect(useTranscriptViewStore.getState().selectedFilterKeys).toEqual([]);- expect(useTranscriptViewStore.getState().defaultExpanded).toBe(false);+ expect(useTranscriptViewStore.getState().density).toBe("smart");});it("setSortDirection switches between the two known directions", () => {@@ -29,12 +27,10 @@ describe("useTranscriptViewStore", () => {});it("stores filter preferences as unique serializable keys", () => {- const { setPreserveFilters, setSelectedFilterKeys, toggleFilterKey, clearFilterKeys } =+ const { setSelectedFilterKeys, toggleFilterKey, clearFilterKeys } =useTranscriptViewStore.getState();- setPreserveFilters(true);setSelectedFilterKeys(["thinking", "tool:terminal", "thinking", ""]);- expect(useTranscriptViewStore.getState().preserveFilters).toBe(true);expect(useTranscriptViewStore.getState().selectedFilterKeys).toEqual(["thinking","tool:terminal",@@ -53,13 +49,24 @@ describe("useTranscriptViewStore", () => {expect(useTranscriptViewStore.getState().selectedFilterKeys).toEqual([]);});- it("stores the default-expanded preference", () => {- const { setDefaultExpanded } = useTranscriptViewStore.getState();+ it("stores the density preference", () => {+ const { setDensity } = useTranscriptViewStore.getState();- setDefaultExpanded(true);- expect(useTranscriptViewStore.getState().defaultExpanded).toBe(true);+ setDensity("expanded");+ expect(useTranscriptViewStore.getState().density).toBe("expanded");- setDefaultExpanded(false);- expect(useTranscriptViewStore.getState().defaultExpanded).toBe(false);+ setDensity("collapsed");+ expect(useTranscriptViewStore.getState().density).toBe("collapsed");+ });++ it("migrates the legacy defaultExpanded boolean and rejects unknown density values", () => {+ const merge = useTranscriptViewStore.persist.getOptions().merge!;+ const current = useTranscriptViewStore.getState();++ expect(merge({ defaultExpanded: true }, current)).toMatchObject({ density: "expanded" });+ expect(merge({ defaultExpanded: false }, current)).toMatchObject({ density: "smart" });+ expect(merge({ density: "collapsed" }, current)).toMatchObject({ density: "collapsed" });+ expect(merge({ density: "bogus" }, current)).toMatchObject({ density: "smart" });+ expect(merge(undefined, current)).toMatchObject({ density: "smart" });});});diff --git a/packages/core/agents/stores/transcript-view-store.ts b/packages/core/agents/stores/transcript-view-store.tsindex cbab15153e..9aad9cd321 100644--- a/packages/core/agents/stores/transcript-view-store.ts+++ b/packages/core/agents/stores/transcript-view-store.ts@@ -7,24 +7,31 @@ import { defaultStorage } from "../../platform/storage";export type TranscriptSortDirection = "chronological" | "newest_first";export type TranscriptFilterKey = string;+/**+ * Persisted expand-mode preference for the transcript. `smart` applies the+ * per-kind reading hierarchy (agent text and errors open, process noise+ * folded); `expanded`/`collapsed` are wholesale overrides. Row-level manual+ * toggles live in the dialog, sit above all three, and reset on mode switch.+ */+export type TranscriptDetailDensity = "smart" | "expanded" | "collapsed";++const DENSITIES: readonly TranscriptDetailDensity[] = ["smart", "expanded", "collapsed"];+interface TranscriptViewState {sortDirection: TranscriptSortDirection;- preserveFilters: boolean;selectedFilterKeys: TranscriptFilterKey[];- defaultExpanded: boolean;+ density: TranscriptDetailDensity;setSortDirection: (dir: TranscriptSortDirection) => void;- setPreserveFilters: (preserve: boolean) => void;setSelectedFilterKeys: (keys: TranscriptFilterKey[]) => void;toggleFilterKey: (key: TranscriptFilterKey) => void;clearFilterKeys: () => void;- setDefaultExpanded: (expanded: boolean) => void;+ setDensity: (density: TranscriptDetailDensity) => void;}const DEFAULTS = {sortDirection: "chronological" as TranscriptSortDirection,- preserveFilters: false,selectedFilterKeys: [] as TranscriptFilterKey[],- defaultExpanded: false,+ density: "smart" as TranscriptDetailDensity,};function uniqueFilterKeys(keys: TranscriptFilterKey[]): TranscriptFilterKey[] {@@ -36,7 +43,6 @@ export const useTranscriptViewStore = create<TranscriptViewState>()((set) => ({...DEFAULTS,setSortDirection: (sortDirection) => set({ sortDirection }),- setPreserveFilters: (preserveFilters) => set({ preserveFilters }),setSelectedFilterKeys: (selectedFilterKeys) =>set({ selectedFilterKeys: uniqueFilterKeys(selectedFilterKeys) }),toggleFilterKey: (key) =>@@ -46,24 +52,32 @@ export const useTranscriptViewStore = create<TranscriptViewState>()(: [...state.selectedFilterKeys, key],})),clearFilterKeys: () => set({ selectedFilterKeys: [] }),- setDefaultExpanded: (defaultExpanded) => set({ defaultExpanded }),+ setDensity: (density) => set({ density }),}),{name: "multica_transcript_view",storage: createJSONStorage(() => defaultStorage),partialize: (state) => ({sortDirection: state.sortDirection,- preserveFilters: state.preserveFilters,selectedFilterKeys: state.selectedFilterKeys,- defaultExpanded: state.defaultExpanded,+ density: state.density,}),merge: (persisted, current) => {if (!persisted) return { ...current, ...DEFAULTS };- const p = persisted as Partial<TranscriptViewState>;+ const p = persisted as Partial<TranscriptViewState> & {+ /** Pre-density persisted shape: a boolean expand-everything flag. */+ defaultExpanded?: boolean;+ };+ const density = DENSITIES.includes(p.density as TranscriptDetailDensity)+ ? (p.density as TranscriptDetailDensity)+ : p.defaultExpanded === true+ ? "expanded"+ : DEFAULTS.density;return {...current,- ...p,+ sortDirection: p.sortDirection ?? DEFAULTS.sortDirection,selectedFilterKeys: uniqueFilterKeys(p.selectedFilterKeys ?? []),+ density,};},},diff --git a/packages/views/common/task-transcript/agent-transcript-dialog.test.tsx b/packages/views/common/task-transcript/agent-transcript-dialog.test.tsxindex 5fdae3c5ec..17020185c0 100644--- a/packages/views/common/task-transcript/agent-transcript-dialog.test.tsx+++ b/packages/views/common/task-transcript/agent-transcript-dialog.test.tsx@@ -23,6 +23,26 @@ vi.mock("@multica/ui/lib/clipboard", () => ({copyText: copyTextMock,}));+// Real react-virtuoso renders no data rows under jsdom's zero-height viewport,+// so stub it with a flat render to make rows visible to these tests.+vi.mock("react-virtuoso", () => ({+ Virtuoso: ({+ data,+ itemContent,+ computeItemKey,+ }: {+ data: TimelineItem[];+ itemContent: (i: number, item: TimelineItem) => ReactNode;+ computeItemKey: (i: number, item: TimelineItem) => number;+ }) => (+ <div>+ {data.map((item, i) => (+ <div key={computeItemKey(i, item)}>{itemContent(i, item)}</div>+ ))}+ </div>+ ),+}));+vi.mock("../actor-avatar", () => ({ActorAvatar: () => <span data-testid="actor-avatar" />,}));@@ -36,7 +56,14 @@ vi.mock("@multica/ui/components/ui/dialog", () => ({DialogTitle: ({ children }: { children: ReactNode }) => <h2>{children}</h2>,}));-vi.mock("@multica/ui/components/ui/dropdown-menu", () => ({+vi.mock("@multica/ui/components/ui/dropdown-menu", async () => {+ const React = await import("react");+ const RadioContext = React.createContext<{+ value?: string;+ onValueChange?: (value: string) => void;+ }>({});++ return {DropdownMenu: ({ children }: { children: ReactNode }) => <div>{children}</div>,DropdownMenuTrigger: ({children,@@ -77,6 +104,45 @@ vi.mock("@multica/ui/components/ui/dropdown-menu", () => ({{children}</button>),+ DropdownMenuRadioGroup: ({+ value,+ onValueChange,+ children,+ }: {+ value?: string;+ onValueChange?: (value: string) => void;+ children: ReactNode;+ }) => (+ <RadioContext.Provider value={{ value, onValueChange }}>{children}</RadioContext.Provider>+ ),+ DropdownMenuRadioItem: ({+ value,+ children,+ }: {+ value: string;+ children: ReactNode;+ }) => {+ const ctx = React.useContext(RadioContext);+ return (+ <button+ type="button"+ role="menuitemradio"+ aria-checked={ctx.value === value}+ onClick={() => ctx.onValueChange?.(value)}+ >+ {children}+ </button>+ );+ },+ };+});++// The transcript body renders agent markdown through RichContent; stub it to+// keep these tests independent of the markdown pipeline.+vi.mock("../../rich-content", () => ({+ RichContent: ({ content }: { content: string }) => (+ <div data-testid="rich-content">{content}</div>+ ),}));vi.mock("@multica/ui/components/ui/collapsible", async () => {@@ -102,15 +168,18 @@ vi.mock("@multica/ui/components/ui/collapsible", async () => {disabled,children,className: _className,+ ...props}: ButtonHTMLAttributes<HTMLButtonElement>) => {const ctx = React.useContext(Context);return (<buttontype="button"disabled={disabled}+ aria-expanded={ctx.open}onClick={() => {if (!disabled) ctx.onOpenChange?.(!ctx.open);}}+ {...props}>{children}</button>@@ -206,9 +275,10 @@ beforeEach(() => {vi.mocked(api.listRuntimes).mockResolvedValue([]);useTranscriptViewStore.setState({sortDirection: "chronological",- preserveFilters: false,selectedFilterKeys: [],- defaultExpanded: false,+ // Legacy row assertions below expect one-line summaries; smart density is+ // exercised by its own tests.+ density: "collapsed",});});@@ -235,15 +305,16 @@ describe("AgentTranscriptDialog", () => {renderDialog([], { task: liveTask, isLive: true });- await screen.findByText("hermes runtime");+ // Runtime detail now lives in the ⓘ popover; its trigger appearing proves+ // the runtime loaded. The non-antigravity live state still waits.+ await screen.findByRole("button", { name: "Run details" });expect(screen.getByText("Waiting for events...")).toBeInTheDocument();});- it("preserves selected filters across dialog remounts when enabled", () => {+ it("preserves selected filters across dialog remounts unconditionally", () => {const first = renderDialog();fireEvent.click(screen.getByRole("menuitemcheckbox", { name: "Thinking" }));- fireEvent.click(screen.getByRole("menuitemcheckbox", { name: "Preserve filters" }));expect(screen.queryByText("Agent summary")).not.toBeInTheDocument();expect(screen.getByText(/Thinking summary/)).toBeInTheDocument();@@ -258,7 +329,6 @@ describe("AgentTranscriptDialog", () => {it("ignores stale persisted filter keys that are not available in the current transcript", () => {useTranscriptViewStore.setState({- preserveFilters: true,selectedFilterKeys: ["thinking"],});@@ -274,30 +344,50 @@ describe("AgentTranscriptDialog", () => {expect(screen.queryByText("No execution data recorded.")).not.toBeInTheDocument();});- it("expands and collapses every currently visible detailed row", () => {+ it("switches wholesale between expand-all and collapse-all via the density menu", () => {renderDialog();expect(screen.queryByText(/Agent hidden detail/)).not.toBeInTheDocument();expect(screen.queryByText(/"command": "pnpm test"/)).not.toBeInTheDocument();- fireEvent.click(screen.getByRole("button", { name: "Expand visible" }));+ fireEvent.click(screen.getByRole("menuitemradio", { name: /Expand all/ }));expect(screen.getByText(/Agent hidden detail/)).toBeInTheDocument();+ expect(screen.getByText(/Thinking hidden detail/)).toBeInTheDocument();expect(screen.getByText(/"command": "pnpm test"/)).toBeInTheDocument();- fireEvent.click(screen.getByRole("button", { name: "Collapse visible" }));+ fireEvent.click(screen.getByRole("menuitemradio", { name: /Collapse all/ }));expect(screen.queryByText(/Agent hidden detail/)).not.toBeInTheDocument();expect(screen.queryByText(/"command": "pnpm test"/)).not.toBeInTheDocument();});- it("uses the default-expanded preference for newly opened transcripts", () => {- useTranscriptViewStore.setState({ defaultExpanded: true });+ it("smart density opens agent text in place and keeps process noise folded", () => {+ useTranscriptViewStore.setState({ density: "smart" });renderDialog();- expect(screen.getByText(/Agent hidden detail/)).toBeInTheDocument();- expect(screen.getByText(/"command": "pnpm test"/)).toBeInTheDocument();+ // Agent body reads without a click (through RichContent), tools stay folded.+ expect(screen.getByTestId("rich-content")).toHaveTextContent("Agent hidden detail");+ expect(screen.queryByText(/Thinking hidden detail/)).not.toBeInTheDocument();+ expect(screen.queryByText(/"command": "pnpm test"/)).not.toBeInTheDocument();+ });++ it("row-level toggles override the density default until the mode changes", () => {+ useTranscriptViewStore.setState({ density: "smart" });++ renderDialog();++ // Fold the default-open agent body back to one line. The `expanded`+ // filter distinguishes the collapse trigger from the timeline segment,+ // which also carries the "Agent" accessible name via its title.+ fireEvent.click(screen.getByRole("button", { name: "Agent", expanded: true }));+ expect(screen.queryByTestId("rich-content")).not.toBeInTheDocument();+ expect(screen.getByText("Agent summary")).toBeInTheDocument();++ // Open a default-folded thinking row.+ fireEvent.click(screen.getByRole("button", { name: /Thinking summary/ }));+ expect(screen.getByText(/Thinking hidden detail/)).toBeInTheDocument();});it("copies RFC 3339 timestamps before event labels", () => {@@ -318,11 +408,13 @@ describe("AgentTranscriptDialog", () => {fireEvent.click(screen.getByRole("button", { name: "Copy all" }));+ // Full body (not the truncated summary) with the RFC 3339 prefix, events+ // separated by a blank line.expect(copyTextMock).toHaveBeenCalledWith([- "[2026-06-08T00:00:00.000Z] [Agent] Agent summary",+ "[2026-06-08T00:00:00.000Z] [Agent] Agent summary\nAgent hidden detail","[2026-06-08T08:00:05.123Z] [Thinking] Thinking summary",- ].join("\n"),+ ].join("\n\n"),);});@@ -344,7 +436,7 @@ describe("AgentTranscriptDialog", () => {fireEvent.click(screen.getByRole("button", { name: "Copy all" }));expect(copyTextMock).toHaveBeenCalledWith(- ["[Agent] Missing timestamp", "[Error] Invalid timestamp"].join("\n"),+ ["[Agent] Missing timestamp", "[Error] Invalid timestamp"].join("\n\n"),);});});diff --git a/packages/views/common/task-transcript/agent-transcript-dialog.tsx b/packages/views/common/task-transcript/agent-transcript-dialog.tsxindex c7446266b2..5943d5779e 100644--- a/packages/views/common/task-transcript/agent-transcript-dialog.tsx+++ b/packages/views/common/task-transcript/agent-transcript-dialog.tsx@@ -1,6 +1,7 @@"use client";-import { useState, useRef, useCallback, useEffect, useMemo } from "react";+import { useState, useRef, useCallback, useEffect, useMemo, forwardRef } from "react";+import { Virtuoso, type VirtuosoHandle, type Components } from "react-virtuoso";import {Bot,ChevronRight,@@ -13,17 +14,17 @@ import {Clock,Copy,Check,- Monitor,- Cloud,- Cpu,Filter,- Folder,ArrowDownNarrowWide,ArrowUpNarrowWide,+ ListCollapse,+ Info,} from "lucide-react";import { cn } from "@multica/ui/lib/utils";import { copyText } from "@multica/ui/lib/clipboard";+import { Button } from "@multica/ui/components/ui/button";import { Dialog, DialogContent, DialogTitle } from "@multica/ui/components/ui/dialog";+import { Popover, PopoverContent, PopoverTrigger } from "@multica/ui/components/ui/popover";import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@multica/ui/components/ui/collapsible";import {DropdownMenu,@@ -32,12 +33,16 @@ import {DropdownMenuSeparator,DropdownMenuCheckboxItem,DropdownMenuItem,+ DropdownMenuRadioGroup,+ DropdownMenuRadioItem,} from "@multica/ui/components/ui/dropdown-menu";import { ActorAvatar } from "../actor-avatar";import { AttributionBadge } from "../../issues/components/attribution-badge";+import { RichContent } from "../../rich-content";import { api } from "@multica/core/api";import {useTranscriptViewStore,+ type TranscriptDetailDensity,type TranscriptFilterKey,type TranscriptSortDirection,} from "@multica/core/agents/stores";@@ -45,7 +50,17 @@ import type { AgentTask, Agent, AgentRuntime } from "@multica/core/types/agent";import { runtimeDisplayName } from "@multica/core/runtimes";import { redactSecrets } from "./redact";import type { TimelineItem } from "./build-timeline";+import {+ traceEventCopyText,+ traceEventDefaultExpanded,+ traceEventHasDetail,+ traceEventKind,+ traceEventLabel,+ traceEventSummary,+ traceEventSummaryIsMono,+} from "./trace-event-presenter";import { useT } from "../../i18n";+import "./task-transcript.css";interface AgentTranscriptDialogProps {open: boolean;@@ -93,23 +108,8 @@ const colorClasses: Record<EventColor, { bg: string; bgActive: string; label: st};// ─── Helpers ────────────────────────────────────────────────────────────────--function getEventLabel(item: TimelineItem): string {- switch (item.type) {- case "text":- return "Agent";- case "thinking":- return "Thinking";- case "tool_use":- return item.tool ?? "Tool";- case "tool_result":- return item.tool ? `${item.tool}` : "Result";- case "error":- return "Error";- default:- return "Event";- }-}+// Presentation rules (kind/label/summary/default expansion) live in the pure+// trace-event-presenter module; only view-plumbing helpers remain here.function getItemFilterKey(item: TimelineItem): TranscriptFilterKey {return item.tool && (item.type === "tool_use" || item.type === "tool_result")@@ -117,59 +117,6 @@ function getItemFilterKey(item: TimelineItem): TranscriptFilterKey {: item.type;}-function getEventSummary(item: TimelineItem): string {- switch (item.type) {- case "text":- return item.content?.split("\n").find((l) => l.trim().length > 0) ?? "";- case "thinking":- return item.content?.slice(0, 200) ?? "";- case "tool_use": {- if (!item.input) return "";- const inp = item.input as Record<string, string>;- if (inp.query) return inp.query;- if (inp.file_path) return shortenPath(inp.file_path);- if (inp.path) return shortenPath(inp.path);- if (inp.pattern) return inp.pattern;- if (inp.description) return String(inp.description);- if (inp.command) {- const cmd = String(inp.command);- return cmd.length > 120 ? cmd.slice(0, 120) + "..." : cmd;- }- if (inp.prompt) {- const p = String(inp.prompt);- return p.length > 120 ? p.slice(0, 120) + "..." : p;- }- if (inp.skill) return String(inp.skill);- for (const v of Object.values(inp)) {- if (typeof v === "string" && v.length > 0 && v.length < 120) return v;- }- return "";- }- case "tool_result":- return item.output?.slice(0, 200) ?? "";- case "error":- return item.content ?? "";- default:- return "";- }-}--function hasEventDetail(item: TimelineItem): boolean {- return (- (item.type === "tool_use" && !!item.input && Object.keys(item.input).length > 0) ||- (item.type === "tool_result" && !!item.output && item.output.length > 0) ||- (item.type === "thinking" && !!item.content && item.content.length > 0) ||- (item.type === "text" && !!item.content && item.content.length > 0) ||- (item.type === "error" && !!item.content && item.content.length > 0)- );-}--function shortenPath(p: string): string {- const parts = p.split("/");- if (parts.length <= 3) return p;- return ".../" + parts.slice(-2).join("/");-}-function formatDuration(start: string, end: string): string {const ms = new Date(end).getTime() - new Date(start).getTime();const seconds = Math.floor(ms / 1000);@@ -187,16 +134,75 @@ function formatElapsedMs(ms: number): string {return `${minutes}m ${secs}s`;}-function formatEventForClipboard(item: TimelineItem): string {- const label = getEventLabel(item);- const summary = getEventSummary(item);- const date = item.created_at ? new Date(item.created_at) : null;- const timestamp = date && !Number.isNaN(date.getTime()) ? `[${date.toISOString()}] ` : "";- return `${timestamp}[${label}] ${summary}`;+function formatRunTime(iso: string): string {+ return new Date(iso).toLocaleString(undefined, {+ month: "short",+ day: "numeric",+ hour: "2-digit",+ minute: "2-digit",+ second: "2-digit",+ });+}++// ─── Run detail row (ⓘ popover) ─────────────────────────────────────────────+// One labeled fact in the diagnostic popover. When `onCopy` is given the whole+// row is a copy button (used for the workdir path).+function RunDetailRow({+ label,+ value,+ mono,+ onCopy,+ copied,+ copyTitle,+}: {+ label: string;+ value: string;+ mono?: boolean;+ onCopy?: () => void;+ copied?: boolean;+ copyTitle?: string;+}) {+ const valueClass = cn("min-w-0 select-text break-all text-foreground/80", mono && "font-mono");+ if (onCopy) {+ return (+ <button+ type="button"+ onClick={onCopy}+ title={copyTitle}+ className="group -mx-1 grid w-[calc(100%+0.5rem)] grid-cols-[4.5rem_minmax(0,1fr)] items-start gap-3 rounded px-1 py-0.5 text-left transition-colors hover:bg-accent/60"+ >+ <span className="text-muted-foreground">{label}</span>+ <span className="flex min-w-0 items-start gap-1.5">+ <span className={cn(valueClass, "flex-1")}>{value}</span>+ {copied ? (+ <Check className="mt-0.5 h-3 w-3 shrink-0 text-success" />+ ) : (+ <Copy className="mt-0.5 h-3 w-3 shrink-0 opacity-0 transition-opacity group-hover:opacity-100" />+ )}+ </span>+ </button>+ );+ }+ return (+ <div className="grid grid-cols-[4.5rem_minmax(0,1fr)] items-start gap-3">+ <span className="text-muted-foreground">{label}</span>+ <span className={valueClass}>{value}</span>+ </div>+ );}// ─── Main dialog ────────────────────────────────────────────────────────────+// Virtuoso mounts rows as direct children of its List element; carry the+// divider styling the plain list container used to provide. Defined at module+// scope — an inline `components` object would remount the list every render.+const VirtuosoList = forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(+ function VirtuosoList(props, ref) {+ return <div ref={ref} {...props} className="divide-y" />;+ },+);+const LIST_COMPONENTS: Components<TimelineItem> = { List: VirtuosoList };+export function AgentTranscriptDialog({open,onOpenChange,@@ -213,28 +219,29 @@ export function AgentTranscriptDialog({const [copiedWorkdir, setCopiedWorkdir] = useState(false);const [agentInfo, setAgentInfo] = useState<Agent | null>(null);const [runtimeInfo, setRuntimeInfo] = useState<AgentRuntime | null>(null);- const [sessionFilterKeys, setSessionFilterKeys] = useState<TranscriptFilterKey[]>([]);- const [expandedSeqs, setExpandedSeqs] = useState<Set<number>>(() => new Set());+ // Row-level expand overrides. A row the user toggled follows the toggle; any+ // other row follows the density preference (see traceEventDefaultExpanded).+ // Switching density or task resets the overrides wholesale.+ const [rowOverrides, setRowOverrides] = useState<Map<number, boolean>>(() => new Map());const sortDirection = useTranscriptViewStore((s) => s.sortDirection);const setSortDirection = useTranscriptViewStore((s) => s.setSortDirection);- const preserveFilters = useTranscriptViewStore((s) => s.preserveFilters);- const setPreserveFilters = useTranscriptViewStore((s) => s.setPreserveFilters);- const persistedFilterKeys = useTranscriptViewStore((s) => s.selectedFilterKeys);- const setPersistedFilterKeys = useTranscriptViewStore((s) => s.setSelectedFilterKeys);- const togglePersistedFilterKey = useTranscriptViewStore((s) => s.toggleFilterKey);- const clearPersistedFilterKeys = useTranscriptViewStore((s) => s.clearFilterKeys);- const defaultExpanded = useTranscriptViewStore((s) => s.defaultExpanded);- const setDefaultExpanded = useTranscriptViewStore((s) => s.setDefaultExpanded);- const eventRefs = useRef<Map<number, HTMLDivElement>>(new Map());- const scrollContainerRef = useRef<HTMLDivElement>(null);- const autoExpandedSeqsRef = useRef<Set<number>>(new Set());- const initializedTaskRef = useRef<string | null>(null);- const previousDefaultExpandedRef = useRef(defaultExpanded);- const selectedFilterKeys = preserveFilters ? persistedFilterKeys : sessionFilterKeys;+ // Filters always persist across opens — a facet a run doesn't have simply+ // no-ops (see activeFilterKeys), so there is no reason to make persistence a+ // user-facing toggle.+ const selectedFilterKeys = useTranscriptViewStore((s) => s.selectedFilterKeys);+ const toggleFilterKey = useTranscriptViewStore((s) => s.toggleFilterKey);+ const clearFilters = useTranscriptViewStore((s) => s.clearFilterKeys);+ const density = useTranscriptViewStore((s) => s.density);+ const setDensity = useTranscriptViewStore((s) => s.setDensity);+ const virtuosoRef = useRef<VirtuosoHandle>(null);++ useEffect(() => {+ setRowOverrides(new Map());+ }, [task.id, density]);// Derive filter options from each item:// tool_use / tool_result → filter value = tool, display = "tool:Bash"- // other types → display from getEventLabel+ // other types → display from traceEventLabelconst filterOptions = useMemo(() => {const options = new Map<string, string>();for (const item of items) {@@ -243,7 +250,7 @@ export function AgentTranscriptDialog({if (!options.has(key)) options.set(key, key);} else {if (!options.has(key)) {- options.set(key, getEventLabel(item));+ options.set(key, traceEventLabel(item));}}}@@ -278,36 +285,19 @@ export function AgentTranscriptDialog({const isAntigravityLiveEmpty =isLive && displayItems.length === 0 && runtimeInfo?.provider === "antigravity";- const detailSeqs = useMemo(- () => displayItems.filter(hasEventDetail).map((item) => item.seq),- [displayItems],- );-- const allVisibleDetailsExpanded =- detailSeqs.length > 0 && detailSeqs.every((seq) => expandedSeqs.has(seq));-- useEffect(() => {- const switchedDefaultOn =- defaultExpanded && previousDefaultExpandedRef.current !== defaultExpanded;- previousDefaultExpandedRef.current = defaultExpanded;-- if (initializedTaskRef.current !== task.id || switchedDefaultOn) {- initializedTaskRef.current = task.id;- autoExpandedSeqsRef.current = new Set(defaultExpanded ? detailSeqs : []);- setExpandedSeqs(defaultExpanded ? new Set(detailSeqs) : new Set());- return;- }-- if (!defaultExpanded) return;-- const unseen = detailSeqs.filter((seq) => !autoExpandedSeqsRef.current.has(seq));- if (unseen.length === 0) return;-- for (const seq of unseen) {- autoExpandedSeqsRef.current.add(seq);- }- setExpandedSeqs((prev) => new Set([...prev, ...unseen]));- }, [task.id, defaultExpanded, detailSeqs]);+ // Newest-first shows live events as PREPENDS, and Virtuoso items opt out of+ // native scroll anchoring (`overflow-anchor: none`), so without compensation+ // every 500ms flush shifts the reading position. Virtuoso's contract: a+ // decrease of firstItemIndex by N anchors the viewport across an N-item+ // prepend, and the value must never increase within an instance — counting+ // down from a large base satisfies that while the list only grows. Sort,+ // filter, or task changes can shrink the list, so `listEpoch` remounts the+ // instance (fresh at top) instead of letting firstItemIndex climb.+ // `scrollToIndex`/`computeItemKey` are unaffected: indices stay data-relative+ // (verified against scrollToIndexSystem — it never reads firstItemIndex).+ const firstItemIndex =+ sortDirection === "newest_first" ? 1_000_000 - displayItems.length : 0;+ const listEpoch = `${task.id}:${sortDirection}:${activeFilterKeys.join(",")}`;// Toggling direction is a manual user action; jump the scroll container back// to the top so the newest end of the timeline (per the chosen direction) is@@ -316,7 +306,7 @@ export function AgentTranscriptDialog({(dir: typeof sortDirection) => {if (dir === sortDirection) return;setSortDirection(dir);- scrollContainerRef.current?.scrollTo({ top: 0 });+ virtuosoRef.current?.scrollTo({ top: 0 });},[sortDirection, setSortDirection],);@@ -353,10 +343,17 @@ export function AgentTranscriptDialog({return () => clearInterval(interval);}, [isLive, task.started_at, task.dispatched_at]);- const handleSegmentClick = useCallback((seq: number) => {- setSelectedSeq(seq);- eventRefs.current.get(seq)?.scrollIntoView({ behavior: "smooth", block: "center" });- }, []);+ // Rows are virtualized, so an off-screen target is not in the DOM;+ // navigate by index instead of a node ref.+ const handleSegmentClick = useCallback(+ (seq: number) => {+ setSelectedSeq(seq);+ const index = displayItems.findIndex((item) => item.seq === seq);+ if (index < 0) return;+ virtuosoRef.current?.scrollToIndex({ index, align: "center", behavior: "smooth" });+ },+ [displayItems],+ );// Copy all events as text. Use the displayed order so users get the same// sequence they see on screen — matters when sort is set to newest-first.@@ -370,9 +367,11 @@ export function AgentTranscriptDialog({}, [task.relative_work_dir]);const handleCopyAll = useCallback(() => {+ // Copy the full body of each event (not the truncated row summary), with+ // the same secret redaction the detail view applies.const text = displayItems- .map(formatEventForClipboard)- .join("\n");+ .map((item) => redactSecrets(traceEventCopyText(item)))+ .join("\n\n");void copyText(text).then((ok) => {if (!ok) return;setCopied(true);@@ -380,68 +379,11 @@ export function AgentTranscriptDialog({});}, [displayItems]);- const toggleSessionFilterKey = useCallback((key: TranscriptFilterKey) => {- setSessionFilterKeys((prev) => {- const next = new Set(prev);- if (next.has(key)) next.delete(key);- else next.add(key);- return Array.from(next);- });- }, []);-- const clearFilters = useCallback(() => {- if (preserveFilters) {- clearPersistedFilterKeys();- return;- }- setSessionFilterKeys([]);- }, [clearPersistedFilterKeys, preserveFilters]);-- const toggleFilterKey = useCallback(- (key: TranscriptFilterKey) => {- if (preserveFilters) {- togglePersistedFilterKey(key);- return;- }- toggleSessionFilterKey(key);- },- [preserveFilters, togglePersistedFilterKey, toggleSessionFilterKey],- );-- const handlePreserveFiltersChange = useCallback(- (next: boolean) => {- if (next) {- setPersistedFilterKeys(sessionFilterKeys);- } else {- setSessionFilterKeys(persistedFilterKeys);- }- setPreserveFilters(next);- },- [persistedFilterKeys, sessionFilterKeys, setPersistedFilterKeys, setPreserveFilters],- );-- const handleToggleVisibleExpanded = useCallback(() => {- for (const seq of detailSeqs) {- autoExpandedSeqsRef.current.add(seq);- }- setExpandedSeqs((prev) => {- if (allVisibleDetailsExpanded) {- const next = new Set(prev);- for (const seq of detailSeqs) {- next.delete(seq);- }- return next;- }- return new Set([...prev, ...detailSeqs]);- });- }, [allVisibleDetailsExpanded, detailSeqs]);const handleRowExpandedChange = useCallback((seq: number, expanded: boolean) => {- autoExpandedSeqsRef.current.add(seq);- setExpandedSeqs((prev) => {- const next = new Set(prev);- if (expanded) next.add(seq);- else next.delete(seq);+ setRowOverrides((prev) => {+ const next = new Map(prev);+ next.set(seq, expanded);return next;});}, []);@@ -454,34 +396,112 @@ export function AgentTranscriptDialog({? elapsed: null;- const toolCount = items.filter((i) => i.type === "tool_use").length;const copyTranscriptLabel = copied? t(($) => $.transcript.copied): activeFilterKeys.length > 0? t(($) => $.transcript.copy_filtered): t(($) => $.transcript.copy_all);- // Status display- const statusBadge = isLive ? (- <span className="inline-flex shrink-0 items-center gap-1 rounded-full bg-info/15 px-2 py-0.5 text-xs font-medium text-info">- <Loader2 className="h-3 w-3 animate-spin" />- {t(($) => $.transcript.status_running)}- </span>- ) : task.status === "completed" ? (- <span className="inline-flex shrink-0 items-center gap-1 rounded-full bg-success/15 px-2 py-0.5 text-xs font-medium text-success">- <CheckCircle2 className="h-3 w-3" />- {t(($) => $.transcript.status_completed)}- </span>- ) : task.status === "failed" ? (- <span className="inline-flex shrink-0 items-center gap-1 rounded-full bg-destructive/15 px-2 py-0.5 text-xs font-medium text-destructive">- <XCircle className="h-3 w-3" />- {t(($) => $.transcript.status_failed)}- </span>- ) : (- <span className="inline-flex shrink-0 items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground capitalize">- {task.status}- </span>- );+ // Status badge — full state machine, so queued/dispatched/cancelled render as+ // proper labels instead of raw enum text.+ const effectiveStatus = isLive ? "running" : task.status;+ const statusBadge = (() => {+ const base = "inline-flex shrink-0 items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium";+ switch (effectiveStatus) {+ case "running":+ return (+ <span className={cn(base, "bg-info/15 text-info")}>+ <Loader2 className="h-3 w-3 animate-spin" />+ {t(($) => $.transcript.status_running)}+ </span>+ );+ case "completed":+ return (+ <span className={cn(base, "bg-success/15 text-success")}>+ <CheckCircle2 className="h-3 w-3" />+ {t(($) => $.transcript.status_completed)}+ </span>+ );+ case "failed":+ return (+ <span className={cn(base, "bg-destructive/15 text-destructive")}>+ <XCircle className="h-3 w-3" />+ {t(($) => $.transcript.status_failed)}+ </span>+ );+ case "cancelled":+ return (+ <span className={cn(base, "bg-muted text-muted-foreground")}>+ <XCircle className="h-3 w-3" />+ {t(($) => $.transcript.status_cancelled)}+ </span>+ );+ case "queued":+ return (+ <span className={cn(base, "bg-muted text-muted-foreground")}>+ {t(($) => $.transcript.status_queued)}+ </span>+ );+ case "dispatched":+ return (+ <span className={cn(base, "bg-info/15 text-info")}>+ {t(($) => $.transcript.status_dispatched)}+ </span>+ );+ case "waiting_local_directory":+ return (+ <span className={cn(base, "bg-muted text-muted-foreground")}>+ {t(($) => $.transcript.status_waiting)}+ </span>+ );+ default:+ return (+ <span className={cn(base, "bg-muted text-muted-foreground capitalize")}>+ {task.status}+ </span>+ );+ }+ })();++ // Trigger source: one word answering "why does this run exist" — more useful+ // up front than the runtime/provider diagnostics, which move to the ⓘ popover.+ const triggerLabel = task.parent_task_id+ ? t(($) => $.transcript.trigger_retry)+ : task.kind === "comment" || task.trigger_comment_id+ ? t(($) => $.transcript.trigger_comment)+ : task.kind === "autopilot" || task.autopilot_run_id+ ? t(($) => $.transcript.trigger_autopilot)+ : task.kind === "chat" || task.chat_session_id+ ? t(($) => $.transcript.trigger_chat)+ : task.kind === "quick_create"+ ? t(($) => $.transcript.trigger_quick_create)+ : task.kind === "direct" || task.handoff_note+ ? t(($) => $.transcript.trigger_direct)+ : t(($) => $.transcript.trigger_initial);++ // Diagnostic detail for the ⓘ popover: everything a reader needs only when+ // debugging this specific run, kept off the always-visible surface.+ const providerLabel = runtimeInfo?.provider ? formatProvider(runtimeInfo.provider) : null;+ const createdLabel = task.created_at ? formatRunTime(task.created_at) : null;+ const startedLabel = task.started_at ? formatRunTime(task.started_at) : null;+ const completedLabel = task.completed_at ? formatRunTime(task.completed_at) : null;+ // "When was this run created" — a read-before-you-read fact worth the toolbar+ // surface (the ⓘ popover keeps the full-precision created/started/completed).+ const createdShort = task.created_at+ ? new Date(task.created_at).toLocaleString(undefined, {+ month: "short",+ day: "numeric",+ hour: "2-digit",+ minute: "2-digit",+ })+ : null;+ const hasTriggeredBy = !!task.attribution?.initiator;+ const hasRunDetails =+ !!runtimeInfo ||+ !!task.relative_work_dir ||+ !!createdLabel ||+ !!startedLabel ||+ !!completedLabel;return (<Dialog open={open} onOpenChange={onOpenChange}>@@ -491,213 +511,247 @@ export function AgentTranscriptDialog({><DialogTitle className="sr-only">{t(($) => $.transcript.dialog_title)}</DialogTitle>- {/* ── Header ─────────────────────────────────────────────── */}- <div className="border-b px-4 py-3 shrink-0 space-y-2">- {/* Top row: agent name, status, actions */}- <div className="flex flex-wrap items-center gap-x-3 gap-y-2">+ {/* ── Header: identity only ──────────────────────────────────+ Tier 1 — everything a viewer needs BEFORE reading: outcome+ (status anchors the left), who ran it, why it exists (trigger),+ and who's accountable. All diagnostics move to the ⓘ popover. */}+ <div className="border-b px-4 py-3 shrink-0">+ <div className="flex min-w-0 items-center gap-3">+ {statusBadge}+ {/* Primary identity: the agent that ran this. It is the one+ foreground entity — avatar + medium weight. */}<div className="flex min-w-0 items-center gap-2">{task.agent_id ? (- <ActorAvatar actorType="agent" actorId={task.agent_id} size="md" />+ <ActorAvatar actorType="agent" actorId={task.agent_id} size="sm" enableHoverCard />) : (- <div className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-info/10 text-info">- <Bot className="h-3.5 w-3.5" />+ <div className="flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-info/10 text-info">+ <Bot className="h-3 w-3" /></div>)}- <span className="truncate font-medium text-sm">{agentName}</span>+ <span className="truncate font-medium text-sm">+ {agentName || agentInfo?.name || ""}+ </span></div>-- {statusBadge}-- {/* Accountable member (MUL-4302 §9): whose behalf this run is on. */}- <AttributionBadge attribution={task.attribution} className="shrink-0" />-- <div className="flex w-full max-w-full flex-wrap items-center justify-end gap-1 sm:ml-auto sm:w-auto">- {detailSeqs.length > 0 && (- <button- type="button"- onClick={handleToggleVisibleExpanded}- aria-label={- allVisibleDetailsExpanded- ? t(($) => $.transcript.collapse_visible)- : t(($) => $.transcript.expand_visible)- }- className="flex shrink-0 items-center gap-1 rounded px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"- >- <ChevronRight- className={cn(- "h-3 w-3 transition-transform",- !allVisibleDetailsExpanded && "rotate-90",- )}+ {/* Provenance, one muted secondary unit set apart from the agent:+ who triggered the run and how — reads as "<person> · <how>",+ not three peer entities. The person's avatar is dropped here so+ two same-size faces don't read as two agents. */}+ <div className="flex min-w-0 flex-1 items-center gap-x-1.5 overflow-hidden text-xs text-muted-foreground">+ {hasTriggeredBy && (+ <>+ <AttributionBadge+ attribution={task.attribution}+ variant="inline"+ hideAvatar+ className="min-w-0"/>- <span className="hidden sm:inline">- {allVisibleDetailsExpanded- ? t(($) => $.transcript.collapse_visible)- : t(($) => $.transcript.expand_visible)}- </span>- </button>- )}- {items.length > 1 && (- <SortDirectionToggle- value={sortDirection}- onChange={handleSortDirectionChange}- labels={{- chronological: t(($) => $.transcript.sort_chronological),- newestFirst: t(($) => $.transcript.sort_newest_first),- ariaLabel: t(($) => $.transcript.sort_label),- }}- />+ <FactDot />+ </>)}- {filterOptions.length > 0 && (- <DropdownMenu>- <DropdownMenuTrigger- aria-label={t(($) => $.transcript.filter)}- className={cn(- "flex shrink-0 items-center gap-1 rounded px-2 py-1 text-xs transition-colors",- activeFilterKeys.length > 0- ? "text-blue-600 dark:text-blue-400 bg-blue-500/10 hover:bg-blue-500/20"- : "text-muted-foreground hover:text-foreground hover:bg-accent",- )}+ <span className="shrink-0">{triggerLabel}</span>+ </div>++ <div className="flex shrink-0 items-center gap-0.5">+ {hasRunDetails && (+ <Popover>+ <PopoverTrigger+ render={+ <Button+ variant="ghost"+ size="icon-sm"+ aria-label={t(($) => $.transcript.run_info)}+ title={t(($) => $.transcript.run_info)}+ className="text-muted-foreground"+ />+ }>- <Filter className="h-3 w-3" />- <span className="hidden sm:inline">{t(($) => $.transcript.filter)}</span>- {activeFilterKeys.length > 0 && (- <span className="ml-0.5 rounded-full bg-blue-500/20 px-1.5 py-0 text-[10px] font-medium">- {activeFilterKeys.length}- </span>- )}- </DropdownMenuTrigger>- <DropdownMenuContent align="end" className="w-auto">- {filterOptions.map(([value, label]) => (- <DropdownMenuCheckboxItem- key={value}- checked={selectedFilterKeys.includes(value)}- onCheckedChange={() => toggleFilterKey(value)}- >- {label}- </DropdownMenuCheckboxItem>- ))}- <DropdownMenuSeparator />- <DropdownMenuCheckboxItem- checked={preserveFilters}- onCheckedChange={(checked) => handlePreserveFiltersChange(checked === true)}- >- {t(($) => $.transcript.preserve_filters)}- </DropdownMenuCheckboxItem>- <DropdownMenuCheckboxItem- checked={defaultExpanded}- onCheckedChange={(checked) => setDefaultExpanded(checked === true)}- >- {t(($) => $.transcript.default_expanded)}- </DropdownMenuCheckboxItem>- {selectedFilterKeys.length > 0 && (- <>- <DropdownMenuSeparator />- <DropdownMenuItem onClick={clearFilters} className="text-muted-foreground">- {t(($) => $.transcript.clear_filters)}- </DropdownMenuItem>- </>- )}- </DropdownMenuContent>- </DropdownMenu>+ <Info className="h-3.5 w-3.5" />+ </PopoverTrigger>+ <PopoverContent align="end" className="w-80 max-w-[calc(100vw-2rem)] p-3">+ <div className="mb-2 text-xs font-medium text-foreground">+ {t(($) => $.transcript.run_info)}+ </div>+ <div className="space-y-1 text-xs">+ {runtimeInfo && (+ <RunDetailRow+ label={t(($) => $.transcript.details_runtime)}+ value={runtimeDisplayName(runtimeInfo)}+ />+ )}+ {providerLabel && (+ <RunDetailRow label={t(($) => $.transcript.details_provider)} value={providerLabel} />+ )}+ {runtimeInfo && (+ <RunDetailRow label={t(($) => $.transcript.details_mode)} value={runtimeInfo.runtime_mode} />+ )}+ {task.relative_work_dir && (+ <RunDetailRow+ label={t(($) => $.transcript.details_workdir)}+ value={task.relative_work_dir}+ mono+ onCopy={handleCopyWorkdir}+ copied={copiedWorkdir}+ copyTitle={t(($) => $.transcript.copy_workdir)}+ />+ )}+ {createdLabel && (+ <RunDetailRow label={t(($) => $.transcript.details_created)} value={createdLabel} />+ )}+ {startedLabel && (+ <RunDetailRow label={t(($) => $.transcript.details_started)} value={startedLabel} />+ )}+ {completedLabel && (+ <RunDetailRow label={t(($) => $.transcript.details_completed)} value={completedLabel} />+ )}+ </div>+ </PopoverContent>+ </Popover>)}- <button- type="button"- onClick={handleCopyAll}- aria-label={copyTranscriptLabel}- className="flex shrink-0 items-center gap-1 rounded px-2 py-1 text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors"- >- {copied ? <Check className="h-3 w-3" /> : <Copy className="h-3 w-3" />}- <span className="hidden sm:inline">{copyTranscriptLabel}</span>- </button>- <button- type="button"+ <Button+ variant="ghost"+ size="icon-sm"onClick={() => onOpenChange(false)}- className="flex shrink-0 items-center justify-center rounded p-1 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors"+ aria-label={t(($) => $.transcript.close)}+ className="text-muted-foreground"><X className="h-4 w-4" />- </button>+ </Button></div></div>+ </div>- {/* Metadata chips row */}- <div className="flex items-center gap-2 flex-wrap text-xs">- {/* Runtime provider */}- {runtimeInfo?.provider && (- <MetadataChip icon={<Cpu className="h-3 w-3" />}>- {formatProvider(runtimeInfo.provider)}- </MetadataChip>- )}-- {/* Runtime environment */}- {runtimeInfo && (- <MetadataChip- icon={runtimeInfo.runtime_mode === "cloud" ? <Cloud className="h-3 w-3" /> : <Monitor className="h-3 w-3" />}- >- {runtimeDisplayName(runtimeInfo)}- <span className="text-muted-foreground/60 ml-0.5">({runtimeInfo.runtime_mode})</span>- </MetadataChip>- )}-- {/* Agent type / description */}- {agentInfo?.description && (- <MetadataChip icon={<Bot className="h-3 w-3" />}>- {agentInfo.description.length > 40 ? agentInfo.description.slice(0, 40) + "..." : agentInfo.description}- </MetadataChip>+ {/* ── List toolbar: read-before-you-read summary (left) + controls+ (right). Duration + event count fill the left, so the row balances+ instead of leaving dead space. ── */}+ <div className="flex items-center gap-3 border-b px-4 py-1.5 shrink-0">+ <div className="flex min-w-0 flex-1 items-center gap-x-1.5 overflow-hidden whitespace-nowrap text-xs text-muted-foreground">+ {createdShort && (+ <>+ <span>{t(($) => $.transcript.fact_created, { time: createdShort })}</span>+ <FactDot />+ </>)}-- {/* Duration */}{duration && (- <MetadataChip icon={<Clock className="h-3 w-3" />}>- {duration}- </MetadataChip>- )}-- {/* Event counts */}- {toolCount > 0 && (- <MetadataChip>{t(($) => $.transcript.tool_calls, { count: toolCount })}</MetadataChip>+ <>+ <span>{t(($) => $.transcript.fact_took, { duration })}</span>+ <FactDot />+ </>)}- <MetadataChip>+ <span>{activeFilterKeys.length > 0? t(($) => $.transcript.events_filtered, { shown: filteredItems.length, total: items.length }): t(($) => $.transcript.events, { count: items.length })}- </MetadataChip>-- {/* Working directory — server-derived display path. Falls back to- nothing when older backends omit the field rather than rendering- `work_dir` raw and leaking the user's home directory. The- absolute `task.work_dir` deliberately never reaches the DOM- anywhere — only `relative_work_dir` is safe to render / put in- title / copy to clipboard, because the server has already- stripped $HOME and the username out of it. The button- truncates because real workdir paths are routinely long- enough to push every other chip off the row. */}- {task.relative_work_dir && (- <button- type="button"- onClick={handleCopyWorkdir}- title={task.relative_work_dir}- className="inline-flex max-w-[16rem] items-center gap-1 rounded-md border bg-muted/50 px-2 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"- >- {copiedWorkdir ? (- <Check className="h-3 w-3 shrink-0 text-emerald-500" />- ) : (- <Folder className="h-3 w-3 shrink-0" />- )}- <span className="truncate font-mono">{task.relative_work_dir}</span>- </button>+ </span>+ </div>+ <div className="flex shrink-0 items-center gap-1">+ {items.length > 0 && (+ <DropdownMenu>+ <DropdownMenuTrigger+ render={+ <Button+ variant="ghost"+ size="sm"+ aria-label={t(($) => $.transcript.density_label)}+ className="text-muted-foreground"+ />+ }+ >+ <ListCollapse className="h-3 w-3" />+ <span className="hidden sm:inline">+ {density === "smart"+ ? t(($) => $.transcript.density_smart)+ : density === "expanded"+ ? t(($) => $.transcript.density_expanded)+ : t(($) => $.transcript.density_collapsed)}+ </span>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="w-64">+ <DropdownMenuRadioGroup+ value={density}+ onValueChange={(value) => setDensity(value as TranscriptDetailDensity)}+ >+ {(+ [+ ["smart", t(($) => $.transcript.density_smart), t(($) => $.transcript.density_smart_desc)],+ ["expanded", t(($) => $.transcript.density_expanded), t(($) => $.transcript.density_expanded_desc)],+ ["collapsed", t(($) => $.transcript.density_collapsed), t(($) => $.transcript.density_collapsed_desc)],+ ] as const+ ).map(([value, name, description]) => (+ <DropdownMenuRadioItem key={value} value={value} className="items-start">+ <span className="flex min-w-0 flex-col gap-0.5">+ <span>{name}</span>+ <span className="text-[11px] leading-snug text-muted-foreground">+ {description}+ </span>+ </span>+ </DropdownMenuRadioItem>+ ))}+ </DropdownMenuRadioGroup>+ </DropdownMenuContent>+ </DropdownMenu>)}-- {/* Created time */}- {task.created_at && (- <MetadataChip>- {new Date(task.created_at).toLocaleString(undefined, {- month: "short",- day: "numeric",- hour: "2-digit",- minute: "2-digit",- })}- </MetadataChip>+ {items.length > 1 && (+ <SortDirectionToggle+ value={sortDirection}+ onChange={handleSortDirectionChange}+ labels={{+ chronological: t(($) => $.transcript.sort_chronological),+ newestFirst: t(($) => $.transcript.sort_newest_first),+ ariaLabel: t(($) => $.transcript.sort_label),+ }}+ />)}+ {filterOptions.length > 0 && (+ <DropdownMenu>+ <DropdownMenuTrigger+ render={+ <Button+ variant={activeFilterKeys.length > 0 ? "brand" : "ghost"}+ size="sm"+ aria-label={t(($) => $.transcript.filter)}+ className={activeFilterKeys.length > 0 ? undefined : "text-muted-foreground"}+ />+ }+ >+ <Filter className="h-3 w-3" />+ <span className="hidden sm:inline">{t(($) => $.transcript.filter)}</span>+ {activeFilterKeys.length > 0 && (+ <span className="ml-0.5 rounded-full bg-brand-foreground/20 px-1.5 py-0 text-[10px] font-medium tabular-nums">+ {activeFilterKeys.length}+ </span>+ )}+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="w-auto">+ {filterOptions.map(([value, label]) => (+ <DropdownMenuCheckboxItem+ key={value}+ checked={selectedFilterKeys.includes(value)}+ onCheckedChange={() => toggleFilterKey(value)}+ >+ {label}+ </DropdownMenuCheckboxItem>+ ))}+ {selectedFilterKeys.length > 0 && (+ <>+ <DropdownMenuSeparator />+ <DropdownMenuItem onClick={clearFilters} className="text-muted-foreground">+ {t(($) => $.transcript.clear_filters)}+ </DropdownMenuItem>+ </>+ )}+ </DropdownMenuContent>+ </DropdownMenu>+ )}+ <Button+ variant="ghost"+ size="sm"+ onClick={handleCopyAll}+ aria-label={copyTranscriptLabel}+ className="text-muted-foreground"+ >+ {copied ? <Check className="h-3 w-3" /> : <Copy className="h-3 w-3" />}+ <span className="hidden sm:inline">{copyTranscriptLabel}</span>+ </Button></div></div>@@ -720,10 +774,7 @@ export function AgentTranscriptDialog({)}{/* ── Event list ─────────────────────────────────────────── */}- <div- ref={scrollContainerRef}- className="flex-1 overflow-y-auto min-h-0"- >+ <div className="flex-1 min-h-0">{displayItems.length === 0 ? (<div className="flex items-center justify-center h-full text-sm text-muted-foreground">{isAntigravityLiveEmpty ? (@@ -741,21 +792,28 @@ export function AgentTranscriptDialog({)}</div>) : (- <div className="divide-y">- {displayItems.map((item) => (+ // Virtualized so a multi-thousand-event run mounts a bounded number+ // of DOM rows (#5733). Rows expand/collapse to variable heights;+ // Virtuoso re-measures them via ResizeObserver.+ <Virtuoso+ key={listEpoch}+ ref={virtuosoRef}+ style={{ height: "100%" }}+ data={displayItems}+ firstItemIndex={firstItemIndex}+ computeItemKey={(_, item) => item.seq}+ components={LIST_COMPONENTS}+ itemContent={(_, item) => (<TranscriptEventRow- key={item.seq}- ref={(el) => {- if (el) eventRefs.current.set(item.seq, el);- else eventRefs.current.delete(item.seq);- }}item={item}isSelected={selectedSeq === item.seq}- expanded={expandedSeqs.has(item.seq)}+ expanded={+ rowOverrides.get(item.seq) ?? traceEventDefaultExpanded(item, density)+ }onExpandedChange={(expanded) => handleRowExpandedChange(item.seq, expanded)}/>- ))}- </div>+ )}+ />)}</div></DialogContent>@@ -771,54 +829,38 @@ interface SortDirectionToggleProps {labels: { chronological: string; newestFirst: string; ariaLabel: string };}+// Sort is a two-state toggle, not a mode picker: one button showing the+// current direction that flips on click. Shares the toolbar button chassis so+// it reads as the same control family as density/filter/copy — no tab strip.function SortDirectionToggle({ value, onChange, labels }: SortDirectionToggleProps) {+ const isChronological = value === "chronological";return (- <div- role="group"+ <Button+ variant="ghost"+ size="sm"+ onClick={() => onChange(isChronological ? "newest_first" : "chronological")}aria-label={labels.ariaLabel}- className="inline-flex shrink-0 items-center rounded border bg-muted/40 p-0.5 text-xs"+ title={labels.ariaLabel}+ className="text-muted-foreground">- <button- type="button"- aria-pressed={value === "chronological"}- title={labels.chronological}- onClick={() => onChange("chronological")}- className={cn(- "flex items-center gap-1 rounded px-1.5 py-0.5 transition-colors",- value === "chronological"- ? "bg-background text-foreground shadow-sm"- : "text-muted-foreground hover:text-foreground",- )}- >+ {isChronological ? (<ArrowDownNarrowWide className="h-3 w-3" />- <span className="hidden sm:inline">{labels.chronological}</span>- </button>- <button- type="button"- aria-pressed={value === "newest_first"}- title={labels.newestFirst}- onClick={() => onChange("newest_first")}- className={cn(- "flex items-center gap-1 rounded px-1.5 py-0.5 transition-colors",- value === "newest_first"- ? "bg-background text-foreground shadow-sm"- : "text-muted-foreground hover:text-foreground",- )}- >+ ) : (<ArrowUpNarrowWide className="h-3 w-3" />- <span className="hidden sm:inline">{labels.newestFirst}</span>- </button>- </div>+ )}+ <span className="hidden sm:inline">+ {isChronological ? labels.chronological : labels.newestFirst}+ </span>+ </Button>);}-// ─── Metadata chip ──────────────────────────────────────────────────────────+// ─── Facts line separator ───────────────────────────────────────────────────-function MetadataChip({ icon, children }: { icon?: React.ReactNode; children: React.ReactNode }) {+function FactDot() {return (- <span className="inline-flex items-center gap-1 rounded-md border bg-muted/50 px-2 py-0.5 text-[11px] text-muted-foreground">- {icon}- {children}+ <span aria-hidden className="text-muted-foreground/40">+ ·</span>);}@@ -881,11 +923,11 @@ function TimelineBar({)}style={{ width: `${Math.max(widthPercent, 0.5)}%` }}onClick={() => onSegmentClick(items[seg.startIdx]!.seq)}- title={`${getEventLabel(items[seg.startIdx]!)}${seg.count > 1 ? ` (+${seg.count - 1} more)` : ""}`}+ title={`${traceEventLabel(items[seg.startIdx]!)}${seg.count > 1 ? ` (+${seg.count - 1} more)` : ""}`}><div className="absolute bottom-full left-1/2 -translate-x-1/2 mb-1 hidden group-hover:block z-10 pointer-events-none"><div className="rounded bg-popover border px-2 py-1 text-[10px] text-popover-foreground shadow-md whitespace-nowrap">- {getEventLabel(items[seg.startIdx]!)}+ {traceEventLabel(items[seg.startIdx]!)}{seg.count > 1 && <span className="text-muted-foreground ml-1">+{seg.count - 1}</span>}</div></div>@@ -906,28 +948,34 @@ interface TranscriptEventRowProps {}const TranscriptEventRow = ({- ref,item,isSelected,expanded,onExpandedChange,-}: TranscriptEventRowProps & { ref?: React.Ref<HTMLDivElement> }) => {+}: TranscriptEventRowProps) => {+ const { t } = useT("agents");+ const kind = traceEventKind(item);const color = getEventColor(item);- const label = getEventLabel(item);- const summary = getEventSummary(item);+ const label = traceEventLabel(item);+ const summary = traceEventSummary(item);const date = useMemo(() => (item.created_at ? new Date(item.created_at) : null),[item.created_at],);- const hasDetail = hasEventDetail(item);+ const hasDetail = traceEventHasDetail(item);+ // Prose kinds swap the one-line summary for the full body in place when+ // expanded (no box). Tool kinds keep the summary line and reveal the+ // params/output surface below it.+ const isProse = kind !== "tool_use" && kind !== "tool_result";+ const showInlineBody = isProse && hasDetail && expanded;return (<div- ref={ref}className={cn("group transition-colors",isSelected && "bg-accent/50",+ kind === "error" && "bg-destructive/5",)}><Collapsible open={expanded} onOpenChange={onExpandedChange}>@@ -944,27 +992,63 @@ const TranscriptEventRow = ({{label}</span>- {/* Summary */}- <CollapsibleTrigger- className={cn(- "flex-1 text-left text-xs min-w-0 py-0.5 transition-colors",- hasDetail ? "cursor-pointer hover:text-foreground" : "cursor-default",- item.type === "error" ? "text-destructive" : "text-muted-foreground",- )}- disabled={!hasDetail}- >- <div className="flex items-start gap-1.5">- {hasDetail && (- <ChevronRight+ {showInlineBody ? (+ <div className="flex flex-1 items-start gap-1.5 min-w-0">+ <CollapsibleTrigger+ aria-label={label}+ className="shrink-0 mt-0.5 cursor-pointer rounded p-0.5 text-muted-foreground/50 transition-colors hover:text-foreground"+ >+ <ChevronRight className="h-3 w-3 rotate-90 transition-transform" />+ </CollapsibleTrigger>+ <div className="flex-1 min-w-0">+ {kind === "agent" ? (+ <RichContent+ content={item.content ?? ""}+ density="compact"+ className="transcript-prose"+ />+ ) : (+ <div+ className={cn(+ "whitespace-pre-wrap break-words text-xs leading-relaxed",+ kind === "error" ? "text-destructive" : "text-muted-foreground",+ )}+ >+ {item.content ?? ""}+ </div>+ )}+ </div>+ </div>+ ) : (+ <CollapsibleTrigger+ className={cn(+ "flex-1 text-left text-xs min-w-0 py-0.5 transition-colors",+ hasDetail ? "cursor-pointer hover:text-foreground" : "cursor-default",+ kind === "error" ? "text-destructive" : "text-muted-foreground",+ )}+ disabled={!hasDetail}+ >+ <div className="flex items-start gap-1.5">+ {hasDetail && (+ <ChevronRight+ className={cn(+ "h-3 w-3 shrink-0 mt-0.5 text-muted-foreground/50 transition-transform",+ expanded && "rotate-90",+ )}+ />+ )}+ <spanclassName={cn(- "h-3 w-3 shrink-0 mt-0.5 text-muted-foreground/50 transition-transform",- expanded && "rotate-90",+ "truncate",+ traceEventSummaryIsMono(kind) && summary && "font-mono text-[11px]",+ !summary && "text-muted-foreground/60",)}- />- )}- <span className="truncate">{summary || "(empty)"}</span>- </div>- </CollapsibleTrigger>+ >+ {summary || t(($) => $.transcript.no_output)}+ </span>+ </div>+ </CollapsibleTrigger>+ )}{/* Seq number / index */}<span className="shrink-0 text-[10px] text-muted-foreground/50 tabular-nums mt-1">@@ -983,12 +1067,23 @@ const TranscriptEventRow = ({)}</div>- {/* Expanded detail */}- {hasDetail && (+ {/* Expanded params/output for tool kinds — a quiet, borderless surface+ aligned to the content column. */}+ {!isProse && hasDetail && (<CollapsibleContent><div className="px-4 pb-3">- <div className="ml-[72px] rounded bg-muted/40 border">- <EventDetailContent item={item} />+ <div className="ml-[72px] rounded-md bg-muted/40">+ <ToolDetailSurface+ text={+ kind === "tool_use"+ ? redactSecrets(JSON.stringify(item.input ?? {}, null, 2))+ : item.output+ ? item.output.length > 4000+ ? redactSecrets(item.output.slice(0, 4000)) + "\n... (truncated)"+ : redactSecrets(item.output)+ : ""+ }+ /></div></div></CollapsibleContent>@@ -998,45 +1093,39 @@ const TranscriptEventRow = ({);};-// ─── Event detail content ───────────────────────────────────────────────────+// ─── Tool detail surface ────────────────────────────────────────────────────-function EventDetailContent({ item }: { item: TimelineItem }) {- switch (item.type) {- case "tool_use":- return (- <pre className="max-h-60 overflow-auto p-3 text-[11px] text-muted-foreground whitespace-pre-wrap break-all">- {item.input ? redactSecrets(JSON.stringify(item.input, null, 2)) : ""}- </pre>- );- case "tool_result":- return (- <pre className="max-h-60 overflow-auto p-3 text-[11px] text-muted-foreground whitespace-pre-wrap break-all">- {item.output- ? item.output.length > 4000- ? redactSecrets(item.output.slice(0, 4000)) + "\n... (truncated)"- : redactSecrets(item.output)- : ""}- </pre>- );- case "thinking":- return (- <pre className="max-h-60 overflow-auto p-3 text-[11px] text-muted-foreground whitespace-pre-wrap break-words">- {item.content ?? ""}- </pre>- );- case "text":- return (- <pre className="max-h-60 overflow-auto p-3 text-[11px] text-muted-foreground whitespace-pre-wrap break-words">- {item.content ?? ""}- </pre>- );- case "error":- return (- <pre className="max-h-60 overflow-auto p-3 text-[11px] text-destructive whitespace-pre-wrap break-words">- {item.content ?? ""}- </pre>- );- default:- return null;- }+/**+ * Long content fades out behind a "show all" affordance instead of trapping a+ * nested scrollbar inside the virtualized list.+ */+function ToolDetailSurface({ text }: { text: string }) {+ const { t } = useT("agents");+ const [showAll, setShowAll] = useState(false);+ const isLong = text.length > 1600 || text.split("\n").length > 14;++ return (+ <div className="relative">+ <pre+ className={cn(+ "p-3 font-mono text-[11px] text-muted-foreground whitespace-pre-wrap break-all",+ isLong && !showAll && "max-h-52 overflow-hidden",+ )}+ >+ {text}+ </pre>+ {isLong && !showAll && (+ <div className="absolute inset-x-0 bottom-0 flex h-12 items-end justify-center rounded-b-md bg-gradient-to-b from-transparent to-background">+ <button+ type="button"+ onClick={() => setShowAll(true)}+ className="mb-1.5 rounded px-2 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"+ >+ {t(($) => $.transcript.show_all)}+ </button>+ </div>+ )}+ </div>+ );}+diff --git a/packages/views/common/task-transcript/task-transcript.css b/packages/views/common/task-transcript/task-transcript.cssnew file mode 100644index 0000000000..019033200e--- /dev/null+++ b/packages/views/common/task-transcript/task-transcript.css@@ -0,0 +1,62 @@+/*+ * Log-scale markdown for transcript agent text (rendered via RichContent with+ * className="transcript-prose"). Structure is preserved; the type scale is+ * flattened to the transcript's data-panel rhythm: body 12.5px, mono 11px,+ * headings demoted to body size. Selectors double up with .rich-text-editor+ * (the RichContent root) so they outrank the shared base styles regardless of+ * CSS load order.+ */++.rich-text-editor.transcript-prose {+ font-size: 12.5px;+ line-height: 1.7;+}++.rich-text-editor.transcript-prose > :first-child {+ margin-top: 0;+}++.rich-text-editor.transcript-prose > :last-child {+ margin-bottom: 0;+}++.rich-text-editor.transcript-prose p {+ margin: 0.25rem 0;+}++.rich-text-editor.transcript-prose ul,+.rich-text-editor.transcript-prose ol {+ margin: 0.25rem 0;+ padding-left: 1.25rem;+}++.rich-text-editor.transcript-prose li {+ margin: 0.1rem 0;+}++/* A transcript is not an article: every heading demotes to emphasized body. */+.rich-text-editor.transcript-prose h1,+.rich-text-editor.transcript-prose h2,+.rich-text-editor.transcript-prose h3,+.rich-text-editor.transcript-prose h4,+.rich-text-editor.transcript-prose h5,+.rich-text-editor.transcript-prose h6 {+ font-size: 12.5px;+ font-weight: 500;+ margin: 0.5rem 0 0.15rem;+}++.rich-text-editor.transcript-prose code {+ font-size: 11px;+}++.rich-text-editor.transcript-prose pre,+.rich-text-editor.transcript-prose .code-block-wrapper {+ font-size: 11px;+ margin: 0.35rem 0;+}++.rich-text-editor.transcript-prose blockquote {+ margin: 0.35rem 0;+ font-size: 12.5px;+}diff --git a/packages/views/common/task-transcript/trace-event-presenter.test.ts b/packages/views/common/task-transcript/trace-event-presenter.test.tsnew file mode 100644index 0000000000..027fa4e265--- /dev/null+++ b/packages/views/common/task-transcript/trace-event-presenter.test.ts@@ -0,0 +1,118 @@+import { describe, expect, it } from "vitest";+import {+ stripShellWrapper,+ traceEventCopyText,+ traceEventDefaultExpanded,+ traceEventHasDetail,+ traceEventKind,+ traceEventLabel,+ traceEventSummary,+ traceToolArgSummary,+} from "./trace-event-presenter";++describe("traceEventKind / traceEventLabel", () => {+ it("maps the five persisted types and keeps unknown types as generic", () => {+ expect(traceEventKind({ type: "text" })).toBe("agent");+ expect(traceEventKind({ type: "thinking" })).toBe("thinking");+ expect(traceEventKind({ type: "tool_use" })).toBe("tool_use");+ expect(traceEventKind({ type: "tool_result" })).toBe("tool_result");+ expect(traceEventKind({ type: "error" })).toBe("error");+ expect(traceEventKind({ type: "provider_custom" })).toBe("generic");+ });++ it("shows provider-native tool names verbatim and surfaces raw unknown types", () => {+ expect(traceEventLabel({ type: "tool_use", tool: "exec_command" })).toBe("exec_command");+ expect(traceEventLabel({ type: "tool_result", tool: "patch_apply" })).toBe("patch_apply");+ expect(traceEventLabel({ type: "tool_use" })).toBe("Tool");+ expect(traceEventLabel({ type: "provider_custom" })).toBe("provider_custom");+ });+});++describe("stripShellWrapper", () => {+ it("strips login-shell wrappers but keeps bare commands", () => {+ expect(stripShellWrapper("/bin/zsh -lc 'rm ./reply.md'")).toBe("rm ./reply.md");+ expect(stripShellWrapper('/bin/bash -c "git status"')).toBe("git status");+ expect(stripShellWrapper("sh -c 'ls -la'")).toBe("ls -la");+ expect(stripShellWrapper("pnpm test")).toBe("pnpm test");+ // Mismatched quotes are not a wrapper match.+ expect(stripShellWrapper("/bin/zsh -lc 'echo hi\"")).toBe("/bin/zsh -lc 'echo hi\"");+ });+});++describe("traceToolArgSummary", () => {+ it("prefers query, then paths (shortened), then command with wrapper stripped", () => {+ expect(traceToolArgSummary({ query: "flaky tests", command: "x" })).toBe("flaky tests");+ expect(traceToolArgSummary({ file_path: "/a/b/c/d/e.ts" })).toBe(".../d/e.ts");+ expect(traceToolArgSummary({ command: "/bin/zsh -lc 'kubectl get pods -n prd'" })).toBe(+ "kubectl get pods -n prd",+ );+ });++ it("falls back to the first short string value and tolerates empty input", () => {+ expect(traceToolArgSummary({ n: 3, note: "short value" })).toBe("short value");+ expect(traceToolArgSummary(undefined)).toBe("");+ expect(traceToolArgSummary({})).toBe("");+ });+});++describe("traceEventSummary", () => {+ it("takes the first non-empty line for agent text", () => {+ expect(traceEventSummary({ type: "text", content: "\n\nFirst line\nrest" })).toBe(+ "First line",+ );+ });++ it("collapses pretty-printed JSON output to a content preview, not a lone bracket", () => {+ const output = '[\n {\n "id": "694c",\n "title": "x"\n }\n]';+ expect(traceEventSummary({ type: "tool_result", output })).toBe(+ '[ { "id": "694c", "title": "x" } ]',+ );+ });++ it("retains unknown events instead of dropping them", () => {+ expect(traceEventSummary({ type: "custom", content: "payload" })).toBe("payload");+ });+});++describe("traceEventCopyText", () => {+ it("copies the full untruncated body, not the one-line summary", () => {+ const longOutput = "line 1\n".repeat(60);+ expect(traceEventCopyText({ type: "tool_result", tool: "Bash", output: longOutput })).toBe(+ `[Bash] ${longOutput}`,+ );+ expect(+ traceEventCopyText({ type: "tool_use", tool: "Bash", input: { command: "ls" } }),+ ).toBe('[Bash] {\n "command": "ls"\n}');+ expect(traceEventCopyText({ type: "text", content: "full\nagent\nreply" })).toBe(+ "[Agent] full\nagent\nreply",+ );+ });++ it("emits a bare label when the event has no body", () => {+ expect(traceEventCopyText({ type: "tool_use", tool: "Bash" })).toBe("[Bash]");+ });+});++describe("traceEventDefaultExpanded", () => {+ const agent = { type: "text", content: "hello" };+ const error = { type: "error", content: "boom" };+ const thinking = { type: "thinking", content: "hmm" };+ const tool = { type: "tool_use", tool: "Bash", input: { command: "ls" } };++ it("smart: agent and error read without a click, process noise stays folded", () => {+ expect(traceEventDefaultExpanded(agent, "smart")).toBe(true);+ expect(traceEventDefaultExpanded(error, "smart")).toBe(true);+ expect(traceEventDefaultExpanded(thinking, "smart")).toBe(false);+ expect(traceEventDefaultExpanded(tool, "smart")).toBe(false);+ });++ it("expanded/collapsed override the hierarchy wholesale", () => {+ expect(traceEventDefaultExpanded(thinking, "expanded")).toBe(true);+ expect(traceEventDefaultExpanded(agent, "collapsed")).toBe(false);+ });++ it("a row without detail never expands", () => {+ expect(traceEventDefaultExpanded({ type: "text" }, "expanded")).toBe(false);+ expect(traceEventHasDetail({ type: "tool_use", input: {} })).toBe(false);+ });+});diff --git a/packages/views/common/task-transcript/trace-event-presenter.ts b/packages/views/common/task-transcript/trace-event-presenter.tsnew file mode 100644index 0000000000..6ccddda69d--- /dev/null+++ b/packages/views/common/task-transcript/trace-event-presenter.ts@@ -0,0 +1,206 @@+// Trace Event Presenter — the pure readability layer for the execution+// transcript. Given one timeline event it decides visual kind, label, one-line+// summary, and default expansion, encoding the reading hierarchy:+//+// 1. Agent text is the primary layer and reads without a click.+// 2. Errors stand out and also read without a click.+// 3. Tool calls are compact — provider-native name + most-informative arg.+// 4. Tool results and thinking are de-emphasized and collapsed by default.+// 5. Unknown event types are retained as a generic event, never dropped.+//+// This module owns no React and no fetching, so it is unit-testable in+// isolation and independent of whichever list shell renders the events.++import type { TranscriptDetailDensity } from "@multica/core/agents/stores";++export type { TranscriptDetailDensity };++export interface TraceEvent {+ seq?: number;+ type: string;+ tool?: string;+ content?: string;+ input?: Record<string, unknown>;+ output?: string;+ created_at?: string;+}++/** Visual kind driving color/emphasis. `generic` covers any unknown `type`. */+export type TraceEventKind =+ | "agent"+ | "thinking"+ | "tool_use"+ | "tool_result"+ | "error"+ | "generic";++export function traceEventKind(event: TraceEvent): TraceEventKind {+ switch (event.type) {+ case "text":+ return "agent";+ case "thinking":+ return "thinking";+ case "tool_use":+ return "tool_use";+ case "tool_result":+ return "tool_result";+ case "error":+ return "error";+ default:+ return "generic";+ }+}++/**+ * Human label. Tool events show the provider-native tool name verbatim+ * (exec_command, patch_apply — never renamed); an unknown type shows its own+ * raw type string so evidence is never mislabeled.+ */+export function traceEventLabel(event: TraceEvent): string {+ switch (event.type) {+ case "text":+ return "Agent";+ case "thinking":+ return "Thinking";+ case "tool_use":+ return event.tool && event.tool.length > 0 ? event.tool : "Tool";+ case "tool_result":+ return event.tool && event.tool.length > 0 ? event.tool : "Result";+ case "error":+ return "Error";+ default:+ return event.type && event.type.length > 0 ? event.type : "Event";+ }+}++/** Shorten a long path to ".../parent/leaf" so a tool summary stays one line. */+export function shortenTracePath(p: string): string {+ const parts = p.split("/");+ if (parts.length <= 3) return p;+ return ".../" + parts.slice(-2).join("/");+}++// Providers commonly wrap the real command in a login-shell invocation; the+// wrapper is pure noise in a one-line summary (the full original stays in the+// expanded params). Matches `<shell> -lc '<cmd>'` / `-c "<cmd>"` forms.+const SHELL_WRAPPER_PATTERN =+ /^(?:\/[\w./-]*\/)?(?:zsh|bash|sh|fish)\s+(?:-[a-z]+\s+)*(['"])([\s\S]+)\1$/;++export function stripShellWrapper(command: string): string {+ const match = SHELL_WRAPPER_PATTERN.exec(command.trim());+ return match?.[2] ?? command;+}++function clip(value: string, max: number): string {+ return value.length > max ? value.slice(0, max) + "..." : value;+}++/**+ * The single most informative argument of a tool call, as one line. Preference+ * order matches what a reviewer scans for first, falling back to the first+ * short string value.+ */+export function traceToolArgSummary(input: Record<string, unknown> | undefined): string {+ if (!input) return "";+ const str = (v: unknown): string => (typeof v === "string" ? v : "");+ if (str(input.query)) return str(input.query);+ if (str(input.file_path)) return shortenTracePath(str(input.file_path));+ if (str(input.path)) return shortenTracePath(str(input.path));+ if (str(input.pattern)) return str(input.pattern);+ if (str(input.description)) return str(input.description);+ if (str(input.command)) return clip(stripShellWrapper(str(input.command)), 120);+ if (str(input.prompt)) return clip(str(input.prompt), 120);+ if (str(input.skill)) return str(input.skill);+ for (const v of Object.values(input)) {+ if (typeof v === "string" && v.length > 0 && v.length < 120) return v;+ }+ return "";+}++function firstLine(value: string | undefined): string {+ return value?.split("\n").find((l) => l.trim().length > 0) ?? "";+}++/**+ * Collapse all whitespace runs to single spaces. Unlike firstLine this keeps+ * content that spans lines, so a pretty-printed JSON result previews as+ * `[ { "id": ... } ]` instead of a lone opening bracket.+ */+function collapseWhitespace(value: string | undefined): string {+ return (value ?? "").replace(/\s+/g, " ").trim();+}++/** One-line summary for the collapsed row — never contains a newline. */+export function traceEventSummary(event: TraceEvent): string {+ switch (traceEventKind(event)) {+ case "thinking":+ return clip(firstLine(event.content), 200);+ case "tool_use":+ return traceToolArgSummary(event.input);+ case "tool_result":+ return clip(collapseWhitespace(event.output), 200);+ default:+ return firstLine(event.content ?? event.output);+ }+}++/**+ * Full, untruncated text for "copy all" — the complete body, not the one-line+ * summary. Tool calls copy their full input JSON; results and prose copy their+ * whole content. An RFC 3339 timestamp prefixes the line when the event has a+ * valid `created_at` (#5873). Callers apply secret redaction on the result.+ */+export function traceEventCopyText(event: TraceEvent): string {+ const label = traceEventLabel(event);+ let body: string;+ switch (traceEventKind(event)) {+ case "tool_use":+ body = event.input ? JSON.stringify(event.input, null, 2) : "";+ break;+ case "tool_result":+ body = event.output ?? "";+ break;+ default:+ body = event.content ?? "";+ }+ const date = event.created_at ? new Date(event.created_at) : null;+ const timestamp = date && !Number.isNaN(date.getTime()) ? `[${date.toISOString()}] ` : "";+ return body ? `${timestamp}[${label}] ${body}` : `${timestamp}[${label}]`;+}++export function traceEventHasDetail(event: TraceEvent): boolean {+ switch (traceEventKind(event)) {+ case "tool_use":+ return !!event.input && Object.keys(event.input).length > 0;+ case "tool_result":+ return !!event.output && event.output.length > 0;+ default:+ return !!event.content && event.content.length > 0;+ }+}++/** Whether a monospace face fits the collapsed summary (commands/output). */+export function traceEventSummaryIsMono(kind: TraceEventKind): boolean {+ return kind === "tool_use" || kind === "tool_result";+}++/**+ * Default expansion under the `smart` density: the reading hierarchy itself.+ * Agent text and errors read without a click; process noise stays folded.+ */+export function traceEventDefaultExpanded(+ event: TraceEvent,+ density: TranscriptDetailDensity,+): boolean {+ if (!traceEventHasDetail(event)) return false;+ switch (density) {+ case "expanded":+ return true;+ case "collapsed":+ return false;+ case "smart": {+ const kind = traceEventKind(event);+ return kind === "agent" || kind === "error";+ }+ }+}diff --git a/packages/views/issues/components/attribution-badge.test.tsx b/packages/views/issues/components/attribution-badge.test.tsxindex 58be0ea7f3..8e0f9d9fab 100644--- a/packages/views/issues/components/attribution-badge.test.tsx+++ b/packages/views/issues/components/attribution-badge.test.tsx@@ -96,6 +96,24 @@ describe("AttributionBadge", () => {expect(screen.getByText("On behalf of someone")).toBeInTheDocument();});+ it("inline variant renders the bare name (no on-behalf-of wrapper), source in tooltip", () => {+ const attribution: TaskAttribution = {+ source: "direct_human",+ precise: true,+ initiator: { id: "u1", name: "Ada Lovelace" },+ };+ const { container } = renderWithI18n(+ <AttributionBadge attribution={attribution} variant="inline" />,+ );++ // The caller supplies the label; the value is just the person (the mocked+ // avatar also echoes the name, hence getAllByText).+ expect(screen.getAllByText("Ada Lovelace").length).toBeGreaterThan(0);+ expect(screen.queryByText("On behalf of Ada Lovelace")).toBeNull();+ // Typography, not a chip: the inline shape must not render a Badge border.+ expect(container.querySelector("[data-slot='badge']")).toBeNull();+ });+it("renders nothing when no responsible member resolved (MUL-4765)", () => {const attribution: TaskAttribution = {source: "unattributed",diff --git a/packages/views/issues/components/attribution-badge.tsx b/packages/views/issues/components/attribution-badge.tsxindex f16953ad4d..d31f72e2f0 100644--- a/packages/views/issues/components/attribution-badge.tsx+++ b/packages/views/issues/components/attribution-badge.tsx@@ -31,7 +31,7 @@ function initialsOf(name: string): string {* earns no warning tone; its historical origin still shows in the tooltip and* the raw `source` field (MUL-4768).*- * Two shapes, both silent when no responsible member resolved (MUL-4765):+ * Three shapes, all silent when no responsible member resolved (MUL-4765):* - `variant="badge"` (default): the full "on behalf of <name>" chip. Renders* nothing when there's no accountable member, so an unassigned run reads as* plain rather than a warning.@@ -39,6 +39,10 @@ function initialsOf(name: string): string {* source in a hover tooltip. Compact enough for a dense task row. Renders* nothing when there's no accountable member — an avatar-only surface has* nothing meaningful to show for an unattributed run.+ * - `variant="inline"`: the bare member name (borderless, avatar optional via+ * `hideAvatar`) with the source in a tooltip — for a sentence-like identity+ * row (transcript header) where the caller supplies the label. Same silence+ * rule.** Renders nothing when the task has no attribution at all (older backends) —* the caller should optional-chain `task.attribution`.@@ -47,10 +51,14 @@ export function AttributionBadge({attribution,className,variant = "badge",+ hideAvatar = false,}: {attribution?: TaskAttribution;className?: string;- variant?: "badge" | "avatar";+ variant?: "badge" | "avatar" | "inline";+ /** Inline variant only: render the name without the avatar, so it does not+ * compete with a nearby primary avatar (the transcript identity row). */+ hideAvatar?: boolean;}) {const { t } = useT("issues");if (!attribution) return null;@@ -104,6 +112,42 @@ export function AttributionBadge({attribution.precise === false && attribution.source !== "backfill";const initiator = attribution.initiator;+ // Inline shape: avatar + bare name, no border and no "on behalf of" wrapper —+ // the caller supplies the label ("Triggered by") so the value is just the+ // person. The resolution source stays in the tooltip.+ if (variant === "inline") {+ const initiatorInline = attribution.initiator;+ if (!initiatorInline) return null;+ const name = initiatorInline.name || t(($) => $.execution_log.attribution.someone);+ return (+ <Tooltip>+ <TooltipTrigger+ render={+ <span+ className={cn(+ "inline-flex min-w-0 items-center gap-1.5 text-xs",+ uncertain ? "text-warning" : "text-foreground/80",+ className+ )}+ >+ {!hideAvatar && (+ <ActorAvatar+ name={name}+ initials={initialsOf(name)}+ avatarUrl={initiatorInline.avatar_url}+ size="xs"+ className="shrink-0"+ />+ )}+ <span className="min-w-0 truncate">{name}</span>+ </span>+ }+ />+ <TooltipContent>{sourceLabel}</TooltipContent>+ </Tooltip>+ );+ }+// Avatar-only shape: just the accountable member's face, with the name +// source in a hover tooltip. Nothing to show without an accountable member.if (variant === "avatar") {diff --git a/packages/views/locales/en/agents.json b/packages/views/locales/en/agents.jsonindex 799d189e9f..d90736c498 100644--- a/packages/views/locales/en/agents.json+++ b/packages/views/locales/en/agents.json@@ -765,9 +765,7 @@"status_failed": "Failed","filter": "Filter","clear_filters": "Clear filters",- "tool_calls_one": "{{count}} tool call",- "tool_calls_other": "{{count}} tool calls",- "events_one": "{{count}} events",+ "events_one": "{{count}} event","events_other": "{{count}} events","events_filtered": "{{shown}} of {{total}} events","copy_all": "Copy all",@@ -779,10 +777,38 @@"sort_label": "Sort","sort_chronological": "Oldest first","sort_newest_first": "Newest first",- "expand_visible": "Expand visible",- "collapse_visible": "Collapse visible",- "preserve_filters": "Preserve filters",- "default_expanded": "Open details by default"+ "density_label": "Expand mode",+ "density_smart": "Focus",+ "density_smart_desc": "Replies and errors open; thinking and tool steps stay folded",+ "density_expanded": "Expand all",+ "density_expanded_desc": "Every row's full params and output, for step-by-step review",+ "density_collapsed": "Collapse all",+ "density_collapsed_desc": "One line per event — the most compact scan",+ "no_output": "No output",+ "show_all": "Show all",+ "status_queued": "Queued",+ "status_dispatched": "Dispatched",+ "status_cancelled": "Cancelled",+ "status_waiting": "Waiting",+ "trigger_initial": "Initial run",+ "trigger_comment": "From a comment",+ "trigger_autopilot": "Autopilot",+ "trigger_retry": "Retry",+ "trigger_chat": "From chat",+ "trigger_quick_create": "Quick create",+ "trigger_direct": "Direct assignment",+ "run_info": "Run details",+ "details_runtime": "Runtime",+ "details_provider": "Provider",+ "details_mode": "Mode",+ "details_workdir": "Workdir",+ "details_created": "Created",+ "details_started": "Started",+ "details_completed": "Completed",+ "copy_workdir": "Copy working directory",+ "close": "Close",+ "fact_created": "Created {{time}}",+ "fact_took": "Took {{duration}}"},"task_failure": {"agent_error": "Agent execution error",diff --git a/packages/views/locales/ja/agents.json b/packages/views/locales/ja/agents.jsonindex 6f16a7f271..6883be7094 100644--- a/packages/views/locales/ja/agents.json+++ b/packages/views/locales/ja/agents.json@@ -647,7 +647,6 @@"status_failed": "失敗","filter": "フィルター","clear_filters": "フィルターをクリア",- "tool_calls_other": "ツール呼び出し {{count}} 回","events_other": "イベント {{count}} 件","events_filtered": "イベント {{total}} 件中 {{shown}} 件","copy_all": "すべてコピー",@@ -659,10 +658,38 @@"sort_label": "並び替え","sort_chronological": "古い順","sort_newest_first": "新しい順",- "expand_visible": "表示中を展開",- "collapse_visible": "表示中を折りたたむ",- "preserve_filters": "フィルターを保持",- "default_expanded": "詳細をデフォルトで展開"+ "density_label": "展開モード",+ "density_smart": "重点展開",+ "density_smart_desc": "回答とエラーは展開、思考とツールの過程は折りたたみ",+ "density_expanded": "すべて展開",+ "density_expanded_desc": "各行のパラメータと出力を完全に展開し、逐次レビューに",+ "density_collapsed": "すべて折りたたむ",+ "density_collapsed_desc": "1 行 1 イベントの最もコンパクトな表示",+ "no_output": "出力なし",+ "show_all": "すべて表示",+ "status_queued": "待機列",+ "status_dispatched": "ディスパッチ済み",+ "status_cancelled": "キャンセル",+ "status_waiting": "待機中",+ "trigger_initial": "初回実行",+ "trigger_comment": "コメントから",+ "trigger_autopilot": "Autopilot",+ "trigger_retry": "再試行",+ "trigger_chat": "チャットから",+ "trigger_quick_create": "クイック作成",+ "trigger_direct": "直接アサイン",+ "run_info": "実行の詳細",+ "details_runtime": "ランタイム",+ "details_provider": "プロバイダー",+ "details_mode": "モード",+ "details_workdir": "作業ディレクトリ",+ "details_created": "作成",+ "details_started": "開始",+ "details_completed": "完了",+ "copy_workdir": "作業ディレクトリをコピー",+ "close": "閉じる",+ "fact_created": "作成 {{time}}",+ "fact_took": "所要 {{duration}}"},"task_failure": {"agent_error": "エージェント実行エラー",diff --git a/packages/views/locales/ko/agents.json b/packages/views/locales/ko/agents.jsonindex 20e2ac8b76..75fe4483f7 100644--- a/packages/views/locales/ko/agents.json+++ b/packages/views/locales/ko/agents.json@@ -655,7 +655,6 @@"status_failed": "실패함","filter": "필터","clear_filters": "필터 지우기",- "tool_calls_other": "도구 호출 {{count}}회","events_other": "이벤트 {{count}}개","events_filtered": "이벤트 {{total}}개 중 {{shown}}개","copy_all": "전체 복사",@@ -667,10 +666,38 @@"sort_label": "정렬","sort_chronological": "오래된 순","sort_newest_first": "최신 순",- "expand_visible": "표시 항목 펼치기",- "collapse_visible": "표시 항목 접기",- "preserve_filters": "필터 유지",- "default_expanded": "기본으로 세부 정보 펼치기"+ "density_label": "펼치기 방식",+ "density_smart": "핵심 펼치기",+ "density_smart_desc": "응답과 오류는 펼치고, 사고와 도구 과정은 접힌 상태 유지",+ "density_expanded": "모두 펼치기",+ "density_expanded_desc": "각 행의 전체 매개변수와 출력을 펼쳐 단계별 검토에 사용",+ "density_collapsed": "모두 접기",+ "density_collapsed_desc": "이벤트당 한 줄, 가장 간결한 보기",+ "no_output": "출력 없음",+ "show_all": "모두 보기",+ "status_queued": "대기열",+ "status_dispatched": "디스패치됨",+ "status_cancelled": "취소됨",+ "status_waiting": "대기 중",+ "trigger_initial": "최초 실행",+ "trigger_comment": "댓글에서",+ "trigger_autopilot": "Autopilot",+ "trigger_retry": "재시도",+ "trigger_chat": "채팅에서",+ "trigger_quick_create": "빠른 생성",+ "trigger_direct": "직접 지정",+ "run_info": "실행 세부정보",+ "details_runtime": "런타임",+ "details_provider": "제공자",+ "details_mode": "모드",+ "details_workdir": "작업 디렉터리",+ "details_created": "생성",+ "details_started": "시작",+ "details_completed": "완료",+ "copy_workdir": "작업 디렉터리 복사",+ "close": "닫기",+ "fact_created": "생성 {{time}}",+ "fact_took": "소요 {{duration}}"},"task_failure": {"agent_error": "에이전트 실행 오류",diff --git a/packages/views/locales/zh-Hans/agents.json b/packages/views/locales/zh-Hans/agents.jsonindex fad3e7230b..e316315e04 100644--- a/packages/views/locales/zh-Hans/agents.json+++ b/packages/views/locales/zh-Hans/agents.json@@ -751,7 +751,6 @@"status_failed": "失败","filter": "筛选","clear_filters": "清除筛选",- "tool_calls_other": "{{count}} 次工具调用","events_other": "{{count}} 个事件","events_filtered": "{{shown}} / {{total}} 个事件","copy_all": "全部复制",@@ -761,12 +760,40 @@"antigravity_live_unavailable": "Antigravity 暂不提供实时执行事件。task 完成后即可查看执行记录。","no_data": "未记录执行数据。","sort_label": "排序",- "sort_chronological": "时间顺序",+ "sort_chronological": "最早在前","sort_newest_first": "最新在前",- "expand_visible": "展开当前可见项",- "collapse_visible": "收起当前可见项",- "preserve_filters": "保留筛选",- "default_expanded": "默认展开详情"+ "density_label": "展开方式",+ "density_smart": "重点展开",+ "density_smart_desc": "汇报与错误展开,思考和工具过程保持折叠",+ "density_expanded": "全部展开",+ "density_expanded_desc": "展开每一行的完整参数与输出,逐条审阅用",+ "density_collapsed": "全部收起",+ "density_collapsed_desc": "一行一事件,最紧凑的扫读视图",+ "no_output": "无输出",+ "show_all": "显示全部",+ "status_queued": "排队中",+ "status_dispatched": "已派发",+ "status_cancelled": "已取消",+ "status_waiting": "等待中",+ "trigger_initial": "初次运行",+ "trigger_comment": "评论触发",+ "trigger_autopilot": "Autopilot",+ "trigger_retry": "重试",+ "trigger_chat": "来自对话",+ "trigger_quick_create": "快速创建",+ "trigger_direct": "直接指派",+ "run_info": "运行详情",+ "details_runtime": "运行时",+ "details_provider": "提供方",+ "details_mode": "模式",+ "details_workdir": "工作目录",+ "details_created": "创建",+ "details_started": "开始",+ "details_completed": "完成",+ "copy_workdir": "复制工作目录",+ "close": "关闭",+ "fact_created": "创建于 {{time}}",+ "fact_took": "用时 {{duration}}"},"task_failure": {"agent_error": "智能体执行出错",