import { memo, useCallback, type JSX, type ReactNode } from "react"; import type { WorkspaceLinkAction } from "../../../contexts/workspace/presentation/renderer/actions/workspaceLinkActions"; import type { AgentMessageMarkdownWorkspaceAppIcon } from "../../AgentMessageMarkdown"; import type { AgentGUIProviderSkillOption } from "../../../agent-gui/agentGuiNode/model/agentGuiNodeTypes"; import { resolveAgentConversationLinkAction } from "../actions/agentConversationLinkActions"; import type { AgentTranscriptRowVM } from "../contracts/agentTranscriptRowVM"; import type { AgentConversationParticipantPresentation } from "../contracts/agentConversationParticipantPresentation"; import { AgentGeneratedImageRow } from "./AgentGeneratedImageRow"; import { AgentGoalControlRow } from "./AgentGoalControlRow"; import { AgentMessageBlock } from "./AgentMessageBlock"; import { AgentProcessingRow } from "./AgentProcessingRow"; import { AgentToolGroupRow } from "./AgentToolGroupRow"; import { AgentTurnSummaryRow } from "./AgentTurnSummaryRow"; import type { AgentUserMessageEditRetryControl } from "./AgentUserMessageEditRetry"; interface AgentTranscriptItemViewProps { workspaceRoot: string | null; basePath: string; row: AgentTranscriptRowVM; editRetry?: AgentUserMessageEditRetryControl; labels: { toolCallsLabel: (count: number) => string; thinkingLabel: string; processing: string; turnSummary: string; rawTimelineJson?: string; }; onLinkAction?: (action: WorkspaceLinkAction) => void; onAuthLogin?: (provider?: string | null) => void; provider?: string | null; availableSkills?: readonly AgentGUIProviderSkillOption[]; workspaceAppIcons?: readonly AgentMessageMarkdownWorkspaceAppIcon[]; showRawTimelineJson?: boolean; participantPresentation?: AgentConversationParticipantPresentation; showParticipantHeader?: boolean; isActiveTurn?: boolean; processingPaused?: boolean; toolGroupExpanded?: boolean; toolGroupExpansionKey?: string; onToolGroupExpandedChange?: (key: string, expanded: boolean) => void; footerAction?: ReactNode; } export const AgentTranscriptItemView = memo(function AgentTranscriptItemView({ workspaceRoot, basePath, row, editRetry, labels, onLinkAction, onAuthLogin, provider, availableSkills, workspaceAppIcons, showRawTimelineJson = false, participantPresentation, showParticipantHeader, isActiveTurn = false, processingPaused = false, toolGroupExpanded, toolGroupExpansionKey, onToolGroupExpandedChange, footerAction }: AgentTranscriptItemViewProps): JSX.Element { "use memo"; const handleLinkClick = useCallback( (href: string) => { const action = resolveAgentConversationLinkAction({ workspaceRoot, basePath, href, source: "agent-markdown" }); if (action) { onLinkAction?.(action); } }, [basePath, onLinkAction, workspaceRoot] ); switch (row.kind) { case "generated-image": return ; case "goal-control": return ( ); case "message": return ( ); case "tool-group": return ( ); case "turn-summary": return ( ); case "processing": return ( ); } });