feat(rituals): Phase 5 — morning triage, evening wind-down, autostart
Some checks failed
check / cargo check (macos-latest) (push) Has been cancelled
check / cargo check (ubuntu-22.04) (push) Has been cancelled
check / cargo check (windows-latest) (push) Has been cancelled
check / svelte build + lint (push) Has been cancelled

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:
2026-04-24 17:48:01 +01:00
parent 9f53702c7e
commit 3cf3e41899
21 changed files with 967 additions and 8 deletions

View File

@@ -9,6 +9,7 @@
import ToastViewport from "$lib/components/ToastViewport.svelte";
import ResizeHandles from "$lib/components/ResizeHandles.svelte";
import FocusTimer from "$lib/components/FocusTimer.svelte";
import MorningTriageModal from "$lib/components/MorningTriageModal.svelte";
import { hasTauriRuntime } from "$lib/utils/runtime.js";
import { loadOsInfo, isLinux } from "$lib/utils/osInfo.js";
import { page, settings, saveSettings } from "$lib/stores/page.svelte.js";
@@ -205,6 +206,17 @@
}
}
// Phase 5: tray menu routes "Evening wind-down" here so the page
// opens on whichever window the user clicks from. Unlisten on
// destroy like every other subscription in this file.
let unlistenWindDown = null;
async function setupWindDownListener() {
if (!tauriRuntimeAvailable) return;
unlistenWindDown = await listen("kon:open-wind-down", () => {
page.current = "shutdown";
});
}
// Cross-window preference sync: apply updates broadcast by any other
// window (float, viewer) while skipping our own echoes.
let unlistenPrefs = null;
@@ -262,6 +274,9 @@
// Cross-window preference sync (no-op outside Tauri).
setupPreferencesSync();
// Phase 5: subscribe to tray wind-down event.
setupWindDownListener();
// Diagnostics: capture every uncaught frontend error to error_log.
installGlobalErrorCapture();
@@ -362,6 +377,9 @@
if (unlistenPrefs) {
unlistenPrefs();
}
if (unlistenWindDown) {
unlistenWindDown();
}
});
</script>
@@ -404,6 +422,11 @@
wires the dangling emit in MicroSteps.svelte. -->
<FocusTimer />
<!-- Phase 5: morning triage modal. Self-gated — no-op unless the user
has enabled `ritualsMorning` and the local clock is past their set
trigger time. Mounted here so it can appear over any page. -->
<MorningTriageModal />
<!-- Invisible resize margins for frameless (macOS/Windows). On Linux we
use native decorations, so ResizeHandles would compete with the
compositor's own resize and is suppressed. -->

View File

@@ -6,6 +6,7 @@
import HistoryPage from "$lib/pages/HistoryPage.svelte";
import SettingsPage from "$lib/pages/SettingsPage.svelte";
import FirstRunPage from "$lib/pages/FirstRunPage.svelte";
import ShutdownRitualPage from "$lib/pages/ShutdownRitualPage.svelte";
// Redirect legacy "profiles" page to settings
$effect(() => {
@@ -26,5 +27,7 @@
<HistoryPage />
{:else if page.current === "settings"}
<SettingsPage />
{:else if page.current === "shutdown"}
<ShutdownRitualPage />
{/if}
</main>