@@ -2092,6 +2092,157 @@ fn public_runtime_footer_keeps_throughput_once_without_wrapping() {
20922092 }
20932093}
20942094
2095+ #[ test]
2096+ fn public_memory_footer_drops_stale_trace_and_keeps_scope ( ) {
2097+ let now = Instant :: now ( ) ;
2098+ let mut data = InfoWidgetData {
2099+ memory_info : Some ( MemoryInfo {
2100+ total_count : 7 ,
2101+ project_count : 4 ,
2102+ global_count : 3 ,
2103+ activity : Some ( MemoryActivity {
2104+ state : MemoryState :: Embedding ,
2105+ state_since : now,
2106+ pipeline : None ,
2107+ recent_events : vec ! [ MemoryEvent {
2108+ kind: MemoryEventKind :: MemoryInjected {
2109+ count: 2 ,
2110+ prompt_chars: 318 ,
2111+ age_ms: 44 ,
2112+ preview: "prefers terse answers" . into( ) ,
2113+ items: Vec :: new( ) ,
2114+ } ,
2115+ timestamp: now,
2116+ detail: None ,
2117+ } ] ,
2118+ } ) ,
2119+ ..Default :: default ( )
2120+ } ) ,
2121+ ..Default :: default ( )
2122+ } ;
2123+ for width in [ 8 , 12 , 24 , 44 ] {
2124+ let ( above, footer) = footer_probe ( WidgetKind :: MemoryActivity , & data, width) ;
2125+ assert ! ( !above. contains( "Trace:" ) ) ;
2126+ if width >= 24 {
2127+ assert ! ( footer. contains( "Trace:" ) , "{footer}" ) ;
2128+ }
2129+ }
2130+ let activity = data
2131+ . memory_info
2132+ . as_mut ( )
2133+ . unwrap ( )
2134+ . activity
2135+ . as_mut ( )
2136+ . unwrap ( ) ;
2137+ activity. state = MemoryState :: Idle ;
2138+ activity. state_since = now - Duration :: from_secs ( 60 ) ;
2139+ for width in [ 8 , 12 , 24 , 44 ] {
2140+ let ( above, footer) = footer_probe ( WidgetKind :: MemoryActivity , & data, width) ;
2141+ assert ! ( !above. contains( "Trace:" ) && !footer. contains( "Trace:" ) ) ;
2142+ if width >= 24 {
2143+ assert ! ( footer. contains( "4 project · 3 global" ) , "{footer}" ) ;
2144+ assert ! ( !above. contains( "4 project" ) ) ;
2145+ }
2146+ }
2147+ }
2148+
2149+ #[ test]
2150+ fn public_swarm_footer_tracks_output_clients_and_overflow ( ) {
2151+ let mut first = managed_member ( "fox" , "running" , None ) ;
2152+ first. runtime . output_tokens = Some ( 12_000 ) ;
2153+ let mut second = managed_member ( "owl" , "completed" , None ) ;
2154+ second. runtime . output_tokens = Some ( 8_000 ) ;
2155+ let mut data = InfoWidgetData {
2156+ swarm_info : Some ( SwarmInfo {
2157+ managed_members : vec ! [ first, second] ,
2158+ client_count : Some ( 1 ) ,
2159+ ..Default :: default ( )
2160+ } ) ,
2161+ ..Default :: default ( )
2162+ } ;
2163+ for width in [ 8 , 12 , 24 , 44 ] {
2164+ let ( above, footer) = footer_probe ( WidgetKind :: SwarmStatus , & data, width) ;
2165+ assert ! ( !above. contains( "20K out" ) ) ;
2166+ if width >= 12 {
2167+ assert ! ( footer. contains( "20K out" ) , "{footer}" ) ;
2168+ }
2169+ }
2170+ for member in & mut data. swarm_info . as_mut ( ) . unwrap ( ) . managed_members {
2171+ member. runtime . output_tokens = None ;
2172+ }
2173+ let ( _, footer) = footer_probe ( WidgetKind :: SwarmStatus , & data, 44 ) ;
2174+ assert ! ( footer. contains( "1 client" ) , "{footer}" ) ;
2175+ assert ! ( !footer. contains( "1 clients" ) , "{footer}" ) ;
2176+
2177+ data. swarm_info = Some ( SwarmInfo {
2178+ session_count : 4 ,
2179+ session_names : vec ! [ "one" . into( ) , "two" . into( ) , "three" . into( ) , "four" . into( ) ] ,
2180+ client_count : Some ( 1 ) ,
2181+ ..Default :: default ( )
2182+ } ) ;
2183+ for width in [ 8 , 12 , 24 , 44 ] {
2184+ let ( above, footer) = footer_probe ( WidgetKind :: SwarmStatus , & data, width) ;
2185+ assert ! ( !above. contains( "1 client" ) ) ;
2186+ if width >= 12 {
2187+ assert ! ( footer. contains( "+1 more" ) , "{footer}" ) ;
2188+ }
2189+ if width == 44 {
2190+ assert ! ( footer. contains( "1 client" ) , "{footer}" ) ;
2191+ }
2192+ }
2193+ }
2194+
2195+ #[ test]
2196+ fn public_background_footer_distinguishes_states_and_preserves_overflow ( ) {
2197+ use crate :: tui:: { BackgroundTaskRow , BackgroundTaskRowStatus } ;
2198+
2199+ let row = |status| BackgroundTaskRow {
2200+ task_id : "task" . into ( ) ,
2201+ label : "build" . into ( ) ,
2202+ percent : Some ( 100.0 ) ,
2203+ status,
2204+ completed_at : Some ( Instant :: now ( ) ) ,
2205+ } ;
2206+ let mut data = InfoWidgetData :: default ( ) ;
2207+ for ( status, legend) in [
2208+ ( BackgroundTaskRowStatus :: Running , "◌ running" ) ,
2209+ ( BackgroundTaskRowStatus :: Completed , "✓ complete" ) ,
2210+ ( BackgroundTaskRowStatus :: Failed , "✗ failed" ) ,
2211+ ] {
2212+ data. background_info = Some ( super :: BackgroundInfo {
2213+ rows : vec ! [ row( status) ] ,
2214+ ..Default :: default ( )
2215+ } ) ;
2216+ for width in [ 8 , 12 , 24 , 44 ] {
2217+ let ( above, footer) = footer_probe ( WidgetKind :: BackgroundTasks , & data, width) ;
2218+ assert ! ( !above. contains( legend) ) ;
2219+ if width >= 24 {
2220+ assert ! ( footer. contains( legend) , "{footer}" ) ;
2221+ }
2222+ }
2223+ }
2224+ data. background_info = Some ( super :: BackgroundInfo {
2225+ rows : vec ! [
2226+ row( BackgroundTaskRowStatus :: Running ) ,
2227+ row( BackgroundTaskRowStatus :: Completed ) ,
2228+ ] ,
2229+ ..Default :: default ( )
2230+ } ) ;
2231+ let ( _, footer) = footer_probe ( WidgetKind :: BackgroundTasks , & data, 44 ) ;
2232+ assert ! ( footer. contains( "◌ running · ✓ complete" ) , "{footer}" ) ;
2233+
2234+ data. background_info = Some ( super :: BackgroundInfo {
2235+ running_count : 8 ,
2236+ running_tasks : ( 0 ..8 ) . map ( |index| format ! ( "task {index}" ) ) . collect ( ) ,
2237+ ..Default :: default ( )
2238+ } ) ;
2239+ let ( _, footer) = footer_probe ( WidgetKind :: BackgroundTasks , & data, 44 ) ;
2240+ assert ! ( footer. contains( "+2 more" ) , "{footer}" ) ;
2241+ data. background_info . as_mut ( ) . unwrap ( ) . running_tasks . clear ( ) ;
2242+ let ( _, footer) = footer_probe ( WidgetKind :: BackgroundTasks , & data, 44 ) ;
2243+ assert ! ( footer. contains( "this session" ) , "{footer}" ) ;
2244+ }
2245+
20952246#[ test]
20962247fn public_workspace_footer_counts_visible_sessions_and_running_state ( ) {
20972248 use crate :: tui:: workspace_map:: {
0 commit comments