From 2bb28fe65f773601c9e683ceedce1b59e1a3672a Mon Sep 17 00:00:00 2001 From: bot-hermes Date: Thu, 6 Aug 2026 13:53:29 +0000 Subject: [PATCH] fix(tasks): support status query param in list API and use it in today-tasks widget The dashboard widget was filtering with a broken filter=status!=done query param that the list API never interpreted, so completed tasks could appear. Add a status= todo,in_progress filter to GET /api/tasks and update the widget to use it (also fix domain badge to use domainId). --- apps/web/app/api/tasks/route.ts | 5 +++++ .../components/dashboard/widgets/today-tasks-widget.tsx | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/web/app/api/tasks/route.ts b/apps/web/app/api/tasks/route.ts index 53adbd7..ae53d26 100644 --- a/apps/web/app/api/tasks/route.ts +++ b/apps/web/app/api/tasks/route.ts @@ -34,6 +34,7 @@ export const GET = withAuth(async (request: NextRequest, _user) => { const page = Math.max(1, parseInt(searchParams.get('page') || '1')); const perPage = Math.min(100, Math.max(1, parseInt(searchParams.get('perPage') || '50'))); const filter = searchParams.get('filter') || undefined; + const status = searchParams.get('status'); const sort = searchParams.get('sort') || '-created'; const domainId = searchParams.get('domain') || undefined; @@ -54,6 +55,10 @@ export const GET = withAuth(async (request: NextRequest, _user) => { const conditions: any[] = [isNull(tasks.deletedAt)]; if (domainId) conditions.push(eq(tasks.domainId, domainId)); + if (status) { + const statuses = status.split(','); + conditions.push(inArray(tasks.status, statuses as any)); + } if (filter) { conditions.push( or( diff --git a/apps/web/components/dashboard/widgets/today-tasks-widget.tsx b/apps/web/components/dashboard/widgets/today-tasks-widget.tsx index 1508a34..dba365f 100644 --- a/apps/web/components/dashboard/widgets/today-tasks-widget.tsx +++ b/apps/web/components/dashboard/widgets/today-tasks-widget.tsx @@ -12,7 +12,8 @@ interface Task { title: string; status: string; priority: string; - domain: string; + domainId?: string; + domain?: string; } interface Domain { id: string; name: string; color: string; } @@ -43,7 +44,7 @@ export function TodayTasksWidget() { async function fetchTasks() { try { const response = await fetch( - '/api/tasks?filter=status!%3D%22done%22&perPage=5&sort=-priority' + '/api/tasks?status=todo,in_progress&perPage=5&sort=-priority' ); if (response.ok) { const data = await response.json(); @@ -115,7 +116,7 @@ export function TodayTasksWidget() { {task.title} - {domainMap.get(task.domain) || task.domain} + {domainMap.get(task.domainId ?? task.domain ?? '') || task.domainId || task.domain} ))}