import * as Collapsible from "@radix-ui/react-collapsible"; import { ChevronRightIcon, Cross2Icon, CubeIcon } from "@radix-ui/react-icons"; import { Button, Heading, IconButton, Tabs, Text } from "@radix-ui/themes"; import { useEffect, useMemo, useState } from "react"; import type { BranchView, Call, Capture, DetailView, EntrySummary, Json, Snapshot } from "../model.js"; import { Copy, Data, Metadata, Status } from "./components.js"; import { entryCalls } from "./entry-calls.js"; import { count, duration, eventName, output, promptDiff, record, scripts } from "./format.js"; import { RecordedContent } from "./recorded-content.js"; import { ToolInspector } from "./tool-inspector.js"; export function Inspector({ close, selected, node, detail, detailError, retryDetails, call, branch, branchError, retryBranch, snapshot, tab, changeTab, select, selectCall, preview, }: { close(): void; selected: string; node?: EntrySummary; detail?: DetailView; detailError: string; retryDetails(): void; call?: Call; branch?: BranchView; branchError: string; retryBranch(): void; snapshot?: Snapshot; tab: string; changeTab(tab: string): void; select(id: string): void; selectCall(id: string): void; preview(): void; }) { const [format, setFormat] = useState("formatted"); const raw = record(detail?.raw.value); const message = record(raw?.message); const payload = raw?.data ?? message?.content; const related = snapshot?.nodes.filter((entry) => entry.parentId === selected || entry.id === node?.parentId) ?? []; const recordedCall = snapshot?.calls.find( (item) => item.id === node?.toolCallId && item.branchAnchor === detail?.toolAnchor && !item.parentOccurrenceId, ); const liveRaw: Capture | undefined = call ? { value: JSON.parse(JSON.stringify(call)) as Json, truncated: Boolean(call.args.truncated || call.result?.truncated), } : undefined; const activeRaw = liveRaw ?? detail?.raw; const captured = entryCalls(detail?.raw, snapshot?.calls ?? [], detail?.toolAnchor); const code = call ? (record(call.args.value)?.code as Json | undefined) : scripts(detail?.raw)?.value; const codemode = call?.name === "codemode" || Boolean(scripts(detail?.raw)) || message?.toolName === "codemode"; const isCall = Boolean(call); const hasSkills = Boolean( snapshot?.skills.length || (Array.isArray(branch?.skillEvidence.value) && branch.skillEvidence.value.length), ); const enabled = useMemo( () => [ "content", "raw", ...(isCall ? [] : ["prompt", "tools", "context", ...(hasSkills ? ["skills"] : [])]), ...(codemode ? ["codemode"] : []), ], [isCall, hasSkills, codemode], ); useEffect(() => { if (!enabled.includes(tab)) changeTab("content"); }, [enabled, tab, changeTab]); return (
Event details {activeRaw && }
{call?.branchAnchor && !snapshot?.nodes.some((entry) => entry.id === call.branchAnchor) && ( Recorded anchor omitted from this bounded inventory; navigator target unavailable. )} {call ? "Captured execution" : node ? eventName(node.kind) : "Entry"} ·{" "} {selected.slice(0, 16) || "no selection"} {call?.name ?? node?.name ?? "Session log entry"}
{detailError && (
{detailError}
)} {branchError && (
{branchError}
)} {detail?.ancestryIssue && ( Projection unavailable: {detail.ancestryIssue}. Raw entry retained. )} {["content", "raw", "prompt", "tools", "context", "skills", "codemode"].map((tab) => ( {tab} ))} {call ? ( <>
child.parentOccurrenceId === call.occurrenceId).length ?? 0, ), ], ]} />
{call.parentId && !snapshot?.calls.some((parent) => parent.occurrenceId === call.parentOccurrenceId) && ( Parent {call.parentId} (not captured) )} {snapshot?.calls .filter( (item) => item.parentOccurrenceId === call.occurrenceId || item.occurrenceId === call.parentOccurrenceId, ) .map((item) => ( ))} {call.branchAnchor && snapshot?.nodes.some((entry) => entry.id === call.branchAnchor) && ( )} ) : ( <> Session log entry · bounded recorded content {node?.status && } )} {!detail && !call && !detailError && ( Loading bounded entry details… )}
{["formatted", "json"].map((mode) => ( ))}
{format === "formatted" && (
entry.parentId === selected).length), ], ["Tokens", node?.tokens === undefined ? undefined : count(node.tokens)], [ "Reported tool duration", recordedCall?.durationMs === undefined ? undefined : duration(recordedCall.durationMs), ], ] ).filter((row): row is [string, string] => typeof row[1] === "string")} /> {(call?.status ?? node?.status) && }
)} {format === "formatted" && call ? ( <> {call.branchAnchor && ( )} ) : ( )} {call ? snapshot?.calls .filter( (item) => item.parentOccurrenceId === call.occurrenceId || item.occurrenceId === call.parentOccurrenceId, ) .map((item) => ( )) : related.map((entry) => ( ))}
Advertised or read does not prove model compliance. Historical discovery may be unavailable. Pi projection applies compaction and context edits. Request-local hooks can still transform it; this is not the final provider HTTP request. Script source, output and historical nested metadata appear in the selected raw entry. Child results before activation are not captured. Sandbox variables, discovery-helper results and model-helper responses are unavailable unless the script printed them. {captured.map((call) => ( ))}
); }