import { useState, useEffect } from "react" import api from "../lib/api" import Reveal from "./Reveal" import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer, Legend, } from "recharts" // Palette for up to 6 speakers const SPEAKER_COLORS = ["#3b82f6", "#8b5cf6", "#34d399", "#f59e0b", "#f87171", "#0891b2"] function speakerDisplayName(id, detectedSpeaker) { if (id === detectedSpeaker) return "You" const num = parseInt(id.replace("SPEAKER_", ""), 10) return isNaN(num) ? id : `Participant ${num}` } function formatMin(s) { return `${Math.floor(s / 60)}m` } function SpeakerTimeline({ speakersTimeline, detectedSpeaker }) { const speakers = Object.keys(speakersTimeline || {}) if (!speakers.length) return null // Merge all per-speaker windows into a unified time axis const windowMap = {} for (const sp of speakers) { for (const w of speakersTimeline[sp]) { const key = w.window_start_s if (!windowMap[key]) windowMap[key] = { t: key } windowMap[key][sp] = w.speech_rate_wpm } } const chartData = Object.values(windowMap).sort((a, b) => a.t - b.t) if (chartData.length < 2) return null return (
{s.insights.summary_sentence}
{/* Signal stats */}Could not load sessions — the server may be starting up.
No sessions yet.
Upload your first conversation to get started.
{sessions.length < total ? `${sessions.length} of ${total} sessions loaded` : `${filtered.length} of ${total} session${total !== 1 ? "s" : ""}`}
{total - sessions.length} more session{total - sessions.length !== 1 ? "s" : ""} not shown