@@ -32,6 +32,7 @@ import {
3232 isProviderNativeSubagentThread ,
3333 NodeId ,
3434 type EnvironmentId ,
35+ type OrchestrationV2DelegatedFrom ,
3536 type OrchestrationV2RemoteTaskChild ,
3637 type OrchestrationV2Subagent ,
3738 type OrchestrationV2ThreadShell ,
@@ -60,6 +61,7 @@ import { useArchivedThreadSnapshots } from "../../lib/archivedThreadsState";
6061import { buildThreadRouteParams } from "../../threadRoutes" ;
6162import {
6263 useProjects ,
64+ useQuietThreadShell ,
6365 useThreadProjection ,
6466 useThreadRelationshipShells ,
6567} from "../../state/entities" ;
@@ -261,7 +263,8 @@ function RemoteSubagentRow(props: {
261263 }
262264 >
263265 < ThreadRelationshipIcon
264- driver = { props . agent . driver }
266+ // The task's own driver here is only a "remote" label.
267+ driver = { props . provider ?. driver }
265268 provider = { props . provider }
266269 fallbackIcon = { BotIcon }
267270 status = { status }
@@ -287,6 +290,62 @@ function RemoteSubagentRow(props: {
287290 ) ;
288291}
289292
293+ /**
294+ * The thread on a linked environment whose agent delegated this one. It opens
295+ * there when this client is connected to that environment.
296+ */
297+ function DelegatedFromRow ( props : {
298+ readonly delegatedFrom : OrchestrationV2DelegatedFrom ;
299+ readonly fallbackLabel : string | undefined ;
300+ } ) {
301+ const navigate = useNavigate ( ) ;
302+ const { delegatedFrom } = props ;
303+ const environment = useEnvironment ( delegatedFrom . environmentId ) ;
304+ const parentRef = scopeThreadRef ( delegatedFrom . environmentId , delegatedFrom . threadId ) ;
305+ // The title it had at delegation, until this client sees the parent itself.
306+ const parent = useQuietThreadShell ( parentRef ) ;
307+ const label = environment ?. label ?? props . fallbackLabel ;
308+ const title = parent ?. title ?? delegatedFrom . title ;
309+ return (
310+ < li className = "group relative flex h-8 items-center rounded-lg" >
311+ < Tooltip >
312+ < TooltipTrigger
313+ delay = { 200 }
314+ render = {
315+ < ThreadDetailsControl
316+ size = "sm"
317+ variant = "ghost"
318+ part = "row"
319+ disabled = { environment === null }
320+ onClick = { ( ) =>
321+ void navigate ( {
322+ to : "/$environmentId/$threadId" ,
323+ params : buildThreadRouteParams ( parentRef ) ,
324+ } )
325+ }
326+ />
327+ }
328+ >
329+ < ThreadRelationshipIcon fallbackIcon = { CornerLeftUpIcon } status = { null } />
330+ < span className = "min-w-0 flex-1" >
331+ < span className = "block truncate text-left text-sm font-medium leading-4 text-foreground/85" >
332+ { title }
333+ </ span >
334+ </ span >
335+ { label ? (
336+ < span className = "shrink-0 text-2xs text-muted-foreground" > on { label } </ span >
337+ ) : null }
338+ </ TooltipTrigger >
339+ < TooltipPopup side = "left" >
340+ { environment === null
341+ ? `Delegated from ${ label ?? "a linked environment" } . Connect to it to open the parent thread.`
342+ : "Open parent agent" }
343+ </ TooltipPopup >
344+ </ Tooltip >
345+ </ li >
346+ ) ;
347+ }
348+
290349export function ThreadRelationshipsPanel ( props : {
291350 readonly environmentId : EnvironmentId ;
292351 readonly threadId : ThreadId ;
@@ -412,7 +471,15 @@ export function ThreadRelationshipsPanel(props: {
412471 ( agent ) => agent . childThreadId === null && agent . status === "running" ,
413472 ) . length ?? 0 ) + active . filter ( ( { edge } ) => edge . status === "running" ) . length ;
414473
415- if ( relationshipRows . length === 0 && runningCount === 0 && remoteSubagents . length === 0 ) {
474+ // A linked environment's agent may have delegated this thread from there.
475+ const delegatedFrom = currentThread ?. delegatedFrom ;
476+
477+ if (
478+ relationshipRows . length === 0 &&
479+ runningCount === 0 &&
480+ remoteSubagents . length === 0 &&
481+ delegatedFrom === undefined
482+ ) {
416483 return null ;
417484 }
418485
@@ -487,7 +554,13 @@ export function ThreadRelationshipsPanel(props: {
487554 headingId = "thread-details-lineage-heading"
488555 title = { runningCount > 0 ? `Lineage · ${ runningCount } running` : "Lineage" }
489556 // A lone "Previous agents" row names itself; the heading returns for status or actions.
490- showHeading = { runningCount > 0 || canDetach || related . length > 0 || active . length > 0 }
557+ showHeading = {
558+ runningCount > 0 ||
559+ canDetach ||
560+ related . length > 0 ||
561+ active . length > 0 ||
562+ delegatedFrom !== undefined
563+ }
491564 data-thread-relationships-panel
492565 actions = {
493566 canDetach ? (
@@ -515,6 +588,14 @@ export function ThreadRelationshipsPanel(props: {
515588 ) : null
516589 }
517590 >
591+ { delegatedFrom === undefined ? null : (
592+ < ThreadLineageRowList hiddenCount = { 0 } onShowMore = { ( ) => { } } >
593+ < DelegatedFromRow
594+ delegatedFrom = { delegatedFrom }
595+ fallbackLabel = { currentThread ?. linkOrigin ?. label }
596+ />
597+ </ ThreadLineageRowList >
598+ ) }
518599 { groups . map ( ( group ) => (
519600 < ThreadLineageGroup key = { `${ scopedThreadKey ( ref ) } :${ group . id } ` } { ...group } >
520601 { ( visibleRows ) =>
0 commit comments