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): drop duplicate refresh effect, unwrap panics, em dashes

purple46c005610ada
diff --git a/src-tauri/src/commands/trainer.rs b/src-tauri/src/commands/trainer.rs
index 0b96abe9..88027789 100644
--- a/src-tauri/src/commands/trainer.rs
+++ b/src-tauri/src/commands/trainer.rs
@@ -231,7 +231,7 @@ fn active_comfy_dir(state: &AppState) -> Option<PathBuf> {
/// `Accelerator.__init__` (`accelerate/accelerator.py` Z. 460-461) turns that
/// into `kwargs["backend"] = "gloo"` and passes it on to `PartialState`.
/// `_prepare_backend` (`state.py` Z. 735-804) finds no `LOCAL_RANK` and
-/// returns `("gloo", DistributedType.NO)` UNCHANGED — the backend name
+/// returns `("gloo", DistributedType.NO)` UNCHANGED: the backend name
/// itself leaks through even though nothing distributed was ever set up.
/// Back in `PartialState.__init__` (Z. 268-292), the branch that should read
/// `if self.backend is None:` is then false, because `self.backend == "gloo"`,
@@ -249,7 +249,7 @@ fn active_comfy_dir(state: &AppState) -> Option<PathBuf> {
/// A second, unused NVIDIA card the driver still enumerates would fit
/// (Tesla P100 has no display output, so a Windows box built around one
/// commonly has a second card for the screen), but that is a plausible read
-/// of the report, not a measurement — see the question drafted in
+/// of the report, not a measurement; see the question drafted in
/// `lu-301/bau/trainer.md`.
fn trainer_child_env(cmd: &mut Command) {
cmd.env("PYTHONIOENCODING", "utf-8");
@@ -1324,7 +1324,7 @@ pub fn install_character_trainer(
// Cloned here, resolved (nvidia-smi and all) inside the thread: the same
// card the setup's own smoke test measures is the one training pins to
// later, see `resolve_trainer_gpu`.
- let gpu_selection = state.gpu_selection.lock().unwrap().clone();
+ let gpu_selection = state.gpu_selection.lock().map_err(|e| e.to_string())?.clone();
cancel.store(false, Ordering::SeqCst);
std::thread::spawn(move || {
@@ -1415,7 +1415,7 @@ pub(crate) fn venv_create_args(action: VenvAction) -> &'static [&'static str] {
/// what version was on the machine but not where LU looked or which install
/// it was reading. gekiritz's rebuild loop (see `python_version_and_arch`)
/// is exactly the case where two Pythons report the same version and only
-/// one of them is real — the path is what lets the customer, or us reading a
+/// one of them is real; the path is what lets the customer, or us reading a
/// Discord paste, tell which is which.
pub(crate) fn no_trainer_python_message(found: &[(String, String)], os: &str, winget_tried: bool) -> String {
let have = if found.is_empty() {
@@ -1460,7 +1460,7 @@ fn trainer_base_python(
}
// K4: a 32-bit or ARM64 Python answers `sys.version_info` exactly
// like a normal one, builds a venv that looks complete, and only
- // dies once pip resolves torch — which reports as the wrong
+ // dies once pip resolves torch, which reports as the wrong
// Python-version message and sends the customer back to the same
// interpreter. Excluding it here, before the venv is ever built,
// is what makes the retry pick a different one instead of
@@ -2260,7 +2260,7 @@ pub fn start_character_training(
// Same reason, same pattern: resolved for real (nvidia-smi and all)
// inside the thread, from the Hardware tab's own pick, so a repair mid
// run and the training step after it measure and train the same card.
- let gpu_selection = state.gpu_selection.lock().unwrap().clone();
+ let gpu_selection = state.gpu_selection.lock().map_err(|e| e.to_string())?.clone();
cancel.store(false, Ordering::SeqCst);
std::thread::spawn(move || {
@@ -3088,7 +3088,7 @@ mod tests {
/// K3, 2026-09-18, nachgebessert nach dem Opus-Review: `pin_trainer_gpu`,
/// not `trainer_child_env`, is what keeps `torch.cuda.device_count() > 1`
- /// from being true inside a trainer child — the review's finding that a
+ /// from being true inside a trainer child: the review's finding that a
/// hardcoded index "0" is neither guaranteed to be the strong card nor
/// respects the Hardware tab's own picker or a user-set
/// `CUDA_VISIBLE_DEVICES`.
diff --git a/src-tauri/src/python.rs b/src-tauri/src/python.rs
index 3ff1ceb3..015e4b90 100644
--- a/src-tauri/src/python.rs
+++ b/src-tauri/src/python.rs
@@ -436,7 +436,7 @@ pub fn is_trainer_arch(bits: u32, machine: &str) -> bool {
/// 3.11/3.12 answers exactly like a normal one. Such an interpreter passes
/// every check `trainer_base_python` runs, builds a venv that looks complete,
/// and only dies once pip actually resolves torch, with "Could not find a
-/// version that satisfies the requirement torch" — which `pip_failure_kind`
+/// version that satisfies the requirement torch", which `pip_failure_kind`
/// reads as `NoMatchingWheel` and reports as the wrong-Python-version
/// message. The version was never the problem, so the button that message
/// points at chose the same interpreter again on every retry.
@@ -956,7 +956,7 @@ mod tests {
fn a_32_bit_interpreter_is_wrong_even_when_wow64_says_amd64() {
// A 32-bit interpreter on 64-bit Windows still reports
// platform.machine() == "AMD64" (that reads the OS, not the
- // process) — struct.calcsize('P') is the one that catches it.
+ // process); struct.calcsize('P') is the one that catches it.
assert!(!is_trainer_arch(32, "AMD64"));
}
diff --git a/src/components/create/experimental/CreateContext.tsx b/src/components/create/experimental/CreateContext.tsx
index 64cdb870..b06a9b58 100644
--- a/src/components/create/experimental/CreateContext.tsx
+++ b/src/components/create/experimental/CreateContext.tsx
@@ -214,7 +214,6 @@ export function CreateExpProvider({ children }: { children: ReactNode }) {
})
} catch { /* node probe is best-effort */ }
}, [connected, setCaps])
- useEffect(() => { void refreshModelLists() }, [refreshModelLists])
// K3 proof-vorgabe Station 10 / GH #109, the completion case: a character
// trained locally lands in models/loras the same way a manually dropped
// .safetensors does, and needed the same manual Rescan click to appear in
@@ -222,7 +221,11 @@ export function CreateExpProvider({ children }: { children: ReactNode }) {
// `useCreate` sees the run finish (`src/hooks/useCreate.ts`); reusing it
// here instead of adding a second "training done" signal keeps the picker
// in sync with zero clicks, matching what the finished-training message
- // now claims.
+ // now claims. Runde 2 (Opus review): this ALSO replaces the plain
+ // "refresh once on connect" effect the round-1 fix had; connected flips
+ // once per session and charactersVersion starts at the same value, so the
+ // dependency below already fires on mount, a second effect only refreshed
+ // twice on every connect.
const charactersVersion = useCreateStore((s) => s.charactersVersion)
useEffect(() => { void refreshModelLists() }, [charactersVersion, refreshModelLists])
diff --git a/src/components/create/experimental/__tests__/lora-stack-discoverable.test.ts b/src/components/create/experimental/__tests__/lora-stack-discoverable.test.ts
index 7430a0f5..d20d428d 100644
--- a/src/components/create/experimental/__tests__/lora-stack-discoverable.test.ts
+++ b/src/components/create/experimental/__tests__/lora-stack-discoverable.test.ts
@@ -38,7 +38,11 @@ describe('der LoRA-Stack ist auffindbar (#109)', () => {
const src = lies('CreateContext.tsx')
expect(src).toMatch(/refreshModelLists: \(\) => Promise<void>/)
expect(src).toMatch(/const refreshModelLists = useCallback/)
- expect(src).toMatch(/refreshModelLists\(\) \}, \[refreshModelLists\]\)/)
+ // Runde 2 (Opus review): der alte, separate `[refreshModelLists]`-Effekt
+ // ist raus, der Connect-Pfad laeuft jetzt ueber denselben Effekt wie der
+ // charactersVersion-Refresh weiter unten (ein Effekt statt zwei, kein
+ // doppelter Fetch mehr bei jedem Connect).
+ expect(src).not.toMatch(/refreshModelLists\(\) \}, \[refreshModelLists\]\)/)
})
it('ein Rescan liest wirklich frisch statt aus dem Node-Cache', () => {