import { useMemo } from 'react'; import { useStore } from '@renderer/store'; import { computeTakeaways } from '@renderer/utils/reportAssessments'; import { analyzeSession } from '@renderer/utils/sessionAnalyzer'; import { CostSection } from './sections/CostSection'; import { ErrorSection } from './sections/ErrorSection'; import { FrictionSection } from './sections/FrictionSection'; import { GitSection } from './sections/GitSection'; import { InsightsSection } from './sections/InsightsSection'; import { KeyTakeawaysSection } from './sections/KeyTakeawaysSection'; import { OverviewSection } from './sections/OverviewSection'; import { QualitySection } from './sections/QualitySection'; import { SubagentSection } from './sections/SubagentSection'; import { TimelineSection } from './sections/TimelineSection'; import { TokenSection } from './sections/TokenSection'; import { ToolSection } from './sections/ToolSection'; import type { Tab } from '@renderer/types/tabs'; interface SessionReportTabProps { tab: Tab; } export const SessionReportTab = ({ tab }: SessionReportTabProps) => { // Find session data from any session tab with matching sessionId const sessionDetail = useStore((s) => { const allTabs = s.paneLayout.panes.flatMap((p) => p.tabs); const sourceTab = allTabs.find((t) => t.type === 'session' && t.sessionId === tab.sessionId); return sourceTab ? s.tabSessionData[sourceTab.id]?.sessionDetail : null; }); const report = useMemo( () => (sessionDetail ? analyzeSession(sessionDetail) : null), [sessionDetail] ); const takeaways = useMemo(() => (report ? computeTakeaways(report) : []), [report]); if (!report) { return (
No session data available. Open the session tab first.
); } return (

Session Analysis Report

{takeaways.length > 0 && } {report.subagentMetrics.count > 0 && ( )} {report.errors.errors.length > 0 && }
); };