Something went wrong. Try again.
Effortlessly glide through your todos
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import type { GlideDecision, TaskId } from '@/domain/glide';
import { streak } from './streak-store';import { currentOwnerId, isVisibleForOwner } from './sync/owner';import { useTaskStore } from './task-store';
/** * The task repository — the single imperative write surface the UI talks to, and * the seam a future Convex sync engine decorates. Today each call delegates straight * to the local store; later it can also write-through a mutation queue and let the * sync engine reconcile remote changes back into the same store — with nothing above * this line changing (the deep-module boundary from TASTE.md). * * Reads are reactive and go through `useBoard`; these are the writes, mirroring the * old Convex mutations one-for-one. Calling `getState()` outside React is the * standard Zustand pattern for imperative access. */export const tasks = { createTask: (title: string) => useTaskStore.getState().createTask(title), assess: (id: TaskId, decision: GlideDecision) => useTaskStore.getState().assess(id, decision), complete: (id: TaskId) => { useTaskStore.getState().complete(id); // Completing a committed ready task may close today's day-clear. streak.recheckToday(); }, demoteReadyTasks: () => useTaskStore.getState().demoteReadyTasks(), deferNow: (id: TaskId) => useTaskStore.getState().deferNow(id), startPlanSession: () => useTaskStore.getState().startPlanSession(), ensureActionSession: () => useTaskStore.getState().ensureActionSession(), ensureStarterTasks: () => useTaskStore.getState().ensureStarterTasks(), /** * Freeze today's streak commitment from the current ready queue. Call when a * planning pass finishes (deck empty after a full scan). */ commitStreakFromReady: () => { const ownerId = currentOwnerId(); const readyIds = useTaskStore .getState() .tasks.filter( (task) => task.status === 'ready' && task.deletedAt === undefined && isVisibleForOwner(task.ownerId, ownerId) ) .map((task) => task.id); streak.commitReady(readyIds); },};