Files
t3code/apps/web/src/components/chat/ModelListRow.tsx
T
+36 de34391427 feat(orchestrator): introduce new orchestrator (#2829)
Co-authored-by: maria-rcks <[email protected]>
Co-authored-by: Bilal Bakr <[email protected]>
Co-authored-by: shivam <[email protected]>
Co-authored-by: Vitalii Yehorov <[email protected]>
Co-authored-by: Jake Leventhal <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Alex Southwell <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nicholas Wasmiller <[email protected]>
Co-authored-by: PB <[email protected]>
Co-authored-by: Exotic <[email protected]>
Co-authored-by: Yash Singh <[email protected]>
Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Theo Browne <[email protected]>
Co-authored-by: Gabriel De Andrade <[email protected]>
Co-authored-by: Dara Adedeji <[email protected]>
Co-authored-by: scratchyone <[email protected]>
Co-authored-by: Dominic Roy <[email protected]>
Co-authored-by: chukfinley <[email protected]>
Co-authored-by: Primož Ajdišek <[email protected]>
Co-authored-by: benthecarman <[email protected]>
Co-authored-by: NaveDanan <[email protected]>
Co-authored-by: aaditagrawal <[email protected]>
Co-authored-by: Aditya Garud <[email protected]>
Co-authored-by: Nick Anisimov <[email protected]>
Co-authored-by: MacKinley Smith <[email protected]>
Co-authored-by: Yordis Prieto <[email protected]>
Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
Co-authored-by: AKolenda <[email protected]>
Co-authored-by: Guillermo Casanova <[email protected]>
Co-authored-by: Otavio Salvador <[email protected]>
Co-authored-by: Shirish Pothi <[email protected]>
Co-authored-by: Ishaan Kothari <[email protected]>
Co-authored-by: Bob Fowler <[email protected]>
Co-authored-by: Anton Bezdenezhnykh <[email protected]>
Co-authored-by: ValeraZSD <[email protected]>
Co-authored-by: Ephraim <[email protected]>
Co-authored-by: Ryan Ilano <[email protected]>
Co-authored-by: Alex <[email protected]>
Co-authored-by: maco <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Tristan Knight <[email protected]>
Co-authored-by: PR Batch Tester <[email protected]>
Co-authored-by: oliver <[email protected]>
Co-authored-by: kamkm <[email protected]>
Signed-off-by: Yordis Prieto <[email protected]>
2026-10-02 12:22:22 -07:00

155 lines
5.3 KiB
TypeScript

import { type ProviderDriverKind, type ProviderInstanceId } from "@t3tools/contracts";
import { memo } from "react";
import { CheckIcon, StarIcon } from "lucide-react";
import {
getDisplayModelName,
getTriggerDisplayModelLabel,
type ModelEsque,
} from "./providerIconUtils";
import { ComboboxItem } from "../ui/combobox";
import { Button } from "../ui/button";
import { Badge } from "../ui/badge";
import { Kbd } from "../ui/kbd";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import { cn } from "~/lib/utils";
import { modelPickerModelKey } from "./modelPickerKeys";
import { ProviderInstanceIcon } from "./ProviderInstanceIcon";
export const ModelListRow = memo(function ModelListRow(props: {
index: number;
model: ModelEsque;
/** Instance the model belongs to — the routing key used in combobox values. */
instanceId: ProviderInstanceId;
/** Driver kind of the instance — used for the provider icon glyph. */
driverKind: ProviderDriverKind;
/**
* Display name to show in the secondary line (provider footer). Usually
* the instance's configured `displayName` so custom instances like
* "Codex Personal" render with their user-authored label.
*/
providerDisplayName: string;
providerAccentColor?: string | undefined;
acpRegistryAgentId?: string | undefined;
acpRegistryIconUrl?: string | undefined;
isFavorite: boolean;
isSelected: boolean;
showSelection?: boolean;
showProvider: boolean;
preferShortName?: boolean;
useTriggerLabel?: boolean;
showNewBadge?: boolean;
unavailable?: boolean;
jumpLabel?: string | null;
disabledReason?: string | null;
onToggleFavorite: () => void;
}) {
const providerLabel = props.model.subProvider
? `${props.providerDisplayName} · ${props.model.subProvider}`
: props.providerDisplayName;
const row = (
<ComboboxItem
hideIndicator
index={props.index}
value={modelPickerModelKey(props.instanceId, props.model.slug)}
disabled={Boolean(props.disabledReason)}
className={cn(
"group relative w-full !min-w-0 max-w-full cursor-pointer",
props.disabledReason &&
"data-disabled:pointer-events-auto data-disabled:cursor-not-allowed",
)}
>
<div className="min-w-0 flex-1 text-left">
<div className="flex min-w-0 items-center gap-2">
<div className="min-w-0 truncate text-xs font-medium leading-snug">
{props.useTriggerLabel
? getTriggerDisplayModelLabel(props.model)
: getDisplayModelName(
props.model,
props.preferShortName ? { preferShortName: true } : undefined,
)}
</div>
{props.showNewBadge ? (
<span
className="shrink-0 rounded border border-update/35 bg-update/15 px-0.5 py-px text-3xs font-bold uppercase leading-none tracking-wide text-update-foreground"
aria-label="New model"
>
New
</span>
) : null}
{props.unavailable ? (
<Badge variant="outline" size="sm">
Unavailable
</Badge>
) : null}
</div>
{props.showProvider && (
<div className="mt-1 flex items-center gap-1.5">
<ProviderInstanceIcon
driverKind={props.driverKind}
displayName={props.providerDisplayName}
acpRegistryAgentId={props.acpRegistryAgentId}
acpRegistryIconUrl={props.acpRegistryIconUrl}
className="size-3"
iconClassName="size-3"
/>
<span className="truncate text-xs font-normal leading-snug text-muted-foreground/70">
{providerLabel}
</span>
</div>
)}
</div>
<div className="flex shrink-0 items-center gap-1.5">
{props.showSelection && props.isSelected ? (
<CheckIcon className="size-3.5" aria-hidden="true" />
) : null}
{props.jumpLabel ? <Kbd>{props.jumpLabel}</Kbd> : null}
<Tooltip>
<TooltipTrigger
render={
<Button
size="icon-xs"
variant="ghost-muted"
className="-mr-1 shrink-0"
onClick={(event) => {
event.stopPropagation();
props.onToggleFavorite();
}}
onKeyDown={(event) => {
event.stopPropagation();
}}
disabled={Boolean(props.disabledReason)}
aria-label={props.isFavorite ? "Remove from favorites" : "Add to favorites"}
>
<StarIcon
className={cn(
"size-3.5 sm:size-3",
props.isFavorite && "fill-current text-warning",
)}
/>
</Button>
}
/>
<TooltipPopup side="top" align="center">
{props.isFavorite ? "Remove from favorites" : "Add to favorites"}
</TooltipPopup>
</Tooltip>
</div>
</ComboboxItem>
);
if (!props.disabledReason) {
return row;
}
return (
<Tooltip>
<TooltipTrigger render={row} />
<TooltipPopup side="left" align="center">
{props.disabledReason}
</TooltipPopup>
</Tooltip>
);
});