Show push step progress in publish dialogs
Rust / build (macos-latest, stable) (push) Canceled after 0s
Rust / build (ubuntu-latest, stable) (push) Canceled after 0s
Rust / build (windows-latest, stable) (push) Canceled after 0s
Rust / build (macos-latest, stable) (pull_request) Canceled after 0s
Rust / build (ubuntu-latest, stable) (pull_request) Canceled after 0s
Rust / build (windows-latest, stable) (pull_request) Canceled after 0s

This commit is contained in:
2026-10-14 09:02:30 +07:00
parent f25aa9fdc0
commit dd42d921a9
6 changed files with 138 additions and 194 deletions
+33 -12
View File
@@ -528,6 +528,7 @@ impl Backend {
}
let owner = public_key.to_bech32().unwrap();
let addr = RepoAddr::new(public_key, repo_id.clone());
let servers = grasp_servers.clone();
let client = self.client.clone();
let signer = self.signer.clone();
@@ -542,7 +543,7 @@ impl Backend {
folder.join(dir_name)
};
cx.spawn(async move |_this, cx| {
cx.spawn(async move |this, cx| {
let work = cx.background_spawn({
let destination = destination.clone();
let name = name.clone();
@@ -589,8 +590,19 @@ impl Backend {
mode: GitPushMode::Main,
};
let on_step = &mut |status: PushStepStatus, cx: &mut AsyncApp| {
this.update(cx, |_, cx| {
cx.emit(BackendEvent::PushProgress {
addr: addr.clone(),
status,
});
})?;
Ok::<(), Error>(())
};
let event =
announce_and_push_or_retract(&client, &signer, &state, announcement, cx).await?;
announce_and_push_or_retract(&client, &signer, &state, announcement, cx, on_step)
.await?;
let announcement = Announcement::from_event(&event)
.ok_or_else(|| anyhow!("failed to parse announcement"))?;
@@ -638,12 +650,13 @@ impl Backend {
}
let owner = public_key.to_bech32().unwrap();
let addr = RepoAddr::new(public_key, repo_id.clone());
let servers = grasp_servers.clone();
let client = self.client.clone();
let signer = self.signer.clone();
cx.spawn(async move |_this, cx| {
cx.spawn(async move |this, cx| {
let (mut state, euc) = cx
.background_spawn({
let path = path.clone();
@@ -670,7 +683,19 @@ impl Backend {
let euc = euc.and_then(|commit: String| Sha1Hash::from_str(&commit).ok());
let ann = build_announcement(&repo_id, &name, &description, &owner, &servers, euc);
let event = announce_and_push_or_retract(&client, &signer, &state, ann, cx).await?;
let on_step = &mut |status: PushStepStatus, cx: &mut AsyncApp| {
this.update(cx, |_, cx| {
cx.emit(BackendEvent::PushProgress {
addr: addr.clone(),
status,
});
})?;
Ok::<(), Error>(())
};
let event =
announce_and_push_or_retract(&client, &signer, &state, ann, cx, on_step).await?;
if let Some(base) = servers.first().and_then(grasp_base_url) {
let url = format!("{base}/{owner}/{repo_id}.git");
@@ -1151,15 +1176,17 @@ fn build_announcement(
/// Announces a repository and pushes its state to grasp servers,
/// or retracts the announcement if the push fails.
async fn announce_and_push_or_retract<S>(
async fn announce_and_push_or_retract<S, P>(
client: &Client,
signer: &S,
state: &SyncState,
announcement: GitRepositoryAnnouncement,
cx: &mut AsyncApp,
on_step: &mut P,
) -> Result<Event, Error>
where
S: AsyncGetPublicKey + AsyncSignEvent + ?Sized,
P: FnMut(PushStepStatus, &mut AsyncApp) -> Result<(), Error>,
{
let state_event = state
.state_event(&announcement.id)
@@ -1168,13 +1195,7 @@ where
let announcement_event = announcement.finalize_async(signer).await?;
match state
.announce_and_push(
client,
announcement_event.clone(),
state_event,
cx,
&mut |_, _| Ok(()),
)
.announce_and_push(client, announcement_event.clone(), state_event, cx, on_step)
.await
{
Ok(event) => Ok(event),