feat(tasks): label hierarchy with path names and a label filter in the Tasks view

Merged
KI
2mo ago
+687-32

Refs #8454 (label hierarchy and grouping by company and project).

What changes

  • Path labels. A label named acme/website creates its parents (acme) and links each label to its parent through task_labels.parent_id. Names stay unique per organization, so there is no migration, and clients that match labels by name keep working. normalizeLabelName trims each segment, so Acme / Website becomes acme/website.
  • Filter includes sub-labels. The labels filter on task.list and task.listPage (from #8458) now matches a label and its sub-labels, so acme returns tasks labelled acme/website. A name prefix does not match: acm returns nothing. CLI --labels, MCP tasks_list, and the docs say so.
  • Desktop Tasks view: Label filter. A new top-bar filter shows the labels as a tree and filters on the server, so it covers every task and not only the loaded pages. It is in the URL (?label=), kept when opening a task and going back, and when leaving Tasks and coming back through the sidebar.
  • Label picker. Sub-labels are indented under their parent. The Create item stays visible when the typed path has spaces around the slash; before, cmdk's fuzzy match hid it and nothing could be created.

The sidebar of companies and projects from the issue is not in this PR. The Label filter covers the same navigation.

Tests

  • Unit: ensureLabels creates and links parents (new labels.test.ts), the SQL matches sub-labels with LIKE escaped (task-list-query.test.ts), the routers forward labels (list.test.ts), and path helpers and tree order (packages/shared/src/labels.test.ts). The new server tests fail on main.
  • End to end on a local API and the dev desktop over CDP. Screenshots are on the Superset page linked in the comments.
    • Seeded 9 tasks through task.create with path labels. The DB shows each label linked to its parent, 3 levels deep for globex/platform/api.
    • listPage with acme returns all 5 Acme tasks, acme/website returns 2, globex/platform returns 1, and acm returns 0.
    • In the app, choosing acme, then acme/website, then globex (board view) shows the right tasks. "All labels" clears the filter. The filter is kept when opening a task and going back, and through a sidebar round trip.
    • Created Acme / Design from the task's label picker. It saved as acme/design and is linked to acme.
    • No console errors during the flow.
  • bun test: shared, db, trpc, mcp, cli, i18n, and the desktop dashboard all pass. check:i18n passes, with translations for all 16 locales. The filter button's "Label" has its own context, because the existing "Label" string means a field name.

Summary by cubic

Adds label hierarchy with path names and a server-side Label filter in the desktop Tasks view (refs #8454).

New Features

  • A label named acme/web creates its parents (acme) and links each label to its parent via task_labels.parent_id; names stay unique per organization, so no migration is needed.
  • Creating a path label runs in a transaction, so a failure can't leave a partial label tree.
  • normalizeLabelName trims each segment, so Acme / Website becomes acme/website.
  • The labels filter on task.list and task.listPage matches a label, its sub-labels, and the stored name of labels saved before normalization. acme returns tasks labelled acme/website, but acm matches nothing; a filter that cannot be a label (over 64 characters, or only slashes) matches nothing instead of being dropped.
  • The Tasks view's Label filter shows labels as a tree, filters server-side, and persists in the URL (?label=).
  • Sub-labels are indented in the label picker, and the Create item stays visible when the typed path has spaces around the slash.
  • The company/project sidebar from the issue is not included; the Label filter covers that navigation.

Summary by CodeRabbit

  • New Features
    • Filter tasks by label with searchable selection and nested labels displayed in a hierarchy.
    • Preserve the selected label when navigating between the task list and task details, and when creating tasks.
    • Label filters match the selected label and its sub-labels, ignoring letter case and surrounding spaces.
  • Documentation
    • Clarified that task label filters match sub-labels as well as exact labels.