feat(tasks): filter task lists by exact labels

Merged
KI
2mo ago
+90-0

Refs #8454 (the exact label filter part; hierarchy and sidebar are not in this PR).

Problem

There is no way to list tasks with a given label. --search acme also matches titles and descriptions. The query layer already had an exact label filter (TaskListFilters.labels), but taskListFilterSchema had no labels field, so zod dropped it.

Change

  • task.list / task.listPage: optional labels: string[] (max 20), passed to buildTaskListConditions. A task must have every label; names are trimmed and lowercased. Optional field, so released clients are unaffected.
  • CLI: superset tasks list --labels acme,client-one. Rejected for --tracker linear.
  • MCP tasks_list: labels input, rejected for Linear.
  • SDK TaskListParams.labels, CLI and SDK docs.

The desktop Tasks view still filters on the client; moving it to the server filter is a follow-up.

Tests

  • list.test.ts calls task.list and task.listPage and checks that each label reaches the query (trimmed, lowercased), and that a label of only spaces is rejected. Both tests fail without the change.
  • End to end against a local API on a worktree Neon branch, with the built CLI, the /mcp endpoint and the SDK:
    • --labels acme returns only tasks with that label; a task that only mentions "acme" in its title is not returned (--search acme returns it).
    • --labels acme,client-one requires both. " ACME , Client-One " matches the same. An unknown label returns nothing.
    • Combines with --assignee-me. --labels "," applies no filter.
    • task.listPage (desktop path) and MCP tasks_list filter the same way. SDK tasks.list({ labels }) works.
    • --tracker linear --labels and MCP tracker: "linear" with labels are rejected.
    • 21 labels and "" are rejected. A call without labels returns the same rows as before.
  • bun test in packages/trpc passes. Typecheck shows no errors in changed files.

Summary by CodeRabbit

  • New Features
    • Filter Superset tasks by labels when listing them through the CLI, SDK, and task tools. Provide one or more labels; tasks must match all specified labels.
    • Label matching is exact and ignores capitalization in the task tools. The CLI accepts comma-separated labels and ignores extra whitespace.
  • Limitations
    • Label filtering is not supported for Linear task listings.