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(create): stop the trainer reinstall dialog from customizing trainer_root

purple2816cf568db3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 46405d57..bf1083db 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -137,9 +137,8 @@ installs stop losing environment variables to it.
- **ltx-2 LoRA renders in the desktop app now carry a credit cost**, matching
the web catalog, instead of pricing as free.
- **Reinstall trainer in Character Studio now opens a confirmation dialog
- first**, showing the current trainer folder and the same install-path field
- as the first setup, instead of starting the reinstall the moment the button
- is clicked.
+ first**, showing the current trainer folder, instead of starting the
+ reinstall the moment the button is clicked.
## [3.0.0] - 2026-09-13
diff --git a/e2e/trainer-reinstall-confirm.spec.ts b/e2e/trainer-reinstall-confirm.spec.ts
index 2cd065ff..9d279a3e 100644
--- a/e2e/trainer-reinstall-confirm.spec.ts
+++ b/e2e/trainer-reinstall-confirm.spec.ts
@@ -6,38 +6,55 @@ import { routeCloud, seedOnboardingDone, cloudSwitch } from './support/cloud-moc
* Z5 (box-gruen/b BERICHT.md, Zusatzpunkt Z5, e2e Windows 18.09.2026): auf
* einer Box mit bereits installiertem Trainer hat "Reinstall trainer"
* `install_character_trainer` im selben Moment ausgeloest, in dem geklickt
- * wurde -- keine Bestaetigung, keine Chance, den Installationsordner vorher
- * zu sehen oder zu aendern, echte pip-Aktivitaet (5,3 GB venv, ein editable
- * Reinstall) hat begonnen, bevor der Tester irgendetwas entschieden hatte.
- * Diese Spec beweist den Fix: der Klick oeffnet jetzt nur einen Dialog, und
- * `install_character_trainer` wird genau einmal aufgerufen, erst nachdem
- * "Reinstall" gedrueckt wurde, mit dem Pfad, der im eigenen Ordnerfeld des
- * Dialogs steht.
+ * wurde -- keine Bestaetigung, keine Chance, vorher zu sehen, was passiert.
+ * Diese Spec beweist den ersten Teil des Fixes: der Klick oeffnet jetzt nur
+ * einen Dialog, und `install_character_trainer` wird genau einmal
+ * aufgerufen, erst nachdem "Reinstall" gedrueckt wurde.
+ *
+ * Final Review (19.09.2026, ZURUECK, Blocker): ein erster Entwurf dieses
+ * Dialogs hatte ein EDITIERBARES Pfadfeld, vorbelegt mit dem bestehenden
+ * Ordner. Ein Kunde, der bloss bestaetigt ohne etwas zu tippen, schickte
+ * diesen Ordner dann als nicht-leeren Pfad an install_character_trainer, und
+ * die Rust-Seite haelt einen nicht-leeren Pfad fuer "customized" -- genau der
+ * Migrationsschutz, den es fuer einen unveraenderten Reinstall nicht geben
+ * soll, griff dann ungewollt und liess pip/Torch-Caches umziehen. Der Dialog
+ * zeigt den Ordner jetzt nur noch als Text; Bestaetigen schickt dasselbe
+ * Argument, das der Knopf vor dem gesamten Z5-Umbau schickte (der
+ * Erstsetup-Zustand `installPath`, leer fuer einen Kunden, der ihn nie
+ * angefasst hat). Die Tests unten pruefen genau das.
*
* Run: npx playwright test e2e/trainer-reinstall-confirm.spec.ts
*/
const SHOT_DIR = '/Users/purple/Desktop/LU/lu-301/bau/trainerconfirm-shots'
-async function gotoReadyTrainer(page: import('@playwright/test').Page) {
+function trainerStatusMock(overrides: Record<string, unknown> = {}) {
+ return {
+ envReady: true, basesReady: true, dit: 'x', textEncoder: 'x', vae: 'x',
+ root: 'C:\\test-trainer', customized: false, suggestedRoot: null,
+ install: { status: 'idle', logs: [] },
+ ...overrides,
+ }
+}
+
+async function gotoReadyTrainer(
+ page: import('@playwright/test').Page,
+ statusOverrides: Record<string, unknown> = {},
+) {
await page.addInitScript(tauriMockInit, {
assistantReply: DEFAULT_ASSISTANT_REPLY, modelName: DEFAULT_MODEL_NAME, platform: 'windows' as const,
})
- await page.addInitScript(() => {
+ await page.addInitScript((status: Record<string, unknown>) => {
const bridge = (window as unknown as {
__TAURI_INTERNALS__: { invoke: (cmd: string, args: unknown) => Promise<unknown> }
}).__TAURI_INTERNALS__
const invoke = bridge.invoke
;(window as unknown as { __installCalls: unknown[] }).__installCalls = []
bridge.invoke = async (cmd: string, args: unknown) => {
- if (cmd === 'character_trainer_status') return {
- envReady: true, basesReady: true, dit: 'x', textEncoder: 'x', vae: 'x',
- root: 'C:\\test-trainer', customized: false, suggestedRoot: null,
- install: { status: 'idle', logs: [] },
- }
+ if (cmd === 'character_trainer_status') return status
if (cmd === 'install_character_trainer') {
;(window as unknown as { __installCalls: unknown[] }).__installCalls.push(args)
- const installPath = (args as { installPath?: string } | null)?.installPath
+ const installPath = (args as { installPath?: string | null } | null)?.installPath ?? null
if (installPath && !/^[A-Za-z]:\\|^\//.test(installPath)) {
throw new Error('The trainer folder must be an absolute path.')
}
@@ -45,7 +62,7 @@ async function gotoReadyTrainer(page: import('@playwright/test').Page) {
}
return invoke(cmd, args)
}
- })
+ }, trainerStatusMock(statusOverrides))
await seedOnboardingDone(page)
await routeCloud(page, { license: 'active', access: true, mediaLive: true })
await page.goto('/')
@@ -54,8 +71,8 @@ async function gotoReadyTrainer(page: import('@playwright/test').Page) {
await page.getByRole('radio', { name: 'Character Studio', exact: true }).click()
}
-async function installCallCount(page: import('@playwright/test').Page): Promise<number> {
- return page.evaluate(() => (window as unknown as { __installCalls: unknown[] }).__installCalls.length)
+async function installCalls(page: import('@playwright/test').Page): Promise<unknown[]> {
+ return page.evaluate(() => (window as unknown as { __installCalls: unknown[] }).__installCalls)
}
test('Reinstall trainer opens a dialog first -- no install call on the bare click (Negativkontrolle)', async ({ page }, testInfo) => {
@@ -63,16 +80,19 @@ test('Reinstall trainer opens a dialog first -- no install call on the bare clic
await page.getByRole('button', { name: 'Reinstall trainer', exact: true }).click()
const dialog = page.getByRole('dialog', { name: 'Reinstall the trainer?' })
await expect(dialog).toBeVisible()
- expect(await installCallCount(page)).toBe(0)
+ expect(await installCalls(page)).toHaveLength(0)
await page.screenshot({ path: `${SHOT_DIR}/${testInfo.titlePath.length}-dialog-open.png` })
})
-test('the dialog shows the current trainer folder, pre-filled, and focuses Cancel', async ({ page }) => {
+test('the dialog shows the current trainer folder as read-only text and focuses Cancel', async ({ page }) => {
await gotoReadyTrainer(page)
await page.getByRole('button', { name: 'Reinstall trainer', exact: true }).click()
const dialog = page.getByRole('dialog', { name: 'Reinstall the trainer?' })
await expect(dialog).toBeVisible()
- await expect(dialog.locator('input')).toHaveValue('C:\\test-trainer')
+ // A1-Korrektur: kein editierbares Feld mehr -- der Ordner steht nur als
+ // Text im Dialog, ein Kunde kann ihn hier nicht mehr aendern.
+ await expect(dialog.locator('input')).toHaveCount(0)
+ await expect(dialog).toContainText('C:\\test-trainer')
await expect(dialog.getByRole('button', { name: 'Cancel' })).toBeFocused()
})
@@ -83,7 +103,7 @@ test('Cancel closes the dialog and calls nothing', async ({ page }) => {
await expect(dialog).toBeVisible()
await dialog.getByRole('button', { name: 'Cancel' }).click()
await expect(dialog).not.toBeVisible()
- expect(await installCallCount(page)).toBe(0)
+ expect(await installCalls(page)).toHaveLength(0)
// Der Trainer bleibt exakt wie vorher -- der Knopf zeigt wieder sein Ruhe-Label.
await expect(page.getByRole('button', { name: 'Reinstall trainer', exact: true })).toBeVisible()
})
@@ -95,46 +115,54 @@ test('Escape closes the dialog and calls nothing', async ({ page }) => {
await expect(dialog).toBeVisible()
await page.keyboard.press('Escape')
await expect(dialog).not.toBeVisible()
- expect(await installCallCount(page)).toBe(0)
+ expect(await installCalls(page)).toHaveLength(0)
})
-test('confirming calls install_character_trainer exactly once, with the edited path', async ({ page }, testInfo) => {
- await gotoReadyTrainer(page)
+test('BLOCKER: confirming an unmodified reinstall does not turn the existing folder into a customized trainer_root', async ({ page }, testInfo) => {
+ // customized: false, so an honest reinstall must send the same argument the
+ // Reinstall button sent before the confirmation dialog existed at all: no
+ // path, not the folder that happens to be showing in the dialog. Sending
+ // the folder here would flip trainer_root_is_customized() to true on the
+ // Rust side and redirect the pip/HF/torch caches away from the ones
+ // already on disk -- exactly the migration a customer who never touched
+ // this setting must not trigger.
+ await gotoReadyTrainer(page, { customized: false, suggestedRoot: null, root: 'C:\\test-trainer' })
await page.getByRole('button', { name: 'Reinstall trainer', exact: true }).click()
const dialog = page.getByRole('dialog', { name: 'Reinstall the trainer?' })
- const field = dialog.locator('input')
- await field.fill('D:\\NewTrainerDrive')
await dialog.getByRole('button', { name: 'Reinstall', exact: true }).click()
await expect(dialog).not.toBeVisible()
- expect(await installCallCount(page)).toBe(1)
- const calls = await page.evaluate(() => (window as unknown as { __installCalls: unknown[] }).__installCalls)
- expect(calls).toEqual([{ installPath: 'D:\\NewTrainerDrive' }])
+ const calls = await installCalls(page)
+ expect(calls).toEqual([{ installPath: null }])
await page.screenshot({ path: `${SHOT_DIR}/${testInfo.titlePath.length}-confirmed-reinstall.png` })
})
-test('confirming with an unchanged path reinstalls to the same folder, still exactly once', async ({ page }) => {
- await gotoReadyTrainer(page)
+test('confirming a reinstall of an already customized install keeps sending that same folder', async ({ page }) => {
+ // customized: true means a customer DID set this folder on purpose in the
+ // past. Reinstalling must keep using it, not fall back to empty -- that
+ // would silently move a deliberate choice back to the app data default.
+ await gotoReadyTrainer(page, { customized: true, suggestedRoot: null, root: 'D:\\CustomTrainer' })
await page.getByRole('button', { name: 'Reinstall trainer', exact: true }).click()
const dialog = page.getByRole('dialog', { name: 'Reinstall the trainer?' })
await dialog.getByRole('button', { name: 'Reinstall', exact: true }).click()
await expect(dialog).not.toBeVisible()
- expect(await installCallCount(page)).toBe(1)
- const calls = await page.evaluate(() => (window as unknown as { __installCalls: unknown[] }).__installCalls)
- expect(calls).toEqual([{ installPath: 'C:\\test-trainer' }])
+ const calls = await installCalls(page)
+ expect(calls).toEqual([{ installPath: 'D:\\CustomTrainer' }])
})
-test('an invalid path blocks: the backend rejects, no environment ever gets touched', async ({ page }, testInfo) => {
- await gotoReadyTrainer(page)
+test('a rejected install still counts as one call -- the note shows the error, not a second attempt', async ({ page }, testInfo) => {
+ // The Rust validation runs on whatever path install_character_trainer gets
+ // handed, independent of whether a human typed it. This uses a broken
+ // suggestedRoot to reach that path without an editable field.
+ await gotoReadyTrainer(page, { customized: false, suggestedRoot: 'relative-path-not-allowed', root: 'C:\\test-trainer' })
await page.getByRole('button', { name: 'Reinstall trainer', exact: true }).click()
const dialog = page.getByRole('dialog', { name: 'Reinstall the trainer?' })
- const field = dialog.locator('input')
- await field.fill('relative-path-not-allowed')
await dialog.getByRole('button', { name: 'Reinstall', exact: true }).click()
// Der Dialog schliesst optimistisch (dieselbe UX wie beim "Set up trainer"
- // des Erstsetup-Gates); die Ablehnung erscheint als Statuszeile.
+ // des Erstsetup-Gates); die Ablehnung erscheint als Statuszeile. Der Aufruf
+ // GEHT raus -- nur die Rust-Validierung dahinter lehnt ab.
const note = page.getByRole('status').filter({ hasText: 'absolute path' })
await expect(note).toBeVisible()
- expect(await installCallCount(page)).toBe(1)
+ expect(await installCalls(page)).toHaveLength(1)
await page.screenshot({ path: `${SHOT_DIR}/${testInfo.titlePath.length}-invalid-path-blocked.png` })
// Erneutes Klicken auf Reinstall haeuft keinen zweiten Aufruf auf den
// abgelehnten obendrauf -- der Knopf zeigt wieder sein Ruhe-Label.
diff --git a/src/components/create/experimental/SpecialIntentControls.tsx b/src/components/create/experimental/SpecialIntentControls.tsx
index 9a5ace89..1332923b 100644
--- a/src/components/create/experimental/SpecialIntentControls.tsx
+++ b/src/components/create/experimental/SpecialIntentControls.tsx
@@ -258,12 +258,19 @@ function CharacterPanel() {
)
}
-// Das Trainer-Installationspfad-Feld, gemeinsam genutzt vom Erstsetup-Gate
-// UND dem Reinstall-Bestaetigungsdialog (Z5-Fund, box-gruen/b): beide
-// brauchen genau dasselbe "Pfad eintippen wird zum Installationsziel"
-// Bedienelement mit derselben Rust-Validierung, also eine Komponente statt
-// zweier Kopien, die auseinanderlaufen koennten. `status` speist nur
+// Das Trainer-Installationspfad-Feld des Erstsetup-Gates. `status` speist nur
// `trainerRootHint`; Wert und Aenderungs-Handler gehoeren dem Aufrufer.
+//
+// A1-Korrektur (Final Review, 19.09.2026): dieses Feld war bis eben auch im
+// Reinstall-Dialog, mit demselben Ordner vorbelegt. Das war der Blocker: ein
+// Kunde, der bloss bestaetigt, schickte seinen bestehenden Standardordner als
+// nicht-leeren Pfad an install_character_trainer, und trainer_root_is_customized()
+// kippte auf true, obwohl sich nichts geaendert hatte -- die Cache-Migration
+// (apply_trainer_cache_env, trainer.rs:363) griff dann fuer einen Kunden, der
+// sie nie ausgeloest hatte, und liess pip/Torch mehrere GB neu laden, die
+// schon auf der Platte lagen. Der Reinstall-Dialog zeigt den Ordner jetzt nur
+// noch als Text (siehe TrainerReinstallModal) und schickt denselben leeren
+// bzw. vorbelegten Pfad wie vor dem Z5-Umbau.
function TrainerPathField({
value,
onChange,
@@ -288,15 +295,23 @@ function TrainerPathField({
// Z5 (box-gruen/b, e2e Windows, 18.09.2026): "Reinstall trainer" hat bisher
// install_character_trainer im selben Moment ausgeloest, in dem der Knopf
-// geklickt wurde, ohne Bestaetigung, ohne Chance, den Installationsordner
-// vorher zu sehen oder zu aendern. Die Rust-Seite loescht `<root>` dabei
-// NICHT (siehe Doc-Kommentar von provision_trainer_env: `<root>/train` und
-// `<root>/models` werden nie angefasst), ersetzt aber die venv (Rebuild oder
-// Torch/musubi neu installieren, siehe `venv_action`), und genau das hat den
-// Tester auf box-gruen mitten im Klick ueberrascht. Dieser Dialog sagt das
-// ehrlich, zeigt DASSELBE Pfad-Feld wie das Erstsetup (dieselbe Komponente,
-// dieselbe Rust-Validierung) und ruft den Install-Befehl erst auf, wenn der
-// Kunde "Reinstall" drueckt.
+// geklickt wurde, ohne Bestaetigung, ohne Chance, vorher zu sehen, was
+// passiert. Die Rust-Seite loescht `<root>` dabei NICHT (siehe Doc-Kommentar
+// von provision_trainer_env: `<root>/train` und `<root>/models` werden nie
+// angefasst), ersetzt aber die venv (Rebuild oder Torch/musubi neu
+// installieren, siehe `venv_action`), und genau das hat den Tester auf
+// box-gruen mitten im Klick ueberrascht. Dieser Dialog sagt das ehrlich und
+// ruft den Install-Befehl erst auf, wenn der Kunde "Reinstall" drueckt.
+//
+// A1/Blocker-Korrektur (Final Review, 19.09.2026): der Ordner ist hier nur
+// noch Text, nicht editierbar. Ein editierbares Feld, vorbelegt mit dem
+// bestehenden Ordner, hat jeden gewoehnlichen Reinstall (Kunde bestaetigt
+// ohne etwas zu aendern) zu einem "customized" Pfad gemacht und damit den
+// Cache-Migrationsschutz ausgeloest, den es hier nicht geben soll. Einen
+// anderen Ordner fuer den Trainer waehlen geht weiterhin nur ueber das
+// Erstsetup-Gate (TrainerPathField oben, bevor envReady zum ersten Mal wahr
+// wird); ein Weg, das nach der Erstinstallation zu aendern, existiert in der
+// App bisher nicht.
function TrainerReinstallModal({
open,
onClose,
@@ -306,27 +321,18 @@ function TrainerReinstallModal({
open: boolean
onClose: () => void
status: TrainerStatus
- onConfirm: (path: string) => void
+ onConfirm: () => void
}) {
- const [path, setPath] = useState(status.root)
- // Bei jedem Oeffnen frisch aus dem echten aktuellen Root setzen, damit ein
- // getippter und dann abgebrochener Pfad aus einem frueheren Oeffnen nie in
- // das naechste durchsickert, und das Feld immer mit dem startet, was
- // tatsaechlich gerade installiert ist.
- useEffect(() => {
- if (open) setPath(status.root)
- }, [open, status.root])
-
return (
<Modal open={open} onClose={onClose} title="Reinstall the trainer?">
<div className="space-y-4 text-sm text-gray-200">
<p className="t-body leading-relaxed text-gray-300">
- This replaces the trainer's Python environment: PyTorch and musubi-tuner get reinstalled from scratch. Your training photos and downloaded base models are not touched. Setup needs about 3 GB of downloads, same as the first install.
+ This sets up the trainer's Python environment again: PyTorch and musubi-tuner get reinstalled. Your training photos and downloaded base models are not touched. Setup needs about 3 GB of downloads, same as the first install.
</p>
- <TrainerPathField value={path} onChange={setPath} status={status} />
+ <p className="t-label text-gray-500 text-center">Trainer folder: {status.root}</p>
<div className="flex flex-col gap-2 pt-1">
<button
- onClick={() => onConfirm(path)}
+ onClick={onConfirm}
data-destructive
className="w-full px-4 py-2 rounded-lg bg-blue-500/20 hover:bg-blue-500/30 border border-blue-500/30 text-blue-200 text-sm font-medium transition-colors"
>
@@ -457,18 +463,17 @@ function LocalTrainControls() {
setBusy(null)
}
}
- // Z5 (box-gruen/b): der Reinstall-Dialog sammelt seinen EIGENEN Pfad
- // (vorbelegt aus dem aktuellen Root, siehe `TrainerReinstallModal`), fasst
- // also `installPath` nicht an -- das Feld gehoert dem Erstsetup-Gate oben,
- // das nicht mehr rendert, sobald `envReady` wahr ist.
- const confirmReinstall = async (path: string) => {
+ // Blocker-Korrektur (Final Review, 19.09.2026): der Reinstall-Dialog hat
+ // keinen eigenen Pfad mehr. Bestaetigen schickt GENAU das Argument, das der
+ // Knopf vor dem Z5-Umbau schickte -- `installPath.trim() || undefined`, der
+ // Zustand des Erstsetup-Gates oben, den ein Kunde, der das Feld nie
+ // angefasst hat, nie auf einen nicht-leeren Wert gebracht hat. Ohne diese
+ // Wiederverwendung wuerde jeder gewoehnliche Reinstall `trainer_root` auf
+ // einen nicht-leeren String setzen und `trainer_root_is_customized()`
+ // ungewollt auf true kippen.
+ const confirmReinstall = async () => {
setReinstallOpen(false)
- setBusy('install')
- setNote('Setting up the trainer...')
- try { await installCharacterTrainer(path.trim() || undefined) } catch (e) {
- setNote(e instanceof Error ? e.message : 'Install could not start.')
- setBusy(null)
- }
+ await startInstall()
}
const startBases = async () => {
if (!status) return
diff --git a/src/lib/release-notes.ts b/src/lib/release-notes.ts
index 7b1e2521..a44d23d1 100644
--- a/src/lib/release-notes.ts
+++ b/src/lib/release-notes.ts
@@ -158,7 +158,7 @@ export const RELEASE_NOTES: ReleaseNote[] = [
'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.',
- 'Reinstall trainer in Character Studio now opens a confirmation dialog first, showing the current trainer folder and the same install-path field as the first setup, instead of starting the reinstall the moment the button is clicked.',
+ 'Reinstall trainer in Character Studio now opens a confirmation dialog first, showing the current trainer folder, instead of starting the reinstall the moment the button is clicked.',
],
},
],