"use client" /** * LeoLoadingRow — the table's consumer of the shared Leo generation pattern * (`lib/leo-generation.ts`, `LeoGenerationSurface`). It owns no lifecycle of * its own: hand it a `state` and it paints one row. * * A real row: one cell per column, so it lines up under the headers and takes * the table's gridlines. Single-brand blob + dot backdrop spans the row. * * - `inited` Leo mark plays its invited gesture; empty cells. * - `thinking` Working mark, shimmering label, pulsing bars. * - `completed` A brand check with "Leo is done". The consumer then drops the row and renders data. * * A Leo row is never a parent or a child of other rows. When Leo is filling a * section, the SECTION is the parent (`LeoGenerationSection`) and the table is * its child; every row in the table is a flat peer. * * No checkbox, selection, or row click. Decorative parts are `aria-hidden`; * each row's `` announces its own state. */ import * as React from "react" import { cn } from "../../lib/utils" import { LEO_GENERATION_ICON_STATE, LEO_GENERATION_LABEL, type LeoGenerationState, } from "../../lib/leo-generation" import { LeoBrandBackdrop } from "../ui/leo-brand-backdrop" import { LeoStopButton } from "../ui/leo-generation-surface" import { LeoIcon } from "../ui/leo-icon" /** Same lifecycle as every Leo surface. */ export type LeoLoadingState = LeoGenerationState /** One loading row in an explicit stack. */ export interface LeoLoadingRowSpec { id: string state: LeoGenerationState /** Sub-rows in the split columns, matching a split data row. Default 1 (not split). */ splitCount?: number label?: string onStop?: () => void } const BAR_WIDTHS = ["w-3/4", "w-1/2", "w-2/3"] as const export interface LeoLoadingRowProps { /** Columns the table is showing, in order. */ columns: ReadonlyArray<{ key: string; split?: unknown }> state?: LeoGenerationState /** Varies the skeleton bars. */ index?: number /** Show the Leo mark + label in the first data cell. Default true. */ showStatus?: boolean /** Overrides the state's status text. */ label?: string /** Sub-rows in the table's split columns. Default 1 (a normal row). */ splitCount?: number /** Adds a Stop button while inited or thinking: in the status cell, or the last column when `showStatus` is off. */ onStop?: () => void className?: string } export function LeoLoadingRow({ columns, state = "thinking", index = 0, showStatus = true, label, splitCount = 1, onStop, className, }: LeoLoadingRowProps) { const text = label ?? LEO_GENERATION_LABEL[state] const isControl = (key: string) => key === "select" || key === "actions" const firstDataKey = columns.find(c => !isControl(c.key))?.key const lastDataKey = [...columns].reverse().find(c => !isControl(c.key))?.key const canStop = Boolean(onStop) && state !== "completed" return ( {columns.map((col, i) => { const control = isControl(col.key) const isStatusCell = showStatus && col.key === firstDataKey const isStopCell = canStop && !showStatus && col.key === lastDataKey const showBars = state === "thinking" && !control && !isStatusCell && !isStopCell && !(col.split && splitCount > 1) const isSplit = Boolean(col.split) && splitCount > 1 return ( {i === 0 ? : null} {isSplit ? (
{Array.from({ length: splitCount }, (_, si) => (
{state === "thinking" ? ( ) : null}
))}
) : null} {isSplit ? null : isStatusCell ? (
{state === "completed" ? (