fix(ui): gesperrte Modelle zeigen Engine, Pfad und GPUs und zählen im Reiter Engines mit (#1068)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GmHhg3osejhFSpUz472iQ1
This commit is contained in:
2026-11-16 13:12:32 +01:00
parent 46046d154e
commit 3f5b7f46eb
4 changed files with 63 additions and 14 deletions

View File

@ -69,6 +69,16 @@ fn parse_gpus(text: &str) -> Result<Vec<u32>> {
.collect()
}
/// Angaben zu einem registrierten Modell, auch wenn es gesperrt ist (für die
/// Anzeige; zum Starten dient [`StartPlan`]).
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ModelDetails {
pub engine: String,
pub path: String,
pub gpus: Vec<u32>,
pub context: Option<u32>,
}
/// Ergebnis von [`Store::remove_model`].
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RemoveOutcome {
@ -232,6 +242,39 @@ impl Store {
Ok(changed > 0)
}
/// Engine, Pfad, GPUs und Kontext des ersten Profils, unabhängig von der
/// Freigabe. `None`, wenn es das Modell nicht gibt.
pub fn model_details(&self, model: &str) -> Result<Option<ModelDetails>> {
let row = self.connection().query_row(
"SELECT e.name, a.pfad, p.gpus, p.kontext
FROM model m
JOIN artifact a ON a.model_id = m.id
JOIN engine e ON e.id = a.engine_id
JOIN profile p ON p.artifact_id = a.id
WHERE m.name = ?1
ORDER BY p.rang, p.id LIMIT 1",
[model],
|r| {
Ok((
r.get::<_, String>(0)?,
r.get::<_, String>(1)?,
r.get::<_, String>(2)?,
r.get::<_, Option<u32>>(3)?,
))
},
);
match row {
Ok((engine, path, gpus, context)) => Ok(Some(ModelDetails {
engine,
path,
gpus: parse_gpus(&gpus)?,
context,
})),
Err(rusqlite::Error::QueryReturnedNoRows) => Ok(None),
Err(e) => Err(db(e)),
}
}
/// Wählt für ein freigegebenes Modell das Profil mit dem niedrigsten
/// `rang`. `None`, wenn das Modell fehlt, gesperrt ist oder kein Profil hat.
pub fn start_plan(&self, model: &str) -> Result<Option<StartPlan>> {