//! Phase 5 of the feature-complete roadmap: start- and shutdown-rituals. //! //! Layer-1 scope is narrow. The frontend owns rendering and logic; this //! module only persists the "last date the morning triage modal was //! shown" sentinel so the modal can refuse to re-prompt on the same //! calendar day. Task queries re-use `list_tasks_cmd` with client-side //! filtering rather than adding a second query path. //! //! Stored under the existing SQLite settings table via //! `kon_storage::{get_setting, set_setting}` — same bag as //! `kon_preferences`. use kon_storage::{get_setting, set_setting}; use crate::AppState; const LAST_TRIAGE_KEY: &str = "kon_morning_triage_last_shown"; /// Returns the YYYY-MM-DD date string stored on the last successful /// morning triage dismissal, or `None` if the user has never been /// shown the modal. #[tauri::command] pub async fn get_last_morning_triage( state: tauri::State<'_, AppState>, ) -> Result, String> { get_setting(&state.db, LAST_TRIAGE_KEY) .await .map_err(|e| e.to_string()) } /// Records that the morning triage modal was shown (and either skipped /// or completed) on `date`. Caller is responsible for passing a valid /// YYYY-MM-DD string in the user's local timezone — Rust deliberately /// stays timezone-agnostic here so the frontend retains control. #[tauri::command] pub async fn mark_morning_triage_shown( state: tauri::State<'_, AppState>, date: String, ) -> Result<(), String> { set_setting(&state.db, LAST_TRIAGE_KEY, &date) .await .map_err(|e| e.to_string()) }