fix: support sections in filter views - #472
Merged
Merged
Conversation
doistbot
reviewed
Aug 10, 2026
doistbot
left a comment
Member
There was a problem hiding this comment.
This PR fixes support for Todoist's comma-separated saved filters by splitting them into individual API requests per section, with concurrent fetching and order-preserving output across human, JSON, and NDJSON formats.
Few things worth tightening:
- Skip the project/cache lookup in the multi-section path when all sections return no tasks — currently an empty multi-section filter still calls
getProjects(), and if that unrelated request fails, the command errors instead of cleanly rendering the empty results.
I also included a few optional follow-up notes in the details below.
Optional follow-up notes (5)
src/commands/filter/filter.test.ts:507: Reuse
fixtures.tasks.basic(with per-test overrides) for these new task responses instead of hand-building partial task objects. The shared fixture supplies a valid SDK task shape and keeps test data consistent; the same applies to the new literals in this test block.src/commands/filter/view.ts:79:
formatFilterSectionsJsonandformatFilterSectionsNdjsonshare an identicalsections.map((section) => ({ query, results: section.results.map(task => processJsonItem(...)), nextCursor }))body — only the outer wrapper (formatJson({ sections })vsformatNdjson(...)) differs. Extract the shared mapping into a small helper (e.g.mapFilterSections(sections, full, showUrls)) so the two callers don't drift apart if the section payload shape changes.src/commands/filter/view.ts:134: Move this flattening below the JSON/NDJSON early returns. Structured output only reads
sections, so this creates an unused second array of every task; with--allon a multi-section filter that can be a large allocation.src/commands/filter/view.ts:107:
Promise.allfans out all section requests concurrently with no bound. A filter with many comma-separated queries — say, 20+ — would fire that many concurrent API calls, each of which may paginate further. While uncommon in practice, adding a modest concurrency cap (e.g., 5–10) with a simple semaphore or a library likep-limitwould prevent request bursts without meaningfully hurting latency for the common case of 2–5 sections.src/commands/filter/filter.test.ts:630: No test covers the documented behavior that empty fragments like the middle fragment in
today,,tomorroware ignored. The exportedsplitFilterQueriesfunction explicitly skips empty trimmed sections (lines 37-38 in view.ts), and the PR description calls this out as intentional. A naive refactor (e.g., usingquery.split(',')) would regress silently — users would see empty section headers in their output. Consider adding a unit test forsplitFilterQueriescovering empty fragments and/or the odd-backslash escape rule, since the function is exported and has documented edge cases not exercised by the integration tests.
scottlovegrove
approved these changes
Aug 11, 2026
Co-authored-by: Scott Lovegrove <scott@ferretlabs.com>
gnapse
force-pushed
the
ernesto/fix-filter-view-sections
branch
from
August 11, 2026 12:58
23b479e to
2757576
Compare
Contributor
|
🎉 This PR is included in version 3.1.8 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #274
Why
Todoist saved filters use commas to display queries as separate lists. However, the public Get Tasks By Filter API documentation states: “Multiple filters (using the comma
,operator) are not supported.”The CLI passed the full saved query to that endpoint, which returned a successful empty result. This change splits the saved query and calls the endpoint once per section.
Behavior and deliberate simplifications
today,,tomorrow, are ignored.--limitapplies independently to each section.--cursoris rejected for multi-section filters because one cursor cannot represent several independent streams. Use--all, or query one section directly. Structured output includesnextCursorper section.{ sections: [{ query, results, nextCursor }] }. NDJSON emits one section object per line. Single-section output stays unchanged.Validation
Tests
npm run type-checknpm run checknpm run check:skill-syncnpm test— 1,795 tests pass