feat: due dates, subtasks, and task detail page (HQ-{number} URLs)

- Schema: added due_date and subtasks JSONB columns to tasks
- API: CRUD endpoints for subtasks (/tasks/:id/subtasks)
- API: due date support in create/update task
- TaskDetailPanel: due date picker with overdue/soon badges
- TaskDetailPanel: subtask checklist with progress bar
- TaskPage: full-page task view at /task/HQ-{number}
- Dashboard: task cards link to detail page, show subtask progress & due date badges
- Migration: 0001_mighty_callisto.sql
This commit is contained in:
2026-01-29 07:06:59 +00:00
parent f2b477c03d
commit e874cafbec
11 changed files with 1433 additions and 5 deletions

View File

@@ -0,0 +1,2 @@
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "due_date" timestamp with time zone;--> statement-breakpoint
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "subtasks" jsonb DEFAULT '[]'::jsonb;

View File

@@ -0,0 +1,576 @@
{
"id": "00cb3823-7607-4e8d-ba6a-694ca93dc3d8",
"prevId": "bf5b044c-8c7f-4838-8a0d-8afbfd63d05c",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.accounts": {
"name": "accounts",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"account_id": {
"name": "account_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"provider_id": {
"name": "provider_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"access_token": {
"name": "access_token",
"type": "text",
"primaryKey": false,
"notNull": false
},
"refresh_token": {
"name": "refresh_token",
"type": "text",
"primaryKey": false,
"notNull": false
},
"id_token": {
"name": "id_token",
"type": "text",
"primaryKey": false,
"notNull": false
},
"access_token_expires_at": {
"name": "access_token_expires_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": false
},
"refresh_token_expires_at": {
"name": "refresh_token_expires_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": false
},
"scope": {
"name": "scope",
"type": "text",
"primaryKey": false,
"notNull": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"accounts_user_id_users_id_fk": {
"name": "accounts_user_id_users_id_fk",
"tableFrom": "accounts",
"tableTo": "users",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.projects": {
"name": "projects",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"context": {
"name": "context",
"type": "text",
"primaryKey": false,
"notNull": false
},
"repos": {
"name": "repos",
"type": "jsonb",
"primaryKey": false,
"notNull": false,
"default": "'[]'::jsonb"
},
"links": {
"name": "links",
"type": "jsonb",
"primaryKey": false,
"notNull": false,
"default": "'[]'::jsonb"
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.sessions": {
"name": "sessions",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"expires_at": {
"name": "expires_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true
},
"token": {
"name": "token",
"type": "text",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"ip_address": {
"name": "ip_address",
"type": "text",
"primaryKey": false,
"notNull": false
},
"user_agent": {
"name": "user_agent",
"type": "text",
"primaryKey": false,
"notNull": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {
"sessions_user_id_users_id_fk": {
"name": "sessions_user_id_users_id_fk",
"tableFrom": "sessions",
"tableTo": "users",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"sessions_token_unique": {
"name": "sessions_token_unique",
"nullsNotDistinct": false,
"columns": [
"token"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.tasks": {
"name": "tasks",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"task_number": {
"name": "task_number",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"source": {
"name": "source",
"type": "task_source",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'donovan'"
},
"status": {
"name": "status",
"type": "task_status",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'queued'"
},
"priority": {
"name": "priority",
"type": "task_priority",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'medium'"
},
"position": {
"name": "position",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 0
},
"assignee_id": {
"name": "assignee_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
"assignee_name": {
"name": "assignee_name",
"type": "text",
"primaryKey": false,
"notNull": false
},
"project_id": {
"name": "project_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"due_date": {
"name": "due_date",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": false
},
"subtasks": {
"name": "subtasks",
"type": "jsonb",
"primaryKey": false,
"notNull": false,
"default": "'[]'::jsonb"
},
"progress_notes": {
"name": "progress_notes",
"type": "jsonb",
"primaryKey": false,
"notNull": false,
"default": "'[]'::jsonb"
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"completed_at": {
"name": "completed_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"tasks_project_id_projects_id_fk": {
"name": "tasks_project_id_projects_id_fk",
"tableFrom": "tasks",
"tableTo": "projects",
"columnsFrom": [
"project_id"
],
"columnsTo": [
"id"
],
"onDelete": "set null",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.users": {
"name": "users",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"email_verified": {
"name": "email_verified",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"image": {
"name": "image",
"type": "text",
"primaryKey": false,
"notNull": false
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": true,
"default": "'user'"
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"users_email_unique": {
"name": "users_email_unique",
"nullsNotDistinct": false,
"columns": [
"email"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.verifications": {
"name": "verifications",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"identifier": {
"name": "identifier",
"type": "text",
"primaryKey": false,
"notNull": true
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true
},
"expires_at": {
"name": "expires_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {
"public.task_priority": {
"name": "task_priority",
"schema": "public",
"values": [
"critical",
"high",
"medium",
"low"
]
},
"public.task_source": {
"name": "task_source",
"schema": "public",
"values": [
"donovan",
"david",
"hammer",
"heartbeat",
"cron",
"other"
]
},
"public.task_status": {
"name": "task_status",
"schema": "public",
"values": [
"active",
"queued",
"blocked",
"completed",
"cancelled"
]
}
},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View File

@@ -8,6 +8,13 @@
"when": 1769658956087,
"tag": "0000_grey_starhawk",
"breakpoints": true
},
{
"idx": 1,
"version": "7",
"when": 1769670192629,
"tag": "0001_mighty_callisto",
"breakpoints": true
}
]
}

View File

@@ -38,6 +38,14 @@ export interface ProgressNote {
note: string;
}
export interface Subtask {
id: string;
title: string;
completed: boolean;
completedAt?: string;
createdAt: string;
}
// ─── Projects ───
export interface ProjectLink {
@@ -73,6 +81,8 @@ export const tasks = pgTable("tasks", {
assigneeId: text("assignee_id"),
assigneeName: text("assignee_name"),
projectId: uuid("project_id").references(() => projects.id, { onDelete: "set null" }),
dueDate: timestamp("due_date", { withTimezone: true }),
subtasks: jsonb("subtasks").$type<Subtask[]>().default([]),
progressNotes: jsonb("progress_notes").$type<ProgressNote[]>().default([]),
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull(),

View File

@@ -1,6 +1,6 @@
import { Elysia, t } from "elysia";
import { db } from "../db";
import { tasks, type ProgressNote } from "../db/schema";
import { tasks, type ProgressNote, type Subtask } from "../db/schema";
import { eq, asc, desc, sql, inArray, or } from "drizzle-orm";
import { auth } from "../lib/auth";
@@ -153,6 +153,8 @@ export const taskRoutes = new Elysia({ prefix: "/api/tasks" })
position: (maxPos[0]?.max ?? 0) + 1,
taskNumber: nextNumber,
projectId: body.projectId || null,
dueDate: body.dueDate ? new Date(body.dueDate) : null,
subtasks: [],
progressNotes: [],
})
.returning();
@@ -190,6 +192,7 @@ export const taskRoutes = new Elysia({ prefix: "/api/tasks" })
])
),
projectId: t.Optional(t.Union([t.String(), t.Null()])),
dueDate: t.Optional(t.Union([t.String(), t.Null()])),
}),
}
)
@@ -236,6 +239,8 @@ export const taskRoutes = new Elysia({ prefix: "/api/tasks" })
if (body.assigneeId !== undefined) updates.assigneeId = body.assigneeId;
if (body.assigneeName !== undefined) updates.assigneeName = body.assigneeName;
if (body.projectId !== undefined) updates.projectId = body.projectId;
if (body.dueDate !== undefined) updates.dueDate = body.dueDate ? new Date(body.dueDate) : null;
if (body.subtasks !== undefined) updates.subtasks = body.subtasks;
const updated = await db
.update(tasks)
@@ -263,10 +268,107 @@ export const taskRoutes = new Elysia({ prefix: "/api/tasks" })
assigneeId: t.Optional(t.Union([t.String(), t.Null()])),
assigneeName: t.Optional(t.Union([t.String(), t.Null()])),
projectId: t.Optional(t.Union([t.String(), t.Null()])),
dueDate: t.Optional(t.Union([t.String(), t.Null()])),
subtasks: t.Optional(t.Array(t.Object({
id: t.String(),
title: t.String(),
completed: t.Boolean(),
completedAt: t.Optional(t.String()),
createdAt: t.String(),
}))),
}),
}
)
// POST add subtask - requires auth
.post(
"/:id/subtasks",
async ({ params, body, request, headers }) => {
await requireSessionOrBearer(request, headers);
const task = await resolveTask(params.id);
if (!task) throw new Error("Task not found");
const currentSubtasks = (task.subtasks || []) as Subtask[];
const newSubtask: Subtask = {
id: `st-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
title: body.title,
completed: false,
createdAt: new Date().toISOString(),
};
currentSubtasks.push(newSubtask);
const updated = await db
.update(tasks)
.set({ subtasks: currentSubtasks, updatedAt: new Date() })
.where(eq(tasks.id, task.id))
.returning();
return updated[0];
},
{
params: t.Object({ id: t.String() }),
body: t.Object({ title: t.String() }),
}
)
// PATCH toggle subtask - requires auth
.patch(
"/:id/subtasks/:subtaskId",
async ({ params, body, request, headers }) => {
await requireSessionOrBearer(request, headers);
const task = await resolveTask(params.id);
if (!task) throw new Error("Task not found");
const currentSubtasks = (task.subtasks || []) as Subtask[];
const subtask = currentSubtasks.find((s) => s.id === params.subtaskId);
if (!subtask) throw new Error("Task not found");
if (body.completed !== undefined) {
subtask.completed = body.completed;
subtask.completedAt = body.completed ? new Date().toISOString() : undefined;
}
if (body.title !== undefined) {
subtask.title = body.title;
}
const updated = await db
.update(tasks)
.set({ subtasks: currentSubtasks, updatedAt: new Date() })
.where(eq(tasks.id, task.id))
.returning();
return updated[0];
},
{
params: t.Object({ id: t.String(), subtaskId: t.String() }),
body: t.Object({
completed: t.Optional(t.Boolean()),
title: t.Optional(t.String()),
}),
}
)
// DELETE subtask - requires auth
.delete(
"/:id/subtasks/:subtaskId",
async ({ params, request, headers }) => {
await requireSessionOrBearer(request, headers);
const task = await resolveTask(params.id);
if (!task) throw new Error("Task not found");
const currentSubtasks = (task.subtasks || []) as Subtask[];
const filtered = currentSubtasks.filter((s) => s.id !== params.subtaskId);
const updated = await db
.update(tasks)
.set({ subtasks: filtered, updatedAt: new Date() })
.where(eq(tasks.id, task.id))
.returning();
return updated[0];
},
{
params: t.Object({ id: t.String(), subtaskId: t.String() }),
}
)
// POST add progress note - requires auth
.post(
"/:id/notes",