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.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(n3): engine death on the LU Engine line, separate ComfyUI in its own row, e2e
purple37e8a1974ddf
diff --git a/e2e/n3-plattform.spec.ts b/e2e/n3-plattform.spec.tsnew file mode 100644index 00000000..61fb9a9e--- /dev/null+++ b/e2e/n3-plattform.spec.ts@@ -0,0 +1,105 @@+import { test, expect, type Page } from '@playwright/test'+import { tauriMockInit, DEFAULT_MODEL_NAME } from './support/tauri-mock'+import { seedOnboardingDone } from './support/cloud-mock'++/**+ * N3 (3.1.0), clicked through in the real app with the Tauri bridge mocked:+ * C74 Linux without lspci: an empty card list names the missing pciutils,+ * and a card found through sysfs shows up with its note.+ * C81 The LU Engine died on its own: the chat says how, and Settings →+ * LU Engine keeps the sentence while no engine runs.+ * C80 A ComfyUI is found, and a separate one can still be installed:+ * pick a folder, see the target, nothing starts before the confirm.+ * LU_SHOTS=<folder> writes the screenshots there.+ */+const SHOTS = process.env.LU_SHOTS++const PCIUTILS = 'No graphics card found, and the lspci tool is missing on this system, so LU may simply not see your card. Install pciutils (Fedora/Bazzite: sudo dnf install pciutils, Debian/Ubuntu: sudo apt install pciutils, Arch: sudo pacman -S pciutils). Inside a container (Distrobox, Toolbox) install it there, and make sure the GPU is passed through. Without a detected card ComfyUI gets the slow processor build of PyTorch.'+const SYSFS_CARD = {+ index: 0,+ vendor: 'amd',+ name: 'Advanced Micro Devices, Inc. [AMD/ATI] Navi 21 [Radeon RX 6800/6800 XT / 6900 XT]',+ memory_mib: 16368,+ source: 'sysfs',+ note: 'Found without ROCm tools, so LU cannot confirm the compute backend. Ollama and ComfyUI can still use the card if their ROCm or ZLUDA build is installed. Listed from the kernel (/sys/class/drm) because lspci is not installed.',+ note_severity: 'warn',+}+const DIED = 'The LU Engine stopped unexpectedly (signal 6, SIGABRT). The graphics card ran out of memory. A smaller model, a shorter context or fewer GPU layers usually fixes this. It starts again with your next message; details are in the log.'++async function boot(page: Page, invokeOverrides: Record<string, unknown>) {+ await page.setViewportSize({ width: 1280, height: 860 })+ await page.addInitScript(tauriMockInit, { assistantReply: 'ok', modelName: DEFAULT_MODEL_NAME, platform: 'windows' as const, invokeOverrides })+ await seedOnboardingDone(page)+ await page.goto('/')+}++async function openSection(page: Page, title: string, tab = 'General') {+ await page.getByRole('banner').getByRole('button', { name: 'Settings', exact: true }).click()+ if (tab !== 'General') await page.getByRole('button', { name: tab, exact: true }).first().click()+ const section = page.getByRole('button', { name: title })+ await expect(section.first()).toBeVisible({ timeout: 15_000 })+ if ((await section.first().getAttribute('aria-expanded')) === 'false') await section.first().click()+}++test('C74: an empty card list on Linux without lspci names pciutils', async ({ page }) => {+ await boot(page, { detect_gpus: [], gpu_probe_hint: PCIUTILS })+ await openSection(page, 'Hardware (GPU picker)')+ const hint = page.getByTestId('gpu-probe-hint')+ await expect(hint).toHaveText(PCIUTILS)+ await hint.scrollIntoViewIfNeeded()+ if (SHOTS) await page.screenshot({ path: `${SHOTS}/c74-1-ohne-lspci-hinweis.png` })+})++test('C74: a card found through sysfs is listed with its note', async ({ page }) => {+ await boot(page, { detect_gpus: [SYSFS_CARD], gpu_probe_hint: PCIUTILS })+ await openSection(page, 'Hardware (GPU picker)')+ await expect(page.getByText(/Navi 21/).first()).toBeVisible()+ await expect(page.getByTestId('gpu-probe-hint')).toHaveCount(0)+ await page.getByText(/Navi 21/).first().scrollIntoViewIfNeeded()+ if (SHOTS) await page.screenshot({ path: `${SHOTS}/c74-2-karte-aus-sysfs.png` })+})++test('C81: the engine death is named on the engine line and in Settings', async ({ page }) => {+ await boot(page, { bundled_engine_status: { running: false, healthy: false, port: 8127, model_path: null, ctx: null, lastExit: DIED } })+ await expect.poll(() => page.evaluate(() => typeof (window as unknown as { __E2E_EMIT__?: unknown }).__E2E_EMIT__)).toBe('function')+ await page.getByRole('banner').getByRole('button', { name: 'Models', exact: true }).click()+ // Rust's watch reaped the engine and raises the event, the way engine.rs does.+ await expect.poll(async () => {+ await page.evaluate((message) => {+ const w = window as unknown as { __E2E_EMIT__: (e: string, p: unknown) => void }+ w.__E2E_EMIT__('lu-sidecar-gone', { sidecar: 'engine', port: 8127, signal: 6, exitCode: null, message })+ }, DIED)+ return page.getByTestId('lu-engine-switch-note').count()+ }, { timeout: 15_000 }).toBeGreaterThan(0)+ await expect(page.getByTestId('lu-engine-switch-note').first()).toContainText('The LU Engine stopped unexpectedly (signal 6, SIGABRT).')+ if (SHOTS) await page.screenshot({ path: `${SHOTS}/c81-1-engine-zeile.png` })+ await openSection(page, 'LU Engine (expert)', 'AI Backends')+ await expect(page.getByTestId('builtin-engine-last-exit')).toHaveText(DIED)+ await page.getByTestId('builtin-engine-last-exit').scrollIntoViewIfNeeded()+ if (SHOTS) await page.screenshot({ path: `${SHOTS}/c81-2-settings-engine.png` })+})++test('C80: a separate ComfyUI next to the found one', async ({ page }) => {+ await boot(page, {+ comfyui_status: { running: false, found: true, complete: true, path: 'C:\\Users\\Sam\\ComfyUI', port: 8188, isLocal: true },+ pick_folder: 'D:\\AI',+ })+ await openSection(page, 'ComfyUI (Image & Video)', 'AI Backends')+ const open = page.getByTestId('separate-comfy-open')+ await page.waitForTimeout(400)+ await open.scrollIntoViewIfNeeded()+ if (SHOTS) await page.screenshot({ path: `${SHOTS}/c80-1-knopf-settings.png` })+ await open.click()+ const line = page.getByTestId('separate-comfy-target')+ await expect(line).toContainText('D:\\AI\\ComfyUI')+ await page.waitForTimeout(400)+ await page.getByTestId('separate-comfy-confirm').scrollIntoViewIfNeeded()+ await expect(line).toContainText('C:\\Users\\Sam\\ComfyUI')+ if (SHOTS) await page.screenshot({ path: `${SHOTS}/c80-2-ziel-bestaetigen.png` })+ // The path field: typing alone changes nothing.+ const field = page.getByPlaceholder('C:\\ComfyUI')+ await field.fill('E:\\Other\\ComfyUI')+ await expect(page.getByTestId('comfy-path-connect-hint')).toBeVisible()+ await page.getByTestId('comfy-path-connect-hint').scrollIntoViewIfNeeded()+ if (SHOTS) await page.screenshot({ path: `${SHOTS}/c80-3-connect-hinweis.png` })+})diff --git a/e2e/support/tauri-mock.ts b/e2e/support/tauri-mock.tsindex 3f7366b0..f6cea894 100644--- a/e2e/support/tauri-mock.ts+++ b/e2e/support/tauri-mock.ts@@ -17,6 +17,12 @@*/export interface TauriMockOptions {+ /** Fixed answers for single commands, checked before the router (3.1.0,+ * N3): a spec that only needs one surface in a given state names the+ * command and its answer here instead of growing the router. Reads+ * `window.__E2E_INVOKE_OVERRIDES__` too, so a spec can change an answer+ * after the page has loaded. */+ invokeOverrides?: Record<string, unknown>/** Keep chat attachments (write/read_chat_attachment) for real, in* sessionStorage. Off by default: other specs keep the old no-op. */attachmentStore?: boolean@@ -911,6 +917,8 @@ export function tauriMockInit(opts: TauriMockOptions) {}function router(cmd: string, args: any): Promise<any> {+ const overrides = { ...(opts.invokeOverrides ?? {}), ...(w.__E2E_INVOKE_OVERRIDES__ ?? {}) }+ if (Object.prototype.hasOwnProperty.call(overrides, cmd)) return Promise.resolve(overrides[cmd])// The MLX wrappers (api/mlx-image.ts invokeMedia) nest their payload under// an `args` key to match the Rust `args: Value` signature — unwrap once so// the cases below read the fields the caller actually sent.@@ -2104,6 +2112,8 @@ export function tauriMockInit(opts: TauriMockOptions) {if (listener.event === event) callbacks[listener.handler]?.({ event, id: listener.handler, payload })}}+ // A spec raises a backend event the way Rust would (lu-sidecar-gone, N3).+ w.__E2E_EMIT__ = emitw.__TAURI_INTERNALS__ = {metadata: {diff --git a/src-tauri/src/commands/engine.rs b/src-tauri/src/commands/engine.rsindex 50e82ae6..93d5a133 100644--- a/src-tauri/src/commands/engine.rs+++ b/src-tauri/src/commands/engine.rs@@ -5418,47 +5418,77 @@ pub(crate) fn last_engine_exit_note() -> Option<String> {LAST_ENGINE_EXIT.lock().ok().and_then(|g| g.clone())}-/// The name and the usual cause of a POSIX signal, for the ones a model-/// server actually dies of.-fn signal_words(signal: i32) -> String {- match signal {- 9 => "SIGKILL, killed from outside; on Linux most often the system's out-of-memory killer".into(),- 6 => "SIGABRT, the engine stopped itself on an internal error, often a graphics driver (ROCm/CUDA/Vulkan) error".into(),- 11 => "SIGSEGV, a crash inside the engine or the graphics driver".into(),- 4 => "SIGILL, the processor does not support an instruction the engine uses".into(),- 7 => "SIGBUS, a memory access failed, e.g. the model file changed or the disk went away".into(),- 15 => "SIGTERM, asked to stop from outside LU".into(),- 2 => "SIGINT, interrupted".into(),- n => format!("signal {n}"),- }+/// The POSIX name of the signals a model server actually dies of.+fn signal_name(signal: i32) -> Option<&'static str> {+ Some(match signal {+ 2 => "SIGINT",+ 4 => "SIGILL",+ 6 => "SIGABRT",+ 7 => "SIGBUS",+ 9 => "SIGKILL",+ 11 => "SIGSEGV",+ 15 => "SIGTERM",+ _ => return None,+ })+}++/// What that signal usually means for a llama-server, in a user's words.+fn signal_meaning(signal: i32) -> Option<&'static str> {+ Some(match signal {+ 2 => "it was interrupted",+ 4 => "the processor does not support an instruction the engine uses",+ 6 => "the engine stopped itself on an internal error, often a graphics driver error",+ 7 => "a memory access failed, for example because the model file changed or its disk went away",+ 9 => "it was killed from outside, on Linux most often by the system's out-of-memory killer",+ 11 => "it crashed inside the engine or the graphics driver",+ 15 => "it was asked to stop from outside LU",+ _ => return None,+ })}/// Windows NTSTATUS crash codes, read back from `ExitStatus::code()`.-fn windows_code_words(code: i32) -> Option<&'static str> {+fn windows_code_meaning(code: i32) -> Option<&'static str> {match code as u32 {- 0xC000_0005 => Some("access violation, a crash inside the engine or the graphics driver"),- 0xC000_001D => Some("illegal instruction, the processor lacks AVX2"),- 0xC000_0409 => Some("fail-fast abort, the engine stopped itself on an internal error"),- 0xC000_00FD => Some("stack overflow"),- 0xC000_0017 | 0xC000_012D => Some("out of memory"),+ 0xC000_0005 => Some("it crashed inside the engine or the graphics driver (access violation)"),+ 0xC000_001D => Some("the processor lacks AVX2, which the engine needs"),+ 0xC000_0409 => Some("the engine stopped itself on an internal error"),+ 0xC000_00FD => Some("the engine ran out of stack"),+ 0xC000_0017 | 0xC000_012D => Some("the computer ran out of memory"),0xC000_0135 => Some("a DLL the engine needs was not found"),- 0xC000_013A => Some("stopped with Ctrl+C or Ctrl+Break"),+ 0xC000_013A => Some("it was stopped with Ctrl+C or Ctrl+Break"),_ => None,}}-/// "exit code 1", "signal 9 (SIGKILL, …)", "exit code -1073741819 (0xC0000005, access violation …)".-pub(crate) fn exit_cause_words(code: Option<i32>, signal: Option<i32>) -> String {+/// The short label: "signal 6, SIGABRT", "exit code 0xC0000005", "exit code 1".+fn exit_label(code: Option<i32>, signal: Option<i32>) -> String {match (code, signal) {- (_, Some(sig)) => format!("signal {sig} ({})", signal_words(sig)),- (Some(c), None) => match windows_code_words(c) {- Some(w) => format!("exit code {c} (0x{:08X}, {w})", c as u32),- None => format!("exit code {c}"),+ (_, Some(sig)) => match signal_name(sig) {+ Some(name) => format!("signal {sig}, {name}"),+ None => format!("signal {sig}"),},+ (Some(c), None) if windows_code_meaning(c).is_some() => format!("exit code 0x{:08X}", c as u32),+ (Some(c), None) => format!("exit code {c}"),(None, None) => "no exit code".into(),}}+fn exit_meaning(code: Option<i32>, signal: Option<i32>) -> Option<&'static str> {+ match (code, signal) {+ (_, Some(sig)) => signal_meaning(sig),+ (Some(c), None) => windows_code_meaning(c),+ (None, None) => None,+ }+}++/// For the log: "signal 6, SIGABRT: the engine stopped itself on …".+pub(crate) fn exit_cause_words(code: Option<i32>, signal: Option<i32>) -> String {+ match exit_meaning(code, signal) {+ Some(m) => format!("{}: {m}", exit_label(code, signal)),+ None => exit_label(code, signal),+ }+}+/// What the stderr tail says the trouble was, when it says something a user/// can act on. Read from the end: the last words are the cause.fn stderr_exit_hint(tail: &str) -> Option<&'static str> {@@ -5479,18 +5509,20 @@ fn stderr_exit_hint(tail: &str) -> Option<&'static str> {}/// The one sentence a user reads about an engine that stopped on its own.+///+/// What the engine itself said wins over what the signal usually means: a+/// "ROCm error: out of memory" before a SIGABRT is the cause, the abort only+/// the way it ended.pub(crate) fn engine_exit_note(exit: &SidecarExit) -> String {- let head = format!(- "The LU Engine stopped unexpectedly ({}).",- exit_cause_words(exit.code, exit.signal)- );- let hint = stderr_exit_hint(&exit.stderr_tail).or(match (exit.code, exit.signal) {- (_, Some(9)) => Some("This usually means the computer ran out of memory. A smaller model or a shorter context usually fixes this."),- _ => None,- });- match hint {- Some(h) => format!("{head} {h} It starts again with your next message; details are in the log."),- None => format!("{head} It starts again with your next message; details are in the log."),+ let label = exit_label(exit.code, exit.signal);+ let tail = "It starts again with your next message; details are in the log.";+ if let Some(hint) = stderr_exit_hint(&exit.stderr_tail) {+ return format!("The LU Engine stopped unexpectedly ({label}). {hint} {tail}");+ }+ let memory = if exit.signal == Some(9) { " A smaller model or a shorter context usually fixes this." } else { "" };+ match exit_meaning(exit.code, exit.signal) {+ Some(meaning) => format!("The LU Engine stopped unexpectedly ({label}): {meaning}.{memory} {tail}"),+ None => format!("The LU Engine stopped unexpectedly ({label}). {tail}"),}}@@ -9604,7 +9636,7 @@ mod tests {assert_eq!(exit.code, None);assert!(exit.stderr_tail.ends_with("ROCm error: out of memory"), "{exit:?}");let note = engine_exit_note(&exit);- assert!(note.contains("signal 6 (SIGABRT"), "{note}");+ assert!(note.starts_with("The LU Engine stopped unexpectedly (signal 6, SIGABRT). The graphics card ran out of memory."), "{note}");assert!(note.contains("ran out of memory"), "{note}");let payload = sidecar_gone_payload(SIDECAR_ENGINE, port, &exit);assert_eq!(payload["signal"], 6);@@ -9619,7 +9651,7 @@ mod tests {assert_eq!(exit.signal, Some(9));assert!(exit.stderr_tail.is_empty());let note = engine_exit_note(&exit);- assert!(note.contains("SIGKILL") && note.contains("ran out of memory"), "{note}");+ assert!(note.contains("(signal 9, SIGKILL): it was killed from outside") && note.contains("out-of-memory killer"), "{note}");}#[cfg(unix)]@@ -9639,12 +9671,12 @@ mod tests {fn exit_causes_read_like_words_on_every_platform() {assert_eq!(exit_cause_words(Some(1), None), "exit code 1");assert_eq!(exit_cause_words(None, None), "no exit code");- assert!(exit_cause_words(None, Some(11)).starts_with("signal 11 (SIGSEGV"));- assert!(exit_cause_words(None, Some(42)).starts_with("signal 42 (signal 42"));+ assert!(exit_cause_words(None, Some(11)).starts_with("signal 11, SIGSEGV: it crashed"));+ assert_eq!(exit_cause_words(None, Some(42)), "signal 42");// Windows hands NTSTATUS back as a negative i32.assert_eq!(exit_cause_words(Some(0xC000_0005u32 as i32), None),- "exit code -1073741819 (0xC0000005, access violation, a crash inside the engine or the graphics driver)",+ "exit code 0xC0000005: it crashed inside the engine or the graphics driver (access violation)",);assert!(exit_cause_words(Some(ILLEGAL_INSTRUCTION_EXIT_CODE), None).contains("AVX2"));// A driver error in the tail beats the generic signal guess.diff --git a/src/App.tsx b/src/App.tsxindex e6a3dc8c..d3de2d71 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -44,6 +44,9 @@ function App() {// So does the idle unload of the LU Engine (lib/engine-idle-unload.ts).void import('./lib/engine-idle-unload').then(({ startEngineIdleUnloadSync }) => startEngineIdleUnloadSync())+ // C81: an engine that died on its own says how (lib/engine-exit-notice.ts).+ void import('./lib/engine-exit-notice').then(({ startEngineExitNotices }) => startEngineExitNotices())+// The phone's tab name (GitHub #19) sits in Rust the same way// (lib/remote-page-title.ts).void import('./lib/remote-page-title').then(({ startRemotePageTitleSync }) => startRemotePageTitleSync())diff --git a/src/components/chat/ChatNotices.tsx b/src/components/chat/ChatNotices.tsxindex e7f4e759..ff511584 100644--- a/src/components/chat/ChatNotices.tsx+++ b/src/components/chat/ChatNotices.tsx@@ -11,7 +11,7 @@* fuer Anmerkungen und Fehler vorschreibt: eine Zeile, kein Kasten, ruhiges* Grau oder Rot, und ein x, das sie wegnimmt.*/-import { Binary, Bot, Download, FileText, FolderOpen, ImageOff, Images, Paperclip, PowerOff, Scissors } from 'lucide-react'+import { Binary, Bot, Download, FileText, FolderOpen, ImageOff, Images, Paperclip, Scissors } from 'lucide-react'import { Hinweis } from '../ui/Hinweis'import { useChatNoticeStore, CONVERSATION_BOUND, type ChatNoticeId } from '../../stores/chatNoticeStore'import { COMPOSER_MAX_W } from './composer-width'@@ -32,7 +32,6 @@ const ICON: Record<ChatNoticeId, typeof Paperclip> = {'agent-outside-workspace': FolderOpen,'agent-for-local-files': Bot,'create-save': Download,- 'engine-stopped': PowerOff,}diff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsxindex 98d4b17b..7b4b19e0 100644--- a/src/components/settings/SettingsPage.tsx+++ b/src/components/settings/SettingsPage.tsx@@ -1391,17 +1391,6 @@ export function ComfyUISettings() {Update ComfyUI</button>)}- {/* C80 (GitHub #230): a second, separate install next to the found one. */}- {status?.found && status?.complete !== false && installIdle && (- <SeparateComfyInstall- currentPath={status?.path}- onInstall={(target) => {- clearInstallNotice()- void useComfyInstallStore.getState().runInstall(target)- }}- buttonClassName="flex items-center gap-1 px-2 py-1 rounded t-micro bg-white/5 text-gray-400 hover:text-gray-200 hover:bg-white/10 transition-colors"- />- )}{(!status?.found || status?.complete === false) && installIdle && (<p className="w-full t-micro text-gray-600">Installs to your home folder by default. Set Path above (e.g. D:\ComfyUI) to install on another drive.@@ -1490,6 +1479,18 @@ export function ComfyUISettings() {)}</div>)}+ {/* C80 (GitHub #230): a second, separate install next to the found one.+ Its own row: the button row above does not wrap. */}+ {status?.isLocal !== false && status?.found && status?.complete !== false && installIdle && (+ <SeparateComfyInstall+ currentPath={status?.path}+ onInstall={(target) => {+ clearInstallNotice()+ void useComfyInstallStore.getState().runInstall(target)+ }}+ buttonClassName="flex items-center gap-1 px-2 py-1 rounded t-micro bg-white/5 text-gray-400 hover:text-gray-200 hover:bg-white/10 transition-colors"+ />+ )}<ComfyUpdateConfirmModalopen={updateConfirmOpen}onClose={() => setUpdateConfirmOpen(false)}diff --git a/src/components/settings/__tests__/engine-status-follows-a-dead-sidecar.test.ts b/src/components/settings/__tests__/engine-status-follows-a-dead-sidecar.test.tsindex b3efabf0..f1f4fc6c 100644--- a/src/components/settings/__tests__/engine-status-follows-a-dead-sidecar.test.ts+++ b/src/components/settings/__tests__/engine-status-follows-a-dead-sidecar.test.ts@@ -112,7 +112,7 @@ describe('an engine killed from outside while the panel stands open', () => {// of the exit status and the last stderr lines.it('names the cause of the death while no engine runs', async () => {await panelWithARunningEngine()- const why = 'The LU Engine stopped unexpectedly (signal 9 (SIGKILL, killed from outside)).'+ const why = 'The LU Engine stopped unexpectedly (signal 9, SIGKILL): it was killed from outside.'bundledEngineStatus.mockResolvedValue({ ...DEAD, lastExit: why })await fireSidecarGone()expect(screen.getByTestId('builtin-engine-last-exit').textContent).toBe(why)diff --git a/src/hooks/useBuiltinEngineStatus.ts b/src/hooks/useBuiltinEngineStatus.tsindex 87b20fa0..9e37125e 100644--- a/src/hooks/useBuiltinEngineStatus.ts+++ b/src/hooks/useBuiltinEngineStatus.ts@@ -19,7 +19,6 @@ import { useEffect, useRef, useState } from 'react'import { bundledEngineStatus, type EngineStatus } from '../api/engine'import { isTauri } from '../api/backend'import { onAppForeground } from '../lib/app-lifecycle'-import { noteSidecarGone } from '../lib/engine-exit-notice'/** Rust meldet den eingesammelten toten Griff hierunter. */export const SIDECAR_GONE_EVENT = 'lu-sidecar-gone'@@ -65,7 +64,7 @@ export function useBuiltinEngineStatus(pausiert?: () => boolean): EngineStatusViconst timer = setInterval(read, ENGINE_STATUS_POLL_MS)let unlisten: (() => void) | null = nullvoid import('@tauri-apps/api/event')- .then(({ listen }) => listen(SIDECAR_GONE_EVENT, (event) => { noteSidecarGone(event.payload); read() }))+ .then(({ listen }) => listen(SIDECAR_GONE_EVENT, () => read())).then((off) => { if (alive) unlisten = off; else off() }).catch(() => {})// After a stay in the background the interval was frozen and the enginediff --git a/src/lib/__tests__/engine-exit-notice.test.ts b/src/lib/__tests__/engine-exit-notice.test.tsindex b4e1fb9c..1f403a28 100644--- a/src/lib/__tests__/engine-exit-notice.test.ts+++ b/src/lib/__tests__/engine-exit-notice.test.ts@@ -1,23 +1,22 @@/**- * C81 (3.1.0): an engine that dies on its own is named, with its cause, above- * the chat. Negative control: return null from engineStoppedMessage and the- * first case turns red.+ * C81 (3.1.0): an engine that dies on its own is named, with its cause, on the+ * LU Engine line. Negative control: return null from engineStoppedMessage and+ * the first case turns red.*/import { describe, it, expect, beforeEach } from 'vitest'-import { engineStoppedMessage, noteSidecarGone, ENGINE_STOPPED_NOTICE_MS } from '../engine-exit-notice'-import { useChatNoticeStore } from '../../stores/chatNoticeStore'+import { engineStoppedMessage, noteSidecarGone } from '../engine-exit-notice'+import { useLuEngineSwitchStore } from '../../stores/luEngineSwitchStore'-const SENTENCE = 'The LU Engine stopped unexpectedly (signal 6 (SIGABRT, …)). The graphics card ran out of memory.'+const SENTENCE = 'The LU Engine stopped unexpectedly (signal 6, SIGABRT). The graphics card ran out of memory.'-beforeEach(() => useChatNoticeStore.getState().clear())+beforeEach(() => useLuEngineSwitchStore.getState().dismiss())-describe('C81: the engine death reaches the chat', () => {- it('shows the sentence Rust sent for the chat engine', () => {+describe('C81: the engine death reaches the engine line', () => {+ it('announces the sentence Rust sent for the chat engine, as an error', () => {noteSidecarGone({ sidecar: 'engine', port: 8127, signal: 6, message: SENTENCE })- const n = useChatNoticeStore.getState().notices- expect(n).toHaveLength(1)- expect(n[0]).toMatchObject({ id: 'engine-stopped', text: SENTENCE, ton: 'fehler' })- expect(ENGINE_STOPPED_NOTICE_MS).toBeGreaterThanOrEqual(30_000)+ const s = useLuEngineSwitchStore.getState()+ expect(s.note).toBe(SENTENCE)+ expect(s.tone).toBe('error')})it('says nothing for the embeddings server, an old payload or garbage', () => {@@ -25,14 +24,7 @@ describe('C81: the engine death reaches the chat', () => {noteSidecarGone({ sidecar: 'engine', port: 8127 })noteSidecarGone(null)noteSidecarGone('engine')- expect(useChatNoticeStore.getState().notices).toHaveLength(0)+ expect(useLuEngineSwitchStore.getState().note).toBeNull()expect(engineStoppedMessage({ sidecar: 'engine', message: ' ' })).toBeNull()})-- it('a second death replaces the line instead of stacking', () => {- noteSidecarGone({ sidecar: 'engine', message: 'first' })- noteSidecarGone({ sidecar: 'engine', message: 'second' })- const n = useChatNoticeStore.getState().notices- expect(n.map((x) => x.text)).toEqual(['second'])- })})diff --git a/src/lib/engine-exit-notice.ts b/src/lib/engine-exit-notice.tsindex e6cdd371..1eda23f5 100644--- a/src/lib/engine-exit-notice.ts+++ b/src/lib/engine-exit-notice.ts@@ -5,13 +5,15 @@* neither the log nor the window said why. Rust now reads the exit code or* signal and the last stderr lines when it reaps the process, and sends one* sentence with the `lu-sidecar-gone` event (`message`, chat engine only).- * This shows that sentence above the chat history, where the other chat- * notices live (stores/chatNoticeStore.ts).+ * That sentence goes on the LU Engine line (stores/luEngineSwitchStore.ts),+ * the place every other engine event already uses, as an error: it stays+ * until it was seen and dismissed, not on a clock.*/-import { useChatNoticeStore } from '../stores/chatNoticeStore'+import { isTauri } from '../api/backend'+import { useLuEngineSwitchStore } from '../stores/luEngineSwitchStore'-/** Long enough to read a two-sentence cause, short enough not to linger. */-export const ENGINE_STOPPED_NOTICE_MS = 60_000+/** Rust's event when its watch reaped a dead sidecar (commands/engine.rs). */+export const SIDECAR_GONE_EVENT = 'lu-sidecar-gone'/** Pure: the sentence in a `lu-sidecar-gone` payload, or null. */export function engineStoppedMessage(payload: unknown): string | null {@@ -21,9 +23,19 @@ export function engineStoppedMessage(payload: unknown): string | null {return typeof p.message === 'string' && p.message.trim() ? p.message.trim() : null}-/** Called for every `lu-sidecar-gone`; shows the sentence when there is one. */+/** Called for every `lu-sidecar-gone`; announces the sentence when there is one. */export function noteSidecarGone(payload: unknown): void {const message = engineStoppedMessage(payload)if (!message) return- useChatNoticeStore.getState().show('engine-stopped', message, 'fehler', ENGINE_STOPPED_NOTICE_MS)+ useLuEngineSwitchStore.getState().announce(message, 'error')+}++/** At boot (App.tsx): one listener for the life of the window. */+export function startEngineExitNotices(): void {+ if (!isTauri()) return+ void import('@tauri-apps/api/event')+ .then(({ listen }) => listen(SIDECAR_GONE_EVENT, (event) => noteSidecarGone(event.payload)))+ .catch(() => {+ /* a build without events keeps the Settings line (lastExit) */+ })}diff --git a/src/stores/chatNoticeStore.ts b/src/stores/chatNoticeStore.tsindex 0b62df3c..a4793e5c 100644--- a/src/stores/chatNoticeStore.ts+++ b/src/stores/chatNoticeStore.ts@@ -34,7 +34,7 @@ import { useChatStore } from './chatStore'/** Die Zeilen, die es gibt. Kein freier Schluessel: eine Aufzaehlung laesst* sich nachzaehlen, ein String-Schluessel waechst unbemerkt. */-export type ChatNoticeId = 'document-belongs-in-docs' | 'model-cannot-see-images' | 'image-attach' | 'file-attach' | 'binary-summary-only' | 'file-cut' | 'agent-outside-workspace' | 'agent-for-local-files' | 'create-save' | 'engine-stopped'+export type ChatNoticeId = 'document-belongs-in-docs' | 'model-cannot-see-images' | 'image-attach' | 'file-attach' | 'binary-summary-only' | 'file-cut' | 'agent-outside-workspace' | 'agent-for-local-files' | 'create-save'export interface ChatNotice {id: ChatNoticeId