Something went wrong. Try again.
Effortlessly glide through your todos
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768/** * Maximum task-title length. Titles are terse action prompts, not descriptions * (the longest seed is ~38 chars), so 64 is generous — a full sentence like * "Reply to the landlord about the broken heating before Friday" (60) — while * staying short enough that even the 2×2 home-screen widget, the binding * constraint, renders the longest allowed title *in full* and readably (≈5 * lines, shrink-to-fit, no truncation). Chosen empirically: the small card holds * ~70 chars before it has to truncate, so 64 leaves a safe margin. Enforced both * on the capture input and in the local store (`src/data/task-store.ts`). */export const TITLE_MAX_LENGTH = 64;
export type GlideDecision = 'clear' | 'resistant';
export type GlideTaskStatus = 'open' | 'ready' | 'done';
/** * A task's identity. Glide is local-first, so this is a client-generated UUID * (see `src/data/ids.ts`) rather than a server key — a task is identifiable the * instant it's created offline, which is what lets a future sync layer reconcile * without a round-trip. Opaque: never shown to the user. */export type TaskId = string;
/** * The whole domain, distilled. A task is just a title and the resistance it has * accrued — prioritization within a pass is emergent from the swipe loop, never * declared by the user. Manual `order` within "Next Up" is the one deliberate * exception: order-dependent tasks can be explicitly sequenced (see `reorderReady`). */export type GlideTask = { id: TaskId; title: string; resistance: 1 | 2 | 3 | 4 | 5; status: GlideTaskStatus; exposureCount: number; deferCount: number;};
/** * The minimal shape `toGlideTask` reads. The persisted `LocalTask` * (`src/data/task-store.ts`) satisfies it structurally, so the domain stays free * of any storage-layer import while still mapping cleanly from the store. */export type GlideTaskSource = { id: TaskId; title: string; resistance: number; status: GlideTaskStatus; exposureCount: number; deferCount?: number;};
function clampResistance(value: number): GlideTask['resistance'] { return Math.min(5, Math.max(1, Math.round(value))) as GlideTask['resistance'];}
export function toGlideTask(task: GlideTaskSource): GlideTask { return { id: task.id, title: task.title, resistance: clampResistance(task.resistance), status: task.status, exposureCount: task.exposureCount, deferCount: task.deferCount ?? 0, };}