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(settings): jeder geglueckte Lauf hinterlaesst eine Ergebniszeile, und die Sektion zeigt sie auch

purpleac33b792b6ce
diff --git a/src-tauri/src/commands/install.rs b/src-tauri/src/commands/install.rs
index 363cf32b..2dc5672e 100644
--- a/src-tauri/src/commands/install.rs
+++ b/src-tauri/src/commands/install.rs
@@ -609,6 +609,19 @@ pub(crate) fn requirements_failure_reason(pip_output: &str) -> &'static str {
}
}
+/// The same question asked of a whole pip failure rather than of its text.
+///
+/// A15 review: an empty `stderr` means pip never wrote any, so the process
+/// could not be started or could not be reaped. Classifying the diagnosis in
+/// that case comes out as "pip exited with an error", which is precisely what
+/// did not happen.
+pub(crate) fn requirements_failure_reason_for(f: &PipFailure) -> &'static str {
+ if f.stderr.is_empty() {
+ return "pip could not be started";
+ }
+ requirements_failure_reason(&f.stderr)
+}
+
/// The live log line that names the fallback while it happens.
pub(crate) fn requirements_fallback_log(folder: &str, reason: &str) -> String {
format!(
@@ -617,9 +630,29 @@ pub(crate) fn requirements_fallback_log(folder: &str, reason: &str) -> String {
)
}
-/// The line the finished run leaves behind, so the fallback survives the last
-/// poll. Without it the panel goes back to idle and every word about the
-/// skipped file scrolls away with the log.
+/// The line every finished run leaves behind.
+///
+/// David, 03.09.: a run that worked has to say so. The cancel already had a
+/// closing sentence and the success had none, so the abort was better labelled
+/// than the success (A13 Befund 1a), and three full repairs of six to eight
+/// minutes each ended with the card simply vanishing. The requirements hint is
+/// appended rather than substituted: the run did finish, and the user needs
+/// both halves of that.
+pub(crate) fn finished_notice(
+ done: &str,
+ fallback: Option<&(String, &'static str)>,
+) -> String {
+ match fallback {
+ Some((folder, reason)) => {
+ format!("{} {}", done, requirements_fallback_notice(folder, reason))
+ }
+ None => done.to_string(),
+ }
+}
+
+/// The half sentence about a requirements.txt the run had to pass over. Without
+/// it the panel goes back to idle and every word about the skipped file scrolls
+/// away with the log.
pub(crate) fn requirements_fallback_notice(folder: &str, reason: &str) -> String {
format!(
"The requirements.txt in {} could not be used ({}), so LU installed its own package \
@@ -2153,11 +2186,7 @@ pub fn install_comfyui(
// gone is the old "non-critical" verdict, which called
// a broken environment a finished one.
println!("[Install] Requirements install warning: {}", diagnosis);
- let reason = requirements_failure_reason(if f.stderr.is_empty() {
- &diagnosis
- } else {
- &f.stderr
- });
+ let reason = requirements_failure_reason_for(&f);
let folder = target_dir.display().to_string();
requirements_fallback = Some((folder.clone(), reason));
update("installing", &requirements_fallback_log(&folder, reason));
@@ -2220,10 +2249,11 @@ pub fn install_comfyui(
);
}
- if let Some((folder, reason)) = requirements_fallback.as_ref() {
- if let Ok(mut s) = install_status.lock() {
- s.notice = requirements_fallback_notice(folder, reason);
- }
+ if let Ok(mut s) = install_status.lock() {
+ s.notice = finished_notice(
+ "Install finished. ComfyUI is ready to start.",
+ requirements_fallback.as_ref(),
+ );
}
update("complete", "ComfyUI installed successfully!");
});
@@ -2401,11 +2431,7 @@ pub fn repair_comfyui_env(state: State<'_, AppState>) -> Result<serde_json::Valu
return;
}
Err(f) => {
- let reason = requirements_failure_reason(if f.stderr.is_empty() {
- &f.diagnosis
- } else {
- &f.stderr
- });
+ let reason = requirements_failure_reason_for(&f);
let folder = comfy_dir.display().to_string();
requirements_fallback = Some((folder.clone(), reason));
update("installing", &requirements_fallback_log(&folder, reason));
@@ -2437,10 +2463,11 @@ pub fn repair_comfyui_env(state: State<'_, AppState>) -> Result<serde_json::Valu
}
}
- if let Some((folder, reason)) = requirements_fallback.as_ref() {
- if let Ok(mut s) = install_status.lock() {
- s.notice = requirements_fallback_notice(folder, reason);
- }
+ if let Ok(mut s) = install_status.lock() {
+ s.notice = finished_notice(
+ "Repair finished. ComfyUI is ready.",
+ requirements_fallback.as_ref(),
+ );
}
update(
"complete",
@@ -2629,11 +2656,7 @@ pub fn update_comfyui(state: State<'_, AppState>) -> Result<serde_json::Value, S
}
Err(f) => {
println!("[Update] Requirements warning: {}", f.diagnosis);
- let reason = requirements_failure_reason(if f.stderr.is_empty() {
- &f.diagnosis
- } else {
- &f.stderr
- });
+ let reason = requirements_failure_reason_for(&f);
let folder = comfy_dir.display().to_string();
requirements_fallback = Some((folder.clone(), reason));
update("installing", &requirements_fallback_log(&folder, reason));
@@ -2663,10 +2686,11 @@ pub fn update_comfyui(state: State<'_, AppState>) -> Result<serde_json::Value, S
}
println!("[Update] ComfyUI update complete");
- if let Some((folder, reason)) = requirements_fallback.as_ref() {
- if let Ok(mut s) = install_status.lock() {
- s.notice = requirements_fallback_notice(folder, reason);
- }
+ if let Ok(mut s) = install_status.lock() {
+ s.notice = finished_notice(
+ "Update finished. Restart ComfyUI to load the new nodes.",
+ requirements_fallback.as_ref(),
+ );
}
update(
"complete",
@@ -5014,16 +5038,62 @@ mod tests {
}
}
- /// Negative control: a run with nothing to add leaves no closing line, so
- /// the panel is not decorated with a warning after a clean rebuild.
+ /// Negative control on the state itself: nothing is carried over from a
+ /// run that never happened.
#[test]
- fn a_run_that_used_the_requirements_file_leaves_no_notice() {
+ fn a_fresh_install_state_carries_no_closing_line() {
let fresh = crate::state::InstallState::default();
assert!(fresh.notice.is_empty());
let json = serde_json::to_value(&fresh).expect("serialises");
assert_eq!(json["notice"], serde_json::json!(""));
}
+ /// David, 03.09.: a run that worked says so, every time.
+ #[test]
+ fn a_run_that_worked_leaves_a_closing_line_of_its_own() {
+ for done in [
+ "Install finished. ComfyUI is ready to start.",
+ "Repair finished. ComfyUI is ready.",
+ "Update finished. Restart ComfyUI to load the new nodes.",
+ ] {
+ assert_eq!(finished_notice(done, None), done);
+ }
+ }
+
+ /// And a run that had to skip the requirements.txt says both halves, in
+ /// that order: it finished, and here is what it could not use.
+ #[test]
+ fn a_finished_run_that_skipped_the_file_says_both_halves() {
+ let fallback = (
+ "C:\\Users\\ddrob\\ComfyUI".to_string(),
+ requirements_failure_reason(INVENTED_PACKAGE),
+ );
+ let line = finished_notice("Repair finished. ComfyUI is ready.", Some(&fallback));
+ assert!(line.starts_with("Repair finished. ComfyUI is ready. "), "got: {line}");
+ assert!(line.contains("could not be used"), "got: {line}");
+ assert!(line.contains("C:\\Users\\ddrob\\ComfyUI"), "got: {line}");
+ // Negative control on the substitution: the success half is not
+ // replaced by the warning, which is what a run that finished deserves.
+ assert!(line.contains("Repair finished"), "got: {line}");
+ }
+
+ /// A pip that never started is not a pip that exited with an error.
+ #[test]
+ fn a_pip_that_never_ran_is_not_reported_as_a_pip_that_failed() {
+ let never_ran = PipFailure::bare("Could not start pip (not found). Is Python on PATH?");
+ assert_eq!(requirements_failure_reason_for(&never_ran), "pip could not be started");
+ // Negative control: a real pip failure keeps its own classification and
+ // does not fall into the "could not be started" arm.
+ let really_failed = PipFailure {
+ diagnosis: "whatever the hint says".to_string(),
+ stderr: INVENTED_PACKAGE.to_string(),
+ };
+ assert_eq!(
+ requirements_failure_reason_for(&really_failed),
+ "pip found no installable version for a package it names"
+ );
+ }
+
// ── PyTorch-Kanalwahl (W2-Befund 16.08., comfy_kitchen braucht 2.6+) ─
#[test]
diff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsx
index 2854e110..e4f35c08 100644
--- a/src/components/settings/SettingsPage.tsx
+++ b/src/components/settings/SettingsPage.tsx
@@ -1579,7 +1579,7 @@ export function SettingsPage() {
// subscribing, because the value is only ever wanted at the moment
// this Section mounts, which is the moment a section switch brings
// it back.
- <Section title="ComfyUI (Image & Video)" defaultOpen={entryFocus?.section === 'comfyui' || comfySectionShouldOpen(useComfyInstallStore.getState().phase)}>
+ <Section title="ComfyUI (Image & Video)" defaultOpen={entryFocus?.section === 'comfyui' || comfySectionShouldOpen(useComfyInstallStore.getState())}>
{settings.appMode === 'cloud' && (
<p className="text-[0.55rem] text-gray-500 leading-snug pb-1">
Local mode only. Cloud renders run on lu-labs.ai and never use ComfyUI.
diff --git a/src/stores/__tests__/comfy-install-notice.test.ts b/src/stores/__tests__/comfy-install-notice.test.ts
index add95b70..4d8021dc 100644
--- a/src/stores/__tests__/comfy-install-notice.test.ts
+++ b/src/stores/__tests__/comfy-install-notice.test.ts
@@ -63,7 +63,9 @@ describe('a repair that had to skip the requirements.txt says so at the end', ()
expect(store().notice).toContain('is not installed')
})
- it('leaves no line behind when the run used the file it found', async () => {
+ it('carries only what the backend sent, and nothing of its own', async () => {
+ // Negative control on the wiring: the store does not invent a line, it
+ // relays one. A backend that sends an empty notice leaves the panel bare.
await repairThatEndsWith({
status: 'complete',
logs: ['Dependencies installed.', 'All packages import cleanly.'],
@@ -91,13 +93,39 @@ describe('a repair that had to skip the requirements.txt says so at the end', ()
})
describe('the ComfyUI section opens itself while a run is on screen', () => {
- it('opens for every phase that is not idle, and stays shut for idle', async () => {
+ it('opens for every phase that is not idle, and stays shut for an empty idle', async () => {
const { comfySectionShouldOpen } = await import('../comfyInstallStore')
for (const phase of ['checking', 'python', 'comfyui', 'repair', 'error'] as const) {
- expect(comfySectionShouldOpen(phase)).toBe(true)
+ expect(comfySectionShouldOpen({ phase, notice: '' })).toBe(true)
}
- // Negative control: a settings page with nothing running must not force the
- // section open, or the accordion would be no accordion at all.
- expect(comfySectionShouldOpen('idle')).toBe(false)
+ // Negative control: a settings page with nothing running and nothing to
+ // report must not force the section open, or the accordion would be no
+ // accordion at all.
+ expect(comfySectionShouldOpen({ phase: 'idle', notice: '' })).toBe(false)
+ })
+
+ it('opens for the closing line a finished run left behind', async () => {
+ // Review 03.09.: the panel renders the closing line only while the phase is
+ // idle, so asking about the phase alone folded the section shut in exactly
+ // the one state the line exists in. An eight minute repair then reported
+ // its result to nobody.
+ const { comfySectionShouldOpen } = await import('../comfyInstallStore')
+ expect(comfySectionShouldOpen({ phase: 'idle', notice: 'Repair finished. ComfyUI is ready.' }))
+ .toBe(true)
+ expect(comfySectionShouldOpen({ phase: 'idle', notice: SKIPPED })).toBe(true)
+ })
+})
+
+describe('a run that simply worked still says so', () => {
+ it('keeps the closing line of a clean repair', async () => {
+ await repairThatEndsWith({
+ status: 'complete',
+ logs: ['All packages import cleanly.'],
+ notice: 'Repair finished. ComfyUI is ready.',
+ })
+ expect(store().phase).toBe('idle')
+ expect(store().notice).toBe('Repair finished. ComfyUI is ready.')
+ const { comfySectionShouldOpen } = await import('../comfyInstallStore')
+ expect(comfySectionShouldOpen(store())).toBe(true)
})
})
diff --git a/src/stores/comfyInstallStore.ts b/src/stores/comfyInstallStore.ts
index c57bd5da..4272be58 100644
--- a/src/stores/comfyInstallStore.ts
+++ b/src/stores/comfyInstallStore.ts
@@ -58,15 +58,24 @@ export const LOST_CONTACT = 'Lost contact with the installer. Check the log and
export const LOST_CONTACT_PYTHON = 'Lost contact with the Python installer. Check the log and try again.'
/** True while the ComfyUI section has something the user must not miss: a run
- * in flight, or a failure nobody has dismissed yet.
+ * in flight, a failure nobody has dismissed yet, or the closing line a run
+ * left behind.
*
* A15, Windows Nachlauf 02.09.: the section is an ordinary accordion, so a
* trip to General and back folded it up again while a twenty minute repair was
* still running. The progress itself survives the remount (that is what this
* store is for), but it survives behind a closed lid, and a user who does not
- * think to open it sees an app that looks idle. */
-export function comfySectionShouldOpen(phase: ComfyInstallPhase): boolean {
- return phase !== 'idle'
+ * think to open it sees an app that looks idle.
+ *
+ * Review 03.09.: the first cut asked about the phase alone, and the panel
+ * renders the closing line only while the phase is idle. So the one state the
+ * line exists in was the one state that folded the section shut, and the
+ * result of a run that had just taken eight minutes was gone on the next
+ * section switch. Both halves are asked about now. */
+export function comfySectionShouldOpen(
+ run: { phase: ComfyInstallPhase; notice: string },
+): boolean {
+ return run.phase !== 'idle' || run.notice !== ''
}
/** The one poll in flight, module level so it outlives every mount. */