From 8359d0d7ca6e3531700e7920cac532259e08d405 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 14 Sep 2024 07:28:39 +0100 Subject: [PATCH] refactor: Update TUI sooner when receiving CI status Looking to avoid getting stuck on 'Checking CI status', but this doesn't appear to be where the problem is coming from. --- .../src/repo/handlers/receive_ci_status.rs | 22 +++++++++---------- crates/cli/src/repo/handlers/validate_repo.rs | 1 - 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/crates/cli/src/repo/handlers/receive_ci_status.rs b/crates/cli/src/repo/handlers/receive_ci_status.rs index b39fc20..335dffc 100644 --- a/crates/cli/src/repo/handlers/receive_ci_status.rs +++ b/crates/cli/src/repo/handlers/receive_ci_status.rs @@ -17,21 +17,20 @@ impl Handler for RepoActor { type Result = (); fn handle(&mut self, msg: ReceiveCIStatus, ctx: &mut Self::Context) -> Self::Result { - let log = self.log.clone(); - logger(log.as_ref(), "start: ReceiveCIStatus"); - let addr = ctx.address(); + logger(self.log.as_ref(), "start: ReceiveCIStatus"); let (next, status) = msg.peel(); + self.update_tui(RepoUpdate::ReceiveCIStatus { + status: status.clone(), + }); + debug!(?status, ""); + let graph_log = graph::log(&self.repo_details); + self.update_tui_log(graph_log.clone()); + + let addr = ctx.address(); let forge_alias = self.repo_details.forge.forge_alias().clone(); let repo_alias = self.repo_details.repo_alias.clone(); let message_token = self.message_token; let sleep_duration = self.sleep_duration; - let graph_log = graph::log(&self.repo_details); - self.update_tui_log(graph_log.clone()); - self.update_tui(RepoUpdate::ReceiveCIStatus { - status: status.clone(), - }); - - debug!(?status, ""); match status { Status::Pass => { do_send(&addr, AdvanceMain::new(next), self.log.as_ref()); @@ -57,8 +56,9 @@ impl Handler for RepoActor { commit: next, log: graph_log, }, - log.as_ref(), + self.log.as_ref(), ); + let log = self.log.clone(); async move { debug!("sleeping before retrying..."); logger(log.as_ref(), "before sleep"); diff --git a/crates/cli/src/repo/handlers/validate_repo.rs b/crates/cli/src/repo/handlers/validate_repo.rs index f3f710a..876ba68 100644 --- a/crates/cli/src/repo/handlers/validate_repo.rs +++ b/crates/cli/src/repo/handlers/validate_repo.rs @@ -79,7 +79,6 @@ impl Handler for RepoActor { self.update_tui_log(git_log); if next_is_valid && next != main { info!("Checking CI"); - self.update_tui(RepoUpdate::CheckingCI); do_send(&ctx.address(), CheckCIStatus::new(next), self.log.as_ref()); } else if next != dev { info!("Advance next");