@@ -10,7 +10,6 @@ import {
1010import type {
1111 EnvironmentId ,
1212 OrchestrationV2ProjectedTurnItem ,
13- ProviderInstanceConfig ,
1413 ProviderInstanceId ,
1514 ServerProvider ,
1615} from "@t3tools/contracts" ;
@@ -24,6 +23,11 @@ import { environmentThreadDetails } from "../../state/threads";
2423import { serverEnvironment } from "../../state/server" ;
2524import { ThreadContextDivider } from "./thread-context-divider" ;
2625
26+ type HandoffProvider = ServerProvider & {
27+ readonly driverKind : ServerProvider [ "driver" ] ;
28+ readonly acpRegistryAgentId : string | undefined ;
29+ } ;
30+
2731function handoffEndpointsAtom (
2832 environmentId : EnvironmentId ,
2933 { item, sourceThreadId } : OrchestrationV2ProjectedTurnItem ,
@@ -77,8 +81,20 @@ export function ThreadHandoffDivider(props: {
7781 const config = useAtomValue ( serverEnvironment . configValueAtom ( props . environmentId ) ) ;
7882 const { endpoints } = props ;
7983 const endpointProps = {
80- providers : config ?. providers ?? [ ] ,
81- providerInstances : config ?. settings . providerInstances ,
84+ providers : ( config ?. providers ?? [ ] ) . map ( ( provider ) => {
85+ const rawConfig = config ?. settings . providerInstances [ provider . instanceId ] ?. config ;
86+ const instanceConfig =
87+ rawConfig !== null && typeof rawConfig === "object"
88+ ? ( rawConfig as Readonly < Record < string , unknown > > )
89+ : null ;
90+ const agentId = instanceConfig ?. source === "local" ? undefined : instanceConfig ?. agentId ;
91+ return {
92+ ...provider ,
93+ driverKind : provider . driver ,
94+ accentColor : normalizeProviderAccentColor ( provider . accentColor ) ,
95+ acpRegistryAgentId : typeof agentId === "string" ? agentId . trim ( ) || undefined : undefined ,
96+ } ;
97+ } ) ,
8298 surfaceColor : props . surfaceColor ,
8399 } ;
84100 return (
@@ -114,8 +130,7 @@ export function ThreadHandoffDivider(props: {
114130function HandoffEndpoint ( props : {
115131 instanceId : ProviderInstanceId ;
116132 model ?: string | undefined ;
117- providers : ReadonlyArray < ServerProvider > ;
118- providerInstances : Readonly < Record < string , ProviderInstanceConfig > > | undefined ;
133+ providers : ReadonlyArray < HandoffProvider > ;
119134 surfaceColor : string ;
120135} ) {
121136 const provider = props . providers . find ( ( candidate ) => candidate . instanceId === props . instanceId ) ;
@@ -125,30 +140,7 @@ function HandoffEndpoint(props: {
125140 model ?. name ??
126141 props . model ??
127142 ( provider ? resolveProviderInstanceDisplayName ( provider ) : props . instanceId ) ;
128- const accentColor = normalizeProviderAccentColor ( provider ?. accentColor ) ;
129- // Same account badge as the thread rows: a handoff between two accounts of
130- // one provider would otherwise show the same glyph on both sides. Settings
131- // carry each ACP instance's agent, which tells its glyph apart.
132- const badgeEntry = ( candidate : ServerProvider ) => {
133- const config = props . providerInstances ?. [ candidate . instanceId ] ?. config ;
134- // A local ACP command has no registry agent, as on web.
135- const agentId =
136- typeof config === "object" && config && Reflect . get ( config , "source" ) !== "local"
137- ? Reflect . get ( config , "agentId" )
138- : null ;
139- return {
140- driverKind : candidate . driver ,
141- ...( typeof agentId === "string" && agentId . trim ( )
142- ? { acpRegistryAgentId : agentId . trim ( ) }
143- : { } ) ,
144- } ;
145- } ;
146- const showBadge =
147- provider !== undefined &&
148- shouldShowInstanceBadge (
149- { ...badgeEntry ( provider ) , accentColor } ,
150- props . providers . map ( badgeEntry ) ,
151- ) ;
143+ const showBadge = provider !== undefined && shouldShowInstanceBadge ( provider , props . providers ) ;
152144 return (
153145 < Pressable
154146 accessibilityRole = "button"
@@ -169,7 +161,7 @@ function HandoffEndpoint(props: {
169161 iconUrl = { provider . iconUrl }
170162 size = { 14 }
171163 displayName = { resolveProviderInstanceDisplayName ( provider ) }
172- accentColor = { accentColor }
164+ accentColor = { provider . accentColor }
173165 showBadge
174166 surfaceColor = { props . surfaceColor }
175167 />
0 commit comments