import { useMemo, useState } from 'react'; import { Button } from '@renderer/components/ui/button'; import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/components/ui/tooltip'; import { cn } from '@renderer/lib/utils'; import { Brain, Expand, MessageSquare, Terminal, Wrench } from 'lucide-react'; import { ClaudeLogsDialog } from './ClaudeLogsDialog'; import { ClaudeLogsPanel } from './ClaudeLogsPanel'; import { CollapsibleTeamSection } from './CollapsibleTeamSection'; import { useClaudeLogsController } from './useClaudeLogsController'; import type { LastLogPreview } from './useClaudeLogsController'; // ============================================================================= // Constants // ============================================================================= const PREVIEW_ICONS = { output: , thinking: , tool: , } as const; // ============================================================================= // Sub-components // ============================================================================= interface ClaudeLogsSectionProps { teamName: string; position?: 'sidebar' | 'inline'; } /** * Compact inline preview of the most recent log item, shown in the section header. */ const LogPreviewInline = ({ preview }: { preview: LastLogPreview }): React.JSX.Element => { const summaryText = preview.summary.length > 60 ? preview.summary.slice(0, 60) + '...' : preview.summary; return ( {PREVIEW_ICONS[preview.type]} {preview.label} {summaryText && ( <> - {summaryText} )} ); }; // ============================================================================= // Main component // ============================================================================= export const ClaudeLogsSection = ({ teamName, position = 'inline', }: ClaudeLogsSectionProps): React.JSX.Element => { const ctrl = useClaudeLogsController(teamName); const [dialogOpen, setDialogOpen] = useState(false); const isSidebar = position === 'sidebar'; const sectionHeaderExtra = useMemo( () => ( {ctrl.online ? ( ) : null} {ctrl.lastLogPreview ? : null} ), [ctrl.online, ctrl.lastLogPreview, isSidebar] ); return ( <> } badge={ctrl.badge} afterBadge={ ctrl.data.total > 0 ? ( Fullscreen ) : undefined } headerContentClassName={isSidebar ? 'flex-wrap items-center gap-y-1 py-1 pr-3' : 'pr-3'} headerExtra={sectionHeaderExtra} defaultOpen={false} contentClassName="pt-0 [overflow-anchor:none]" > {/* When dialog is open, hide the compact log viewer to avoid two competing scroll containers */} {dialogOpen ? (
Viewing in fullscreen mode
) : ( )} ); };