chore: enforce clippy lints across workspace
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run

This commit is contained in:
2026-11-20 08:14:03 +07:00
parent 51dd5c8630
commit 01c3ced1c7
85 changed files with 2773 additions and 2001 deletions
+23 -20
View File
@@ -8,7 +8,7 @@ use gpui::{
use settings::SettingsStore;
use signed_state::{Backend, CheckoutsStore};
use ui::button::{Button, ButtonVariant};
use ui::common::{h_flex, v_flex};
use ui::common::{ResultLogErr as _, h_flex, v_flex};
use ui::dialog::{Dialog, DialogHandle};
use ui::field::Field;
use ui::icons::{Icon, IconRole};
@@ -17,7 +17,7 @@ use ui::tooltip::Tooltip;
use super::grasp_servers::{GraspServersState, grasp_servers_field, load_user_grasp_servers};
use crate::repo::actions::open_repo_panel;
use crate::shared::progress::{DialogProgress, error_row, push_steps_row};
use crate::shared::progress::{DialogProgress, error_row, push_steps_row, run_dialog_task_with};
use crate::workspace::Workspace;
/// Progress of the create-repository flow, so async results can be rendered.
@@ -94,17 +94,26 @@ impl CreateRepoDialog {
let servers = self.grasp_state.read(cx).grasp_servers.clone();
if name.is_empty() {
self.fail("Repository name is required", cx);
self.state.update(cx, |state, cx| {
state.fail("Repository name is required");
cx.notify();
});
return;
}
if servers.is_empty() {
self.fail("Add at least one grasp server", cx);
self.state.update(cx, |state, cx| {
state.fail("Add at least one grasp server");
cx.notify();
});
return;
}
let backend = Backend::global(cx);
let Some(user) = backend.read(cx).current_user() else {
self.fail("Sign in to create a repository", cx);
self.state.update(cx, |state, cx| {
state.fail("Sign in to create a repository");
cx.notify();
});
return;
};
@@ -123,8 +132,10 @@ impl CreateRepoDialog {
let close = self.handle.clone();
let handle = window.window_handle();
cx.spawn(async move |_this, cx| match task.await {
Ok((announcement, local_path)) => {
run_dialog_task_with(
task,
cx,
move |(announcement, local_path), cx| {
cx.update_window(handle, |_, window, cx| {
let checkouts = CheckoutsStore::global(cx);
checkouts.update(cx, |store, cx| {
@@ -140,23 +151,15 @@ impl CreateRepoDialog {
);
close.close(cx);
})
.ok();
}
Err(error) => {
.log_err();
},
move |error, cx| {
state.update(cx, |state, cx| {
state.fail(error.to_string());
cx.notify();
});
}
})
.detach();
}
fn fail(&mut self, message: impl Into<gpui::SharedString>, cx: &mut Context<Self>) {
self.state.update(cx, |state, cx| {
state.fail(message);
cx.notify();
});
},
);
}
}
@@ -13,6 +13,8 @@ use ui::input::{Input, InputState};
use ui::theme::ActiveTheme as _;
use ui::tooltip::Tooltip;
use crate::shared::progress::error_row;
/// State of the grasp-server section of a publish dialog, so async results can be rendered.
#[derive(Default)]
pub struct GraspServersState {
@@ -137,14 +139,7 @@ pub fn grasp_servers_field(
.child("Loading your grasp servers..."),
)
})
.when_some(error, |section, error| {
section.child(
div()
.text_xs()
.text_color(cx.theme().ramps.destructive.base)
.child(error),
)
})
.when_some(error_row(&error, cx), |section, error| section.child(error))
})
.into_any_element()
}
@@ -155,6 +150,7 @@ fn render_server_row(
state: Entity<GraspServersState>,
cx: &App,
) -> AnyElement {
let relay = relay.clone();
h_flex()
.w_full()
.gap_1()
@@ -168,7 +164,7 @@ fn render_server_row(
.text_color(cx.theme().colors.muted_foreground)
.text_xs()
.rounded(cx.theme().radius.control)
.child(server_host(relay)),
.child(server_host(&relay)),
)
.child(
Button::new(SharedString::from(format!("remove-relay:{ix}")))
@@ -176,9 +172,12 @@ fn render_server_row(
.variant(ButtonVariant::Ghost)
.tooltip(Tooltip::text("Remove"))
.on_click(move |_, _, cx| {
// A row's index can desync after a prior removal; match by value.
state.update(cx, |state, cx| {
if ix < state.grasp_servers.len() {
state.grasp_servers.remove(ix);
if let Some(at) =
state.grasp_servers.iter().position(|known| known == &relay)
{
state.grasp_servers.remove(at);
cx.notify();
}
});
+35 -23
View File
@@ -10,7 +10,7 @@ use signed_core::RepoAddr;
use signed_git::Repo;
use signed_state::Backend;
use ui::button::Button;
use ui::common::v_flex;
use ui::common::{ResultLogErr as _, v_flex};
use ui::dialog::{Dialog, DialogHandle};
use ui::field::Field;
use ui::icons::{Icon, IconRole};
@@ -20,7 +20,7 @@ use ui::theme::ActiveTheme as _;
use super::grasp_servers::{GraspServersState, grasp_servers_field, load_user_grasp_servers};
use crate::repo::RepoDetailView;
use crate::shared::progress::{DialogProgress, error_row, push_steps_row};
use crate::shared::progress::{DialogProgress, error_row, push_steps_row, run_dialog_task_with};
pub struct InitRepoDialog {
handle: DialogHandle,
@@ -105,17 +105,26 @@ impl InitRepoDialog {
.filter(|branch| !branch.is_empty());
if name.is_empty() {
self.fail("Repository name is required", cx);
self.state.update(cx, |state, cx| {
state.fail("Repository name is required");
cx.notify();
});
return;
}
if servers.is_empty() {
self.fail("Add at least one grasp server", cx);
self.state.update(cx, |state, cx| {
state.fail("Add at least one grasp server");
cx.notify();
});
return;
}
let backend = Backend::global(cx);
let Some(user) = backend.read(cx).current_user() else {
self.fail("Sign in to publish a repository", cx);
self.state.update(cx, |state, cx| {
state.fail("Sign in to publish a repository");
cx.notify();
});
return;
};
@@ -134,31 +143,25 @@ impl InitRepoDialog {
let close = self.handle.clone();
let handle = window.window_handle();
cx.spawn(async move |_this, cx| match task.await {
Ok(announcement) => {
run_dialog_task_with(
task,
cx,
move |announcement, cx| {
cx.update_window(handle, |_, _window, cx| {
close.close(cx);
if let Some(view) = view.upgrade() {
view.update(cx, |this, cx| this.apply_announcement(announcement, cx));
}
})
.ok();
}
Err(error) => {
.log_err();
},
move |error, cx| {
state.update(cx, |state, cx| {
state.fail(error.to_string());
cx.notify();
});
}
})
.detach();
}
fn fail(&mut self, message: impl Into<SharedString>, cx: &mut Context<Self>) {
self.state.update(cx, |state, cx| {
state.fail(message);
cx.notify();
});
},
);
}
}
@@ -271,9 +274,18 @@ fn load_branches(dialog: Entity<InitRepoDialog>, cx: &mut App) {
})
.await;
let Ok((branches, current)) = loaded else {
log::warn!("failed to list branches for the default branch selector");
return;
let (branches, current) = match loaded {
Ok(loaded) => loaded,
Err(error) => {
log::warn!("failed to list branches for the default branch selector: {error}");
dialog.update(cx, |dialog, cx| {
dialog.state.update(cx, |state, cx| {
state.fail("Could not list the repository's branches");
cx.notify();
});
});
return;
}
};
dialog.update(cx, |dialog, cx| {
+31 -7
View File
@@ -1,25 +1,31 @@
use gpui::prelude::FluentBuilder as _;
use gpui::{
AnyElement, App, AppContext as _, Context, Entity, IntoElement, ParentElement as _, Render,
Styled as _, Window, div, px,
};
use signed_state::RepoStore;
use ui::button::{Button, ButtonVariant};
use ui::common::v_flex;
use ui::common::{ResultLogErr as _, v_flex};
use ui::dialog::{Dialog, DialogHandle};
use ui::theme::ActiveTheme as _;
use crate::shared::progress::{DialogProgress, error_row};
pub struct ResetRemoteDialog {
handle: DialogHandle,
store: Entity<RepoStore>,
deleted: Vec<String>,
state: Entity<DialogProgress>,
}
impl ResetRemoteDialog {
pub fn new(store: Entity<RepoStore>, deleted: Vec<String>, cx: &mut App) -> Entity<Self> {
let state = cx.new(|_| DialogProgress::default());
cx.new(|_| Self {
handle: DialogHandle::new(true),
store,
deleted,
state,
})
}
}
@@ -30,12 +36,16 @@ impl Render for ResetRemoteDialog {
let store = self.store.clone();
let cancel_close = self.handle.clone();
let confirm_close = self.handle.clone();
let content_state = self.state.clone();
let action_state = self.state.clone();
Dialog::new("reset-remote-dialog")
.handle(self.handle.clone())
.min_width(px(480.))
.title("Reset remote to local")
.content(move |_, cx| {
let progress = content_state.read(cx);
v_flex()
.gap_2()
.child(
@@ -60,12 +70,15 @@ impl Render for ResetRemoteDialog {
}))
.into_any_element()
})
.when_some(error_row(&progress.error, cx), |el, error| el.child(error))
.into_any_element()
})
.actions(move |_, _| {
.actions(move |_, cx| {
let busy = action_state.read(cx).busy;
let store = store.clone();
let cancel_close = cancel_close.clone();
let confirm_close = confirm_close.clone();
let confirm_state = action_state.clone();
let cancel: AnyElement = Button::new("cancel-reset-remote")
.label("Cancel")
@@ -76,15 +89,26 @@ impl Render for ResetRemoteDialog {
let confirm: AnyElement = Button::new("confirm-reset-remote")
.label("Reset remote")
.variant(ButtonVariant::Destructive)
.on_click(move |_, _, cx| {
.loading(busy)
.disabled(busy)
.on_click(move |_, window, cx| {
let task = store.update(cx, |store, cx| store.reset_repository(cx));
cx.spawn(async move |_cx| {
if let Err(error) = task.await {
log::error!("failed to reset remote: {error:#}");
let state = confirm_state.clone();
let close = confirm_close.clone();
let handle = window.window_handle();
cx.spawn(async move |cx| match task.await {
Ok(()) => {
cx.update_window(handle, |_, _, cx| close.close(cx))
.log_err();
}
Err(error) => {
state.update(cx, |state, cx| {
state.fail(error.to_string());
cx.notify();
});
}
})
.detach();
confirm_close.close(cx);
})
.into_any_element();