import { ArrowUpRightIcon, ChevronRightIcon } from "lucide-react";
import { useContext, useState, type ReactNode } from "react";
import { cn } from "../lib/cn";
import { useForcedDefaultOpen } from "./disclosure-context";
import type { AgentTitleParts } from "./platform-activity-presentation";
import { ActivityDisclosure, CompactActivityContext } from "./shared";
import { ShimmerText } from "./shimmer-text";
import { useOpenGeniText } from "../messages/runtime";
/* ----------------------------------------------------------------------------
Agent row
One row for everything that crosses between agents: spawning one, messaging
one, and every update one sends back. It names the agent, previews what was
said, opens the full text in place, and deep-links to the agent's session.
It reuses the rail's row geometry (chevron, icon, title) so it reads as a
sibling of tool rows, and spends color only on failure.
-------------------------------------------------------------------------- */
export type AgentRowProps = {
icon: ReactNode;
title: AgentTitleParts;
/** Quiet secondary text shown while collapsed. */
preview?: string | null | undefined;
/** Two lines suit inbound messages; spawns and messages use one. */
previewLines?: 1 | 2 | undefined;
/** Short trailing note after the title, e.g. "+2 earlier". */
meta?: string | null | undefined;
/** The agent session the row deep-links to. */
sessionId?: string | null | undefined;
onOpenSession?: ((sessionId: string) => void) | undefined;
running?: boolean | undefined;
failed?: boolean | undefined;
cancelled?: boolean | undefined;
/** Expanded body; the row is static when absent. */
children?: ReactNode | undefined;
};
export function AgentRow({
icon,
title,
preview,
previewLines = 1,
meta,
sessionId,
onOpenSession,
running,
failed,
cancelled,
children,
}: AgentRowProps) {
const t = useOpenGeniText();
const compact = useContext(CompactActivityContext);
const forcedDefaultOpen = useForcedDefaultOpen();
const [open, setOpen] = useState(forcedDefaultOpen ?? false);
if (compact) {
return (
{children}
; } /** A labelled section inside an expanded agent row (Brief, Report, Evidence). */ export function AgentRowSection({ label, children, muted, }: { label: string; children: string; muted?: boolean | undefined; }) { return ({label}
{children}