@ -161,6 +161,12 @@ pub async fn list(opts: &crate::cli::GlobalOpts) -> Result<()> {
crate ::db ::sync ::ensure_synced ( & db , session_ref ) . await ? ;
crate ::db ::sync ::ensure_synced ( & db , session_ref ) . await ? ;
}
}
// Build a map from session_id -> file_path for agent discovery.
let session_file_map : std ::collections ::HashMap < String , std ::path ::PathBuf > = sessions
. into_iter ( )
. map ( | sr | ( sr . session_id , sr . file_path ) )
. collect ( ) ;
// Query DB for display.
// Query DB for display.
let conn = db
let conn = db
. connect ( )
. connect ( )
@ -206,18 +212,31 @@ pub async fn list(opts: &crate::cli::GlobalOpts) -> Result<()> {
project_path
project_path
} ;
} ;
// Count sub-agents for this session.
let agent_count = if let Some ( file_path ) = session_file_map . get ( & session_id ) {
crate ::parser ::discovery ::discover_agents_for_session ( file_path )
. unwrap_or_default ( )
. len ( )
} else {
0
} ;
rows . push ( vec! [
rows . push ( vec! [
display_id ,
display_id ,
last_msg_at ,
last_msg_at ,
display_path ,
display_path ,
model ,
model ,
message_count . to_string ( ) ,
message_count . to_string ( ) ,
agent_count . to_string ( ) ,
] ) ;
] ) ;
}
}
let output = match opts . output {
let output = match opts . output {
crate ::cli ::OutputFormat ::Table = > {
crate ::cli ::OutputFormat ::Table = > {
crate ::output ::render_table ( & [ "ID" , "Date" , "Project" , "Model" , "Messages" ] , & rows ) ?
crate ::output ::render_table (
& [ "ID" , "Date" , "Project" , "Model" , "Messages" , "Sub-agents" ] ,
& rows ,
) ?
}
}
crate ::cli ::OutputFormat ::Json = > {
crate ::cli ::OutputFormat ::Json = > {
let objects : Vec < serde_json ::Value > = rows
let objects : Vec < serde_json ::Value > = rows
@ -229,14 +248,14 @@ pub async fn list(opts: &crate::cli::GlobalOpts) -> Result<()> {
"project" : r [ 2 ] ,
"project" : r [ 2 ] ,
"model" : r [ 3 ] ,
"model" : r [ 3 ] ,
"messages" : r [ 4 ] ,
"messages" : r [ 4 ] ,
"subagents" : 0 ,
"subagents" : r [ 5 ] ,
} )
} )
} )
} )
. collect ( ) ;
. collect ( ) ;
crate ::output ::render_json ( & objects ) ?
crate ::output ::render_json ( & objects ) ?
}
}
crate ::cli ::OutputFormat ::Xml = > crate ::output ::render_xml_rows (
crate ::cli ::OutputFormat ::Xml = > crate ::output ::render_xml_rows (
& [ "session_id" , "date" , "project" , "model" , "messages" ],
& [ "session_id" , "date" , "project" , "model" , "messages" , "subagents" ],
& rows ,
& rows ,
) ? ,
) ? ,
} ;
} ;