33//! Layout comes from [`crate::todo::stages::stage_layout`], the same function
44//! `run_plan` uses, so the card always matches execution order. The header row
55//! labels each phase with its pips (`phase 1 ●●● phase 2 ○○`). Below it each
6- //! lane (todo group) is one row: its status strip, its name, then its titles
7- //! left to right. Lanes run in parallel within a phase, titles along a row in
6+ //! lane (todo group) is one row: its worker's todo-status strip, its name,
7+ //! then its coordinator todo titles left to right. If worker todos are not
8+ //! available, the strip falls back to the coordinator items. Lanes run in
9+ //! parallel within a phase, titles along a row in
810//! sequence. No divider lines or rails. A list with no stages renders exactly
911//! like a plain checklist.
1012//!
@@ -29,6 +31,9 @@ pub(crate) struct TodoCardAgent {
2931 /// Seconds since the worker's last tool event or token.
3032 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
3133 pub activity_age_secs : Option < u64 > ,
34+ /// Ordered statuses of the worker's own todos, not the coordinator's lane tasks.
35+ #[ serde( default , skip_serializing_if = "Vec::is_empty" ) ]
36+ pub todo_statuses : Vec < String > ,
3237}
3338
3439impl TodoCardAgent {
@@ -63,6 +68,15 @@ impl TodoCardAgent {
6368 activity,
6469 age_secs : member. status_age_secs ,
6570 activity_age_secs : member. runtime . activity_age_secs ,
71+ todo_statuses : if member. runtime . todo_statuses . is_empty ( ) {
72+ member
73+ . todo_items
74+ . iter ( )
75+ . map ( |item| item. status . clone ( ) )
76+ . collect ( )
77+ } else {
78+ member. runtime . todo_statuses . clone ( )
79+ } ,
6680 }
6781 }
6882
@@ -245,7 +259,11 @@ fn current_stage(
245259}
246260
247261fn pip_span ( todo : & crate :: todo:: TodoItem ) -> Span < ' static > {
248- let ( glyph, color) = match todo. status . as_str ( ) {
262+ status_pip_span ( & todo. status )
263+ }
264+
265+ fn status_pip_span ( status : & str ) -> Span < ' static > {
266+ let ( glyph, color) = match status {
249267 "completed" => ( "●" , rgb ( 100 , 180 , 100 ) ) ,
250268 "in_progress" => ( "●" , asap_color ( ) ) ,
251269 _ => ( "○" , rgb ( 90 , 90 , 105 ) ) ,
@@ -458,27 +476,54 @@ fn lane_name_spans(
458476 name
459477}
460478
461- /// A lane's status strip (`✓●○`), padded to `strip_width` so the names after
462- /// it line up across lanes.
463- fn lane_strip_spans (
464- lane_todos : & [ & crate :: todo:: TodoItem ] ,
465- strip_width : usize ,
466- live : bool ,
467- ) -> Vec < Span < ' static > > {
468- // The lane's active step spins while its worker is running, so a frozen
469- // dot means a frozen worker.
470- let mut strip: Vec < Span < ' static > > = lane_todos
479+ fn lane_item_statuses < ' a > (
480+ lane_todos : & [ & ' a crate :: todo:: TodoItem ] ,
481+ agents : & ' a [ TodoCardAgent ] ,
482+ ) -> Vec < ( & ' a str , bool ) > {
483+ let mut seen = std:: collections:: HashSet :: new ( ) ;
484+ let mut statuses = Vec :: new ( ) ;
485+ for todo in lane_todos {
486+ let agent = todo
487+ . assigned_to
488+ . as_deref ( )
489+ . and_then ( |key| agents. iter ( ) . find ( |agent| agent. matches ( key) ) )
490+ . filter ( |agent| !agent. todo_statuses . is_empty ( ) ) ;
491+ if let Some ( agent) = agent {
492+ // Several coordinator todos may point at the same worker.
493+ if seen. insert ( agent. session_id . as_str ( ) ) {
494+ statuses. extend (
495+ agent
496+ . todo_statuses
497+ . iter ( )
498+ . map ( |status| ( status. as_str ( ) , is_live_status ( & agent. status ) ) ) ,
499+ ) ;
500+ }
501+ } else {
502+ statuses. push ( (
503+ todo. status . as_str ( ) ,
504+ lane_live_agent ( & [ todo] , agents) . is_some ( ) ,
505+ ) ) ;
506+ }
507+ }
508+ statuses
509+ }
510+
511+ /// One dot per worker todo, falling back to coordinator todos without a worker list.
512+ fn lane_strip_spans ( statuses : & [ ( & str , bool ) ] , strip_width : usize ) -> Vec < Span < ' static > > {
513+ let strip: Vec < Span < ' static > > = statuses
471514 . iter ( )
472- . map ( |todo | {
473- let mut span = pip_span ( todo ) ;
474- if live && todo . status == "in_progress" {
515+ . map ( |( status , live ) | {
516+ let mut span = status_pip_span ( status ) ;
517+ if * live && * status == "in_progress" {
475518 span. content = LIVE_DOT_SENTINEL . into ( ) ;
476519 }
477520 span
478521 } )
479522 . collect ( ) ;
523+ let mut strip =
524+ super :: truncate_line_with_ellipsis_to_width ( & Line :: from ( strip) , strip_width) . spans ;
480525 strip. push ( Span :: raw (
481- " " . repeat ( strip_width. saturating_sub ( lane_todos . len ( ) ) + 2 ) ,
526+ " " . repeat ( strip_width. saturating_sub ( width_of ( & strip ) ) + 2 ) ,
482527 ) ) ;
483528 strip
484529}
@@ -710,9 +755,10 @@ pub(crate) fn push_stage_lines(
710755 } ;
711756 let strip_width = lanes
712757 . iter ( )
713- . map ( |( _, lane) | lane. items . len ( ) )
758+ . map ( |( _, lane) | lane_item_statuses ( & items_of ( lane) , agents ) . len ( ) )
714759 . max ( )
715- . unwrap_or ( 0 ) ;
760+ . unwrap_or ( 0 )
761+ . min ( ( inner_width / 3 ) . max ( 1 ) ) ;
716762 let name_width = lanes
717763 . iter ( )
718764 . map ( |( _, lane) | {
@@ -732,8 +778,8 @@ pub(crate) fn push_stage_lines(
732778 // dimmed (with its titles and dots) while the phase has not started.
733779 let later = current. is_some_and ( |current| phase > current) ;
734780 let items = items_of ( lane) ;
735- let live = lane_live_agent ( & items, agents) . is_some ( ) ;
736- let mut row = lane_strip_spans ( & items , strip_width, live ) ;
781+ let statuses = lane_item_statuses ( & items, agents) ;
782+ let mut row = lane_strip_spans ( & statuses , strip_width) ;
737783 if name_width > 0 {
738784 let name = lane_name_spans (
739785 lane. group . as_deref ( ) ,
0 commit comments