Skip to content

feat(filter): sort tasks the way the Todoist apps do - #479

Open
craigcarlyle wants to merge 2 commits into
craigcarlyle/task-sortfrom
craigcarlyle/fix-issue-473
Open

feat(filter): sort tasks the way the Todoist apps do#479
craigcarlyle wants to merge 2 commits into
craigcarlyle/task-sortfrom
craigcarlyle/fix-issue-473

Conversation

@craigcarlyle

@craigcarlyle craigcarlyle commented Aug 17, 2026

Copy link
Copy Markdown

Summary

  • td filter view now orders tasks the way the Todoist apps order them, instead of printing whatever order the API returned
  • Applies the sorting saved on that filter's view, and falls back to Todoist's default hierarchy when the view has none, which is what "Manual (default)" means in the app
  • Adds --sort default|priority|date|deadline|date-added|name|project|assignee|workspace|none and --sort-order asc|desc, with precedence running flag, saved view, Todoist default
  • --sort none gives back the raw API order
  • Sorts each section of a comma-separated filter on its own, and returns --json / --ndjson in the same order as the pretty output
  • Prints the resolved sort in the view header, under Query: and URL:
  • Stacked on feat(sort): add task ordering that matches the Todoist apps #480, which adds the two modules this wires up

Why the order was wrong

  • Todoist doesn't sort server-side. GET /tasks/filter returns storage order, roughly date added ascending, which is why the reporter found that setting their filter to "date added asc" made the app match the CLI
  • Every Todoist client sorts locally, by sorted_by on the view and then by a documented default
  • The CLI read neither piece

Not addressed

Test plan

  • 11 new tests in the filter suite: saved sort applied, flag overrides it, per-section ordering, JSON path sorted, unreadable view options fall back
  • Full suite passes (1838 tests)
  • Type-check, lint, format and SKILL.md sync clean
  • Manual: a filter whose view is saved with sorted_by: PRIORITY renders p1 first
  • Manual: --sort none reproduces the pre-fix order
  • Manual: default-sorted filter with date queries leads with date, priority breaks the tie, and a p1 due later still sorts last
$ td filter show <filter-id> --all --json | jq -r '.sections[0].results[] | "p\(5 - .priority)  \(.due.date)"'
p3  2026-08-17
p3  2026-08-17
p4  2026-08-17
p4  2026-08-18
p4  2026-08-19
p4  2026-08-21
p1  2026-08-23
  • Manual: --sort assignee across a workspace filter with 13 assignees sorts A-Z with unassigned last, and --sort-order desc reverses to Z-A with unassigned first

Closes #473

@doistbot

This comment was marked as outdated.

@craigcarlyle
craigcarlyle force-pushed the craigcarlyle/fix-issue-473 branch from 712c7b8 to f2ed126 Compare August 17, 2026 18:10
@craigcarlyle
craigcarlyle changed the base branch from main to craigcarlyle/task-sort August 17, 2026 18:11
craigcarlyle and others added 2 commits August 17, 2026 11:29
`td filter view` printed tasks in whatever order the API returned, because
the CLI never read the sorting saved on the view and never applied Todoist's
default ordering.

Wires `task-sort` and the view options reader into the command behind
`--sort` and `--sort-order`. Each section of a multi-query filter sorts on
its own, and `--json` / `--ndjson` come back in the same order as the pretty
output.

Closes #473

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`sortNeedsProjects` now covers every field except `none`, so `--json --sort
name` fetches projects like the pretty path does and the two orders agree.
Splits the old assertion in two: one for a named sort, one for `--sort none`,
which is the only path that still skips the fetch.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@craigcarlyle
craigcarlyle force-pushed the craigcarlyle/fix-issue-473 branch from f2ed126 to 627fe70 Compare August 17, 2026 18:30
@craigcarlyle craigcarlyle self-assigned this Aug 17, 2026
@craigcarlyle craigcarlyle added the 🙋 Ask PR PR must be reviewed before merging label Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🙋 Ask PR PR must be reviewed before merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: sorting via views is not working by default

2 participants