Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(download): die LM-Studio-Zeile stellt wieder die ganze Frage

purple87206c1679e9
diff --git a/src-tauri/src/commands/download.rs b/src-tauri/src/commands/download.rs
index db55909b..ebcef30c 100644
--- a/src-tauri/src/commands/download.rs
+++ b/src-tauri/src/commands/download.rs
@@ -1813,14 +1813,14 @@ pub fn detect_model_path(provider: String) -> Result<serde_json::Value, String>
/// report that folder as evidence of an install.
///
/// Installed is answered from the folder first because that is free on every
-/// platform, and only then from `install::lmstudio_lms_path()`, which knows the
-/// `lms` CLI on every layout. A user who has LM Studio but has not downloaded a
-/// model yet is therefore still recognised.
+/// platform, and only then from `install::lmstudio_installed()`, which knows
+/// the `lms` CLI and, on macOS, the app bundle. A user who has LM Studio but
+/// has not downloaded a model yet is therefore still recognised.
///
/// ASYNC + spawn_blocking, the same shape as `list_bundled_models`: a
/// SYNCHRONOUS Tauri command runs on the MAIN thread, and neither half of this
/// one is cheap enough for that. `lmstudio_dir_in` touches the disk, and
-/// `lmstudio_lms_path()` walks several fixed paths and falls back to a `which`
+/// `lmstudio_installed()` walks several fixed paths and falls back to a `which`
/// lookup, which spawns a process. Settings opens this on mount, so that was
/// the window freezing while a panel drew one line of grey text. That is the
/// same mistake the Mac ComfyUI search made in 2.6.8, one door further along.
@@ -1834,7 +1834,7 @@ pub async fn lmstudio_model_dir() -> Result<serde_json::Value, String> {
fn lmstudio_model_dir_blocking() -> Result<serde_json::Value, String> {
let home = dirs::home_dir().ok_or("Cannot find home directory")?;
let found = lmstudio_dir_in(&home);
- let installed = found.is_some() || crate::commands::install::lmstudio_lms_path().is_some();
+ let installed = found.is_some() || crate::commands::install::lmstudio_installed();
Ok(serde_json::json!({
"installed": installed,
"path": found.map(|p| p.to_string_lossy().to_string()),
@@ -2100,15 +2100,42 @@ pub async fn check_model_sizes(
mod tests {
use super::*;
+ /// Der Rueckfall, den dieser Test verhindert, ist im Zusammenschluss des
+ /// Design-Stroms mit 2.6.8 einmal passiert: die Zeile fragte nur noch nach
+ /// der `lms`-CLI. Wer LM Studio ueber die Oberflaeche installiert und
+ /// `lms bootstrap` nie laufen laesst, hat keine CLI, und Settings meldete
+ /// "nicht installiert", obwohl das Programm da war.
+ ///
+ /// Die Nadeln sind aus zwei Haelften gebaut, damit dieser Test sie nicht
+ /// in sich selbst findet.
+ #[test]
+ fn the_lm_studio_row_asks_the_whole_question_not_just_the_cli() {
+ // Die ganze Datei, nicht nur die ausgelieferte Haelfte: sie hat mehrere
+ // Testmodule, ein Schnitt am ersten `#[cfg(test)]` liesse 98 Prozent
+ // des Quelltextes ungelesen und der Test waere still gruen.
+ let src = include_str!("download.rs");
+ let ganze_frage = format!("{}{}", "lmstudio_inst", "alled()");
+ let nur_cli = format!("{}{}", "lmstudio_lms_p", "ath().is_some()");
+ assert!(
+ src.contains(&ganze_frage),
+ "die Settings-Zeile fragt nicht mehr nach der ganzen Installation"
+ );
+ assert!(
+ !src.contains(&nur_cli),
+ "die Settings-Zeile fragt wieder nur nach der CLI, das App-Bundle faellt damit weg"
+ );
+ }
+
#[tokio::test]
async fn the_lm_studio_row_never_runs_on_the_main_thread() {
// A14 review 3. A SYNCHRONOUS Tauri command runs on the MAIN thread,
- // and this one reaches os_paths::lmstudio_installed() ->
- // find_lmstudio_app() -> spotlight_app(), which spawns mdfind and
- // waits for it. Settings asks on mount, so the shipped shape would
- // have frozen the window on a Mac with a busy Spotlight index for as
- // long as mdfind took. Same mistake the Mac ComfyUI search made in
- // 2.6.8, one door further along.
+ // and this one reaches install::lmstudio_installed(), which walks
+ // fixed paths and can end in a `which` lookup that spawns a process.
+ // Settings asks on mount, so the synchronous shape froze the window
+ // for as long as that took. The Spotlight lookup that made the worst
+ // case seconds long is gone (see lmstudio_app_bundle), but disk and a
+ // spawned process are still not main-thread work. Same mistake the
+ // Mac ComfyUI search made in 2.6.8, one door further along.
//
// The guard is the TYPE, not the source text. A source-text check
// would have been self-referential here: the assertion's own string
diff --git a/src-tauri/src/commands/install/lmstudio.rs b/src-tauri/src/commands/install/lmstudio.rs
index 2a667346..4e1f5015 100644
--- a/src-tauri/src/commands/install/lmstudio.rs
+++ b/src-tauri/src/commands/install/lmstudio.rs
@@ -212,6 +212,42 @@ pub(super) fn lmstudio_gui_exe() -> Option<PathBuf> {
if p.exists() { Some(p) } else { None }
}
+/// Das App-Bundle an den zwei Stellen, an denen es unter macOS landet.
+///
+/// KEINE Spotlight-Suche. Die alte Fassung in `os_paths` hing hier ein
+/// `mdfind` an, und das war der Grund, warum die Settings-Zeile den
+/// Hauptthread blockieren konnte: auf einem Mac mit beschaeftigtem Index
+/// dauert der Aufruf Sekunden. Damit faellt der Fall weg, dass jemand LM
+/// Studio an eine ungewoehnliche Stelle gelegt hat. Wer das tut, hat fast
+/// immer auch `lms bootstrap` gelaufen, und dann findet ihn der Weg darueber.
+#[cfg(target_os = "macos")]
+fn lmstudio_app_bundle() -> Option<PathBuf> {
+ [
+ PathBuf::from("/Applications/LM Studio.app"),
+ dirs::home_dir()?.join("Applications").join("LM Studio.app"),
+ ]
+ .into_iter()
+ .find(|p| p.exists())
+}
+
+#[cfg(not(target_os = "macos"))]
+fn lmstudio_app_bundle() -> Option<PathBuf> {
+ // Windows deckt `lmstudio_lms_path` selbst ab, es kennt dort beide
+ // Programmverzeichnisse. Unter Linux liefert LM Studio ein AppImage ohne
+ // festen Ort, es gibt also nichts nachzusehen.
+ None
+}
+
+/// Ist LM Studio ueberhaupt da? Die `lms`-CLI ODER das App-Bundle.
+///
+/// Beide Haelften werden gebraucht: wer LM Studio ueber die Oberflaeche
+/// installiert und `lms bootstrap` nie laufen laesst, hat keine CLI und kein
+/// `~/.lmstudio`, und die Settings-Zeile meldete dann faelschlich "nicht
+/// installiert".
+pub(crate) fn lmstudio_installed() -> bool {
+ lmstudio_lms_path().is_some() || lmstudio_app_bundle().is_some()
+}
+
/// Fast, BOUNDED reachability probe for the LM Studio server. A plain HTTP GET
/// to a DOWN server is catastrophically slow on some Windows boxes: connecting
/// to a closed `127.0.0.1:<port>` can take ~2 s to refuse (the IPv4 loopback