import { useMemo, type JSX } from "react"; import type { WorkspaceLinkAction } from "../contexts/workspace/presentation/renderer/actions/workspaceLinkActions"; import { translate } from "../i18n/index"; import type { AgentMessageMarkdownAgentTarget } from "./AgentTargetPresentationContext"; import { AgentConversationFlow } from "./agentConversation/components/AgentConversationFlow"; import type { AgentConversationParticipantPresentation } from "./agentConversation/contracts/agentConversationParticipantPresentation"; import { useProjectedAgentConversation } from "./agentConversation/projection/useProjectedAgentConversation"; import type { WorkspaceAgentSessionDetailViewModel } from "./workspaceAgentSessionDetailViewModel"; export interface WorkspaceAgentSessionDetailProps { detail: WorkspaceAgentSessionDetailViewModel; avoidGroupingEdits?: boolean; isLoading: boolean; timelineItemCount: number; agentTargets?: readonly AgentMessageMarkdownAgentTarget[]; onLinkAction?: (action: WorkspaceLinkAction) => void; toolCallsLabel: (count: number) => string; thinkingLabel?: string; loadingLabel?: string; rawTimelineJsonLabel?: string; showRawTimelineJson?: boolean; participantPresentation?: AgentConversationParticipantPresentation; } export function WorkspaceAgentSessionDetail({ detail, avoidGroupingEdits = false, isLoading, timelineItemCount, agentTargets, onLinkAction, toolCallsLabel, thinkingLabel = translate("agentHost.workspaceAgentSessionDetailThinking"), loadingLabel = translate("common.loading"), rawTimelineJsonLabel, showRawTimelineJson = false, participantPresentation }: WorkspaceAgentSessionDetailProps): JSX.Element { const conversation = useProjectedAgentConversation({ detail, avoidGroupingEdits }); const showLoadingSkeleton = detail.turns.length === 0 && (isLoading || detail.activity.status === "waiting" || detail.activity.status === "working"); const emptySummary = detail.activity.latestActivitySummary || (timelineItemCount > 0 ? translate("agentHost.workspaceAgentSessionDetailEmptyWithTimeline") : translate("agentHost.workspaceAgentSessionDetailEmptyNoTimeline")); const flowLabels = useMemo( () => ({ thinkingLabel, toolCallsLabel, processing: translate("agentHost.agentGui.processing"), turnSummary: translate("agentHost.agentGui.turnSummary"), rawTimelineJson: rawTimelineJsonLabel }), [rawTimelineJsonLabel, thinkingLabel, toolCallsLabel] ); const emptyState = useMemo( () => (