3 Commits

Author SHA1 Message Date
bbc7c217be docs(roadmap): archive Phase 1 focus-timer screenshot (sent to Jake)
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
2026-04-24 12:00:51 +01:00
0c34a29367 feat(focus-timer): Phase 1 — visual countdown ring + just-start timer
Closes the Core MVP gap in docs/brief/feature-set.md ("visual time
representation") and wires the dangling kon:start-timer emit that
MicroSteps.svelte has been firing into the void since the stub was
written. Implements phase 1 of the 2026-04-23 feature-complete
roadmap.

New:
- src/lib/stores/focusTimer.svelte.ts — singleton timer store with
  localStorage persistence so a timer started in Dictation survives
  page nav, window close, and reopen. Gentle WebAudio chime at
  completion (no bundled asset). 250 ms tick. Completion flash for
  3 s before auto-clear.
- src/lib/components/FocusTimer.svelte — floating top-right overlay
  with SVG progress ring (shrinking colour: accent -> warning in
  the final 15% -> success on completion). Cancel + "+1 min" on
  hover. Renders nothing when idle.

Wired in +layout.svelte next to ToastViewport.

Two triggers now in the app:
- MicroSteps row 2-min button (pre-existing emit, previously no
  listener)
- WipTaskList row 5-min button (new; the brief's "just-start"
  from the Now column)

Respects prefers-reduced-motion via the existing
[data-reduce-motion] attribute.

Out of scope, carried to later phases: rhythmic voice anchoring
(Phase 6), custom-duration picker, multi-timer UI, native OS
notification (deferred to Phase 6 with the full nudge pipeline).
2026-04-24 11:50:45 +01:00
df6b19834d docs(roadmap): feature-complete plan for v0.1, 10 phases from visual-countdown through Corbie rename + release 2026-04-24 11:43:48 +01:00
6 changed files with 792 additions and 1 deletions

View File

@@ -0,0 +1,267 @@
---
name: Corbie — feature-complete roadmap
description: Build plan from 2026-04-23 baseline to full feature-complete v0.1 release
type: roadmap
tags: [roadmap, planning, corbie, release]
created: 2026/04/23
status: active
author: Wren (CORBEL's resident agent) on behalf of Jake Sames
---
# Corbie — Feature-Complete Roadmap
> **What Corbie is.** A local-first, cognitive-load-aware dictation + task-capture desktop app. Vulkan-accelerated Whisper / Parakeet speech-to-text, a local LLM (Qwen3 tiers) for transcript cleanup and task extraction, an MCP server for integration with Claude Desktop / Cline / Cursor, and a UI designed around ADHD / executive-dysfunction needs. Tauri 2 + Svelte 5 + Rust. Zero telemetry.
>
> **Formerly known as Kon.** Rebrand in flight; repo names at `jakejars/kon` + `git.corbel.consulting/jake/kon` still carry the Kon name and will rename together with the codebase sweep in the final phase.
## Baseline — where we are (2026/04/23)
**Core MVP (from `docs/brief/feature-set.md`):** 9 of 10 complete.
One gap: **visual time representation** (the spec's "#1 community-requested feature" — shrinking colour disks / progress rings, externalising time passage). The rest — local transcription, auto-populating tasks, WIP limits, history + search, light/dark theming, templates, vocabulary profiles, file upload, open-format markdown export — all shipped.
**Post-MVP (designed, not yet prioritised):** 1 of 9 complete.
MicroSteps is shipped; its "just-start" timer button emits an event that currently has no listener anywhere in the codebase. The differentiating ADHD-specific features (Margot nudges, energy-aware sequencing, rituals, if-then intentions, forgiving gamification, TTS, human-in-the-loop feedback) are all documented in the brief but not started.
**Release-blockers:** 1 — RB-08 macOS power-assertion, pending manual verification on a real Mac (Jake's friend Rachmann has a Mac and can run this offline).
**Workspace state:** main is clippy-zero-warnings, 245/245 tests passing, fmt clean, svelte-check clean, npm build clean. Three dependabot bumps landed this session plus a clippy cleanup pass and a needless_range_loop refactor. One orphan design-system WIP branch parked on github as archive.
## Approach
> **Layer 1 first** (per Jake's standing rule): build the features roughly, in series, through Phase 1 Phase 8. Do polish passes in Phase 9 and QC + release in Phase 10. **Do not mix make-it-work and make-it-neat passes** — every phase ships end-to-end (event wired, UI rendered, store state committed, tests updated) but does not chase aesthetic polish until Phase 9.
> **Ordering rationale.** Phase 1 closes the Core MVP gap and unblocks the already-half-wired just-start timer. Phase 2 enables model improvement by collecting human feedback — useful even while later phases are being built. Phases 38 build the differentiating ADHD-specific features from highest-utility-per-effort to lowest. Phase 9 is polish debt. Phase 10 is release prep (including Rachmann's RB-08 verification and the Kon → Corbie codebase rename).
---
## Phase 1 — Visual countdown + Just-Start timer
**Why now.** Closes the one remaining Core MVP gap. Unblocks the dangling `kon:start-timer` emit from MicroSteps. Directly combats time blindness, which the brief names as the single biggest lever for the target audience.
**Scope.**
- `FocusTimer.svelte` — a progress-ring countdown component. Shrinking colour ring (not digital). Subtle colour shift across the last 15%. Remaining time label inside the ring for users who want the number; small enough that the ring dominates the visual field.
- `focusTimer.svelte.ts` store — single active timer, running / paused / completed state, elapsed / remaining computed, event dispatch on state transitions.
- Mount in `+layout.svelte` so the timer persists across page navigation (dictation → tasks → settings).
- Listener for `window` event `kon:start-timer` with `{ durationSeconds, label }` payload.
- Trigger from MicroSteps row (already exists). Trigger from task-row context button (new).
- Floating position top-right of main content, above everything, not intrusive when idle (hidden until a timer is running).
- On completion: gentle chime + 3-second ring flourish + OS notification via `tauri-plugin-notification`. No modal. No guilt copy.
- Store survives window close/reopen via localStorage.
**Out of scope for Phase 1.** Rhythmic voice anchoring (part of Margot, Phase 6). Custom-duration picker (fixed 2 / 5 / 10 / 15 min presets for now). Multi-timer UI.
**Acceptance.** From a MicroStep row, clicking the timer button (a) shows the ring visible somewhere on screen, (b) it counts down, (c) at 0 it fires completion + notification, (d) works across page switches, (e) survives a window close + reopen mid-countdown.
**Estimated effort.** Half day.
---
## Phase 2 — Human-in-the-loop feedback
**Why here.** AI output quality is the single biggest determinant of whether Corbie feels useful. Thumbs-up / thumbs-down on AI-generated micro-steps and task extractions costs almost nothing to add and gives us a feedback corpus the moment anyone uses it. Enables later retraining / prompt tuning.
**Scope.**
- Thumbs-up / thumbs-down buttons on every AI-generated item (micro-step row, extracted task, cleanup paragraph).
- "Edit" path already exists for text; the feedback is additive.
- `feedback` table in SQLite: `item_id`, `item_type`, `rating`, `timestamp`, optional `correction_text`.
- Rust command `record_feedback` + `list_feedback` (for later export).
- No UI surface for viewing feedback yet. Just capture. A future export pass to JSONL feeds prompt-engineering or fine-tuning.
**Out of scope.** Retraining loop, per-user profile adjustment, any UI to view feedback history.
**Acceptance.** Thumbs visible on AI-generated items. Clicking records to SQLite. `cargo test` on storage covers migration + insert + list.
**Estimated effort.** Half day to 1 day.
---
## Phase 3 — Energy-aware task sequencing
**Why here.** Next-highest-utility post-MVP feature. Replaces the cut-for-OS-reasons temptation-bundling feature. Small surface, clear user-facing outcome.
**Scope.**
- `energy` column on tasks: nullable enum `High | Medium | BrainDead`.
- Migration + Rust CRUD.
- Tag chip on task rows; tap to cycle / set.
- Sort / filter option on the tasks page: "Match my energy" → AI surfaces tasks matching a user-set current energy, falls back to `Medium` if unset.
- No automatic energy detection. Pure user input.
**Out of scope.** Time-of-day heuristics, calendar integration, AI-predicted user energy.
**Acceptance.** User tags a task, sets their current energy via a header control, tasks page filter respects it.
**Estimated effort.** 1 day.
---
## Phase 4 — Read Page Aloud (TTS)
**Why here.** Small and self-contained. Engages auditory processing which the brief specifically calls out as a retention lever for the target audience. Uses OS-native TTS (no new dependencies, no model download). Clean single-tap affordance.
**Scope.**
- Rust command `tts_speak(text: String, rate: f32, voice: Option<String>)` — platform dispatch:
- Linux: `spd-say` (speech-dispatcher is available on most distros; graceful fallback to `espeak` if missing).
- macOS: `say` (built in).
- Windows: PowerShell `System.Speech.Synthesis.SpeechSynthesizer`.
- Small "speaker" icon on any text view (transcript viewer, micro-step list, cleanup result).
- Single-tap play; second tap stops. No pause/resume in v1.
- Settings: voice picker (populated from OS), rate slider (0.52.0).
**Out of scope.** Premium voices. Cloud TTS. Concurrent-speaking queue. SSML.
**Acceptance.** Tap speaker icon on a transcript → hear it read on Linux + expected-to-work-on macOS+Windows (test matrix in Phase 10).
**Estimated effort.** Half day.
---
## Phase 5 — Start / shutdown rituals
**Why here.** Meaningful UX but larger surface. Needs calm copy, gentle flow, and a default-off toggle because rituals can feel parental if not optional.
**Scope.**
- Morning triage: on first launch after 06:00, show a modal / dedicated page: "yesterday's incomplete tasks" (from SQLite query: `completed = false AND created_at < today`), with checkbox pick-list, and "pick 13 for today" constraint that refuses selections > 3.
- Evening shutdown: user-triggerable (not scheduled) review: "what got done today", "open loops to close", "separate work from rest" copy. No automation; ritual as reflection.
- Both off by default in settings. When off, no modal, no pressure.
- Skip-for-today button on morning triage; never shows guilt copy.
**Out of scope.** Calendar integration, automatic sleep detection, weekly / monthly reviews.
**Acceptance.** Morning modal shows correct tasks. Selecting > 3 is prevented with a gentle message. Skip works and doesn't re-prompt same day. Evening shutdown opens a reflective page, doesn't block closing the app.
**Estimated effort.** 1 2 days.
---
## Phase 6 — Soft-touch nudging (Margot protocol)
**Why here.** This is the big differentiator and it's intentionally scheduled late because it depends on the phases before it (it nudges *about* tasks, timers, rituals) and on a careful copy pass to not feel like a push notification. The brief explicitly calls out: reminders must not function as standard push notifications; they must be anticipatory guidance.
**Scope.**
- Context-aware trigger engine in Rust: watches activity signals (keyboard activity, active window, last-interaction timestamp) and fires `nudge` events when triggers match.
- Trigger set for v1: `inactivity_with_active_timer` (timer running, no UI interaction for 90 s), `pending_morning_triage` (past 10:00 and triage untouched), `micro_step_idle` (micro-step generated, not acted on within 15 min).
- Delivery: OS notification via `tauri-plugin-notification`. Platform sounds: `Glass` on macOS, `message-new-instant` on Linux, `Default` on Windows. Haptic cue on mobile (not yet in scope; desktop first).
- Suppression rules: no nudge if user typed in last 5 s, no nudge during a running timer's first 60 s, hard cap at 3 nudges per hour, instant mute button in settings.
- Rhythmic voice anchoring: piggy-back on Phase 4 TTS. Optional "speak nudges aloud" toggle. Default off. When on, short calm lines ("Time to move on", "Your list is still here"). No branding voice, no personality yet — that's a Phase 9 polish item.
**Out of scope.** Custom trigger editor (user-facing rule UI is Phase 7). Cross-device delivery. Biometric signals (HRV, fidget detection, etc.). Any Margot-as-character visual.
**Acceptance.** Nudges fire on each trigger in a dogfood walkthrough. Suppression rules observed. Mute button kills everything immediately.
**Estimated effort.** 1 2 days.
---
## Phase 7 — Implementation intentions (if-then automation)
**Why here.** Leans on Phase 6's trigger engine. The user-facing rule editor is its own thing, but the execution path is the nudge pipeline with user-defined conditions.
**Scope.**
- Rule editor UI: minimal. `if [when-condition], then [action]`.
- When-conditions for v1: `time of day = HH:MM`, `after a task completes`, `morning triage finishes`.
- Actions for v1: `surface task X`, `start a 5-min timer`, `speak a line aloud`.
- Rules stored in SQLite. On/off per rule. Global mute respected.
- No location triggers (desktop app, no geolocation). No app-running detection in v1 (fragile cross-platform; revisit in v0.2).
**Out of scope.** Calendar triggers, cross-app automation, macro-style action chains, shared/community rules.
**Acceptance.** User can write "at 09:00, speak 'time to plan the day' and surface inbox", save it, and have it fire next morning at 09:00. Delete works.
**Estimated effort.** 1 day.
---
## Phase 8 — Forgiving gamification
**Why here.** Last feature phase because it's the lowest-risk and the furthest from make-or-break. Neatly rounds out the spec list.
**Scope.**
- Completion count per day (non-punitive: no streaks, no chain-breaking). "You've completed 4 tasks today. Three in the afternoon. Want to call it?"
- Grace days: the badge logic ignores up-to-3 consecutive days of no activity without reset.
- Visual: soft-edged numeric badges on the tasks header, no leaderboards, no social comparison.
- Zero loss language. Never "you lost your streak". Framing is always "look what you did".
**Out of scope.** Leaderboards. Shared challenges. Streak repair purchases. XP systems.
**Acceptance.** Complete 3 tasks → header shows "3 today". Open the app after 4 days off → no negative framing, header reads today's count only.
**Estimated effort.** Half day to 1 day.
---
## Phase 9 — Polish debt
> **All Phase 9 work is paused until Phase 1 Phase 8 are closed.** Per Jake's rule: features first, polish second.
**Contents.**
- File-system `.md` save dialog (replace clipboard-only export). Rust `write_text_file` command; platform dialog via `tauri-plugin-dialog`.
- Bulk select + bulk export in History.
- LLM-powered content tags (`topic:*`, `intent:*`). Slot into the existing `kon-llm` stub.
- Settings UX overhaul: bundle high-traffic settings into a "Start here" group; hide advanced behind a disclosure.
- Visual polish pass on all Phase 1 Phase 8 surfaces: spacing, typography, motion curves, colour, dark-mode parity.
- Accessibility pass: keyboard navigation, screen reader labels, focus order, colour contrast audit against WCAG AA.
**Estimated effort.** 1 2 days.
---
## Phase 10 — QC + rename + release
**Prerequisite:** Phase 1 Phase 9 complete.
**QC block.**
- Full dogfood walkthrough: record a real brain-dump → clean transcript → task extraction → micro-step one task → run a focus timer → tag energy → complete → check evening shutdown.
- RB-08 macOS power-assertion verification: **Rachmann runs this offline** on his Mac. He runs `pmset -g assertions` while a live session is active; expected: entry for `PreventSystemSleep` attributed to Corbie's bundle id. Once confirmed, mark RB-08 closed and delete `docs/issues/power-assertion-macos-objc2.md` or move to resolved.
- Cross-platform build matrix (CI already runs): Linux / macOS / Windows, ensure all three are green.
- Accessibility regression check: keyboard-only traversal of each new surface.
- Freshly-clean install test on a spare user account: no stray data leaks from dev.
**Kon → Corbie codebase rename sweep.** Runs after QC once Jake has renamed the two repos:
- `package.json` name `kon@0.1.0``corbie@0.1.0`.
- Cargo crate names: `kon`, `kon-audio`, `kon-storage`, `kon-transcription`, `kon-llm`, `kon-ai-formatting`, `kon-core`, `kon-cloud-providers`, `kon-hotkey`, `kon-mcp``corbie-*`. Mass-rename via `Cargo.toml` + `use`-path sweep.
- Binary + product names: `src-tauri/tauri.conf.json`, bundle identifier, `.desktop` file, Windows product name, macOS bundle name.
- Install paths: `~/.local/share/kon/``~/.local/share/corbie/`. **Migration shim required**: first-run check for old dir, move contents, write a sentinel. Document in the release notes.
- Database filename: `kon.db``corbie.db`. Handled by the same migration shim.
- Window titles, tray tooltip, About-dialog text, README body, docs/brief/ references where they refer to the product (leave historical brief content talking about "Kon" as-is — it's a historical document).
- Event names: `kon:start-timer``corbie:start-timer` and similar. Kept `kon:` through Phase 1 Phase 9 so any dogfood doesn't need to re-learn them mid-cycle.
- Logs, error messages, user-facing copy.
- Remotes: `ssh://git.corbel.consulting:2222/jake/kon.git` + `github.com:jakejars/kon.git``…/corbie.git` on both, after Jake has clicked rename in the web UIs. Update `git remote set-url` locally.
**Release.**
- Bump `Cargo.toml` and `package.json` to `0.1.0`. Tag `v0.1.0` on the commit.
- Write `CHANGELOG.md` (seed it with everything from this roadmap's phases).
- Write release notes in plain language — what it does, who it's for, the data-migration note.
- Push tag to both remotes. GitHub Actions release workflow (already in place for cross-platform CI) should auto-build artefacts for Linux / macOS / Windows.
**Estimated effort.** 1 day (QC + rename + release ceremony), plus Rachmann's slot on his Mac (parallel, not blocking).
---
## Totals
- Phase 1 8 feature build: **6.5 9.5 days** of focused work
- Phase 9 polish: **1 2 days**
- Phase 10 QC + rename + release: **1 day + Rachmann's Mac session**
**Total to v0.1.0 feature-complete release:** **~9 13 days of focused work**, depending on how much polish time Jake wants in Phase 9.
## Explicit non-goals
- Mobile apps. Corbie is desktop-first; a mobile companion is post-v0.1.
- Cloud sync. Local-first is the floor, not a feature. Sync is out of scope through v0.1.
- Premium voices, paid tiers, subscription. Licensing + monetisation is a separate track tracked in memory `project_marketplace_creem`.
- AI body doubling (low-fi focus rooms) — validated but parked to post-v0.1.
- Temptation bundling — cut (OS-integration impossible cross-platform; replaced by Phase 3 energy-aware sequencing).
## Anchors
- Spec: [docs/brief/feature-set.md](docs/brief/feature-set.md) + [docs/brief/design-principles.md](docs/brief/design-principles.md)
- Current baseline: this session's HANDOVER.md
- Rebrand memory: `~/.claude/projects/-home-jake-Documents-CORBEL-Main/memory/project_corbie_rebrand.md`
- Release-blocker index: [docs/issues/README.md](docs/issues/README.md)
---
*This roadmap is a living document. Update it at the end of each phase with actuals vs estimates and any scope revisions.*

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 KiB

View File

@@ -0,0 +1,270 @@
<script lang="ts">
// Floating focus-timer overlay. Renders nothing when no timer is
// active. When a timer is running, pins a compact SVG progress ring
// to the top-right of the viewport with the remaining mm:ss in the
// centre. Completion plays a gentle chime, flashes a success ring
// for 3 s, then disappears. Cancel button appears on hover.
//
// Mounted once in +layout.svelte. Listens for `kon:start-timer`
// events from anywhere in the app (e.g. MicroSteps) and delegates
// to the focus-timer store.
//
// Design tokens used: --color-accent (mid-progress),
// --color-warning (final 15%), --color-success (flourish),
// --color-border (unfilled ring track). No literals, so the ring
// follows the sensory-zone theme switcher in Settings.
import { onMount, onDestroy } from "svelte";
import { X, Plus } from "lucide-svelte";
import { focusTimer } from "$lib/stores/focusTimer.svelte.js";
const RING_SIZE = 64;
const RING_STROKE = 5;
const RING_RADIUS = (RING_SIZE - RING_STROKE) / 2;
const RING_CIRCUMFERENCE = 2 * Math.PI * RING_RADIUS;
// Progress ring fills as time elapses. Stroke-dashoffset goes from
// circumference (empty) to 0 (full) — we want it the other way,
// because the UX is a shrinking-time disc: more elapsed = less
// ring visible. Render the remaining arc: dashoffset = circumference * progress.
let dashOffset = $derived(RING_CIRCUMFERENCE * focusTimer.progress);
function formatRemaining(ms: number): string {
const total = Math.ceil(ms / 1000);
const mins = Math.floor(total / 60);
const secs = total % 60;
return `${mins}:${secs.toString().padStart(2, "0")}`;
}
// Colour shifts over the last 15% of the timer to cue "nearly done"
// without resorting to red (which the brief flags as anxiogenic for
// the target audience).
let ringColor = $derived.by(() => {
if (focusTimer.showingCompletionFlash) return "var(--color-success)";
if (focusTimer.progress >= 0.85) return "var(--color-warning)";
return "var(--color-accent)";
});
// Event handler: start a timer when any component fires `kon:start-timer`.
// Payload shape from MicroSteps.svelte and task row buttons:
// { taskId?: string, seconds: number, label?: string }
function handleStartEvent(evt: Event) {
const detail = (evt as CustomEvent).detail ?? {};
const seconds = Number(detail.seconds);
if (!Number.isFinite(seconds) || seconds <= 0) return;
focusTimer.start(seconds, {
taskId: detail.taskId ?? null,
label: detail.label ?? null,
});
}
onMount(() => {
window.addEventListener("kon:start-timer", handleStartEvent);
// Rehydrate any in-flight timer that survived a window close.
focusTimer.rehydrate();
});
onDestroy(() => {
window.removeEventListener("kon:start-timer", handleStartEvent);
});
function handleCancel() {
focusTimer.cancel();
}
function handleExtend() {
focusTimer.extend(60);
}
function handleDismissFlash() {
focusTimer.dismissCompletionFlash();
}
</script>
{#if focusTimer.active || focusTimer.showingCompletionFlash}
<div
class="focus-timer"
class:completed={focusTimer.showingCompletionFlash}
role="status"
aria-live="polite"
aria-label={focusTimer.label ?? "Focus timer"}
>
<div class="ring-wrap">
<svg
width={RING_SIZE}
height={RING_SIZE}
viewBox={`0 0 ${RING_SIZE} ${RING_SIZE}`}
aria-hidden="true"
>
<!-- Track -->
<circle
cx={RING_SIZE / 2}
cy={RING_SIZE / 2}
r={RING_RADIUS}
fill="none"
stroke="var(--color-border)"
stroke-width={RING_STROKE}
/>
<!-- Progress (shrinking slice — full ring at start, none at end) -->
<circle
cx={RING_SIZE / 2}
cy={RING_SIZE / 2}
r={RING_RADIUS}
fill="none"
stroke={ringColor}
stroke-width={RING_STROKE}
stroke-linecap="round"
stroke-dasharray={RING_CIRCUMFERENCE}
stroke-dashoffset={dashOffset}
transform={`rotate(-90 ${RING_SIZE / 2} ${RING_SIZE / 2})`}
style="transition: stroke-dashoffset 250ms linear, stroke 400ms ease"
/>
</svg>
<div class="time" aria-hidden={focusTimer.showingCompletionFlash}>
{#if focusTimer.showingCompletionFlash}
<span class="done">done</span>
{:else}
{formatRemaining(focusTimer.remainingMs)}
{/if}
</div>
</div>
<div class="controls">
{#if focusTimer.showingCompletionFlash}
<button
class="icon-btn"
onclick={handleDismissFlash}
aria-label="Dismiss completion"
title="Dismiss"
>
<X size={14} aria-hidden="true" />
</button>
{:else}
<button
class="icon-btn"
onclick={handleExtend}
aria-label="Add one minute"
title="+1 min"
>
<Plus size={14} aria-hidden="true" />
</button>
<button
class="icon-btn"
onclick={handleCancel}
aria-label="Cancel timer"
title="Cancel"
>
<X size={14} aria-hidden="true" />
</button>
{/if}
</div>
{#if focusTimer.label}
<div class="label" aria-hidden="true">{focusTimer.label}</div>
{/if}
</div>
{/if}
<style>
.focus-timer {
position: fixed;
top: 52px;
right: 16px;
z-index: 40;
display: flex;
align-items: center;
gap: 8px;
padding: 6px 10px 6px 6px;
background: var(--color-bg-elevated);
border: 1px solid var(--color-border);
border-radius: var(--radius-lg);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
font-family: var(--font-family-body);
font-variant-numeric: tabular-nums;
transition: opacity 200ms ease, transform 200ms ease;
}
.focus-timer.completed {
border-color: var(--color-success);
}
.ring-wrap {
position: relative;
width: 64px;
height: 64px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.time {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
font-weight: 500;
color: var(--color-text);
}
.time .done {
font-size: 11px;
color: var(--color-success);
font-family: var(--font-family-display);
letter-spacing: 0.02em;
}
.controls {
display: flex;
flex-direction: column;
gap: 4px;
opacity: 0;
transition: opacity 180ms ease;
}
.focus-timer:hover .controls,
.focus-timer:focus-within .controls,
.focus-timer.completed .controls {
opacity: 1;
}
.icon-btn {
display: inline-flex;
align-items: center;
justify-content: center;
width: 22px;
height: 22px;
padding: 0;
border: 0;
border-radius: var(--radius-sm);
background: transparent;
color: var(--color-text-secondary);
cursor: pointer;
transition: background 150ms ease, color 150ms ease;
}
.icon-btn:hover {
background: var(--color-hover);
color: var(--color-text);
}
.icon-btn:focus-visible {
outline: 2px solid var(--color-accent);
outline-offset: 1px;
}
.label {
max-width: 140px;
font-size: 12px;
color: var(--color-text-secondary);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
:global([data-reduce-motion="true"]) .focus-timer circle {
transition: none !important;
}
</style>

View File

@@ -1,7 +1,13 @@
<script lang="ts">
import { tasks, addTask, completeTask, uncompleteTask, deleteTask } from '$lib/stores/page.svelte.js';
import MicroSteps from '$lib/components/MicroSteps.svelte';
import { ChevronDown, ChevronRight } from 'lucide-svelte';
import { ChevronDown, ChevronRight, Timer } from 'lucide-svelte';
function startFocusTimer(task: { id: string; text: string }) {
window.dispatchEvent(new CustomEvent('kon:start-timer', {
detail: { taskId: task.id, seconds: 300, label: task.text }
}));
}
let { wipLimit = 3 } = $props();
@@ -68,6 +74,16 @@
aria-label="Complete task"
></button>
<span class="text-[13px] text-text flex-1 min-w-0 truncate">{task.text}</span>
<!-- 5-min focus timer — the "just-start" button from the brief -->
<button
class="opacity-0 group-hover:opacity-100 text-text-tertiary hover:text-accent"
onclick={() => startFocusTimer(task)}
aria-label="Start 5-minute focus timer for this task"
title="Start 5-minute focus timer"
style="transition: opacity var(--duration-ui)"
>
<Timer size={12} aria-hidden="true" />
</button>
<!-- Expand/collapse micro-steps toggle -->
<button
class="opacity-0 group-hover:opacity-100 text-text-tertiary hover:text-accent"

View File

@@ -0,0 +1,230 @@
// Focus timer store. Single active timer at a time — the "just-start"
// 2/5/10/15-minute countdown paired with micro-steps. Exposes:
// - focusTimer.active: whether a timer is currently running
// - focusTimer.progress: 0..1 fraction of elapsed time
// - focusTimer.remainingMs: milliseconds until completion
// - focusTimer.label / focusTimer.taskId: what this timer is for
// - start(seconds, opts) / cancel() / extend(seconds)
//
// Survives window close + reopen via localStorage, because a timer
// that loses its clock when the user alt-tabs is a timer that nobody
// trusts. On rehydrate after expiry, fires completion then clears —
// so closing the window mid-timer still gets you the "done" signal
// on next launch.
const STORAGE_KEY = "kon.focusTimer.v1";
const TICK_INTERVAL_MS = 250;
export type FocusTimerPersisted = {
startedAt: number;
durationMs: number;
taskId: string | null;
label: string | null;
};
function readPersisted(): FocusTimerPersisted | null {
if (typeof window === "undefined") return null;
try {
const raw = window.localStorage.getItem(STORAGE_KEY);
if (!raw) return null;
const parsed = JSON.parse(raw);
if (
typeof parsed?.startedAt !== "number" ||
typeof parsed?.durationMs !== "number"
) return null;
return {
startedAt: parsed.startedAt,
durationMs: parsed.durationMs,
taskId: parsed.taskId ?? null,
label: parsed.label ?? null,
};
} catch {
return null;
}
}
function writePersisted(state: FocusTimerPersisted | null): void {
if (typeof window === "undefined") return;
try {
if (state === null) window.localStorage.removeItem(STORAGE_KEY);
else window.localStorage.setItem(STORAGE_KEY, JSON.stringify(state));
} catch { /* storage may be disabled; non-fatal */ }
}
function createFocusTimerStore() {
let startedAt = $state<number | null>(null);
let durationMs = $state<number>(0);
let taskId = $state<string | null>(null);
let label = $state<string | null>(null);
let now = $state<number>(Date.now());
let completionFlashUntil = $state<number>(0);
let interval: ReturnType<typeof setInterval> | null = null;
const active = $derived(startedAt !== null);
const elapsedMs = $derived(startedAt === null ? 0 : Math.max(0, now - startedAt));
const remainingMs = $derived(Math.max(0, durationMs - elapsedMs));
const progress = $derived(durationMs === 0 ? 0 : Math.min(1, elapsedMs / durationMs));
const finished = $derived(active && remainingMs === 0);
const showingCompletionFlash = $derived(now < completionFlashUntil);
// Internal completion + flash bookkeeping. We track whether we have
// already fired the completion chime for the current timer so a
// second tick does not re-fire it. Reset whenever a new timer starts.
let completionFired = false;
function tick() {
now = Date.now();
// Fire completion once, the first tick after we cross remaining=0.
if (startedAt !== null && !completionFired && now - startedAt >= durationMs) {
completionFired = true;
completionFlashUntil = now + 3000;
fireCompletion();
}
// After the 3 s flash window, clear everything and stop ticking.
if (completionFlashUntil > 0 && now >= completionFlashUntil) {
clear();
}
}
function startTick() {
if (interval !== null) return;
interval = setInterval(tick, TICK_INTERVAL_MS);
}
function stopTick() {
if (interval !== null) {
clearInterval(interval);
interval = null;
}
}
function clear() {
startedAt = null;
durationMs = 0;
taskId = null;
label = null;
completionFlashUntil = 0;
completionFired = false;
writePersisted(null);
stopTick();
}
function start(seconds: number, opts?: { taskId?: string | null; label?: string | null }): void {
if (!Number.isFinite(seconds) || seconds <= 0) return;
now = Date.now();
startedAt = now;
durationMs = Math.floor(seconds * 1000);
taskId = opts?.taskId ?? null;
label = opts?.label ?? null;
completionFlashUntil = 0;
completionFired = false;
writePersisted({ startedAt, durationMs, taskId, label });
startTick();
}
function cancel(): void {
clear();
}
function extend(seconds: number): void {
if (startedAt === null) return;
if (!Number.isFinite(seconds) || seconds <= 0) return;
durationMs += Math.floor(seconds * 1000);
writePersisted({ startedAt, durationMs, taskId, label });
}
function dismissCompletionFlash(): void {
completionFlashUntil = 0;
clear();
}
function fireCompletion(): void {
if (typeof window === "undefined") return;
// Gentle chime — WebAudio so we do not ship a bundled asset.
// A 440 Hz fall into 330 Hz over 220 ms, low volume, no sustain.
try {
type AudioCtx = typeof AudioContext;
const win = window as unknown as { AudioContext?: AudioCtx; webkitAudioContext?: AudioCtx };
const Ctx = win.AudioContext ?? win.webkitAudioContext;
if (!Ctx) return;
const ctx = new Ctx();
const osc = ctx.createOscillator();
const gain = ctx.createGain();
osc.type = "sine";
osc.frequency.setValueAtTime(440, ctx.currentTime);
osc.frequency.exponentialRampToValueAtTime(330, ctx.currentTime + 0.22);
gain.gain.setValueAtTime(0.0001, ctx.currentTime);
gain.gain.exponentialRampToValueAtTime(0.15, ctx.currentTime + 0.02);
gain.gain.exponentialRampToValueAtTime(0.0001, ctx.currentTime + 0.28);
osc.connect(gain);
gain.connect(ctx.destination);
osc.start();
osc.stop(ctx.currentTime + 0.3);
osc.onended = () => ctx.close().catch(() => {});
} catch { /* audio is a nicety; never fatal */ }
window.dispatchEvent(new CustomEvent("kon:focus-timer-complete", {
detail: { taskId, label },
}));
}
// Rehydrate on first touch. If the persisted timer has already
// expired, fire completion then clear so the user still gets the
// "done" signal they missed while the window was closed.
function rehydrate(): void {
const persisted = readPersisted();
if (!persisted) return;
const age = Date.now() - persisted.startedAt;
if (age >= persisted.durationMs) {
// Already expired while the window was closed. Fire a completion
// event so downstream listeners (nudges, UI flourishes) can react.
taskId = persisted.taskId;
label = persisted.label;
durationMs = persisted.durationMs;
startedAt = persisted.startedAt;
now = persisted.startedAt + persisted.durationMs;
// Flash briefly so the user knows it happened.
completionFlashUntil = Date.now() + 3000;
completionFired = true;
fireCompletion();
startTick();
return;
}
startedAt = persisted.startedAt;
durationMs = persisted.durationMs;
taskId = persisted.taskId;
label = persisted.label;
now = Date.now();
startTick();
}
// Exposed as frozen object. Getters so derivations stay reactive.
return {
get active() { return active; },
get progress() { return progress; },
get elapsedMs() { return elapsedMs; },
get remainingMs() { return remainingMs; },
get durationMs() { return durationMs; },
get taskId() { return taskId; },
get label() { return label; },
get showingCompletionFlash() { return showingCompletionFlash; },
start,
cancel,
extend,
rehydrate,
dismissCompletionFlash,
};
}
export const focusTimer = createFocusTimerStore();
// Preset durations surfaced in the UI. 2 / 5 / 10 / 15 minutes match
// the brief's guidance for the "just-start" timer and cover common
// Pomodoro / shorter-focus preferences.
export const FOCUS_TIMER_PRESETS_SECONDS: ReadonlyArray<{ label: string; seconds: number }> = [
{ label: "2 min", seconds: 120 },
{ label: "5 min", seconds: 300 },
{ label: "10 min", seconds: 600 },
{ label: "15 min", seconds: 900 },
];

View File

@@ -8,6 +8,7 @@
import Titlebar from "$lib/components/Titlebar.svelte";
import ToastViewport from "$lib/components/ToastViewport.svelte";
import ResizeHandles from "$lib/components/ResizeHandles.svelte";
import FocusTimer from "$lib/components/FocusTimer.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";
@@ -396,6 +397,13 @@
in the bottom-right of the viewport. (Day 3 of the upgrade plan) -->
<ToastViewport />
<!-- Global focus-timer overlay. Renders nothing until a `kon:start-timer`
event fires; then pins a shrinking colour ring to the top-right.
Phase 1 of the 2026-04-23 feature-complete roadmap — closes the
visual-time-representation gap from docs/brief/feature-set.md and
wires the dangling emit in MicroSteps.svelte. -->
<FocusTimer />
<!-- 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. -->