feat(rituals): Phase 5 — morning triage, evening wind-down, autostart
Three opt-in rituals, all default OFF. Research-anchored (Barkley's point-of-performance, Sweller cognitive-load theory, Newport shutdown ritual, Gollwitzer implementation intentions, Thaler/Sunstein nudge with informed consent for the ADHD audience). Morning triage: modal gated on ritualsMorning toggle, configurable trigger time (default 08:00 to respect ADHD sleep inertia rather than the spec's 06:00), "pick up to three for today" with a gentle swap message on the fourth attempt. Skip sets last-shown-today so it never re-prompts the same calendar day. last-shown persists via kon_storage. Evening wind-down: dedicated page, user-triggered only (tray menu + Settings button). Mechanical closure + physical reset + intentional cue — the whole Newport template. Open loops are read-only reflection; Tasks page owns transactions. Copy is additive throughout: "you finished X today", never "you didn't finish Y". Autostart: tauri-plugin-autostart registered (LaunchAgent on macOS, .desktop on Linux, registry Run on Windows). No bespoke Rust commands — frontend calls the plugin's invoke-handlers directly. Toggle in Settings is one-way (click → OS call → state update) to avoid the UI lying during the round-trip. First-run presents a forced-choice prompt for all three options, with "skip all" escape hatches per step. Copy audit against RSD literature: no "overdue", "failed", or day-to-day comparison framing anywhere in ritual surfaces. Post-v0.1 ideas captured in the roadmap: calendar integration (read-only ICS as interim, cloud sync parked) and right-click-to-task (in-app simple, system-wide a separate phase).
This commit is contained in:
@@ -11,6 +11,7 @@ pub mod models;
|
||||
pub mod paste;
|
||||
pub mod power;
|
||||
pub mod profiles;
|
||||
pub mod rituals;
|
||||
pub mod tasks;
|
||||
pub mod transcription;
|
||||
pub mod transcripts;
|
||||
|
||||
43
src-tauri/src/commands/rituals.rs
Normal file
43
src-tauri/src/commands/rituals.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
//! 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<Option<String>, 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())
|
||||
}
|
||||
@@ -130,6 +130,15 @@ pub fn run() {
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||
.plugin(tauri_plugin_updater::Builder::new().build())
|
||||
// Phase 5 rituals: autostart. The plugin registers JS-facing
|
||||
// commands (isEnabled / enable / disable) that the Settings
|
||||
// toggle and first-run prompt invoke directly — no bespoke
|
||||
// Rust commands needed. `LaunchAgent` is the non-root macOS
|
||||
// install path (per-user, no sudo).
|
||||
.plugin(tauri_plugin_autostart::init(
|
||||
tauri_plugin_autostart::MacosLauncher::LaunchAgent,
|
||||
None,
|
||||
))
|
||||
// Remember size + position of every window across app restarts.
|
||||
// Without this, secondary windows (preview overlay, task float,
|
||||
// transcript viewer) open at whatever spot the compositor picks,
|
||||
@@ -297,6 +306,9 @@ pub fn run() {
|
||||
commands::tts::tts_speak,
|
||||
commands::tts::tts_stop,
|
||||
commands::tts::tts_list_voices,
|
||||
// Rituals (Phase 5 roadmap)
|
||||
commands::rituals::get_last_morning_triage,
|
||||
commands::rituals::mark_morning_triage_shown,
|
||||
// Profiles + profile terms (canonical SQLite-backed profile CRUD) — Task 12
|
||||
commands::profiles::list_profiles_cmd,
|
||||
commands::profiles::get_profile_cmd,
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
use tauri::image::Image;
|
||||
use tauri::menu::{MenuBuilder, MenuItemBuilder};
|
||||
use tauri::tray::TrayIconBuilder;
|
||||
use tauri::Manager;
|
||||
use tauri::{Emitter, Manager};
|
||||
|
||||
pub fn setup(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let show = MenuItemBuilder::with_id("show", "Show Kon").build(app)?;
|
||||
let status = MenuItemBuilder::with_id("status", "Ready")
|
||||
.enabled(false)
|
||||
.build(app)?;
|
||||
// Phase 5: always-visible shortcut into the evening wind-down page.
|
||||
// The page itself only renders once the user has enabled the
|
||||
// ritual; clicking this when disabled is harmless (just takes them
|
||||
// there), and Settings is where the toggle lives.
|
||||
let wind_down = MenuItemBuilder::with_id("wind-down", "Evening wind-down").build(app)?;
|
||||
let quit = MenuItemBuilder::with_id("quit", "Quit").build(app)?;
|
||||
|
||||
let menu = MenuBuilder::new(app)
|
||||
@@ -15,6 +20,8 @@ pub fn setup(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
||||
.separator()
|
||||
.item(&status)
|
||||
.separator()
|
||||
.item(&wind_down)
|
||||
.separator()
|
||||
.item(&quit)
|
||||
.build()?;
|
||||
|
||||
@@ -34,6 +41,15 @@ pub fn setup(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let _ = window.set_focus();
|
||||
}
|
||||
}
|
||||
"wind-down" => {
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.show();
|
||||
let _ = window.set_focus();
|
||||
}
|
||||
// The frontend layout listens for this event and routes
|
||||
// to the Phase 5 wind-down page.
|
||||
let _ = app.emit("kon:open-wind-down", ());
|
||||
}
|
||||
"quit" => {
|
||||
app.exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user