M1.12: notifications as toasts

The host publishes picker, command-line and pump errors as notification
events (Engine::notify, same id sequence) instead of stderr, keeps
notifications and watchFailed published before engine_ready and replays
them after the state replay, so startup warnings (corrupt settings,
journal entries) reach the UI. ipc.ts announces engine_ready once all
subscriptions started together are registered.

Frontend: notifications store and NotificationStack (bottom right, info
auto-dismissed after 5 s, warnings/errors stay, close button and Escape,
at most 5 visible with "+n more", role status/alert); watchFailed maps to
a warning toast; failed commands without their own UI raise an error
toast. Catalog keys notification.settings.*, project.*, vfs.*, watch.*,
command.* plus the runtime allow-list. Docs updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-16 16:20:45 +02:00
parent 7b7273a947
commit f41df518b5
21 changed files with 1178 additions and 94 deletions

View file

@ -15,7 +15,7 @@ mod screenshot;
use std::process::ExitCode;
use std::sync::{Arc, OnceLock};
use lutra_engine::{CommandInfo, Engine, EngineConfig, ErrorPayload, Event, theme};
use lutra_engine::{CommandInfo, Engine, EngineConfig, ErrorPayload, theme};
use serde_json::Value;
use tauri::window::Color;
use tauri::{Manager, WebviewUrl, WebviewWindowBuilder};
@ -87,15 +87,16 @@ fn run(args: &args::Args) -> Result<(), String> {
if let Some(path) = &initial_path
&& let Err(e) = setup_host.open_project(path)
{
eprintln!("lutra: cannot open {}: {e}", path.display());
setup_host.report_open_failure(path, &e);
}
Ok(())
})
.build(tauri::generate_context!())
.map_err(|e| e.to_string())?;
let mut engine = Engine::with_config(engine_config(&app)?).map_err(|e| e.to_string())?;
log_startup_events(&engine.take_events());
let startup = engine.take_events();
let host = Host::new(engine);
host.publish_startup(&startup);
app.manage(host.clone());
if slot.set(host.clone()).is_err() {
return Err("the host was set twice".into());
@ -128,21 +129,6 @@ fn engine_config(app: &tauri::App) -> Result<EngineConfig, String> {
})
}
/// Logs the notifications the engine queued while starting, such as the
/// fallback to default settings, to stderr.
fn log_startup_events(events: &[Event]) {
for event in events {
if let Event::Notification {
level,
message: Some(message),
..
} = event
{
eprintln!("lutra: {level:?}: {message}");
}
}
}
/// The stored `appearance.theme` value, `system` if it cannot be read.
fn stored_theme(host: &Host) -> String {
host.run(
@ -199,7 +185,7 @@ fn engine_list_commands(host: tauri::State<'_, Arc<Host>>) -> Vec<CommandInfo> {
}
/// IPC: the frontend listens for engine events now; replays the current
/// project state it may have missed while loading.
/// project state and the notifications it may have missed while loading.
#[tauri::command]
fn engine_ready(host: tauri::State<'_, Arc<Host>>) {
host.replay_to_window();