feat: install si command from settings
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

This commit is contained in:
2026-11-29 21:37:42 +07:00
parent 9de81e31f4
commit df1f232aae
7 changed files with 242 additions and 20 deletions
+31 -7
View File
@@ -8,8 +8,9 @@ use gpui::{
SharedString, Styled as _, Subscription, Task, Window, px,
};
use helpers::{
appearance_select, default_folder_selector, event_fetching_select, grasp_servers_editor,
scan_paths_editor, setting_block, setting_row,
CliInstall, appearance_select, cli_description, current_cli_install, default_folder_selector,
event_fetching_select, grasp_servers_editor, install_cli_button, scan_paths_editor,
setting_block, setting_row,
};
use settings::SettingsStore;
use ui::alert::{Alert, AlertSeverity};
@@ -19,6 +20,7 @@ use ui::input::InputState;
use ui::separator::Separator;
use crate::shared::labels::{RelayHostExt as _, ServerInputExt as _};
use crate::shared::log_dropped;
/// One grasp server row, with its display strings built when settings change.
#[derive(Clone)]
@@ -46,6 +48,8 @@ pub struct SettingsDialog {
servers: Vec<ServerRow>,
/// Scan path rows, rebuilt when the settings change.
scan_paths: Vec<PathRow>,
/// Where the `si` command is installed.
cli: CliInstall,
/// Prompts this dialog started, cancelled when it drops.
tasks: Vec<Task<()>>,
/// Rebuilds the rows when the settings change.
@@ -69,18 +73,25 @@ impl SettingsDialog {
.read_only()
.build(cx);
let dialog = cx.new(|cx| {
let mut dialog = Self {
let dialog = cx.new(|cx: &mut Context<Self>| {
let weak = cx.weak_entity();
cx.defer(move |cx| {
log_dropped(weak.update(cx, |dialog, cx| {
dialog.rebuild_rows(cx);
dialog.refresh_cli();
}));
});
Self {
handle: DialogHandle::new(true),
grasp_input,
default_folder,
servers: Vec::new(),
scan_paths: Vec::new(),
cli: CliInstall::Missing,
tasks: Vec::new(),
_subscription: None,
};
dialog.rebuild_rows(cx);
dialog
}
});
dialog.update(cx, |dialog, cx| {
@@ -129,6 +140,11 @@ impl SettingsDialog {
})
.collect();
}
/// Looks up where the `si` command is installed.
fn refresh_cli(&mut self) {
self.cli = current_cli_install();
}
}
impl Render for SettingsDialog {
@@ -145,6 +161,7 @@ impl Render for SettingsDialog {
let default_folder = self.default_folder.clone();
let servers = self.servers.clone();
let scan_paths = self.scan_paths.clone();
let cli = self.cli.clone();
let this = cx.weak_entity();
Dialog::new("settings-dialog")
@@ -200,6 +217,13 @@ impl Render for SettingsDialog {
FOLDER_DESC,
default_folder_selector(&default_folder, &this),
))
.child(Separator::horizontal())
.child(setting_row(
cx,
"Command Line Tool",
cli_description(&cli),
install_cli_button(&this, &cli),
))
.into_any_element()
})
}