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