Something went wrong. Try again.
Effortlessly glide through your todos
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344import type { GlideDecision, TaskId } from '@/domain/glide';
import { streak } from './streak-store';import { visibleWorkspaceTasks } from './sync/workspace-policy';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(), reorderReady: (orderedIds: TaskId[]) => useTaskStore.getState().reorderReady(orderedIds), 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 state = useTaskStore.getState(); const readyIds = visibleWorkspaceTasks(state.tasks, state.workspace.ownerId) .filter((task) => task.status === 'ready') .map((task) => task.id); streak.commitReady(readyIds); },};