Desktop: background store reads from the tray (no document.hidden skip, backoff), notifications by kind (rejected, approved, live, halted, crash, reviews) with switches, quiet hours and mute, click-through on next show; tray menu with apps and their states, read now, mute, updates, settings, tooltip summary and attention dot; tray_update command; tests

This commit is contained in:
CRTkafa 2026-10-22 22:24:05 +08:00
parent 5d8a0f5e9a
commit 03ef999dac
27 changed files with 1050 additions and 55 deletions

View file

@ -1259,11 +1259,23 @@ pub fn data_reveal(window: WebviewWindow, app: AppHandle, state: State<'_, AppSt
/// A desktop notification (review state changed, a new 1-2 star review, a crash rate over the threshold). The window
/// decides when, from Settings > Notifications; text is plain and short.
#[tauri::command]
pub fn notify(window: WebviewWindow, app: AppHandle, title: String, body: String) -> Res<()> {
pub fn notify(window: WebviewWindow, app: AppHandle, title: String, body: String, target: Option<String>) -> Res<()> {
guard(&window)?;
use tauri_plugin_notification::NotificationExt;
let cut = |s: &str, n: usize| s.chars().filter(|c| !c.is_control()).take(n).collect::<String>();
app.notification().builder().title(cut(&title, 80)).body(cut(&body, 240)).show().map_err(|e| Fail::host(e.to_string()))
app.notification().builder().title(cut(&title, 80)).body(cut(&body, 240)).show().map_err(|e| Fail::host(e.to_string()))?;
// desktop notifications have no click callback: remember where this one points; the window goes there when it is next shown
if let Some(t) = target {
crate::tray::set_pending(&t);
}
Ok(())
}
/// The window's summary for the tray (tooltip, attention flag, apps with their state, menu words) after a read.
#[tauri::command]
pub fn tray_update(window: WebviewWindow, app: AppHandle, summary: crate::tray::TraySummary) -> Res<()> {
guard(&window)?;
crate::tray::apply(&app, &summary).map_err(|e| Fail::host(e.to_string()))
}
/// Forgets everything after a native confirmation: store keys (keychain), studios, accounts, app folders (the folders