Open History to see the last commit
1import { ThreadHoverCardPopup } from "../ThreadHoverCard";
2import { AgentElapsed } from "./AgentElapsed";
3import { projectedSubagentsToRuntime } from "@t3tools/client-runtime/state/subagentRuntime";
4import type { ReactNode } from "react";
5import { useThreadShell, useProject } from "../../state/entities";
6import { useEnvironment } from "../../state/environments";
7import { buildThreadRouteParams } from "../../threadRoutes";
8import { useNavigate } from "@tanstack/react-router";
9import { SubagentTooltipContent } from "./SubagentTooltipContent";
10import { useAtomValue } from "@effect/atom-react";
11import { scopeThreadRef, scopeProjectRef } from "@t3tools/client-runtime/environment";
12import { environmentThreadDetails } from "../../state/threads";
13import { EMPTY_SERVER_PROVIDERS, serverEnvironment } from "../../state/server";
14import { MiddleTruncate } from "../ui/middle-truncate";
15import * as DateTime from "effect/DateTime";
16import { WorkLogRow } from "./WorkLog";
17import {
18 resolveHandoffEndpoints,
19 type HandoffEndpoints,
20 type HandoffTimelineRun,
21} from "@t3tools/client-runtime/handoff";
22import { formatSubagentDisplayTitle } from "@t3tools/client-runtime/state/subagent-display";
23import {
24 ProviderDriverKind,
25 type OrchestrationV2Notification,
26 type OrchestrationV2TurnItem,
27 type OrchestrationV2RemoteTaskChild,
28 type OrchestrationV2Subagent,
29 type ProviderInstanceId,
30 type ServerProvider,
31 type ThreadId,
32 type EnvironmentId,
33 type NodeId,
34 type ScopedThreadRef,
35} from "@t3tools/contracts";
36import type { TimestampFormat } from "@t3tools/contracts/settings";
37import {
38 BotIcon,
39 ChevronRightIcon,
40 CircleStopIcon,
41 ArrowRightLeftIcon,
42 ArrowRightIcon,
43 GitForkIcon,
44 MessageSquareIcon,
45 MinusIcon,
46} from "lucide-react";
47
48import { Tooltip, TooltipTrigger, TooltipPopup } from "../ui/tooltip";
49import {
50 applyProviderInstanceSettings,
51 deriveProviderInstanceEntries,
52 shouldShowInstanceBadge,
53 type ProviderInstanceEntry,
54} from "../../providerInstances";
55import { formatShortTimestamp } from "../../timestampFormat";
56import { getTriggerDisplayModelName } from "./providerIconUtils";
57import { ProviderInstanceIcon, providerTextColor } from "./ProviderInstanceIcon";
58import { cn } from "~/lib/utils";
59import { TimelineSystemDivider } from "./TimelineSystemDivider";
60import { subagentResumedSince } from "./V2LifecycleRow.logic";
61import { Button, InlineButton } from "../ui/button";
62import { T3Wordmark } from "../T3Wordmark";
63
64const LIFECYCLE_TYPES = new Set<OrchestrationV2TurnItem["type"]>([
65 "run_interrupt_request",
66 "run_interrupt_result",
67 "compaction",
68 "handoff",
69 "fork",
70 "subagent",
71 "thread_created",
72]);
73
74export function isV2LifecycleItem(item: OrchestrationV2TurnItem): boolean {
75 return LIFECYCLE_TYPES.has(item.type);
76}
77
78export type { HandoffTimelineRun } from "@t3tools/client-runtime/handoff";
79
80export function V2LifecycleRow(props: {
81 readonly item: OrchestrationV2TurnItem;
82 readonly environmentId: EnvironmentId;
83 readonly resourceSummary?: boolean | undefined;
84 readonly createdAt: string;
85 readonly timestampFormat: TimestampFormat;
86 readonly runs: ReadonlyArray<HandoffTimelineRun>;
87 readonly onOpenThread: (threadId: ThreadId) => void;
88}) {
89 const { item } = props;
90 if (item.type === "run_interrupt_request") {
91 return (
92 <div className="flex justify-end px-1 py-1" data-v2-item-type={item.type}>
93 <div className="flex max-w-[80%] items-center gap-2 text-xs text-muted-foreground">
94 <span aria-hidden="true" className="font-mono">
95 ■
96 </span>
97 <span className="font-medium">Interrupt requested</span>
98 <span aria-hidden="true" className="opacity-50">
99 ·
100 </span>
101 <span className="font-medium">{item.message}</span>
102 <span className="text-3xs text-muted-foreground">
103 {formatShortTimestamp(props.createdAt, props.timestampFormat)}
104 </span>
105 </div>
106 </div>
107 );
108 }
109 if (item.type === "run_interrupt_result") {
110 return (
111 <TimelineSystemDivider label="Run interrupted" detail={item.message} icon={CircleStopIcon} />
112 );
113 }
114 if (item.type === "compaction") {
115 const tokenDetail =
116 item.beforeTokenCount === undefined && item.afterTokenCount === undefined
117 ? null
118 : `${item.beforeTokenCount ?? "?"} → ${item.afterTokenCount ?? "?"} tokens`;
119 const label =
120 item.status === "failed"
121 ? "Context compaction failed"
122 : item.status === "cancelled" || item.status === "interrupted"
123 ? "Context compaction stopped"
124 : item.status === "pending" || item.status === "running" || item.status === "waiting"
125 ? "Compacting context"
126 : "Context compacted";
127 return (
128 <TimelineSystemDivider label={label} detail={item.summary ?? tokenDetail} icon={MinusIcon} />
129 );
130 }
131 if (item.type === "handoff") {
132 return (
133 <EnvironmentHandoffRow
134 environmentId={props.environmentId}
135 endpoints={resolveHandoffEndpoints(item, props.runs)}
136 failed={item.status === "failed"}
137 />
138 );
139 }
140 if (item.type === "fork") {
141 const relatedThreadId = item.source.type === "run" ? item.source.threadId : item.targetThreadId;
142 return (
143 <TimelineSystemDivider
144 label={item.source.type === "run" ? "Forked from conversation" : "Conversation fork"}
145 icon={GitForkIcon}
146 actionLabel={item.source.type === "run" ? "Open source conversation" : "Open fork"}
147 onAction={() => props.onOpenThread(relatedThreadId)}
148 />
149 );
150 }
151 if (item.type === "thread_created") {
152 if (props.resourceSummary) {
153 return (
154 <div
155 data-v2-item-type={item.type}
156 className="flex min-w-0 items-center gap-3 rounded-lg border border-border/60 p-3"
157 >
158 <span className="flex size-9 shrink-0 items-center justify-center rounded-lg bg-muted/60">
159 <MessageSquareIcon className="size-4 text-secondary-label" aria-hidden />
160 </span>
161 <span className="min-w-0 flex-1 truncate text-sm font-medium">
162 {item.title ?? "Created thread"}
163 </span>
164 <Button
165 size="xs"
166 variant="outline"
167 aria-label={`Open ${item.title ?? "created thread"}`}
168 onClick={() => props.onOpenThread(item.targetThreadId)}
169 >
170 Open chat
171 </Button>
172 </div>
173 );
174 }
175 return (
176 <WorkLogRow
177 data-v2-item-type={item.type}
178 icon={<T3Wordmark className="size-4 text-icon-muted" aria-hidden />}
179 label={<>Created thread{item.title ? ` · ${item.title}` : ""}</>}
180 trailing={
181 <InlineButton
182 aria-label={`Open ${item.title ?? "created thread"}`}
183 onClick={() => props.onOpenThread(item.targetThreadId)}
184 >
185 Open chat
186 </InlineButton>
187 }
188 />
189 );
190 }
191 if (item.type === "subagent") {
192 return (
193 <SubagentTimelineLink
194 parentRef={scopeThreadRef(props.environmentId, item.threadId)}
195 subagentId={item.subagentId}
196 providerInstanceId={item.providerInstanceId}
197 origin={item.origin}
198 status={item.status}
199 driver={item.driver}
200 title={formatSubagentDisplayTitle(item.title ?? "Subagent")}
201 result={item.result}
202 progress={item.progress}
203 startedAt={item.startedAt}
204 completedAt={item.completedAt}
205 threadId={item.childThreadId}
206 remote={item.remoteChild}
207 onOpenThread={props.onOpenThread}
208 />
209 );
210 }
211 return null;
212}
213
214const STATUS_VISUALS: Record<
215 OrchestrationV2TurnItem["status"],
216 { dotClass: string; label: string }
217> = {
218 pending: { dotClass: "bg-info", label: "Queued" },
219 running: { dotClass: "bg-info", label: "Running" },
220 waiting: { dotClass: "bg-info", label: "Waiting" },
221 idle: { dotClass: "bg-muted-foreground/50", label: "Idle · resumable" },
222 completed: { dotClass: "bg-success", label: "Completed" },
223 failed: { dotClass: "bg-destructive", label: "Failed" },
224 cancelled: { dotClass: "bg-muted-foreground/60", label: "Stopped" },
225 interrupted: { dotClass: "bg-muted-foreground/60", label: "Stopped" },
226};
227
228function subagentStatusVisual(status: OrchestrationV2TurnItem["status"]) {
229 return STATUS_VISUALS[status];
230}
231
232const SETTLED_SUBAGENT_STATUSES = new Set<OrchestrationV2TurnItem["status"]>([
233 "completed",
234 "failed",
235 "cancelled",
236 "interrupted",
237]);
238
239const GENERIC_CHILD_END = /^Child task ended with status\b/i;
240
241function plainDetail(text: string): string {
242 return text
243 .replace(/\[([^\]]+)\]\([^)]*\)/g, "$1")
244 .replace(/`/g, "")
245 .replace(/^[ \t]*[-*][ \t]+/gm, "")
246 .replace(/\s+/g, " ")
247 .trim();
248}
249
250function isoOrNull(value: DateTime.Utc | null | undefined): string | null {
251 return value ? DateTime.formatIso(value) : null;
252}
253
254export function SubagentElapsed({ agent }: { agent: Parameters<typeof AgentElapsed>[0]["agent"] }) {
255 return <AgentElapsed agent={agent} />;
256}
257
258function SubagentAvatar({
259 driver,
260 displayName,
261 iconUrl,
262 status,
263 className,
264}: {
265 driver?: ProviderDriverKind | undefined;
266 displayName?: string | undefined;
267 iconUrl?: string | undefined;
268 status?: OrchestrationV2TurnItem["status"] | undefined;
269 className?: string;
270}) {
271 return (
272 <span
273 aria-hidden
274 className={cn(
275 "relative inline-flex size-6 shrink-0 items-center justify-center rounded-full border border-border/70 bg-muted ring-2 ring-background",
276 className,
277 )}
278 >
279 {driver ? (
280 <ProviderInstanceIcon
281 driverKind={driver}
282 displayName={displayName ?? driver}
283 acpRegistryIconUrl={iconUrl}
284 className="z-auto"
285 iconClassName="size-3.5"
286 />
287 ) : (
288 <BotIcon className="size-3.5 text-muted-foreground" />
289 )}
290 {status ? (
291 <span
292 className={cn(
293 "absolute -right-px -bottom-px size-2 rounded-full ring-2 ring-background",
294 subagentStatusVisual(status).dotClass,
295 )}
296 />
297 ) : null}
298 </span>
299 );
300}
301
302// Select strings; status pushes replace providers even when avatar fields are unchanged.
303export function EnvironmentSubagentAvatar({
304 environmentId,
305 providerInstanceId,
306 ...props
307}: {
308 environmentId: EnvironmentId;
309 providerInstanceId: ProviderInstanceId;
310 driver?: ProviderDriverKind | undefined;
311 status?: OrchestrationV2TurnItem["status"] | undefined;
312}) {
313 const providersAtom = serverEnvironment.providersValueAtom(environmentId);
314 const displayName = useAtomValue(
315 providersAtom,
316 (providers) =>
317 providers?.find((provider) => provider.instanceId === providerInstanceId)?.displayName,
318 );
319 const iconUrl = useAtomValue(
320 providersAtom,
321 (providers) =>
322 providers?.find((provider) => provider.instanceId === providerInstanceId)?.iconUrl,
323 );
324 return <SubagentAvatar {...props} displayName={displayName} iconUrl={iconUrl} />;
325}
326
327const NOTIFICATION_OUTCOME_STATUS: Record<
328 OrchestrationV2Notification["outcome"],
329 OrchestrationV2TurnItem["status"] | null
330> = {
331 completed: "completed",
332 failed: "failed",
333 cancelled: "cancelled",
334 updated: null,
335 unknown: null,
336};
337
338const NOTIFICATION_OUTCOME_LABEL: Record<OrchestrationV2Notification["outcome"], string> = {
339 completed: "Finished",
340 failed: "Failed",
341 cancelled: "Stopped",
342 updated: "Updated",
343 unknown: "Finished",
344};
345
346export function SubagentNotificationLink(props: {
347 readonly parentRef: ScopedThreadRef;
348 readonly childThreadId: ThreadId;
349 readonly outcome: OrchestrationV2Notification["outcome"];
350 readonly createdAt: string;
351 readonly timestampFormat: TimestampFormat;
352 readonly onOpenThread: (threadId: ThreadId) => void;
353 readonly fallback: ReactNode;
354}) {
355 const agent = useAtomValue(
356 environmentThreadDetails.threadAtom(props.parentRef),
357 (thread) =>
358 thread?.projection.subagents.find((agent) => agent.childThreadId === props.childThreadId) ??
359 null,
360 );
361 if (agent === null) return props.fallback;
362 const resumed =
363 NOTIFICATION_OUTCOME_STATUS[props.outcome] !== null &&
364 subagentResumedSince(agent, props.createdAt);
365 return (
366 <SubagentTimelineLink
367 parentRef={props.parentRef}
368 subagentId={agent.id}
369 providerInstanceId={agent.providerInstanceId}
370 origin={agent.origin}
371 status={agent.status}
372 driver={agent.driver}
373 title={formatSubagentDisplayTitle(agent.title ?? "Subagent")}
374 result={agent.result}
375 progress={agent.progress}
376 startedAt={agent.startedAt}
377 completedAt={agent.completedAt}
378 threadId={props.childThreadId}
379 onOpenThread={props.onOpenThread}
380 {...(resumed
381 ? {}
382 : {
383 event: {
384 status: NOTIFICATION_OUTCOME_STATUS[props.outcome],
385 label: NOTIFICATION_OUTCOME_LABEL[props.outcome],
386 timestamp: formatShortTimestamp(props.createdAt, props.timestampFormat),
387 },
388 })}
389 />
390 );
391}
392
393function SubagentTimelineLink(props: {
394 readonly parentRef: ScopedThreadRef;
395 readonly subagentId: NodeId;
396 readonly providerInstanceId: ProviderInstanceId;
397 readonly origin: OrchestrationV2Subagent["origin"];
398 readonly driver: ProviderDriverKind;
399 readonly title: string;
400 readonly result: string | null;
401 readonly progress: string | undefined;
402 readonly status: OrchestrationV2TurnItem["status"];
403 readonly startedAt: DateTime.Utc | null;
404 readonly completedAt: DateTime.Utc | null;
405 readonly threadId: ThreadId | null;
406 /** The thread in a linked environment that runs this task, when it runs there. */
407 readonly remote?: OrchestrationV2RemoteTaskChild | undefined;
408 readonly onOpenThread: (threadId: ThreadId) => void;
409 readonly event?: {
410 readonly status: OrchestrationV2TurnItem["status"] | null;
411 readonly label: string;
412 readonly timestamp: string;
413 };
414}) {
415 const agent = useAtomValue(
416 environmentThreadDetails.threadAtom(props.parentRef),
417 (thread) => thread?.projection.subagents.find((agent) => agent.id === props.subagentId) ?? null,
418 );
419 const remote = props.remote ?? agent?.remoteChild;
420 const remoteEnvironment = useEnvironment(remote?.environmentId ?? null);
421 const navigate = useNavigate();
422 const threadId = props.threadId;
423 // A task in a linked environment opens there, if this client is connected to it.
424 const open =
425 threadId !== null
426 ? () => props.onOpenThread(threadId)
427 : remote !== undefined && remoteEnvironment !== null
428 ? () =>
429 void navigate({
430 to: "/$environmentId/$threadId",
431 params: buildThreadRouteParams(scopeThreadRef(remote.environmentId, remote.threadId)),
432 })
433 : null;
434 const liveStatus = agent?.status ?? props.status;
435 const status = props.event ? props.event.status : liveStatus;
436 const statusLabel = props.event?.label ?? subagentStatusVisual(liveStatus).label;
437 const result = (agent?.result ?? props.result)?.trim();
438 const progress = (agent?.progress ?? props.progress)?.trim();
439 const settled = SETTLED_SUBAGENT_STATUSES.has(status ?? liveStatus);
440 const rawDetail = settled ? result || progress : progress || result;
441 const detail =
442 rawDetail && !GENERIC_CHILD_END.test(rawDetail) ? plainDetail(rawDetail) || null : null;
443 const failed = status === "failed";
444 const timing = {
445 status: liveStatus,
446 startedAt: isoOrNull(agent?.startedAt ?? props.startedAt),
447 completedAt: isoOrNull(agent?.completedAt ?? props.completedAt),
448 };
449 const content = (
450 <>
451 <EnvironmentSubagentAvatar
452 environmentId={props.parentRef.environmentId}
453 providerInstanceId={props.providerInstanceId}
454 driver={props.driver}
455 status={status ?? undefined}
456 />
457 <span className="min-w-0 flex-1">
458 <span className="flex items-baseline gap-2">
459 <span className="min-w-0 truncate text-xs font-medium text-foreground">
460 {props.title}
461 </span>
462 {remote !== undefined ? (
463 <span className="shrink-0 text-xs text-muted-foreground">on {remote.label}</span>
464 ) : null}
465 </span>
466 <span
467 className={cn(
468 "block text-2xs leading-relaxed",
469 failed ? "text-destructive" : "text-muted-foreground",
470 )}
471 >
472 {detail === null ? (
473 statusLabel
474 ) : detail.includes("/") && !detail.includes(" ") ? (
475 <MiddleTruncate value={detail} showTitle={false} className="flex" />
476 ) : (
477 <span className="block truncate">{detail}</span>
478 )}
479 </span>
480 </span>
481 {detail !== null && (props.event !== undefined || status !== "completed") ? (
482 <span
483 className={cn("shrink-0 text-xs", failed ? "text-destructive" : "text-muted-foreground")}
484 >
485 {statusLabel}
486 </span>
487 ) : null}
488 <span className="shrink-0 text-xs text-muted-foreground tabular-nums">
489 {props.event ? props.event.timestamp : <SubagentElapsed agent={timing} />}
490 </span>
491 {open !== null ? (
492 <ChevronRightIcon
493 aria-hidden
494 className="size-3.5 shrink-0 text-muted-foreground/60 transition-colors group-hover/subagent:text-foreground"
495 />
496 ) : null}
497 </>
498 );
499 const className =
500 "group/subagent flex w-full min-w-0 items-center gap-2.5 rounded-md px-2 py-1.5 text-left";
501 return (
502 <Tooltip>
503 <TooltipTrigger
504 delay={200}
505 render={
506 open === null ? (
507 <div data-v2-item-type="subagent" aria-description={statusLabel} className={className}>
508 {content}
509 </div>
510 ) : (
511 <button
512 type="button"
513 data-v2-item-type="subagent"
514 aria-label={`Open ${props.title}`}
515 aria-description={statusLabel}
516 onClick={open}
517 className={cn(
518 className,
519 "cursor-pointer transition-colors hover:bg-accent/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70",
520 )}
521 >
522 {content}
523 </button>
524 )
525 }
526 />
527 <ThreadHoverCardPopup>
528 <SubagentTimelineTooltip
529 {...props}
530 elapsed={agent ? <AgentElapsed agent={projectedSubagentsToRuntime([agent])[0]!} /> : null}
531 model={agent?.model ?? null}
532 modelSelection={agent?.modelSelection}
533 status={liveStatus}
534 result={agent?.result ?? props.result}
535 progress={agent?.progress ?? props.progress}
536 />
537 </ThreadHoverCardPopup>
538 </Tooltip>
539 );
540}
541
542function SubagentTimelineTooltip(
543 props: Parameters<typeof SubagentTimelineLink>[0] & {
544 model: string | null;
545 modelSelection: OrchestrationV2Subagent["modelSelection"];
546 elapsed: ReactNode;
547 },
548) {
549 const environmentId = props.parentRef.environmentId;
550 // Read providers only in the open popup to avoid per-row subscriptions.
551 const providers =
552 useAtomValue(serverEnvironment.providersValueAtom(environmentId)) ?? EMPTY_SERVER_PROVIDERS;
553 const parent = useThreadShell(props.parentRef)?.source;
554 const child = useThreadShell(
555 props.threadId ? scopeThreadRef(environmentId, props.threadId) : null,
556 )?.source;
557 const parentProject = useProject(
558 parent ? scopeProjectRef(environmentId, parent.projectId) : null,
559 );
560 const childProject = useProject(child ? scopeProjectRef(environmentId, child.projectId) : null);
561 return (
562 <SubagentTooltipContent
563 title={formatSubagentDisplayTitle(child?.title ?? props.title)}
564 model={props.model}
565 providerInstanceId={props.providerInstanceId}
566 origin={props.origin}
567 modelSelection={props.modelSelection}
568 provider={providers.find((provider) => provider.instanceId === props.providerInstanceId)}
569 providers={providers}
570 driver={props.driver}
571 elapsed={props.elapsed}
572 status={props.status}
573 result={props.result}
574 progress={props.progress}
575 parentThread={parent}
576 childThread={child}
577 parentProject={parentProject ?? undefined}
578 childProject={childProject ?? undefined}
579 />
580 );
581}
582
583function EnvironmentHandoffRow({
584 environmentId,
585 ...props
586}: {
587 readonly environmentId: EnvironmentId;
588 readonly endpoints: HandoffEndpoints;
589 readonly failed: boolean;
590}) {
591 const providers =
592 useAtomValue(serverEnvironment.providersValueAtom(environmentId)) ?? EMPTY_SERVER_PROVIDERS;
593 return <HandoffRow {...props} environmentId={environmentId} providers={providers} />;
594}
595
596export function HandoffRow(props: {
597 readonly environmentId: EnvironmentId;
598 readonly endpoints: HandoffEndpoints;
599 readonly providers: ReadonlyArray<ServerProvider>;
600 readonly pending?: boolean;
601 readonly failed?: boolean;
602}) {
603 const { from: fromEndpoints, to } = props.endpoints;
604 const settings = useAtomValue(serverEnvironment.settingsValueAtom(props.environmentId));
605 const derived = deriveProviderInstanceEntries(props.providers);
606 const entries = settings ? applyProviderInstanceSettings(derived, settings, null) : derived;
607 return (
608 <TimelineSystemDivider
609 label={props.pending ? "Context handoff pending" : "Context handoff"}
610 icon={ArrowRightLeftIcon}
611 showDetailSeparator={false}
612 tone={props.failed ? "danger" : "neutral"}
613 detail={
614 <span className="inline-flex min-w-0 flex-wrap items-center justify-center gap-1.5">
615 {fromEndpoints.map((endpoint, index) => (
616 <span
617 key={`${endpoint.instanceId}:${endpoint.model ?? ""}`}
618 className="inline-flex min-w-0 items-center"
619 >
620 <HandoffEndpoint
621 entries={entries}
622 instanceId={endpoint.instanceId}
623 model={endpoint.model}
624 />
625 {index < fromEndpoints.length - 1 ? (
626 <span aria-hidden="true" className="ml-0.5">
627 ,
628 </span>
629 ) : null}
630 </span>
631 ))}
632 {fromEndpoints.length > 0 ? (
633 <ArrowRightIcon aria-hidden="true" className="size-3 shrink-0" />
634 ) : null}
635 <HandoffEndpoint entries={entries} instanceId={to.instanceId} model={to.model} />
636 </span>
637 }
638 />
639 );
640}
641
642function HandoffEndpoint(props: {
643 readonly entries: ReadonlyArray<ProviderInstanceEntry>;
644 readonly instanceId: ProviderInstanceId;
645 readonly model?: string | undefined;
646}) {
647 const entry = props.entries.find((candidate) => candidate.instanceId === props.instanceId);
648 const showBadge = entry !== undefined && shouldShowInstanceBadge(entry, props.entries);
649 const model = props.model?.trim();
650 const providerModel =
651 model === undefined || model.length === 0
652 ? undefined
653 : entry?.models.find((candidate) => candidate.slug === model);
654 const label =
655 providerModel !== undefined
656 ? getTriggerDisplayModelName(providerModel, entry?.driverKind)
657 : model !== undefined && model.length > 0
658 ? model
659 : (entry?.displayName ?? props.instanceId);
660 const labelColor = providerTextColor(
661 entry?.driverKind ?? ProviderDriverKind.make(props.instanceId),
662 );
663 return (
664 <Tooltip>
665 <TooltipTrigger
666 render={
667 <span
668 tabIndex={0}
669 className="inline-flex min-w-0 items-center gap-1.5 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
670 >
671 <ProviderInstanceIcon
672 driverKind={entry?.driverKind ?? ProviderDriverKind.make(props.instanceId)}
673 displayName={entry?.displayName ?? props.instanceId}
674 accentColor={entry?.accentColor}
675 acpRegistryAgentId={entry?.acpRegistryAgentId}
676 acpRegistryIconUrl={entry?.acpRegistryIconUrl}
677 showBadge={showBadge}
678 size="compact"
679 iconClassName={cn(showBadge && "opacity-60")}
680 indicatorBackground="var(--background)"
681 />
682 <span
683 className={cn("truncate font-medium", labelColor.className)}
684 style={labelColor.style}
685 >
686 {label}
687 </span>
688 </span>
689 }
690 />
691 <TooltipPopup>
692 {entry?.displayName ?? props.instanceId} · {label}
693 </TooltipPopup>
694 </Tooltip>
695 );
696}