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.

feat(models): LU-Engine-Zeilen haben einen Eimer, Details zeigt die Datei

David4e2a25ef90f7
diff --git a/src-tauri/src/commands/engine.rs b/src-tauri/src/commands/engine.rs
index c908a63d..b636e7fb 100644
--- a/src-tauri/src/commands/engine.rs
+++ b/src-tauri/src/commands/engine.rs
@@ -1884,6 +1884,97 @@ pub async fn list_bundled_models(
.map_err(|e| format!("list_bundled_models task: {e}"))?
}
+/// Which files go when the user deletes an LU Engine row: the GGUF itself, or
+/// every part of a gguf-split set, and only inside a folder the listing reads
+/// (the app's own models dir, or one named under Model Storage).
+///
+/// .dan_48 (help chat, 2026-09-05, 2.6.7, GTX 1660 Ti with 6 GB): the
+/// Installed list had a bin on Ollama rows and none on LU Engine rows, and
+/// nothing on the page said where the file was, so a model LU had downloaded
+/// could neither be deleted nor found. The path is judged after canonicalize,
+/// so a `..` that walks out of the folder is refused by where it lands.
+pub(crate) fn gguf_delete_plan(path: &Path, roots: &[PathBuf]) -> Result<Vec<PathBuf>, String> {
+ if !path.extension().is_some_and(|e| e.eq_ignore_ascii_case("gguf")) {
+ return Err("Only GGUF model files can be deleted here.".to_string());
+ }
+ let file = std::fs::canonicalize(path)
+ .map_err(|e| format!("That model file could not be found: {}", os_error::english(&e)))?;
+ let inside = roots
+ .iter()
+ .filter_map(|r| std::fs::canonicalize(r).ok())
+ .any(|r| file.starts_with(&r));
+ if !inside {
+ return Err(
+ "LU only deletes models inside its own models folder or a folder named under Model Storage.".to_string(),
+ );
+ }
+ let dir = file.parent().ok_or("That model file has no folder.")?.to_path_buf();
+ let stem = file.file_stem().and_then(|s| s.to_str()).unwrap_or("");
+ let Some((base, _, total)) = split_shard_stem(stem) else {
+ return Ok(vec![file]);
+ };
+ // A split set is one model: every sibling with the same base and total
+ // goes along, whichever part the row pointed at, both digit widths.
+ let mut parts: Vec<PathBuf> = std::fs::read_dir(&dir)
+ .map_err(|e| format!("Could not read the model folder: {}", os_error::english(&e)))?
+ .flatten()
+ .map(|e| e.path())
+ .filter(|p| p.extension().is_some_and(|e| e.eq_ignore_ascii_case("gguf")))
+ .filter(|p| {
+ p.file_stem()
+ .and_then(|s| s.to_str())
+ .and_then(split_shard_stem)
+ .is_some_and(|(b, _, t)| b == base && t == total)
+ })
+ .collect();
+ parts.sort();
+ Ok(parts)
+}
+
+/// Delete an LU Engine row's file(s). The loaded model is refused: on Windows
+/// the mapped file cannot be removed while the engine holds it, and a delete
+/// that half works is worse than one that says why. The frontend stops the
+/// engine first when the row is the active one.
+#[tauri::command]
+pub async fn delete_bundled_model(
+ app: tauri::AppHandle,
+ path: String,
+ extra_dirs: Option<Vec<String>>,
+) -> Result<serde_json::Value, String> {
+ tokio::task::spawn_blocking(move || {
+ let state = app.state::<AppState>();
+ let loaded = state
+ .bundled_engine
+ .lock()
+ .unwrap()
+ .as_ref()
+ .map(|e| e.model_path.clone());
+ let same = |a: &str, b: &str| {
+ a == b
+ || matches!(
+ (std::fs::canonicalize(a), std::fs::canonicalize(b)),
+ (Ok(x), Ok(y)) if x == y
+ )
+ };
+ if loaded.as_deref().is_some_and(|l| same(l, &path)) {
+ return Err(
+ "This model is loaded in the LU Engine right now. Stop the engine or switch to another model, then delete it.".to_string(),
+ );
+ }
+ let roots = bundled_scan_dirs(&builtin_models_dir()?, &extra_dirs.unwrap_or_default());
+ let files = gguf_delete_plan(Path::new(&path), &roots)?;
+ let mut bytes = 0u64;
+ for f in &files {
+ bytes += std::fs::metadata(f).map(|m| m.len()).unwrap_or(0);
+ std::fs::remove_file(f)
+ .map_err(|e| format!("Could not delete {}: {}", f.display(), os_error::english(&e)))?;
+ }
+ Ok(serde_json::json!({ "deleted": files.len(), "bytes": bytes }))
+ })
+ .await
+ .map_err(|e| format!("delete_bundled_model task: {e}"))?
+}
+
fn list_bundled_models_blocking(
state: &AppState,
extra_dirs: &[String],
@@ -2528,6 +2619,46 @@ pub(crate) fn stop_embed_locked(state: &AppState) -> bool {
#[cfg(test)]
mod tests {
+ // .dan_48 (help chat, 2026-09-05): the bin on an LU Engine row. What it may
+ // and may not take with it is decided here, on real files.
+ #[test]
+ fn the_delete_plan_takes_the_gguf_or_the_whole_split_and_nothing_outside_the_folder() {
+ let dir = std::env::temp_dir().join(format!("lu-engine-delete-{}", std::process::id()));
+ let outside = std::env::temp_dir().join(format!("lu-engine-delete-outside-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&dir);
+ let _ = std::fs::remove_dir_all(&outside);
+ let inside = dir.join("inside");
+ std::fs::create_dir_all(&inside).unwrap();
+ std::fs::create_dir_all(&outside).unwrap();
+ let single = inside.join("a.gguf");
+ let text = inside.join("notes.txt");
+ let stranger = outside.join("b.gguf");
+ std::fs::write(&single, b"x").unwrap();
+ std::fs::write(&text, b"x").unwrap();
+ std::fs::write(&stranger, b"x").unwrap();
+ for i in 1..=3 {
+ std::fs::write(inside.join(format!("big-0000{i}-of-00003.gguf")), b"x").unwrap();
+ }
+ std::fs::write(inside.join("other-00001-of-00002.gguf"), b"x").unwrap();
+ let roots = vec![dir.clone()];
+
+ assert_eq!(gguf_delete_plan(&single, &roots).unwrap(), vec![std::fs::canonicalize(&single).unwrap()]);
+ assert!(gguf_delete_plan(&text, &roots).unwrap_err().contains("GGUF"));
+ assert!(gguf_delete_plan(&stranger, &roots).unwrap_err().contains("Model Storage"));
+ // whichever part the row pointed at, the set goes, and only that set
+ let shards = gguf_delete_plan(&inside.join("big-00002-of-00003.gguf"), &roots).unwrap();
+ assert_eq!(shards.len(), 3, "{shards:?}");
+ assert!(shards.iter().all(|p| p.file_name().unwrap().to_str().unwrap().starts_with("big-")));
+ // a path that walks out of the folder is judged by where it lands
+ let sneaky = inside.join("..").join("..").join(outside.file_name().unwrap()).join("b.gguf");
+ assert!(gguf_delete_plan(&sneaky, &roots).is_err());
+ // a file that is gone already is not a plan
+ assert!(gguf_delete_plan(&inside.join("missing.gguf"), &roots).unwrap_err().contains("could not be found"));
+
+ let _ = std::fs::remove_dir_all(&dir);
+ let _ = std::fs::remove_dir_all(&outside);
+ }
+
use super::*;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 2dda8055..89a1a106 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -381,6 +381,7 @@ fn main() {
commands::engine::kv_slot_action,
commands::engine::swap_bundled_model,
commands::engine::list_bundled_models,
+ commands::engine::delete_bundled_model,
commands::engine::list_importable_models,
// The user's own model folder, handed to ComfyUI (GH #122)
commands::custom_models::sync_custom_model_paths,
diff --git a/src/api/engine.ts b/src/api/engine.ts
index 3cff9fc9..95e56e95 100644
--- a/src/api/engine.ts
+++ b/src/api/engine.ts
@@ -130,6 +130,17 @@ export async function startBundledEngine(modelPath: string, tuning?: BuiltinEngi
}
/** Stop the managed engine child if one is running. */
+/** Delete an LU Engine row's file(s): the GGUF, or every part of a split.
+ * The backend refuses the loaded model, so the caller stops the engine first
+ * when the row is the active one. */
+export async function deleteBundledModel(path: string): Promise<{ deleted: number; bytes: number }> {
+ const res = await backendCall<{ deleted?: number; bytes?: number }>('delete_bundled_model', {
+ path,
+ extraDirs: customModelDirs(),
+ })
+ return { deleted: res?.deleted ?? 0, bytes: res?.bytes ?? 0 }
+}
+
export function stopBundledEngine() {
return backendCall('stop_bundled_engine')
}
diff --git a/src/components/models/ModelManager.tsx b/src/components/models/ModelManager.tsx
index 08d268eb..5c2ee851 100644
--- a/src/components/models/ModelManager.tsx
+++ b/src/components/models/ModelManager.tsx
@@ -19,7 +19,7 @@ import { checkComfyConnection, refreshComfyModels } from '../../api/comfyui'
import { isMlxImageHost } from '../../api/mlx-image'
import { MlxMediaSettings } from '../settings/MlxMediaSettings'
import { backendCall } from '../../api/backend'
-import { customModelDirs } from '../../api/engine'
+import { customModelDirs, deleteBundledModel, stopBundledEngine } from '../../api/engine'
import { counterView } from '../../lib/inventory-counter'
import { groupInstalledByProvider, needsBackendSwitchHeading, foldedRowsSentence, LU_ENGINE_GROUP } from '../../lib/lu-engine-rows'
import { isBuiltinEngineEntry } from '../../lib/lmstudio-match'
@@ -123,7 +123,20 @@ export function ModelManager() {
fetchModels()
}, [fetchModels])
+ // An LU Engine row is a file on disk, and the file is what the two buttons
+ // on the right act on. .dan_48 (help chat, 2026-09-05, 2.6.7): the row had
+ // no bin and Details asked Ollama, which knows nothing about it, so a
+ // downloaded model could neither be deleted nor found.
+ const luEngineFile = (m: AIModel): m is AIModel & { path: string } =>
+ m.type === 'text' && isBuiltinEngineEntry(m) && 'path' in m && typeof m.path === 'string' && m.path.length > 0
+
const handleInfo = async (name: string) => {
+ const model = models.find((m: AIModel) => m.name === name)
+ if (model && luEngineFile(model)) {
+ setModelInfo({ name, file: model.path, size: model.size, engine: model.providerName ?? LU_ENGINE_GROUP })
+ setInfoOpen(true)
+ return
+ }
try {
const info = await showModel(name)
setModelInfo({ name, ...info })
@@ -157,6 +170,15 @@ export function ModelManager() {
await fetchModels()
return
}
+ if (model && luEngineFile(model)) {
+ // The loaded file is locked on Windows, so the engine is stopped first
+ // when the row is the active one; the backend refuses otherwise.
+ if (model.name === activeModel) await stopBundledEngine()
+ await deleteBundledModel(model.path)
+ setConfirmDelete(null)
+ await fetchModels()
+ return
+ }
await removeModel(name)
setConfirmDelete(null)
} catch (e) {
@@ -502,9 +524,11 @@ export function ModelManager() {
onInfo={() => handleInfo(model.name)}
canDelete={
// Ollama text models via the Ollama API; image/video
- // models are ComfyUI files we can delete from disk.
+ // models are ComfyUI files we can delete from disk;
+ // an LU Engine row is a GGUF LU can delete itself.
(ollamaEnabled && model.type === 'text' && (!('provider' in model) || model.provider === 'ollama'))
|| model.type === 'image' || model.type === 'video'
+ || luEngineFile(model)
}
/>
</motion.div>
@@ -541,6 +565,12 @@ export function ModelManager() {
Are you sure you want to delete <span className="text-gray-900 dark:text-white font-mono">{confirmDelete}</span>?
This removes the model file from your disk and frees the space.
</p>
+ {(() => {
+ const row = models.find((m: AIModel) => m.name === confirmDelete)
+ return row && luEngineFile(row) ? (
+ <p className="t-micro font-mono text-gray-500 dark:text-gray-400 mb-3 break-all" data-testid="delete-file-path">{row.path}</p>
+ ) : null
+ })()}
<div className="flex gap-2">
<GlowButton variant="secondary" onClick={() => setConfirmDelete(null)} className="flex-1">
Cancel
diff --git a/src/components/models/__tests__/die-lu-engine-zeile-hat-einen-eimer.test.ts b/src/components/models/__tests__/die-lu-engine-zeile-hat-einen-eimer.test.ts
new file mode 100644
index 00000000..c900f498
--- /dev/null
+++ b/src/components/models/__tests__/die-lu-engine-zeile-hat-einen-eimer.test.ts
@@ -0,0 +1,67 @@
+/**
+ * .dan_48 (help chat, 2026-09-05, LU 2.6.7, GTX 1660 Ti with 6 GB): "I see
+ * nowhere to delete models on the app", with a screenshot of two LU Engine
+ * rows that had Bench and Details and no bin, and Details asked Ollama about
+ * a file Ollama has never seen. The row is a file; the file is what the two
+ * buttons act on now.
+ *
+ * Run: npx vitest run src/components/models/__tests__/die-lu-engine-zeile-hat-einen-eimer.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import fs from 'node:fs'
+import path from 'node:path'
+
+const MANAGER = fs.readFileSync(path.join(__dirname, '..', 'ModelManager.tsx'), 'utf8')
+const ENGINE_API = fs.readFileSync(path.join(__dirname, '..', '..', '..', 'api', 'engine.ts'), 'utf8')
+const RUST = fs.readFileSync(path.join(__dirname, '..', '..', '..', '..', 'src-tauri', 'src', 'commands', 'engine.rs'), 'utf8')
+const MAIN = fs.readFileSync(path.join(__dirname, '..', '..', '..', '..', 'src-tauri', 'src', 'main.rs'), 'utf8')
+const slice = (src: string, from: string, to: string) => {
+ const a = src.indexOf(from)
+ const b = src.indexOf(to, a)
+ if (a < 0 || b < 0) throw new Error(`anchor missing: ${from} .. ${to}`)
+ return src.slice(a, b)
+}
+
+describe('an LU Engine row can be deleted', () => {
+ it('the bin shows on an LU Engine row, next to Ollama and ComfyUI rows', () => {
+ const canDelete = slice(MANAGER, 'canDelete={', '}\n')
+ expect(canDelete).toContain('|| luEngineFile(model)')
+ })
+
+ it('the loaded model is stopped before its file goes, and the list is re-read after', () => {
+ const branch = slice(MANAGER, 'if (model && luEngineFile(model)) {\n // The loaded file', 'await removeModel(name)')
+ const stop = branch.indexOf('if (model.name === activeModel) await stopBundledEngine()')
+ const del = branch.indexOf('await deleteBundledModel(model.path)')
+ const reread = branch.indexOf('await fetchModels()')
+ expect(stop).toBeGreaterThan(0)
+ expect(del).toBeGreaterThan(stop)
+ expect(reread).toBeGreaterThan(del)
+ })
+
+ it('the confirm dialog names the file that goes', () => {
+ expect(MANAGER).toContain('data-testid="delete-file-path"')
+ })
+
+ it('Details on an LU Engine row is the file, not a question to Ollama', () => {
+ const info = slice(MANAGER, 'const handleInfo = async', 'const info = await showModel(name)')
+ expect(info).toContain('file: model.path')
+ expect(info).toContain('size: model.size')
+ })
+
+ it('the delete goes through the backend with the Model Storage folders, like the listing', () => {
+ const api = slice(ENGINE_API, 'export async function deleteBundledModel', 'export function stopBundledEngine')
+ expect(api).toContain("backendCall<{ deleted?: number; bytes?: number }>('delete_bundled_model'")
+ expect(api).toContain('extraDirs: customModelDirs()')
+ expect(MAIN).toContain('commands::engine::delete_bundled_model,')
+ })
+
+ it('the backend refuses the loaded model and judges the path after canonicalize', () => {
+ const cmd = slice(RUST, 'pub async fn delete_bundled_model', 'fn list_bundled_models_blocking')
+ expect(cmd).toContain('This model is loaded in the LU Engine right now.')
+ expect(cmd).toContain('gguf_delete_plan(Path::new(&path), &roots)?')
+ const plan = slice(RUST, 'pub(crate) fn gguf_delete_plan', 'pub async fn delete_bundled_model')
+ expect(plan).toContain('std::fs::canonicalize(path)')
+ expect(plan).toContain('file.starts_with(&r)')
+ expect(plan).toContain('split_shard_stem(stem)')
+ })
+})
diff --git a/src/lib/release-notes.ts b/src/lib/release-notes.ts
index 76f625aa..fa6a82c9 100644
--- a/src/lib/release-notes.ts
+++ b/src/lib/release-notes.ts
@@ -72,6 +72,7 @@ export const RELEASE_NOTES: ReleaseNote[] = [
title: 'Local',
items: [
'The built-in engine goes by LU Engine now. It is the same engine with the same models in the same folder; only the name in Settings, in the model list and in the messages changed.',
+ 'An LU Engine model can be deleted from the Installed list. The rows had Bench and Details and no bin, and Details asked Ollama about a file Ollama had never seen, so a model LU downloaded could neither be removed nor found. Each row has a bin now, the confirmation names the file it removes, a split model goes as one, Details shows the file and its size, and the loaded model is taken out of the engine first. Reported in the Discord help chat.',
'The LU Engine moves to a free port when 8127 is taken or reserved by the system, and after a start that fails it retries once instead of giving up until the next restart. The next start begins at 8127 again rather than staying on the port it had to move to. Windows port reservations are marked as researched rather than proven, because no such reservation could be staged here.',
'A chat model you downloaded stays visible as Installed even while the engine is not running, and its tile has a Use button that starts the engine and loads that model, rather than leaving you with a file you cannot reach. The model you just downloaded also becomes the active chat model, so the first message goes to it instead of swapping the engine back to the previous one, and the engine starts on it once rather than twice.',
'A running LM Studio stays in the model picker after the chat has moved to the LU Engine. Its models keep their own heading in the list, and picking one hands the local slot back to LM Studio, with a line that says so. The way back is one click, the same as the way out.',
@@ -86,7 +87,7 @@ export const RELEASE_NOTES: ReleaseNote[] = [
'The ComfyUI installer checks that the environment it just built can import ComfyUI, installs what is missing, and names a missing Visual C++ runtime instead of ending in a silent crash.',
'Repair environment runs the same check with a time limit and a Cancel button that stops it, and the trainer setup stopped blaming the network for failures that had nothing to do with the network.',
'Character Studio sets itself up on a machine whose Python is too new. The trainer needs Python 3.10 to 3.12, and LU built its environment from whatever Python was newest, so a machine with 3.14 failed at the last step on every update since August. The setup now picks a Python from that range by itself, installs 3.12 on Windows if there is none, and rebuilds an environment that came from the wrong one. The failure text under the button also stopped being cut after one line. Reported in Discord ticket 0004.',
- 'The local trainer no longer hands out instructions. On the way from Set up trainer to a finished character every dead end fixes itself or names its cause: the trainer source comes as an archive and needs no git on the machine, the drive is checked for room before the first byte, a download that breaks off is retried twice, a missing Windows runtime library for PyTorch is installed by LU through winget instead of a link to microsoft.com, the setup proves that PyTorch loads before it calls the environment ready, a card with less than 12 GB hears that before ten minutes of caching, the local chat model is paused for the run and comes back afterwards instead of squatting the memory the recipe needs, and a run that still runs out of memory on the card says what to close. The step counter moves with every training step instead of once per epoch, the base-file download keeps showing its progress when you leave the tab and come back, and winget output stays out of the note under the button.',
+ 'The local trainer no longer hands out instructions. On the way from Set up trainer to a finished character every dead end fixes itself or names its cause: the trainer source comes as an archive and needs no git on the machine, the drive is checked for room before the first byte, a download that breaks off is retried twice, a missing Windows runtime library for PyTorch is installed by LU through winget instead of a link to microsoft.com, the setup proves that PyTorch loads before it calls the environment ready, a card with less than 12 GB hears that before ten minutes of caching, the local chat model is paused for the run and comes back afterwards instead of squatting the memory the recipe needs, and a run that still runs out of memory on the card says what to close. The step counter moves with every training step instead of once per epoch, the base-file download keeps showing its progress when you leave the tab and come back, winget output stays out of the note under the button, and a Stop pressed in the first seconds of a run, while the card is still being freed or the environment checked, now stops the run instead of hiding it: the chat model only comes back once the trainer is really gone.',
'A ComfyUI that will not start names the cause. A missing Visual C++ runtime, or a graphics driver older than the PyTorch that was installed, used to arrive as "the Python environment looks broken" next to a Repair button, and neither of those lives in the folder Repair rebuilds. The message now says which of the two it is, and LU no longer starts a repair that cannot fix it.',
'AMD on Windows is read from the HIP SDK itself. The only ROCm probe ran rocm-smi, which the Windows SDK does not ship, so an installed ROCm went unseen. LU reads HIP_PATH and hipinfo now and names the card architecture, and an image run that fails names that architecture and get_arch_list instead of a HIP traceback. This is marked as researched rather than proven, because there is no RDNA4 card here.',
'The Model Manager stopped putting system RAM in the GPU field. ComfyUI reports system memory on a CPU device in a field called vram_total, so a machine with 64 GB of RAM read as if it had 62 GB of video memory.',