@@ -343,7 +343,9 @@ function LaunchedThreadConnector(props: {
343343 /** One "1" or "0" per ancestor level, outermost first. */
344344 ancestorLines : string ;
345345} ) {
346- const { visibleDepth, isFirstChild, isLastChild, isActive, ancestorLines } = props ;
346+ const { visibleDepth, isFirstChild, isLastChild, isActive } = props ;
347+ // A row deeper than the visible limit is drawn at the limit, so it keeps the outermost levels.
348+ const ancestorLines = props . ancestorLines . slice ( 0 , visibleDepth - 1 ) ;
347349 return (
348350 < span
349351 aria-hidden
@@ -384,6 +386,8 @@ interface SidebarThreadRowProps {
384386 launchedCount : number ;
385387 /** Launched threads and subagents folded away below this one. */
386388 launchedHiddenCount : number ;
389+ /** The most urgent status among the folded threads, which have no row of their own. */
390+ launchedHiddenStatus : ThreadStatusPill | null ;
387391 launchedFolded : boolean ;
388392 launchDepth : number ;
389393 isFirstLaunchedChild : boolean ;
@@ -446,6 +450,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
446450 const {
447451 launchedCount,
448452 launchedHiddenCount,
453+ launchedHiddenStatus,
449454 launchedFolded,
450455 launchDepth,
451456 isFirstLaunchedChild,
@@ -847,6 +852,9 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
847852 ) }
848853 </ div >
849854 < div className = "ml-auto flex shrink-0 items-center gap-1.5" >
855+ { launchedHiddenCount > 0 && launchedHiddenStatus ? (
856+ < ThreadStatusLabel status = { launchedHiddenStatus } compact />
857+ ) : null }
850858 { launchedCount > 0 ? (
851859 // Folded, it shows how many threads it hides; the chevron appears on row hover or focus.
852860 < button
@@ -874,7 +882,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
874882 < ChevronRightIcon
875883 className = { cn (
876884 "absolute inset-0 m-auto size-3.5 opacity-0 transition-[opacity,rotate] duration-150 group-hover/menu-sub-item:opacity-100 group-focus-visible/launch-fold:opacity-100" ,
877- ! launchedFolded && "rotate-90" ,
885+ ! launchedFolded && "rotate-90 max-sm:opacity-100 " ,
878886 ) }
879887 />
880888 </ button >
@@ -1024,7 +1032,12 @@ interface SidebarProjectThreadListProps {
10241032 renderedThreads : readonly SidebarThreadSummary [ ] ;
10251033 launchFoldByThreadKey : ReadonlyMap <
10261034 string ,
1027- { childCount : number ; hiddenCount : number ; folded : boolean }
1035+ {
1036+ childCount : number ;
1037+ hiddenCount : number ;
1038+ hiddenStatus : ThreadStatusPill | null ;
1039+ folded : boolean ;
1040+ }
10281041 > ;
10291042 showEmptyThreadState : boolean ;
10301043 shouldShowThreadPanel : boolean ;
@@ -1116,10 +1129,11 @@ const SidebarProjectThreadList = memo(function SidebarProjectThreadList(
11161129 const showMoreButtonRender = < button type = "button" /> ;
11171130 const showLessButtonRender = < button type = "button" /> ;
11181131 // Built from the rendered rows so a hidden launcher or sibling leaves no dangling line.
1132+ const renderedLaunchTree = nestLaunchedSidebarThreads ( renderedThreads ) ;
11191133 const launchTreeByThreadKey = new Map (
1120- nestLaunchedSidebarThreads ( renderedThreads ) . map ( ( entry ) => [
1134+ renderedLaunchTree . map ( ( entry , index ) => [
11211135 scopedThreadKey ( scopeThreadRef ( entry . thread . environmentId , entry . thread . id ) ) ,
1122- entry ,
1136+ { ... entry , hasRenderedChild : ( renderedLaunchTree [ index + 1 ] ?. depth ?? 0 ) > entry . depth } ,
11231137 ] ) ,
11241138 ) ;
11251139
@@ -1143,13 +1157,20 @@ const SidebarProjectThreadList = memo(function SidebarProjectThreadList(
11431157 renderedThreads . map ( ( thread ) => {
11441158 const threadKey = scopedThreadKey ( scopeThreadRef ( thread . environmentId , thread . id ) ) ;
11451159 const launchTree = launchTreeByThreadKey . get ( threadKey ) ;
1146- const launchFold = launchFoldByThreadKey . get ( threadKey ) ;
1160+ // A fold toggle only helps while its children can appear: not in a collapsed project's
1161+ // pinned row, nor when "Show more" cuts off every unfolded child.
1162+ const launchFold =
1163+ projectExpanded &&
1164+ ( launchTree ?. hasRenderedChild || launchFoldByThreadKey . get ( threadKey ) ?. hiddenCount )
1165+ ? launchFoldByThreadKey . get ( threadKey )
1166+ : undefined ;
11471167 return (
11481168 < SidebarThreadRow
11491169 key = { threadKey }
11501170 thread = { thread }
11511171 launchedCount = { launchFold ?. childCount ?? 0 }
11521172 launchedHiddenCount = { launchFold ?. hiddenCount ?? 0 }
1173+ launchedHiddenStatus = { launchFold ?. hiddenStatus ?? null }
11531174 launchedFolded = { launchFold ?. folded ?? false }
11541175 launchDepth = { launchTree ?. depth ?? 0 }
11551176 isFirstLaunchedChild = { launchTree ?. isFirstChild ?? true }
@@ -1334,6 +1355,7 @@ function useProjectThreads(project: SidebarProjectSnapshot) {
13341355// null input and the folded list stays cached across navigation.
13351356function useFoldedProjectThreads (
13361357 nestedProjectThreads : ReturnType < typeof useProjectThreads > [ "nestedProjectThreads" ] ,
1358+ lastVisitedAtByThreadKey : ReadonlyMap < string , string | undefined > ,
13371359 pinnedThreadKey : string | null ,
13381360) {
13391361 const launchGroupCollapsedById = useUiStateStore ( ( state ) => state . launchGroupCollapsedById ) ;
@@ -1350,9 +1372,18 @@ function useFoldedProjectThreads(
13501372 visibleProjectThreads,
13511373 orderedProjectThreadKeys : visibleProjectThreads . map ( keyOf ) ,
13521374 launchFoldByThreadKey : new Map (
1353- foldedProjectThreads . map ( ( { thread, childCount, hiddenCount, folded } ) => [
1375+ foldedProjectThreads . map ( ( { thread, childCount, hiddenCount, hiddenThreads , folded } ) => [
13541376 keyOf ( thread ) ,
1355- { childCount, hiddenCount, folded } ,
1377+ {
1378+ childCount,
1379+ hiddenCount,
1380+ hiddenStatus : resolveProjectStatusIndicator (
1381+ hiddenThreads . map ( ( hidden ) =>
1382+ resolveProjectThreadStatus ( hidden , lastVisitedAtByThreadKey ) ,
1383+ ) ,
1384+ ) ,
1385+ folded,
1386+ } ,
13561387 ] ) ,
13571388 ) ,
13581389 } ;
@@ -1526,7 +1557,11 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
15261557 ? activeRouteThreadKey
15271558 : null ;
15281559 const { visibleProjectThreads, orderedProjectThreadKeys, launchFoldByThreadKey } =
1529- useFoldedProjectThreads ( nestedProjectThreads , pinnedLaunchedThreadKey ) ;
1560+ useFoldedProjectThreads (
1561+ nestedProjectThreads ,
1562+ lastVisitedAtByThreadKey ,
1563+ pinnedLaunchedThreadKey ,
1564+ ) ;
15301565 // The "Delete anyway" toast action runs after the toast delay, so it must see
15311566 // the thread list as of the click, not as of the first prompt.
15321567 const readSidebarThreadByKey = useStableCallback ( ( ) => sidebarThreadByKey ) ;
0 commit comments