Show rad-artifact CLI version in status

- Probe `rad-artifact --version` in artifact_binaries
- Run artifact_binaries off the main thread
- Show the CLI version in the artifact node popover
This commit is contained in:
Daniel Norman
2026-10-08 18:21:48 +02:00
committed by Rūdolfs Ošiņš
parent a24dde90de
commit 6f57b811ef
4 changed files with 28 additions and 6 deletions
@@ -196,10 +196,11 @@ pub async fn artifact_node_running(ctx: tauri::State<'_, AppState>) -> Result<bo
}
/// Which artifact binaries are installed, so a node that is down can be told
/// apart from one that was never installed.
/// apart from one that was never installed. Off the main thread, since the
/// CLI's version comes from running it.
#[tauri::command]
pub fn artifact_binaries() -> radicle_types::binaries::ArtifactBinaries {
radicle_types::binaries::artifact_binaries()
pub async fn artifact_binaries() -> Result<radicle_types::binaries::ArtifactBinaries, Error> {
Ok(tauri::async_runtime::spawn_blocking(radicle_types::binaries::artifact_binaries).await?)
}
#[tauri::command]
@@ -16,6 +16,10 @@ export type ArtifactBinaries = {
* The `rad-artifact` CLI.
*/
cli: boolean;
/**
* Version of the `rad-artifact` CLI, when it answers `--version`.
*/
cliVersion?: string;
/**
* The `rad-artifact-node` seeding daemon.
*/
+16 -3
View File
@@ -139,20 +139,33 @@ const RAD_ARTIFACT_NODE_BIN: &str = "rad-artifact-node";
///
/// Uncached for the same reason as [`rad`]: the UI polls, so an install that
/// happens while the app runs takes effect without a restart.
#[derive(Clone, Copy, Debug, Serialize, TS)]
#[derive(Clone, Debug, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
#[ts(export_to = "artifact/")]
pub struct ArtifactBinaries {
/// The `rad-artifact` CLI.
pub cli: bool,
/// Version of the `rad-artifact` CLI, when it answers `--version`.
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub cli_version: Option<String>,
/// The `rad-artifact-node` seeding daemon.
pub node: bool,
}
pub fn artifact_binaries() -> ArtifactBinaries {
let cli = candidates(RAD_ARTIFACT_BIN).find(|path| path.is_file());
// `rad-artifact --version` prints the crate name before the version.
let cli_version = cli.as_deref().and_then(probe).map(|version| {
version
.rsplit_once(' ')
.map_or(version.clone(), |(_, v)| v.to_owned())
});
ArtifactBinaries {
cli: candidates(RAD_ARTIFACT_BIN).any(|path| path.is_file()),
cli: cli.is_some(),
cli_version,
node: candidates(RAD_ARTIFACT_NODE_BIN).any(|path| path.is_file()),
}
}
@@ -323,7 +336,7 @@ fn probe(path: &Path) -> Option<String> {
}
if std::time::Instant::now() >= deadline {
log::warn!(
"{} did not answer `--version` within {}s, taking it as not being git",
"{} did not answer `--version` within {}s, giving up",
path.display(),
PROBE_TIMEOUT.as_secs()
);
@@ -173,6 +173,10 @@
<span class="key">Node version</span>
<span class="value">{status.version}</span>
{/if}
{#if binaries?.cliVersion}
<span class="key">CLI version</span>
<span class="value">{binaries.cliVersion}</span>
{/if}
<span class="key">Uptime</span>
<span class="value">{uptime}</span>
<span class="key">Seeding</span>