From cb32285ce08105861d6529286f7fed3422c48d22 Mon Sep 17 00:00:00 2001 From: Jake Date: Fri, 24 Apr 2026 20:34:57 +0100 Subject: [PATCH] feat(gamification): DailyCompletionCount type + showMomentumSparkline setting Adds the Phase 8 frontend types. New setting defaults to true (sparkline on for everyone on upgrade) and persists via the existing settings envelope; no migration needed because missing keys spread over the defaults object on load. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/lib/stores/page.svelte.ts | 1 + src/lib/types/app.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/lib/stores/page.svelte.ts b/src/lib/stores/page.svelte.ts index aa85516..6196318 100644 --- a/src/lib/stores/page.svelte.ts +++ b/src/lib/stores/page.svelte.ts @@ -82,6 +82,7 @@ const defaults: SettingsState = { nudgesEnabled: false, nudgesMuted: false, nudgesSpeakAloud: false, + showMomentumSparkline: true, }; function canUseStorage(): boolean { diff --git a/src/lib/types/app.ts b/src/lib/types/app.ts index af160e3..655a1be 100644 --- a/src/lib/types/app.ts +++ b/src/lib/types/app.ts @@ -122,6 +122,12 @@ export interface SettingsState { * has effect when `nudgesEnabled` is true. */ nudgesSpeakAloud: boolean; + /** + * Phase 8. Controls the 7-day momentum sparkline only. The "N today" + * badge on the Tasks header is always on regardless. Default true so + * existing users see the sparkline on upgrade. + */ + showMomentumSparkline: boolean; } export interface Profile { @@ -224,6 +230,15 @@ export interface TranscriptMetaPatch { */ export type EnergyLevel = "high" | "medium" | "brain_dead"; +/** + * Phase 8: one bucket in the 7-day completion history fed to the + * momentum sparkline. `day` is "YYYY-MM-DD" local time. + */ +export interface DailyCompletionCount { + day: string; // "YYYY-MM-DD" local + count: number; +} + export interface TaskDto { id: string; text: string;