Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Desktop: recheck the install fingerprint before accepting a cached capability answer (#16134)

Daniel Hana12502e923a5
diff --git a/studio/src-tauri/src/preflight.rs b/studio/src-tauri/src/preflight.rs
index 3ce0822ea8a..d1f5bcc90bd 100644
--- a/studio/src-tauri/src/preflight.rs
+++ b/studio/src-tauri/src/preflight.rs
@@ -996,6 +996,52 @@ exit 1
remove_managed_capability_cache();
}
+ #[cfg(unix)]
+ #[tokio::test]
+ async fn a_cache_hit_is_rechecked_when_the_tree_changes_during_help() {
+ use std::fs;
+
+ let _cache_guard = MANAGED_CAPABILITY_CACHE_TEST_LOCK.lock().await;
+ let _cache_home = ManagedCapabilityCacheHome::new("cache-hit-tree-change");
+ remove_managed_capability_cache();
+ let fake = fake_cli(
+ "cap-cache-hit-tree-change",
+ r#"#!/bin/sh
+printf '%s\n' "$*" >> "$0.calls"
+if [ "$1" = "-h" ]; then
+ if [ -f "$0.changeonh" ]; then rm -f "$0.changeonh"; touch -m -t 200101010000 "$0"; fi
+ exit 0
+fi
+if [ "$1" = "studio" ] && [ "$2" = "desktop-capabilities" ] && [ "$3" = "--json" ]; then
+ if [ -f "$0.modecap" ]; then exit 42; fi
+ printf '{"desktop_protocol_version":1,"desktop_manageability_version":2,"supports_api_only":true,"supports_provision_desktop_auth":true,"supports_desktop_backend_ownership":true,"studio_install_ok":true,"version":"2026.8.4"}'
+ exit 0
+fi
+exit 1
+"#,
+ );
+ let bin = fake.bin.clone();
+ let calls = bin.with_extension("calls");
+
+ assert!(matches!(
+ probe_managed_bin(bin.clone()).await,
+ ManagedProbe::Ready { .. }
+ ));
+ fs::write(bin.with_extension("modecap"), "broken").unwrap();
+ fs::write(bin.with_extension("changeonh"), "1").unwrap();
+ fs::write(&calls, "").unwrap();
+
+ let probe = probe_managed_bin(bin.clone()).await;
+ let seen = fs::read_to_string(&calls).unwrap();
+ assert!(
+ matches!(probe, ManagedProbe::Stale { .. }),
+ "a cache hit for the old tree was accepted: {probe:?}, calls {seen:?}"
+ );
+ assert!(seen.contains("studio desktop-capabilities --json"), "calls {seen:?}");
+
+ remove_managed_capability_cache();
+ }
+
#[cfg(unix)]
#[tokio::test]
async fn a_cache_miss_runs_help_and_the_capability_probe_at_once() {
diff --git a/studio/src-tauri/src/preflight/managed.rs b/studio/src-tauri/src/preflight/managed.rs
index b92c541b4f8..b1769aaa7b5 100644
--- a/studio/src-tauri/src/preflight/managed.rs
+++ b/studio/src-tauri/src/preflight/managed.rs
@@ -1266,7 +1266,13 @@ pub(super) async fn probe_managed_bin(bin: PathBuf) -> ManagedProbe {
// A cache miss overlaps both Python starts; one task, so the spawns take the guard in turn.
let (cli_probe, capability_probe) = if cache_hit {
- (help_probe.await, None)
+ let help = help_probe.await;
+ // The tree can change while `-h` runs; the cached answer holds only for the tree it was read under.
+ if matches!(help, Ok(true)) && managed_bin_fingerprint(&bin) != fingerprint_before {
+ (help, Some(probe_cli_capability(&bin).await))
+ } else {
+ (help, None)
+ }
} else if let Some(capability) = launch.capability {
drop(help_probe);
(Ok(true), Some(Ok(Some(capability))))