import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@openstatus/ui/components/ui/table"; import type { ReactNode } from "react"; /** * Tabular result view used by `list_*` chat tool renderers — the read-side * counterpart to `ChangesTable`. Each tool ships a descriptor (e.g. * `listStatusPagesTable`) that maps the tool's output to columns + rows; * the registry consumes it via ``. * * `cellClassName` on a column applies to every cell in that column — keep * per-row formatting (mono, badges) in the column definition rather than in * each row's cell. */ export type ResultColumn = { key: K; header: string; cellClassName?: string; }; export type ResultRow = { id: string | number; cells: Record; }; export type ResultTableData = { columns: ResultColumn[]; rows: ResultRow[]; empty: string; }; export function ResultTable({ columns, rows, empty, }: ResultTableData) { if (rows.length === 0) { return (
{empty}
); } return (
{columns.map((col) => ( {col.header} ))} {rows.map((row) => ( {columns.map((col) => ( {row.cells[col.key]} ))} ))}
); }