@@ -17,6 +17,7 @@ import {
1717 threadRelationshipRowStatus ,
1818 orderWebThreadLineageRows ,
1919 resolveMergeBackTargetThreadId ,
20+ resolveThreadOpener ,
2021 type ThreadRelationshipEdge ,
2122 type ThreadRelationshipWalkRow ,
2223} from "@t3tools/client-runtime/state/thread-relationships" ;
@@ -59,7 +60,9 @@ import { Menu, MenuItem, MenuPopup, MenuTrigger } from "../ui/menu";
5960import { Tooltip , TooltipPopup , TooltipTrigger } from "../ui/tooltip" ;
6061import { toastManager } from "../ui/toast" ;
6162import {
63+ THREAD_DETAILS_PANEL_ICON_CLASS ,
6264 THREAD_DETAILS_PANEL_LINK_SPLIT_GROUP_CLASS ,
65+ THREAD_DETAILS_PANEL_LOCKED_ROW_CLASS ,
6366 THREAD_DETAILS_PANEL_ROW_CONTENT_CLASS ,
6467 THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS ,
6568} from "./threadDetailsPanelStyles" ;
@@ -153,6 +156,36 @@ function ThreadLineageGroup(props: {
153156 ) ;
154157}
155158
159+ /** First Lineage row for a thread an agent opened, linking the opener when known. */
160+ function ThreadOpenerRow ( props : {
161+ readonly openerTitle : string | null ;
162+ readonly onOpen : ( ( ) => void ) | null ;
163+ } ) {
164+ const content = (
165+ < >
166+ < BotIcon aria-hidden className = { THREAD_DETAILS_PANEL_ICON_CLASS } />
167+ < span className = "min-w-0 flex-1 truncate text-left text-sm leading-4" >
168+ < span className = "font-normal text-muted-foreground" > Opened by </ span >
169+ < span className = "font-medium text-foreground/85" > { props . openerTitle ?? "an agent" } </ span >
170+ </ span >
171+ </ >
172+ ) ;
173+ return (
174+ < li className = "group flex h-8 items-center rounded-lg" data-thread-opener >
175+ { props . onOpen ? (
176+ < ThreadDetailsControl size = "sm" variant = "ghost" part = "row" onClick = { props . onOpen } >
177+ { content }
178+ < ArrowRightIcon className = "size-3 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100" />
179+ </ ThreadDetailsControl >
180+ ) : (
181+ < span className = { `flex items-center ${ THREAD_DETAILS_PANEL_LOCKED_ROW_CLASS } ` } >
182+ { content }
183+ </ span >
184+ ) }
185+ </ li >
186+ ) ;
187+ }
188+
156189function relationshipLabel ( edge : ThreadRelationshipEdge , currentThreadId : ThreadId ) {
157190 if ( edge . kind === "transfer" ) return "Context transfer" ;
158191 if ( edge . kind === "subagent" ) {
@@ -252,6 +285,8 @@ export function ThreadRelationshipsPanel(props: {
252285 } ) ,
253286 [ graph , mergeTargetThreadId , props . threadId ] ,
254287 ) ;
288+ const opener = currentThread ? resolveThreadOpener ( currentThread ) : null ;
289+ const openerThread = opener ?. threadId ? graph . nodes . get ( opener . threadId ) ?. thread : null ;
255290 const canMerge = mergeTargetThreadId !== null && latestMergeBackRun !== null ;
256291 const canDetach = projection ? canDetachThreadProviderSession ( projection ) : false ;
257292
@@ -279,7 +314,7 @@ export function ThreadRelationshipsPanel(props: {
279314 ( agent ) => agent . childThreadId === null && agent . status === "running" ,
280315 ) . length ?? 0 ) + active . filter ( ( { edge } ) => edge . status === "running" ) . length ;
281316
282- if ( relationshipRows . length === 0 && runningCount === 0 ) {
317+ if ( relationshipRows . length === 0 && runningCount === 0 && opener === null ) {
283318 return null ;
284319 }
285320
@@ -364,6 +399,14 @@ export function ThreadRelationshipsPanel(props: {
364399 ) : null
365400 }
366401 >
402+ { opener ? (
403+ < ul aria-label = "Opened by" className = "m-0 list-none p-0" >
404+ < ThreadOpenerRow
405+ openerTitle = { openerThread ?. title ?? null }
406+ onOpen = { openerThread ? ( ) => openThread ( openerThread . id ) : null }
407+ />
408+ </ ul >
409+ ) : null }
367410 { groups . map ( ( group ) => (
368411 < ThreadLineageGroup key = { `${ scopedThreadKey ( ref ) } :${ group . id } ` } { ...group } >
369412 { ( visibleRows ) =>
0 commit comments