@@ -2793,6 +2793,85 @@ pub(crate) fn render_background_task_message(
27932793 if is_swarm {
27942794 return render_compact_swarm_background_completion ( & parsed, width) ;
27952795 }
2796+ if parsed. status . starts_with ( '✗' ) {
2797+ let muted = Style :: default ( ) . fg ( dim_color ( ) ) ;
2798+ let failure = Style :: default ( ) . fg ( rgb ( 220 , 100 , 100 ) ) ;
2799+ let timing = msg
2800+ . content
2801+ . lines ( )
2802+ . find_map ( |line| {
2803+ let timestamp = line. strip_prefix ( "_Called at:_ `" ) ?. strip_suffix ( '`' ) ?;
2804+ let called = chrono:: DateTime :: parse_from_rfc3339 ( timestamp) . ok ( ) ?;
2805+ let seconds = ( chrono:: Utc :: now ( ) - called. with_timezone ( & chrono:: Utc ) )
2806+ . num_seconds ( )
2807+ . max ( 0 ) ;
2808+ Some ( if seconds < 60 {
2809+ format ! ( "{seconds}s ago" )
2810+ } else if seconds < 3600 {
2811+ format ! ( "{}m ago" , seconds / 60 )
2812+ } else {
2813+ format ! ( "{}h ago" , seconds / 3600 )
2814+ } )
2815+ } )
2816+ . unwrap_or_else ( || format ! ( "took {}" , parsed. duration) ) ;
2817+ let summary = parsed. failure_summary . clone ( ) . or_else ( || {
2818+ let preview = strip_ansi_escape_sequences ( parsed. preview . as_deref ( ) ?) ;
2819+ preview
2820+ . lines ( )
2821+ . map ( str:: trim)
2822+ . map ( |line| {
2823+ line. strip_prefix ( "[stderr] " )
2824+ . or_else ( || line. strip_prefix ( "[stdout] " ) )
2825+ . unwrap_or ( line)
2826+ } )
2827+ . find ( |line| {
2828+ line. starts_with ( "error" )
2829+ || line. starts_with ( "Error:" )
2830+ || line. starts_with ( "Failed:" )
2831+ || line. contains ( "panicked at" )
2832+ } )
2833+ . map ( str:: to_owned)
2834+ } ) ;
2835+ let detail = summary
2836+ . map ( |text| {
2837+ let clean = strip_ansi_escape_sequences ( & text) ;
2838+ format ! (
2839+ "{} · {}" ,
2840+ parsed. exit_label,
2841+ clean. split_whitespace( ) . collect:: <Vec <_>>( ) . join( " " )
2842+ )
2843+ } )
2844+ . unwrap_or_else ( || format ! ( "{} · no diagnostic captured" , parsed. exit_label) ) ;
2845+ let mut header = Line :: from ( vec ! [
2846+ Span :: styled( "✗ " , failure) ,
2847+ Span :: styled(
2848+ if task_label == parsed. tool_name {
2849+ parsed. tool_name. clone( )
2850+ } else {
2851+ format!( "{} {}" , parsed. tool_name, task_label)
2852+ } ,
2853+ Style :: default ( ) ,
2854+ ) ,
2855+ ] ) ;
2856+ let timing = format ! ( " · {timing}" ) ;
2857+ header = super :: truncate_line_with_ellipsis_to_width (
2858+ & header,
2859+ ( width as usize ) . saturating_sub ( UnicodeWidthStr :: width ( timing. as_str ( ) ) ) ,
2860+ ) ;
2861+ header. spans . push ( Span :: styled ( timing, muted) ) ;
2862+ let reason = Line :: from ( vec ! [
2863+ Span :: styled( "╰─ " , muted) ,
2864+ Span :: styled( detail, muted) ,
2865+ ] ) ;
2866+ let mut lines = vec ! [
2867+ super :: truncate_line_with_ellipsis_to_width( & header, width as usize ) ,
2868+ super :: truncate_line_with_ellipsis_to_width( & reason, width as usize ) ,
2869+ ] ;
2870+ if centered {
2871+ left_pad_lines_for_centered_mode ( & mut lines, width) ;
2872+ }
2873+ return lines;
2874+ }
27962875 let ( title, border_color, status_color, preview_color) = if parsed. status . starts_with ( '✓' ) {
27972876 (
27982877 if is_swarm {
0 commit comments