import { Button, Tabs, Text } from "@radix-ui/themes"; import type { EntrySummary } from "../model.js"; import { useDetail } from "./api.js"; import { Data, Metadata } from "./components.js"; import { count, eventName, record } from "./format.js"; import { label } from "./hierarchy.js"; export function InlineEntry({ entry, inspect }: { entry: EntrySummary; inspect(id: string): void }) { const { detail, error, retry } = useDetail(entry.id); const raw = record(detail?.raw.value); const message = record(raw?.message); const content = raw && Object.hasOwn(raw, "data") ? raw.data : message?.content; const textBlocks = Array.isArray(content) && content.every((block) => { const item = record(block); return item?.type === "text" && typeof item.text === "string"; }) ? content.map((block) => record(block)?.text).join("\n") : undefined; const preview = textBlocks ?? content; const inputs = Array.isArray(message?.content) ? message.content.flatMap((block) => { const item = record(block); return item?.type === "toolCall" ? [item.arguments ?? null] : []; }) : []; const usage = record(message?.usage); const input = typeof usage?.input === "number" && usage.input >= 0 ? usage.input : undefined; const output = typeof usage?.output === "number" && usage.output >= 0 ? usage.output : undefined; const known = input !== undefined && output !== undefined; return (
Overview Content Raw Metadata
{known && (
{count(input)} input · {count(output)} output (cache not included)
)}
{content !== undefined && ( )} {inputs.length > 0 && ( )}
{error && (
{error}
)} {!detail && !error && ( Loading bounded entry details… )}
); }