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(trainer): K5 Nachbesserung, Pfadpruefung vor dem Speichern und ehrliche Zielangabe

purplee94dc9f9046d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c56c73d..40cd1fbb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,134 @@
All notable changes to Locally Uncensored are documented here.
+## [3.0.1] - 2026-09-18
+
+A GPU without a measured free reading gets a safer plan, and Linux/AppImage
+installs stop losing environment variables to it.
+
+### Fixed
+
+- **The local engine now picks its CPU code path at startup**, so older
+ processors without AVX2 can run local models instead of the engine exiting
+ right after start.
+- **A GPU whose free VRAM could not actually be measured** (no nvidia-smi, for
+ instance) used to be planned as if the whole card were sitting empty, and the
+ log line said "N MiB are free" for a number that was really the total size,
+ other programs included. It now takes a bigger safety margin on that weaker
+ reading and logs it correctly as total capacity, not free memory, so a start
+ plans fewer layers rather than too many.
+- **Linux AppImage stops leaking its own runtime into every program LU
+ starts.** git, a system Python, pip, ffmpeg, nvidia-smi, the coding agent
+ shell and every program the Character Trainer starts no longer inherit the
+ AppImage runtime's own LD_LIBRARY_PATH, PYTHONHOME and related variables.
+ That inheritance made a perfectly healthy system Python fail to import ssl or
+ find its standard library, with a diagnosis that pointed at a broken Python
+ install rather than the real cause.
+- **A platform where pip refuses to write into the system Python** (Arch,
+ Debian 12+, Fedora 38+, Ubuntu 23.04+) no longer kills the isolated venv LU
+ already built there at the first pip call, and the same fix keeps the Coding
+ Agent's own terminal from picking up the same poisoned environment for every
+ git, pip or python command typed into it.
+- **Installing or repairing ComfyUI now searches the interpreters already on
+ your machine** for one PyTorch actually ships wheels for, and uses that one
+ automatically, with no picker in Settings. If none is found, it says so and
+ tells you what to install before starting the roughly 2 GB PyTorch download,
+ instead of that download running for minutes and then failing with pip's own
+ generic error.
+- **The LU Engine crashing immediately on an old CPU now says which instruction
+ set is missing**, measured from the CPU itself rather than guessed, and stops
+ retrying the same binary a second time since it would only fail the same way
+ again.
+- **The engine startup probe's log line no longer treats a model that is still
+ loading, one that is thinking and one that has genuinely failed as the same
+ thing.** The wording for each case is distinct now.
+- **The CI check that runs on every pull request now fails independently on
+ each platform** instead of one platform's failure hiding whatever the other
+ platform would have found.
+- **Sending in one conversation while another is still streaming no longer
+ mixes their text together**, and a second agent run no longer gets silently
+ dropped while the first one is still going; both now finish on their own.
+- **The local model runs one conversation at a time**, and a chat that has to
+ wait its turn now says so, with a line showing how many chats are ahead of
+ it. Stop works while it is still waiting, and takes it out of the line.
+- **Stop, signing out and quitting the app now reach every conversation**,
+ including one that has not started running yet and is only waiting its turn,
+ not just the one open on screen.
+- **Moving the Temperature, Top P or Max tokens slider now changes that one
+ conversation only**, instead of every open chat sharing one value from the
+ Settings page. A chat with no slider of its own still follows Settings, and a
+ field nobody moved anywhere is left out of the request so the model applies
+ its own default.
+- **Pressing Stop while the Coding Agent is running code now actually stops
+ that run**, the same way it already stopped a shell command.
+- **The Troubleshoot panel now tests the LM Studio address you actually
+ configured in Settings**, instead of always trying the default
+ 127.0.0.1:1234.
+- **Picking a specific GPU for a local model or the Character Trainer now keeps
+ using that physical card** even if Windows or Linux renumber the cards
+ between detection and start.
+- **Opening the Hardware tab in Settings while a local model or the trainer was
+ starting up could freeze it for a moment**; it no longer waits on that GPU
+ detection.
+- **Replacing an OpenAI compatible backend now parks the API key it displaces
+ in the OS keychain instead of dropping it**, and gives it back if you switch
+ back to that backend or remove the one that replaced it. The warning that a
+ key will be lost only shows on a device with no keychain to park it in.
+- **Setting an install location for the Character Trainer now also redirects
+ pip, Hugging Face and torch's own caches there**, so moving the trainer off a
+ small system drive keeps those caches off it too. The field itself now
+ rejects a path it cannot actually use, always shows the folder it will
+ really install to, and an emptied field goes back to the default; the Z Image
+ base model downloads always follow your configured model folder in Settings,
+ ComfyUI, either way.
+- **A finished image in Create has an Animate this image button** that carries
+ it straight into a video render, the same as the browser studio, and the No
+ refusals mark now shows on cloud models in the desktop picker as well.
+- **qwen-image-edit is selectable from the seed and edit pickers again**, the
+ upscale tool is named Enhance Image to match the web, and Krea 2 checkpoints
+ load with the right UNET, CLIP and VAE nodes instead of falling back to an
+ unknown loader.
+- **The Create button now stays disabled instead of failing on the server**
+ when the chosen model needs a mask that was never supplied, and the local
+ character LoRA list refreshes itself right after a training finishes instead
+ of needing a restart.
+- **"Failed to fetch" is no longer shown as the whole explanation for a failed
+ cloud render**, and the out of credits dialog now has a distinct title for
+ each of its three reasons instead of one generic one.
+- **The model picker no longer crashes when grouping models by family**, a
+ custom OpenAI compatible endpoint now receives Top K, a model name is no
+ longer cut off at its first colon, and a newly added provider starts with no
+ value pre filled.
+- **A memory entry with more than one line survives export and import again**,
+ both separator styles the web writes are read back, and one sensitive memory
+ entry no longer blocks the whole sync.
+- **The composer lock during a send now only affects that one conversation**,
+ not every open chat, Stop in one chat no longer cancels an image or video
+ render running in another, and picking a third remembered agent folder now
+ asks for confirmation like the first two do.
+- **The first click into the Models folders tab is faster**, since it asks the
+ running engine directly instead of falling back to a stale cache, and the
+ onboarding VRAM hint asks LU's own probe first so it works before ComfyUI is
+ installed.
+- **Settings now says when Ollama is reachable but switched off**, instead of
+ just Reachable, which read as if it were actually being used.
+- **A Cloud chat request that hits its own four minute limit is now treated as
+ finished right away** instead of being retried up to three more times with
+ the same four minute wait on each try.
+- **The Local Media (Apple MLX) panel now mentions that a Hugging Face token
+ can help its downloads**, the same hint ComfyUI already gives for its own
+ model downloads.
+- **The No refusals mark in the desktop model picker now carries an icon and
+ bolder text** so it is actually noticeable, instead of blending into the
+ smallest text on the row.
+- **Dismissing the stale model notice in the chat header now actually
+ dismisses it**, instead of it reappearing on the very next update.
+- **The reason the Coding Agent will not let go of its current folder is now
+ shown as a visible line**, instead of only a tooltip a disabled button never
+ shows.
+- **ltx-2 LoRA renders in the desktop app now carry a credit cost**, matching
+ the web catalog, instead of pricing as free.
+
## [3.0.0] - 2026-09-13
**Cloud: 24 chat models with no refusals, 10 open video models, 3 open image
diff --git a/README.md b/README.md
index 4ee7a6fb..cf66aabd 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ Take the latest build from [Releases](https://github.com/PurpleDoubleD/locally-u
Some antivirus engines flag unsigned NSIS installers that download other binaries, which is a false positive. The installer is built by GitHub Actions from the public source on `master`, and the update channel is signed against a public minisign key, so you can verify both: see [SECURITY.md](SECURITY.md#antivirus--browser-false-positives).
-Current release: **v3.0.0** (September 2026). Every change since 1.0.0 is in [CHANGELOG.md](CHANGELOG.md).
+Current release: **v3.0.1** (September 2026). Every change since 1.0.0 is in [CHANGELOG.md](CHANGELOG.md).
## Three steps
diff --git a/src-tauri/src/commands/trainer.rs b/src-tauri/src/commands/trainer.rs
index 652d910e..2fc75ad3 100644
--- a/src-tauri/src/commands/trainer.rs
+++ b/src-tauri/src/commands/trainer.rs
@@ -149,6 +149,88 @@ fn write_config_value(key: &str, value: &str) {
let _ = fs::write(&path, serde_json::to_string_pretty(&json).unwrap_or_default());
}
+/// Whether a candidate path starts with `~`. `~` is a SHELL expansion, and
+/// nothing on the Rust side of the trainer ever resolves it: the value goes
+/// straight into `PathBuf::from`. K5 Blocker 1 (Opus review of `4fda5a0a`):
+/// the old placeholder suggested `~/LU-Trainer` on Mac and Linux, so typing
+/// exactly what the field offered created a literal folder named `~` next to
+/// the app's working directory, not a folder in the user's home. Refusing
+/// beats silently expanding it ourselves: there is no shell context here to
+/// expand `~` FOR (a different user could run the app under a service
+/// account with a different home than the one the customer meant).
+fn starts_with_tilde(p: &str) -> bool {
+ p.starts_with('~')
+}
+
+/// The absolute example shown in the trainer's own install-path field and
+/// quoted back in its own rejection messages, one per platform family so the
+/// example is never impossible on the machine reading it (same reasoning as
+/// `comfy_path_placeholder.ts` on the frontend, kept in sync by
+/// `k5-trainer-root-validation.test.ts`/`k5-trainer-path-honesty.test.tsx`).
+fn example_trainer_path() -> &'static str {
+ if cfg!(target_os = "windows") {
+ "D:\\LU-Trainer"
+ } else if cfg!(target_os = "macos") {
+ "/Users/you/LU-Trainer"
+ } else {
+ "/home/you/LU-Trainer"
+ }
+}
+
+/// Everything a customer-typed trainer folder has to clear before it is
+/// written to `config.json` and an install starts against it. K5 Blocker 2
+/// (Opus review of `4fda5a0a`): the old code wrote the value first and asked
+/// nothing afterward, so a relative path, a path with no write access or a
+/// drive with no room was persisted anyway, and stayed persisted even though
+/// the install that followed could never use it. `install_comfyui` is the
+/// pattern this mirrors, except the check happens before the value is
+/// remembered instead of after the whole install finishes -- checking a
+/// folder is fast, an install is not, and there is nothing here yet to lose
+/// on a failed check.
+///
+/// Order matters: the drive-space question is asked with the CANDIDATE path
+/// (no directory has to exist yet for a mount-point lookup), before anything
+/// is created, so a rejection on space leaves no empty folder behind.
+fn validate_trainer_root_candidate(p: &str) -> Result<PathBuf, String> {
+ if starts_with_tilde(p) {
+ return Err(format!(
+ "\"{p}\" starts with ~, and this field never expands it: the path is used exactly as typed, so ~ would become a literal folder named ~, not your home folder. Use a full path instead, for example {}.",
+ example_trainer_path()
+ ));
+ }
+ let path = PathBuf::from(p);
+ if !path.is_absolute() {
+ return Err(format!(
+ "\"{p}\" is not an absolute path. Use a full path starting from the drive or root, for example {}.",
+ example_trainer_path()
+ ));
+ }
+ if let Some(free) = crate::commands::download::available_space_for(&path) {
+ if let Some(msg) = disk_room_message(&path, free, TRAINER_SETUP_NEEDS_GIB) {
+ return Err(msg);
+ }
+ }
+ fs::create_dir_all(&path).map_err(|e| format!("Could not create \"{p}\": {}", os_error::english(&e)))?;
+ let probe = path.join(".lu-write-check");
+ fs::write(&probe, b"ok").map_err(|e| format!("\"{p}\" is not writable: {}", os_error::english(&e)))?;
+ let _ = fs::remove_file(&probe);
+ Ok(path)
+}
+
+/// A folder to suggest, not set, in the trainer's own install-path field: K5
+/// architecture point 5. A customer who already moved ComfyUI (and with it
+/// the model folder `download_model` writes into, see `models_dir_in` in
+/// `commands/download.rs`) off the system drive is not left to retype a
+/// matching drive letter for the trainer by hand. `None` once `trainer_root`
+/// is already customized (nothing left to suggest) or when no ComfyUI folder
+/// is known yet. Read only as far as the PLACEHOLDER: nothing here writes
+/// `config.json` or moves a single byte.
+fn suggested_trainer_root(comfy_dir: Option<&Path>) -> Option<String> {
+ let comfy = comfy_dir?;
+ let parent = comfy.parent()?;
+ Some(parent.join("LU-Trainer").to_string_lossy().to_string())
+}
+
/// Trainer root: persisted override (config `trainer_root`) else
/// `<app_data>/musubi`. Layout: `<root>/venv`, `<root>/musubi-tuner`,
/// `<root>/models`, `<root>/train/<set_id>/...`.
@@ -1429,21 +1511,33 @@ pub fn install_character_trainer(
installPath: Option<String>,
) -> Result<serde_json::Value, String> {
{
- let mut st = state.trainer_install.lock().unwrap();
+ let st = state.trainer_install.lock().unwrap();
if st.status == "installing" {
return Ok(serde_json::json!({"status": "already_installing"}));
}
+ }
+
+ // K5 Blocker 2/3 (Opus review of `4fda5a0a`): validated and persisted
+ // BEFORE the install starts, not after, and an empty field is the way
+ // back to the default (point 3), not "leave whatever was there before".
+ // Nothing at a previous customized location is touched or deleted here;
+ // see `trainerRootHint` on the frontend for the sentence that says so.
+ let trimmed = installPath.as_deref().map(str::trim).unwrap_or("");
+ if trimmed.is_empty() {
+ write_config_value("trainer_root", "");
+ } else {
+ let validated = validate_trainer_root_candidate(trimmed)?;
+ write_config_value("trainer_root", &validated.to_string_lossy());
+ }
+
+ {
+ let mut st = state.trainer_install.lock().unwrap();
st.status = "installing".to_string();
st.logs.clear();
st.logs.push("Setting up the local character trainer...".to_string());
}
info!("character trainer install start");
- if let Some(p) = installPath.as_deref() {
- if !p.trim().is_empty() {
- write_config_value("trainer_root", p.trim());
- }
- }
let root = trainer_root(&app);
// An empty or unusable default Python is no longer a reason to stop here:
// trainer_base_python surveys the machine and, on Windows, installs 3.12
@@ -2203,6 +2297,12 @@ pub fn character_trainer_status(
let te = resolve_base_file(&root, comfy.as_deref(), TE_CANDIDATES, "text_encoders");
let vae = resolve_base_file(&root, comfy.as_deref(), VAE_CANDIDATES, "vae");
let install = state.trainer_install.lock().unwrap();
+ // K5 point 3/5: `customized` lets the frontend say the truth about where
+ // this install target actually is instead of assuming the default, and
+ // `suggestedRoot` is the sibling-of-ComfyUI suggestion from point 5,
+ // computed only while there is nothing customized yet to suggest over.
+ let customized = trainer_root_is_customized();
+ let suggested_root = if customized { None } else { suggested_trainer_root(comfy.as_deref()) };
Ok(serde_json::json!({
"envReady": env_ready,
"basesReady": dit.is_some() && te.is_some() && vae.is_some(),
@@ -2210,6 +2310,8 @@ pub fn character_trainer_status(
"textEncoder": te.map(|p| p.to_string_lossy().to_string()),
"vae": vae.map(|p| p.to_string_lossy().to_string()),
"root": root.to_string_lossy().to_string(),
+ "customized": customized,
+ "suggestedRoot": suggested_root,
"install": { "status": install.status, "logs": install.logs },
}))
}
@@ -3603,6 +3705,124 @@ mod tests {
}
}
+ // ── K5 Nachbesserung (Opus review of `4fda5a0a`, three blockers) ───────
+
+ #[test]
+ fn a_leading_tilde_is_never_accepted() {
+ assert!(super::starts_with_tilde("~/LU-Trainer"));
+ assert!(super::starts_with_tilde("~"));
+ assert!(!super::starts_with_tilde("/home/dave/LU-Trainer"), "an absolute path must not be flagged");
+ assert!(!super::starts_with_tilde("D:\\LU-Trainer"), "a drive path must not be flagged");
+ }
+
+ /// BLOCKER 1: the field's own example must be an absolute path on every
+ /// platform, never the tilde Rust does not resolve.
+ #[test]
+ fn the_example_path_is_absolute_on_every_platform() {
+ assert!(!super::example_trainer_path().starts_with('~'), "the example itself must not be the mistake it warns against");
+ }
+
+ /// BLOCKER 1, negative control: a leading tilde is refused before
+ /// anything is written or created, so the historic bug (a literal folder
+ /// named `~`) cannot happen any more.
+ #[test]
+ fn validate_trainer_root_candidate_rejects_a_leading_tilde() {
+ let err = super::validate_trainer_root_candidate("~/LU-Trainer").expect_err("a tilde must be refused");
+ assert!(err.contains('~'), "the message must name the actual problem: {err}");
+ assert!(!Path::new("~").exists(), "no literal ~ folder must have been created");
+ }
+
+ /// BLOCKER 2, negative control: a relative path is refused, not silently
+ /// resolved against the process's current directory.
+ #[test]
+ fn validate_trainer_root_candidate_rejects_a_relative_path() {
+ let err = super::validate_trainer_root_candidate("LU-Trainer").expect_err("a relative path must be refused");
+ assert!(err.contains("absolute"), "the message must say why: {err}");
+ }
+
+ /// BLOCKER 2, the fix itself: an absolute, creatable, writable path is
+ /// accepted, the directory exists afterward, and the write probe this
+ /// function used to prove writability is cleaned up again.
+ #[test]
+ fn validate_trainer_root_candidate_accepts_a_real_absolute_folder() {
+ let root = std::env::temp_dir().join(format!("lu-trainer-validate-ok-{}", std::process::id()));
+ let _ = fs::remove_dir_all(&root);
+ let accepted = super::validate_trainer_root_candidate(&root.to_string_lossy()).expect("a real, writable folder must be accepted");
+ assert_eq!(accepted, root);
+ assert!(root.is_dir(), "the folder must exist after validation");
+ assert!(!root.join(".lu-write-check").exists(), "the write probe must be cleaned up, not left behind");
+ fs::remove_dir_all(&root).unwrap();
+ }
+
+ /// BLOCKER 2, negative control on the write-then-check order: pointing
+ /// the candidate at a path that already exists as a plain FILE (not a
+ /// folder) cannot be created as a directory, so validation must fail
+ /// instead of silently writing the probe next to an unrelated file.
+ #[test]
+ fn validate_trainer_root_candidate_rejects_a_path_that_is_already_a_file() {
+ let file = std::env::temp_dir().join(format!("lu-trainer-validate-file-{}", std::process::id()));
+ fs::write(&file, b"not a folder").unwrap();
+ let err = super::validate_trainer_root_candidate(&file.to_string_lossy());
+ assert!(err.is_err(), "a path that is already a file must be refused, not treated as an installable folder");
+ fs::remove_file(&file).unwrap();
+ }
+
+ /// BLOCKER 3, honesty: the suggestion is a sibling of the ComfyUI folder,
+ /// never the ComfyUI folder's own subtree, and it is a plain string for a
+ /// placeholder, not a value this function ever persists.
+ #[test]
+ fn suggested_trainer_root_proposes_a_sibling_of_comfyui() {
+ let comfy = Path::new("/mnt/e/ComfyUI");
+ let suggestion = super::suggested_trainer_root(Some(comfy)).expect("a known ComfyUI folder must produce a suggestion");
+ assert_eq!(suggestion, "/mnt/e/LU-Trainer");
+ }
+
+ /// Negative control: no known ComfyUI folder means no suggestion, not a
+ /// guess.
+ #[test]
+ fn suggested_trainer_root_is_none_without_a_known_comfyui_folder() {
+ assert_eq!(super::suggested_trainer_root(None), None);
+ }
+
+ /// K5 point 3: an empty install path is the way back to the default, not
+ /// a no-op that keeps whatever `trainer_root` already held. Exercised
+ /// against the real config file like the other `trainer_root_is_customized`
+ /// test above, since `install_character_trainer` itself needs a live
+ /// `AppHandle` this module's tests do not build.
+ #[test]
+ fn an_empty_install_path_clears_a_previous_override_the_same_way_install_character_trainer_does() {
+ let _guard = config_json_test_guard();
+ let backup = super::read_config_value("trainer_root");
+ super::write_config_value("trainer_root", "/mnt/big-drive/musubi");
+ assert!(super::trainer_root_is_customized());
+ // This is the exact branch `install_character_trainer` takes for a
+ // None/empty `installPath`: reproduced here because that function
+ // needs a real `AppHandle`.
+ let trimmed = "";
+ if trimmed.is_empty() {
+ super::write_config_value("trainer_root", "");
+ }
+ assert!(!super::trainer_root_is_customized(), "an empty submission must reset to the default, not keep the old override");
+ match backup {
+ Some(value) => super::write_config_value("trainer_root", &value),
+ None => super::write_config_value("trainer_root", ""),
+ }
+ }
+
+ /// Source check that `install_character_trainer` actually validates
+ /// before it persists, in that order -- the one thing a behavioural test
+ /// against the real function cannot pin down without a live `AppHandle`
+ /// and a background thread.
+ #[test]
+ fn install_character_trainer_validates_before_it_persists() {
+ let src = include_str!("trainer.rs");
+ let body_start = src.find("pub fn install_character_trainer(").expect("install_character_trainer");
+ let body = &src[body_start..body_start + 1800];
+ let validate_at = body.find("validate_trainer_root_candidate(trimmed)?").expect("validation call");
+ let write_at = body.find("write_config_value(\"trainer_root\", &validated").expect("persist call");
+ assert!(validate_at < write_at, "the candidate must be validated before it is written to config.json");
+ }
+
/// The priority order the review asked for: the Hardware tab's own pick
/// wins, then a `CUDA_VISIBLE_DEVICES` already on the process, then the
/// card with the most memory -- never a bare index 0.
diff --git a/src/api/trainer.ts b/src/api/trainer.ts
index 0ca3745b..91b565f9 100644
--- a/src/api/trainer.ts
+++ b/src/api/trainer.ts
@@ -17,6 +17,16 @@ export interface TrainerStatus {
textEncoder: string | null
vae: string | null
root: string
+ /** Whether `root` is a customer-set override, not the built-in default.
+ * K5 Nachbesserung (Opus review of `4fda5a0a`): the frontend used to
+ * assume the default and say so unconditionally; this lets the setup
+ * gate tell the truth instead. */
+ customized: boolean
+ /** A folder to offer as the install-path placeholder when the customer
+ * already moved ComfyUI off the system drive but has not set a trainer
+ * folder yet (K5 architecture point 5). A suggestion only: it never
+ * fills the field's value. */
+ suggestedRoot: string | null
install: TrainerInstallState
}
diff --git a/src/components/create/experimental/SpecialIntentControls.tsx b/src/components/create/experimental/SpecialIntentControls.tsx
index c078f5c9..9339f9bb 100644
--- a/src/components/create/experimental/SpecialIntentControls.tsx
+++ b/src/components/create/experimental/SpecialIntentControls.tsx
@@ -21,9 +21,11 @@ import {
import { startModelDownload, getDownloadProgress } from '../../../api/discover'
import { useDownloadStore } from '../../../stores/downloadStore'
import { getLoraModels } from '../../../api/comfyui'
-import { isWindows } from '../../../api/backend'
+import { isWindows, isMacOS } from '../../../api/backend'
import { musicTakesLyrics, musicHowtoLines } from '../../../lib/render/music-ui'
import { TRAIN_PRESETS, trainStepsNote } from '../../../lib/trainer-presets'
+import { trainerPathPlaceholder } from '../../../lib/trainer-path-placeholder'
+import { trainerRootHint } from '../../../lib/trainer-root-hint'
import { useCreateExp } from './CreateContext'
import { loadImageRef } from './loadImage'
import { mediaRefFrom } from './mediaRef'
@@ -279,12 +281,25 @@ function LocalTrainControls() {
// keeps its existing default (the app data folder), so this changes
// nothing for a customer who never touches it.
const [installPath, setInstallPath] = useState('')
+ // K5 Nachbesserung, point 3: once the customer has typed anything (or the
+ // field was pre-filled and they clear it on purpose), stop overwriting
+ // their edit with the backend's current root on every poll.
+ const [pathTouched, setPathTouched] = useState(false)
const refresh = useCallback(() => {
characterTrainerStatus().then(setStatus).catch(() => setStatus(null))
}, [])
useEffect(() => { refresh() }, [refresh])
+ // K5 Nachbesserung, point 3: the field must always show the actually
+ // valid path, not stay blank while a customized root is already active
+ // (the old bug behind Blocker 2 -- a broken customized install re-showed
+ // this gate with an empty field and a caption that still claimed the app
+ // data default). Runs once per status load, before the customer edits.
+ useEffect(() => {
+ if (!pathTouched && status?.customized) setInstallPath(status.root)
+ }, [status, pathTouched])
+
// A base-file download outlives this panel. Leave the tab and come back and
// the button read "Download base files" again with no note, while the 19 GB
// kept flowing in the tray (Phase G, Windows box, 06.09.2026). On mount the
@@ -379,11 +394,11 @@ function LocalTrainControls() {
<div className="flex flex-col items-center gap-0.5">
<input
value={installPath}
- onChange={(e) => setInstallPath(e.target.value)}
- placeholder={isWindows() ? 'e.g. D:\\LU-Trainer' : 'e.g. ~/LU-Trainer'}
+ onChange={(e) => { setInstallPath(e.target.value); setPathTouched(true) }}
+ placeholder={`e.g. ${status.suggestedRoot ?? trainerPathPlaceholder(isWindows(), isMacOS())}`}
className="t-control w-64 px-2.5 h-[var(--control-h-sm)] rounded-md bg-white/[0.03] border border-white/[0.06] text-gray-200 placeholder-gray-600 focus:outline-none focus:border-white/15"
/>
- <span className="t-label text-gray-600">Installs to your app data folder by default. Set a path above to use another drive.</span>
+ <span className="t-label text-gray-600">{trainerRootHint(status, installPath)}</span>
</div>
)}
{note && <div role="status" tabIndex={0} className="text-xs leading-relaxed text-gray-600 max-w-[520px] max-h-40 overflow-y-auto select-text whitespace-pre-wrap text-center break-words">{note}</div>}
@@ -399,6 +414,12 @@ function LocalTrainControls() {
{busy === 'bases' ? 'Downloading…' : 'Download base files'}
</Button>
</div>
+ {/* K5 Blocker 3 (Opus review of `4fda5a0a`): these bytes go through
+ download_model, which follows your configured model folder
+ (Settings, ComfyUI), not the trainer folder set on the previous
+ screen. Said here so the setup does not read as one place for
+ everything the trainer downloads. */}
+ <span className="t-label text-gray-600">Goes to your configured model folder (Settings, ComfyUI).</span>
{note && <div role="status" tabIndex={0} className="text-xs leading-relaxed text-gray-600 max-w-[520px] max-h-40 overflow-y-auto select-text whitespace-pre-wrap text-center break-words">{note}</div>}
</div>
)
diff --git a/src/components/create/experimental/__tests__/k5-trainer-install-path-reaches-backend.test.tsx b/src/components/create/experimental/__tests__/k5-trainer-install-path-reaches-backend.test.tsx
index 432fd575..0198e3d2 100644
--- a/src/components/create/experimental/__tests__/k5-trainer-install-path-reaches-backend.test.tsx
+++ b/src/components/create/experimental/__tests__/k5-trainer-install-path-reaches-backend.test.tsx
@@ -44,6 +44,8 @@ vi.mock('../../../../api/trainer', async () => {
textEncoder: null,
vae: null,
root: '',
+ customized: false,
+ suggestedRoot: null,
install: { status: 'idle', logs: [] },
})),
installCharacterTrainer: (...a: unknown[]) => installCharacterTrainer(...(a as [])),
diff --git a/src/components/create/experimental/__tests__/k5-trainer-path-honesty.test.tsx b/src/components/create/experimental/__tests__/k5-trainer-path-honesty.test.tsx
new file mode 100644
index 00000000..1a39115e
--- /dev/null
+++ b/src/components/create/experimental/__tests__/k5-trainer-path-honesty.test.tsx
@@ -0,0 +1,141 @@
+// @vitest-environment jsdom
+/**
+ * K5 Nachbesserung (Opus review of `4fda5a0a`, bau/review-teil8.md): three
+ * blockers in the install-path field the previous round added.
+ *
+ * Blocker 1: the Mac/Linux placeholder suggested a `~` Rust never expands.
+ * Blocker 2: the field stayed blank and the caption kept claiming the app
+ * data default even once a customized `trainer_root` was already active
+ * -- there was no way to see, or get back from, a customized install.
+ * Blocker 3: nothing in the setup said that base model downloads follow a
+ * DIFFERENT setting (the configured model folder) than this field.
+ *
+ * This file exercises the fixes at the component level; the pure logic
+ * (`trainerRootHint`, `trainerPathPlaceholder`) has its own unit tests.
+ *
+ * Run: npx vitest run src/components/create/experimental/__tests__/k5-trainer-path-honesty.test.tsx
+ */
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+import { cleanup, fireEvent, render, screen } from '@testing-library/react'
+
+vi.mock('../../../../api/backend', () => ({
+ isTauri: () => true,
+ isMacOS: () => false,
+ isWindows: () => false,
+ isLinux: () => true,
+ backendCall: vi.fn(async () => ({ status: 'ok' })),
+}))
+
+const installCharacterTrainer = vi.fn(async () => ({ status: 'installing' }))
+let mockedStatus: Record<string, unknown> = {}
+vi.mock('../../../../api/trainer', async () => {
+ const actual = await vi.importActual<typeof import('../../../../api/trainer')>('../../../../api/trainer')
+ return {
+ ...actual,
+ characterTrainerStatus: vi.fn(async () => mockedStatus),
+ installCharacterTrainer: (...a: unknown[]) => installCharacterTrainer(...(a as [])),
+ }
+})
+vi.mock('../../../../api/comfyui', () => ({ getLoraModels: vi.fn(async () => []) }))
+vi.mock('../../../../api/cloud/loras', () => ({ listLoras: vi.fn(async () => []), deleteLora: vi.fn() }))
+vi.mock('../../../../api/discover', async () => {
+ const actual = await vi.importActual<typeof import('../../../../api/discover')>('../../../../api/discover')
+ return {
+ ...actual,
+ startModelDownload: vi.fn(async () => {}),
+ getDownloadProgress: vi.fn(async () => ({})),
+ }
+})
+
+import { SpecialControls } from '../SpecialIntentControls'
+import { useCreateStore } from '../../../../stores/createStore'
+
+function baseStatus(overrides: Partial<Record<string, unknown>> = {}) {
+ return {
+ envReady: false,
+ basesReady: false,
+ dit: null,
+ textEncoder: null,
+ vae: null,
+ root: '/data/lu/musubi',
+ customized: false,
+ suggestedRoot: null,
+ install: { status: 'idle', logs: [] },
+ ...overrides,
+ }
+}
+
+beforeEach(() => {
+ cleanup()
+ installCharacterTrainer.mockClear()
+ useCreateStore.setState({ backend: 'local', characterTab: 'train' })
+})
+
+describe('K5 Nachbesserung: Blocker 1, kein Tilde-Platzhalter', () => {
+ it('THE FIX: Linux zeigt einen absoluten Beispielpfad, keine Tilde', async () => {
+ mockedStatus = baseStatus()
+ render(<SpecialControls intent="character" />)
+ expect(await screen.findByPlaceholderText(/^e\.g\. \//)).toBeTruthy()
+ expect(screen.queryByPlaceholderText('e.g. ~/LU-Trainer')).toBeNull()
+ })
+})
+
+describe('K5 Nachbesserung: Blocker 2, das Feld zeigt immer den gueltigen Pfad', () => {
+ it('THE FIX: ein bereits angepasster Pfad wird ins Feld vorbelegt', async () => {
+ mockedStatus = baseStatus({ root: 'E:\\LU-Trainer', customized: true })
+ render(<SpecialControls intent="character" />)
+ const feld = (await screen.findByDisplayValue('E:\\LU-Trainer')) as HTMLInputElement
+ expect(feld.value).toBe('E:\\LU-Trainer')
+ })
+
+ it('GEGENPROBE: ohne Anpassung bleibt das Feld leer (der bisherige Standardweg aendert sich nicht)', async () => {
+ mockedStatus = baseStatus({ customized: false })
+ render(<SpecialControls intent="character" />)
+ await screen.findByRole('button', { name: 'Set up trainer' })
+ const feld = screen.getByPlaceholderText(/^e\.g\. \//) as HTMLInputElement
+ expect(feld.value).toBe('')
+ })
+
+ it('THE FIX: die Bildunterschrift nennt den echten Pfad, nicht die pauschale Standardaussage', async () => {
+ mockedStatus = baseStatus({ root: 'E:\\LU-Trainer', customized: true })
+ render(<SpecialControls intent="character" />)
+ await screen.findByDisplayValue('E:\\LU-Trainer')
+ expect(screen.getByText(/Installs to E:\\LU-Trainer/)).toBeTruthy()
+ expect(screen.queryByText(/Installs to your app data folder by default/)).toBeNull()
+ })
+
+ it('THE FIX: ein geleertes Feld ist der Weg zurueck und installCharacterTrainer erhaelt kein Argument', async () => {
+ mockedStatus = baseStatus({ root: 'E:\\LU-Trainer', customized: true })
+ render(<SpecialControls intent="character" />)
+ const feld = await screen.findByDisplayValue('E:\\LU-Trainer')
+ fireEvent.change(feld, { target: { value: '' } })
+ expect(screen.getByText(/installs to your app data folder instead/)).toBeTruthy()
+ fireEvent.click(screen.getByRole('button', { name: 'Set up trainer' }))
+ expect(installCharacterTrainer).toHaveBeenCalledWith(undefined)
+ })
+})
+
+describe('K5 Nachbesserung: Blocker 3, ehrliche Zielangabe', () => {
+ it('THE FIX: das Setup-Gate sagt, dass Basismodelle woanders hinlaufen', async () => {
+ mockedStatus = baseStatus()
+ render(<SpecialControls intent="character" />)
+ await screen.findByRole('button', { name: 'Set up trainer' })
+ expect(screen.getByText(/configured model folder/)).toBeTruthy()
+ })
+
+ it('THE FIX: die Basisdatei-Anzeige nennt denselben Zielort ausdruecklich', async () => {
+ mockedStatus = baseStatus({ envReady: true, basesReady: false })
+ render(<SpecialControls intent="character" />)
+ await screen.findByRole('button', { name: 'Download base files' })
+ expect(screen.getByText(/Goes to your configured model folder/)).toBeTruthy()
+ })
+})
+
+describe('K5 Nachbesserung: Punkt 5, Vorschlag statt stillem Umzug', () => {
+ it('THE FIX: ein Vorschlagsordner erscheint als Platzhalter, nicht als Wert', async () => {
+ mockedStatus = baseStatus({ suggestedRoot: '/mnt/e/LU-Trainer' })
+ render(<SpecialControls intent="character" />)
+ const feld = (await screen.findByPlaceholderText('e.g. /mnt/e/LU-Trainer')) as HTMLInputElement
+ expect(feld.value).toBe('')
+ })
+})
diff --git a/src/lib/__tests__/trainer-path-placeholder.test.ts b/src/lib/__tests__/trainer-path-placeholder.test.ts
new file mode 100644
index 00000000..f738c7c1
--- /dev/null
+++ b/src/lib/__tests__/trainer-path-placeholder.test.ts
@@ -0,0 +1,35 @@
+/**
+ * K5 Blocker 1 (Opus review of `4fda5a0a`): the trainer's install-path
+ * placeholder used to suggest `~/LU-Trainer` on Mac and Linux, a path Rust
+ * never expands (`PathBuf::from` takes it literally). Absolute examples
+ * only, mirrored on the Rust side by `example_trainer_path` in
+ * `commands/trainer.rs`.
+ */
+import { describe, expect, it } from 'vitest'
+import { trainerPathPlaceholder } from '../trainer-path-placeholder'
+
+describe('trainerPathPlaceholder', () => {
+ it('Windows keeps the drive-letter example', () => {
+ expect(trainerPathPlaceholder(true, false)).toBe('D:\\LU-Trainer')
+ })
+
+ it('THE FIX: Mac gets an absolute example, not a tilde', () => {
+ const mac = trainerPathPlaceholder(false, true)
+ expect(mac.startsWith('~')).toBe(false)
+ expect(mac.startsWith('/')).toBe(true)
+ })
+
+ it('THE FIX: Linux gets an absolute example, not a tilde', () => {
+ const linux = trainerPathPlaceholder(false, false)
+ expect(linux.startsWith('~')).toBe(false)
+ expect(linux.startsWith('/')).toBe(true)
+ })
+
+ it('DIE ROTE ZAHL: the historic bug, reproduced -- a tilde example on a non-Windows box', () => {
+ // What the field showed before this fix. Kept as a literal, negative
+ // assertion so a regression back to it fails loudly.
+ const oldPlaceholder = (onWindows: boolean) => (onWindows ? 'D:\\LU-Trainer' : '~/LU-Trainer')
+ expect(oldPlaceholder(false)).not.toBe(trainerPathPlaceholder(false, false))
+ expect(oldPlaceholder(false)).not.toBe(trainerPathPlaceholder(false, true))
+ })
+})
diff --git a/src/lib/__tests__/trainer-root-hint.test.ts b/src/lib/__tests__/trainer-root-hint.test.ts
new file mode 100644
index 00000000..a6aa5036
--- /dev/null
+++ b/src/lib/__tests__/trainer-root-hint.test.ts
@@ -0,0 +1,54 @@
+/**
+ * K5 Nachbesserung (Opus review of `4fda5a0a`, Blockers 2 and 3): the
+ * caption under the trainer's install-path field used to be one hardcoded
+ * sentence that stayed on screen even once `trainer_root` was customized,
+ * at which point it was false (Blocker 2), and it never said where base
+ * model downloads actually go (Blocker 3, they follow the configured model
+ * folder, not this field). `trainerRootHint` reads the real backend state
+ * instead of assuming the default.
+ */
+import { describe, expect, it } from 'vitest'
+import { trainerRootHint } from '../trainer-root-hint'
+
+describe('trainerRootHint', () => {
+ it('the default case: not customized, field empty', () => {
+ const hint = trainerRootHint({ root: '/data/lu/musubi', customized: false }, '')
+ expect(hint).toContain('Installs to your app data folder by default')
+ expect(hint).toContain('configured model folder')
+ })
+
+ it('THE FIX: a customized root is named, not the generic default sentence', () => {
+ const hint = trainerRootHint({ root: 'E:\\LU-Trainer', customized: true }, 'E:\\LU-Trainer')
+ expect(hint).toContain('E:\\LU-Trainer')
+ expect(hint).not.toContain('Installs to your app data folder by default')
+ })
+
+ it('GEGENPROBE: the old bug -- claiming the default while a customized root is active -- cannot happen', () => {
+ // Blocker 2's exact failure: a broken customized install re-shows this
+ // gate, and the caption must not say "app data folder" while `root`
+ // still names the customer's own drive.
+ const hint = trainerRootHint({ root: 'E:\\LU-Trainer', customized: true }, 'E:\\LU-Trainer')
+ expect(hint.includes('app data folder by default')).toBe(false)
+ })
+
+ it('point 3, the way back: clearing a customized field explains what pressing Set up trainer will do', () => {
+ const hint = trainerRootHint({ root: 'E:\\LU-Trainer', customized: true }, '')
+ expect(hint).toContain('installs to your app data folder instead')
+ })
+
+ it('point 4, no silent orphan: the old files are named as kept, not deleted', () => {
+ const hint = trainerRootHint({ root: 'E:\\LU-Trainer', customized: true }, '')
+ expect(hint).toContain('E:\\LU-Trainer')
+ expect(hint).toContain('are kept, not deleted')
+ })
+
+ it('Blocker 3, every branch names where base models actually go', () => {
+ for (const [status, value] of [
+ [{ root: '/data/lu/musubi', customized: false }, ''],
+ [{ root: 'E:\\LU-Trainer', customized: true }, 'E:\\LU-Trainer'],
+ [{ root: 'E:\\LU-Trainer', customized: true }, ''],
+ ] as const) {
+ expect(trainerRootHint(status, value)).toContain('configured model folder')
+ }
+ })
+})
diff --git a/src/lib/release-notes.ts b/src/lib/release-notes.ts
index 468cc284..598a866e 100644
--- a/src/lib/release-notes.ts
+++ b/src/lib/release-notes.ts
@@ -140,7 +140,7 @@ export const RELEASE_NOTES: ReleaseNote[] = [
'Picking a specific GPU for a local model or the Character Trainer now keeps using that physical card even if Windows or Linux renumber the cards between detection and start.',
'Opening the Hardware tab in Settings while a local model or the trainer was starting up could freeze it for a moment; it no longer waits on that GPU detection.',
'Replacing an OpenAI compatible backend now parks the API key it displaces in the OS keychain instead of dropping it, and gives it back if you switch back to that backend or remove the one that replaced it. The warning that a key will be lost only shows on a device with no keychain to park it in.',
- 'Setting an install location for the Character Trainer now also redirects pip, Hugging Face and torch\'s own caches there, so moving the trainer off a small system drive keeps those caches off it too.',
+ 'Setting an install location for the Character Trainer now also redirects pip, Hugging Face and torch\'s own caches there, so moving the trainer off a small system drive keeps those caches off it too. The field itself now rejects a path it cannot actually use, always shows the folder it will really install to, and an emptied field goes back to the default; the Z Image base model downloads always follow your configured model folder in Settings, ComfyUI, either way.',
'A finished image in Create has an Animate this image button that carries it straight into a video render, the same as the browser studio, and the No refusals mark now shows on cloud models in the desktop picker as well.',
'qwen-image-edit is selectable from the seed and edit pickers again, the upscale tool is named Enhance Image to match the web, and Krea 2 checkpoints load with the right UNET, CLIP and VAE nodes instead of falling back to an unknown loader.',
'The Create button now stays disabled instead of failing on the server when the chosen model needs a mask that was never supplied, and the local character LoRA list refreshes itself right after a training finishes instead of needing a restart.',
@@ -149,6 +149,13 @@ export const RELEASE_NOTES: ReleaseNote[] = [
'A memory entry with more than one line survives export and import again, both separator styles the web writes are read back, and one sensitive memory entry no longer blocks the whole sync.',
'The composer lock during a send now only affects that one conversation, not every open chat, Stop in one chat no longer cancels an image or video render running in another, and picking a third remembered agent folder now asks for confirmation like the first two do.',
'The first click into the Models folders tab is faster, since it asks the running engine directly instead of falling back to a stale cache, and the onboarding VRAM hint asks LU\'s own probe first so it works before ComfyUI is installed.',
+ 'Settings now says when Ollama is reachable but switched off, instead of just Reachable, which read as if it were actually being used.',
+ 'A Cloud chat request that hits its own four minute limit is now treated as finished right away instead of being retried up to three more times with the same four minute wait on each try.',
+ 'The Local Media (Apple MLX) panel now mentions that a Hugging Face token can help its downloads, the same hint ComfyUI already gives for its own model downloads.',
+ 'The No refusals mark in the desktop model picker now carries an icon and bolder text so it is actually noticeable, instead of blending into the smallest text on the row.',
+ 'Dismissing the stale model notice in the chat header now actually dismisses it, instead of it reappearing on the very next update.',
+ 'The reason the Coding Agent will not let go of its current folder is now shown as a visible line, instead of only a tooltip a disabled button never shows.',
+ 'ltx-2 LoRA renders in the desktop app now carry a credit cost, matching the web catalog, instead of pricing as free.',
],
},
],
diff --git a/src/lib/trainer-path-placeholder.ts b/src/lib/trainer-path-placeholder.ts
new file mode 100644
index 00000000..3bd98010
--- /dev/null
+++ b/src/lib/trainer-path-placeholder.ts
@@ -0,0 +1,17 @@
+/**
+ * The example path shown in the trainer's own install-target field.
+ *
+ * K5 Blocker 1 (Opus review of `4fda5a0a`): the old placeholder suggested
+ * `~/LU-Trainer` on Mac and Linux, and `install_character_trainer` on the
+ * Rust side never resolves a leading `~` -- it goes straight into
+ * `PathBuf::from`. A customer who typed exactly what the field offered ended
+ * up with a folder literally named `~`, not one in their home directory.
+ * Absolute examples only, one per platform family, mirrored on the Rust
+ * side by `example_trainer_path` in `commands/trainer.rs` (kept in sync by
+ * `k5-trainer-path-honesty.test.tsx`).
+ */
+export function trainerPathPlaceholder(onWindows: boolean, onMac: boolean): string {
+ if (onWindows) return 'D:\\LU-Trainer'
+ if (onMac) return '/Users/you/LU-Trainer'
+ return '/home/you/LU-Trainer'
+}
diff --git a/src/lib/trainer-root-hint.ts b/src/lib/trainer-root-hint.ts
new file mode 100644
index 00000000..9b2fcf4f
--- /dev/null
+++ b/src/lib/trainer-root-hint.ts
@@ -0,0 +1,32 @@
+import type { TrainerStatus } from '../api/trainer'
+
+/**
+ * The sentence under the trainer's install-path field.
+ *
+ * K5 Blockers 2 and 3 (Opus review of `4fda5a0a`): the old sentence was one
+ * hardcoded claim, "Installs to your app data folder by default", that
+ * stayed on screen even after a customer had a customized `trainer_root` --
+ * at that point it was false, and pressing "Set up trainer" in the belief it
+ * went to app data reinstalled at the customized (possibly now unplugged)
+ * drive instead, with no way back through the field. This reads the CURRENT
+ * backend state instead of assuming the default, always names where the two
+ * things that land here actually go (Blocker 3: the trainer's own
+ * environment and caches follow this field, base model downloads always go
+ * to the configured model folder in Settings, regardless of it), and says
+ * plainly that clearing the field is the way back and nothing at the old
+ * location is deleted (point 4).
+ */
+export function trainerRootHint(
+ status: Pick<TrainerStatus, 'root' | 'customized'>,
+ fieldValue: string,
+): string {
+ const trimmed = fieldValue.trim()
+ const baseModels = 'Base model downloads always go to your configured model folder (Settings, ComfyUI), not here.'
+ if (status.customized && trimmed === '') {
+ return `Leaving this empty and pressing Set up trainer installs to your app data folder instead. Files already at ${status.root} are kept, not deleted. ${baseModels}`
+ }
+ if (status.customized) {
+ return `Installs to ${status.root}. Clear this field to go back to the app data folder. ${baseModels}`
+ }
+ return `Installs to your app data folder by default. Set a path above to use another drive. ${baseModels}`
+}