@@ -7,6 +7,7 @@ import { SubagentTooltipContent } from "./SubagentTooltipContent";
77import { useAtomValue } from "@effect/atom-react" ;
88import { scopeThreadRef , scopeProjectRef } from "@t3tools/client-runtime/environment" ;
99import { environmentThreadDetails } from "../../state/threads" ;
10+ import { EMPTY_SERVER_PROVIDERS , serverEnvironment } from "../../state/server" ;
1011import { MiddleTruncate } from "../ui/middle-truncate" ;
1112import * as DateTime from "effect/DateTime" ;
1213import { WorkLogRow } from "./WorkLog" ;
@@ -72,7 +73,6 @@ export function V2LifecycleRow(props: {
7273 readonly resourceSummary ?: boolean | undefined ;
7374 readonly createdAt : string ;
7475 readonly timestampFormat : TimestampFormat ;
75- readonly providerStatuses : ReadonlyArray < ServerProvider > ;
7676 readonly runs : ReadonlyArray < HandoffTimelineRun > ;
7777 readonly onOpenThread : ( threadId : ThreadId ) => void ;
7878} ) {
@@ -125,9 +125,9 @@ export function V2LifecycleRow(props: {
125125 }
126126 if ( item . type === "handoff" ) {
127127 return (
128- < HandoffRow
128+ < EnvironmentHandoffRow
129+ environmentId = { props . environmentId }
129130 endpoints = { resolveHandoffEndpoints ( item , props . runs ) }
130- providers = { props . providerStatuses }
131131 failed = { item . status === "failed" }
132132 />
133133 ) ;
@@ -192,10 +192,6 @@ export function V2LifecycleRow(props: {
192192 origin = { item . origin }
193193 status = { item . status }
194194 driver = { item . driver }
195- provider = { props . providerStatuses . find (
196- ( provider ) => provider . instanceId === item . providerInstanceId ,
197- ) }
198- providers = { props . providerStatuses }
199195 title = { formatSubagentDisplayTitle ( item . title ?? "Subagent" ) }
200196 result = { item . result }
201197 progress = { item . progress }
@@ -253,14 +249,16 @@ export function SubagentElapsed({ agent }: { agent: Parameters<typeof AgentElaps
253249 return < AgentElapsed agent = { agent } /> ;
254250}
255251
256- export function SubagentAvatar ( {
252+ function SubagentAvatar ( {
257253 driver,
258- provider,
254+ displayName,
255+ iconUrl,
259256 status,
260257 className,
261258} : {
262259 driver ?: ProviderDriverKind | undefined ;
263- provider ?: ServerProvider | undefined ;
260+ displayName ?: string | undefined ;
261+ iconUrl ?: string | undefined ;
264262 status ?: OrchestrationV2TurnItem [ "status" ] | undefined ;
265263 className ?: string ;
266264} ) {
@@ -275,8 +273,8 @@ export function SubagentAvatar({
275273 { driver ? (
276274 < ProviderInstanceIcon
277275 driverKind = { driver }
278- displayName = { provider ?. displayName ?? driver }
279- acpRegistryIconUrl = { provider ?. iconUrl }
276+ displayName = { displayName ?? driver }
277+ acpRegistryIconUrl = { iconUrl }
280278 className = "z-auto"
281279 iconClassName = "size-3.5"
282280 />
@@ -295,6 +293,35 @@ export function SubagentAvatar({
295293 ) ;
296294}
297295
296+ /**
297+ * Reads only the two provider fields the avatar draws. Provider status pushes
298+ * replace the provider objects (fresh `checkedAt`), so selecting strings keeps
299+ * the avatar from re-rendering when nothing it shows changed.
300+ */
301+ export function EnvironmentSubagentAvatar ( {
302+ environmentId,
303+ providerInstanceId,
304+ ...props
305+ } : {
306+ environmentId : EnvironmentId ;
307+ providerInstanceId : ProviderInstanceId ;
308+ driver ?: ProviderDriverKind | undefined ;
309+ status ?: OrchestrationV2TurnItem [ "status" ] | undefined ;
310+ } ) {
311+ const providersAtom = serverEnvironment . providersValueAtom ( environmentId ) ;
312+ const displayName = useAtomValue (
313+ providersAtom ,
314+ ( providers ) =>
315+ providers ?. find ( ( provider ) => provider . instanceId === providerInstanceId ) ?. displayName ,
316+ ) ;
317+ const iconUrl = useAtomValue (
318+ providersAtom ,
319+ ( providers ) =>
320+ providers ?. find ( ( provider ) => provider . instanceId === providerInstanceId ) ?. iconUrl ,
321+ ) ;
322+ return < SubagentAvatar { ...props } displayName = { displayName } iconUrl = { iconUrl } /> ;
323+ }
324+
298325const NOTIFICATION_OUTCOME_STATUS : Record <
299326 OrchestrationV2Notification [ "outcome" ] ,
300327 OrchestrationV2TurnItem [ "status" ] | null
@@ -320,7 +347,6 @@ export function SubagentNotificationLink(props: {
320347 readonly outcome : OrchestrationV2Notification [ "outcome" ] ;
321348 readonly createdAt : string ;
322349 readonly timestampFormat : TimestampFormat ;
323- readonly providerStatuses : ReadonlyArray < ServerProvider > ;
324350 readonly onOpenThread : ( threadId : ThreadId ) => void ;
325351 readonly fallback : ReactNode ;
326352} ) {
@@ -339,10 +365,6 @@ export function SubagentNotificationLink(props: {
339365 origin = { agent . origin }
340366 status = { agent . status }
341367 driver = { agent . driver }
342- provider = { props . providerStatuses . find (
343- ( provider ) => provider . instanceId === agent . providerInstanceId ,
344- ) }
345- providers = { props . providerStatuses }
346368 title = { formatSubagentDisplayTitle ( agent . title ?? "Subagent" ) }
347369 result = { agent . result }
348370 progress = { agent . progress }
@@ -365,8 +387,6 @@ function SubagentTimelineLink(props: {
365387 readonly providerInstanceId : ProviderInstanceId ;
366388 readonly origin : OrchestrationV2Subagent [ "origin" ] ;
367389 readonly driver : ProviderDriverKind ;
368- readonly provider : ServerProvider | undefined ;
369- readonly providers : ReadonlyArray < ServerProvider > ;
370390 readonly title : string ;
371391 readonly result : string | null ;
372392 readonly progress : string | undefined ;
@@ -403,9 +423,10 @@ function SubagentTimelineLink(props: {
403423 } ;
404424 const content = (
405425 < >
406- < SubagentAvatar
426+ < EnvironmentSubagentAvatar
427+ environmentId = { props . parentRef . environmentId }
428+ providerInstanceId = { props . providerInstanceId }
407429 driver = { props . driver }
408- provider = { props . provider }
409430 status = { status ?? undefined }
410431 />
411432 < span className = "min-w-0 flex-1" >
@@ -501,6 +522,10 @@ function SubagentTimelineTooltip(
501522 } ,
502523) {
503524 const environmentId = props . parentRef . environmentId ;
525+ // The popup only mounts while open, so the full provider list is read here
526+ // instead of in every timeline row.
527+ const providers =
528+ useAtomValue ( serverEnvironment . providersValueAtom ( environmentId ) ) ?? EMPTY_SERVER_PROVIDERS ;
504529 const parent = useThreadShell ( props . parentRef ) ?. source ;
505530 const child = useThreadShell (
506531 props . threadId ? scopeThreadRef ( environmentId , props . threadId ) : null ,
@@ -516,8 +541,8 @@ function SubagentTimelineTooltip(
516541 providerInstanceId = { props . providerInstanceId }
517542 origin = { props . origin }
518543 modelSelection = { props . modelSelection }
519- provider = { props . provider }
520- providers = { props . providers }
544+ provider = { providers . find ( ( provider ) => provider . instanceId === props . providerInstanceId ) }
545+ providers = { providers }
521546 driver = { props . driver }
522547 elapsed = { props . elapsed }
523548 status = { props . status }
@@ -531,6 +556,19 @@ function SubagentTimelineTooltip(
531556 ) ;
532557}
533558
559+ function EnvironmentHandoffRow ( {
560+ environmentId,
561+ ...props
562+ } : {
563+ readonly environmentId : EnvironmentId ;
564+ readonly endpoints : HandoffEndpoints ;
565+ readonly failed : boolean ;
566+ } ) {
567+ const providers =
568+ useAtomValue ( serverEnvironment . providersValueAtom ( environmentId ) ) ?? EMPTY_SERVER_PROVIDERS ;
569+ return < HandoffRow { ...props } providers = { providers } /> ;
570+ }
571+
534572export function HandoffRow ( props : {
535573 readonly endpoints : HandoffEndpoints ;
536574 readonly providers : ReadonlyArray < ServerProvider > ;
0 commit comments