1- use std:: { io:: Write , process:: Stdio } ;
1+ use std:: { collections :: HashMap , io:: Write , process:: Stdio } ;
22
33use clap_repl:: ReadCommandOutput ;
44use http:: MitoHttpClient ;
@@ -824,36 +824,32 @@ impl MitoClient {
824824 self . http_client . close_task_suite ( args. uuid ) . await
825825 }
826826
827- pub async fn suites_cancel (
828- & mut self ,
829- args : CancelSuiteArgs ,
830- ) -> crate :: error:: Result < CancelSuiteResp > {
827+ pub async fn suites_cancel ( & mut self , args : CancelSuiteArgs ) -> crate :: error:: Result < ( ) > {
831828 self . http_client
832829 . cancel_task_suite ( args. uuid , args. force )
833830 . await
834831 }
835832
836- pub async fn suites_set_agent (
833+ /// Apply a single-agent selection override, reporting the per-agent outcome. Backed
834+ /// by the batch endpoint with a one-entry request.
835+ async fn suites_select_agent (
837836 & mut self ,
838837 args : SuiteAgentArgs ,
839- include : bool ,
840- ) -> crate :: error:: Result < SuiteAgentResp > {
841- let req = SuiteAgentReq {
842- agent_uuid : args. agent ,
843- } ;
844- self . http_client
845- . set_suite_agent ( args. uuid , include, req)
846- . await
847- }
848-
849- pub async fn suites_reset_agent (
850- & mut self ,
851- args : SuiteAgentArgs ,
852- ) -> crate :: error:: Result < ResetSuiteAgentResp > {
853- let req = SuiteAgentReq {
854- agent_uuid : args. agent ,
855- } ;
856- self . http_client . reset_suite_agent ( args. uuid , req) . await
838+ action : SuiteAgentSelectionAction ,
839+ ) {
840+ let ( suite, agent) = ( args. uuid , args. agent ) ;
841+ let selection = HashMap :: from ( [ ( agent, action) ] ) ;
842+ match self . http_client . select_suite_agents ( suite, selection) . await {
843+ Ok ( resp) => match resp. failed . get ( & agent) {
844+ Some ( err) => {
845+ tracing:: error!(
846+ "Failed to apply {action:?} to agent {agent} on suite {suite}: {err:?}"
847+ )
848+ }
849+ None => tracing:: info!( "Applied {action:?} to agent {agent} on suite {suite}" ) ,
850+ } ,
851+ Err ( e) => tracing:: error!( "{}" , e) ,
852+ }
857853 }
858854
859855 pub async fn tasks_batch_cancel (
@@ -2016,9 +2012,16 @@ impl MitoClient {
20162012 if !counted {
20172013 for suite in resp. suites {
20182014 if verbose {
2019- output_suite_list_info ( & suite) ;
2015+ output_suite_info ( & suite) ;
20202016 } else {
2021- tracing:: info!( "{} ({})" , suite. uuid, suite. state) ;
2017+ tracing:: info!(
2018+ "{}, {} ({}), Tasks (incomplete/total): {} / {}" ,
2019+ suite. uuid,
2020+ suite. name. unwrap_or( "[no name]" . to_string( ) ) ,
2021+ suite. state,
2022+ suite. incomplete_tasks,
2023+ suite. total_tasks
2024+ ) ;
20222025 }
20232026 }
20242027 }
@@ -2030,7 +2033,7 @@ impl MitoClient {
20302033 }
20312034 SuitesCommands :: Get ( args) => match self . suites_get ( args) . await {
20322035 Ok ( resp) => {
2033- output_parsed_suite_info ( & resp. info , & resp. assigned_agents ) ;
2036+ output_parsed_suite_info ( & resp. info , & resp. eligible_agents ) ;
20342037 }
20352038 Err ( e) => {
20362039 tracing:: error!( "{}" , e) ;
@@ -2045,58 +2048,25 @@ impl MitoClient {
20452048 }
20462049 } ,
20472050 SuitesCommands :: Cancel ( args) => match self . suites_cancel ( args) . await {
2048- Ok ( resp) => {
2049- tracing:: info!(
2050- "Suite cancelled; {} tasks cancelled" ,
2051- resp. cancelled_task_count
2052- ) ;
2051+ Ok ( _) => {
2052+ tracing:: info!( "Suite cancelled" ) ;
20532053 }
20542054 Err ( e) => {
20552055 tracing:: error!( "{}" , e) ;
20562056 }
20572057 } ,
20582058 SuitesCommands :: IncludeAgent ( args) => {
2059- match self . suites_set_agent ( args, true ) . await {
2060- Ok ( resp) => {
2061- tracing:: info!(
2062- "Agent {} set to {:?} on suite {}" ,
2063- resp. agent_uuid,
2064- resp. selection,
2065- resp. suite_uuid
2066- ) ;
2067- }
2068- Err ( e) => {
2069- tracing:: error!( "{}" , e) ;
2070- }
2071- }
2059+ self . suites_select_agent ( args, SuiteAgentSelectionAction :: Include )
2060+ . await ;
20722061 }
20732062 SuitesCommands :: ExcludeAgent ( args) => {
2074- match self . suites_set_agent ( args, false ) . await {
2075- Ok ( resp) => {
2076- tracing:: info!(
2077- "Agent {} set to {:?} on suite {}" ,
2078- resp. agent_uuid,
2079- resp. selection,
2080- resp. suite_uuid
2081- ) ;
2082- }
2083- Err ( e) => {
2084- tracing:: error!( "{}" , e) ;
2085- }
2086- }
2063+ self . suites_select_agent ( args, SuiteAgentSelectionAction :: Exclude )
2064+ . await ;
2065+ }
2066+ SuitesCommands :: ResetAgent ( args) => {
2067+ self . suites_select_agent ( args, SuiteAgentSelectionAction :: Match )
2068+ . await ;
20872069 }
2088- SuitesCommands :: ResetAgent ( args) => match self . suites_reset_agent ( args) . await {
2089- Ok ( resp) => {
2090- if resp. reset {
2091- tracing:: info!( "Reset the agent to the tag-match default" ) ;
2092- } else {
2093- tracing:: info!( "No manual override to reset" ) ;
2094- }
2095- }
2096- Err ( e) => {
2097- tracing:: error!( "{}" , e) ;
2098- }
2099- } ,
21002070 } ,
21012071 ClientCommand :: Quit => {
21022072 return false ;
0 commit comments