Track per-step push progress and show it in a banner

This commit is contained in:
2026-10-14 08:47:07 +07:00
parent d5acef65a6
commit f25aa9fdc0
3 changed files with 107 additions and 2 deletions
+27 -1
View File
@@ -18,7 +18,7 @@ use crate::checkouts::CheckoutsStore;
use crate::patch_series::{MAX_PATCH_EVENT_BYTES, PatchSeries};
use crate::push::{PushOutcome, grasp_base_url, grasp06_prs_url, pr_clone_urls};
use crate::repos::RepoListStore;
use crate::state::{GitRef, SyncState};
use crate::state::{GitRef, PushStepStatus, SyncState};
use crate::sync_status::SyncStatusStore;
pub struct RepoStore {
@@ -48,6 +48,7 @@ pub struct RepoStore {
// The repository is out of sync on the rejected servers until republished.
pub last_push_warning: Option<String>,
pub pushing: bool,
pub push_steps: Vec<PushStepStatus>,
pub cloning: bool,
// Avoids re-subscribing and re-fetching on every refresh.
repo_relays: HashSet<RelayUrl>,
@@ -101,6 +102,7 @@ impl RepoStore {
last_warning: None,
last_push_warning: None,
pushing: false,
push_steps: Vec::new(),
cloning: false,
repo_relays: HashSet::new(),
root_fetches: HashSet::new(),
@@ -131,6 +133,7 @@ impl RepoStore {
last_warning: None,
last_push_warning: None,
pushing: false,
push_steps: Vec::new(),
cloning: false,
repo_relays: HashSet::new(),
root_fetches: HashSet::new(),
@@ -169,6 +172,14 @@ impl RepoStore {
let backend = Backend::global(cx);
cx.subscribe(&backend, |this, _backend, event, cx| {
if let BackendEvent::PushProgress { addr, status } = event {
if this.addr.as_ref() == Some(addr) {
this.apply_push_step(status.clone(), cx);
}
return;
}
let Some(addr) = this.addr.as_ref() else {
return;
};
@@ -203,6 +214,19 @@ impl RepoStore {
self.addr.as_ref()
}
fn apply_push_step(&mut self, status: PushStepStatus, cx: &mut Context<Self>) {
match self
.push_steps
.iter_mut()
.find(|entry| entry.step() == status.step())
{
Some(entry) => *entry = status,
None => self.push_steps.push(status),
}
cx.notify();
}
pub fn name(&self) -> SharedString {
self.announcement
.as_ref()
@@ -1186,6 +1210,7 @@ impl RepoStore {
cx: &mut Context<Self>,
) -> Task<Result<(), Error>> {
self.pushing = true;
self.push_steps.clear();
self.last_error = None;
self.last_push_warning = None;
cx.notify();
@@ -1195,6 +1220,7 @@ impl RepoStore {
this.update(cx, |this, cx| {
this.pushing = false;
this.push_steps.clear();
match &result {
Ok(outcome) => {
+22
View File
@@ -67,6 +67,28 @@ pub enum PushStepStatus {
Failed(PushStep, String),
}
impl PushStep {
pub fn label(&self) -> String {
match self {
Self::AnnounceRepository => "Announce repository".to_owned(),
Self::StageStateEvent(relay) => format!("Publish state event -> {relay}"),
Self::BroadcastStateEvent => "Publish state event to relays".to_owned(),
Self::PushObjects(relay) => format!(
"Push objects -> {}",
grasp_base_url(relay).unwrap_or_else(|| relay.to_string())
),
}
}
}
impl PushStepStatus {
pub fn step(&self) -> &PushStep {
match self {
Self::Running(step) | Self::Done(step) | Self::Failed(step, _) => step,
}
}
}
impl SyncState {
pub fn build(id: &str, refs: &[GitRef], head: Option<&str>) -> EventBuilder {
let mut tags: Vec<Tag> = vec![Tag::identifier(id.to_owned())];