import { X } from "lucide-react";
import type { FC } from "react";
import type { Capture } from "@/api/gen/model/capture";
import { useStatsRecordingGet } from "@/api/gen/stats/stats";
import { QueryState } from "@/components/query-state";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import type { Loadable } from "@/lib/query";
import { m } from "@/paraglide/messages";
import { HealthChart, LatencyChart, ThroughputChart } from "./charts";
import { ChartBlock } from "./helpers";
/** Container: the full graph set for the selected recording — fetched by id. */
export const DetailSection: FC<{ id: string; onClose: () => void }> = ({
id,
onClose,
}) => {
const detail = useStatsRecordingGet(id, { query: { enabled: !!id } });
return ;
};
/** Full graph set for one selected recording: latency (p99 toggle) + throughput + health. */
export const DetailCard: FC<{
detail: Loadable;
onClose: () => void;
}> = ({ detail, onClose }) => {
const cap = detail.data;
const samples = cap?.samples ?? [];
return (
{m.stats_detail_title()}
{cap && (
// Encoder + GPU ride along with the mode: the stage split below can't be
// read without knowing which backend produced it (a 10 ms `submit` means
// very different things on NVENC and on Vulkan). Older recordings predate
// the fields and simply omit them.
{cap.meta.width}×{cap.meta.height}@{cap.meta.fps} ·{" "}
{cap.meta.codec.toUpperCase()}
{cap.meta.encoder_backend && ` · ${cap.meta.encoder_backend}`}
{cap.meta.gpu && ` · ${cap.meta.gpu}`}
)}
{samples.length === 0 ? (