@@ -18,8 +18,11 @@ import type { ThreadFeedActivity } from "../../lib/threadActivity";
1818import { serverEnvironment } from "../../state/server" ;
1919import { environmentThreadDetails } from "../../state/threads" ;
2020import { subagentCardElapsed } from "./subagent-card-presentation" ;
21+ import { useEnvironments } from "../../state/environments" ;
22+ import { useServerConfigs } from "../../state/entities" ;
2123import { SubagentRow } from "./SubagentRow" ;
2224import { useVisibleSecondClock } from "./use-visible-second-clock" ;
25+ import { subagentThreadTarget } from "./threadAgentsPresentation" ;
2326import { WorkLogBlock } from "./work-log-layout" ;
2427
2528import { useOpenThreadInspector } from "./thread-inspector-navigation" ;
@@ -68,6 +71,7 @@ export function ThreadSubagentGroup(props: {
6871 environmentThreadDetails . threadAtom ( scopeThreadRef ( props . environmentId , members [ 0 ] ! . threadId ) ) ,
6972 ( thread ) => thread ?. projection . subagents ,
7073 ) ;
74+ const { presentationById } = useEnvironments ( ) ;
7175 const agents = members . map ( ( item ) => {
7276 const live = liveAgents ?. find ( ( agent ) => agent . id === item . subagentId ) ;
7377 return {
@@ -85,8 +89,13 @@ export function ThreadSubagentGroup(props: {
8589 const label = `${ agents . length } subagents` ;
8690 const summary = summarizeSubagentStatuses ( agents . map ( ( agent ) => agent . status ) ) ;
8791 const expanded = props . expandedRows [ props . anchorKey ] ?? false ;
92+ const serverConfigs = useServerConfigs ( ) ;
93+ // A task in a linked environment runs a provider instance of that environment.
8894 const iconUrl = ( item : SubagentItem ) =>
89- config ?. providers . find ( ( provider ) => provider . instanceId === item . providerInstanceId ) ?. iconUrl ;
95+ ( item . remoteChild === undefined
96+ ? config
97+ : serverConfigs . get ( item . remoteChild . environmentId )
98+ ) ?. providers . find ( ( provider ) => provider . instanceId === item . providerInstanceId ) ?. iconUrl ;
9099 return (
91100 < WorkLogBlock >
92101 { grouped ? (
@@ -137,29 +146,40 @@ export function ThreadSubagentGroup(props: {
137146 { ! grouped || expanded ? (
138147 < View className = "mb-1 gap-px rounded-xl border border-border bg-card/30 p-1" >
139148 { agents . map ( ( agent ) => {
140- const threadId = agent . childThreadId ;
149+ // A task in a linked environment opens there, if this app is connected to it.
150+ const target = subagentThreadTarget ( agent , props . environmentId , ( id ) =>
151+ presentationById . has ( id ) ,
152+ ) ;
141153 return (
142154 < Pressable
143155 key = { agent . item . id }
144156 accessible
145- accessibilityRole = { threadId === null ? undefined : "link" }
157+ accessibilityRole = { target === null ? undefined : "link" }
146158 accessibilityHint = {
147- threadId === null ? "Provider-managed agent" : "Opens this agent's thread"
159+ target !== null
160+ ? "Opens this agent's thread"
161+ : agent . remoteChild !== undefined
162+ ? `Runs on ${ agent . remoteChild . label } `
163+ : "Provider-managed agent"
148164 }
149- disabled = { threadId === null }
165+ disabled = { target === null }
150166 onPress = { ( ) => {
151- if ( threadId === null ) return ;
167+ if ( target === null ) return ;
152168 if (
153169 openInspector (
154170 { environmentId : props . environmentId , threadId : members [ 0 ] ! . threadId } ,
155- { type : "thread" , environmentId : props . environmentId , threadId } ,
171+ {
172+ type : "thread" ,
173+ environmentId : target . environmentId ,
174+ threadId : target . threadId ,
175+ } ,
156176 )
157177 )
158178 return ;
159179 navigation . dispatch (
160180 StackActions . push ( "Thread" , {
161- environmentId : String ( props . environmentId ) ,
162- threadId : String ( threadId ) ,
181+ environmentId : String ( target . environmentId ) ,
182+ threadId : String ( target . threadId ) ,
163183 } ) ,
164184 ) ;
165185 } }
@@ -168,6 +188,7 @@ export function ThreadSubagentGroup(props: {
168188 < SubagentRow
169189 environmentId = { props . environmentId }
170190 subagent = { agent }
191+ canOpenRemote = { target !== null }
171192 elapsed = { < SubagentElapsed agents = { [ agent ] } /> }
172193 />
173194 </ Pressable >
0 commit comments