Conversation
Rizhiy
force-pushed
the
feat/active-first-task-widget
branch
from
August 14, 2026 01:57
0f4692f to
66797be
Compare
Rizhiy
force-pushed
the
feat/active-first-task-widget
branch
from
August 14, 2026 02:07
66797be to
60b8dff
Compare
tintinweb
added a commit
that referenced
this pull request
Aug 16, 2026
The built-in `status` order is completed-first, the reverse of the TaskList tool, so finished work sits on top of active work. Two PRs reached for a fix a month apart: #35 added a sortDirection flag that reverses the result, #54 made sortOrder a comparator function loaded by require() from a tasks-config.cjs — including one inside the project's .pi/. Neither shape survives. Reversing an order also flips its tie-breaks, so `status` descending gives pending-first with ids descending inside each group, which is not what either author wanted. And executing config code from a path that lives inside every cloned repository trades a display setting for arbitrary code execution. sortOrder now also accepts a sort spec: an ordered list of comparison keys (id / status / updatedAt), each with an optional direction and, on status, a custom rank. Pure data, no code. The presets are themselves specs, and a new `active` preset — in-progress → pending → completed, ties by id ascending — is exactly the order both PRs were chasing, selectable from the settings menu without editing a file. Specs are validated where they are read: an unknown field, direction or status falls back to id order rather than breaking the widget. collapseCompleted folds finished tasks into one `✔ N completed` line, composing with the visible limit instead of overriding it — collapsing decides what is in the list, then maxVisible/showAll/hiddenAt apply to what is left, so a long backlog stays bounded. The header still counts every task. The four existing presets reproduce their original comparators exactly, tie-breaks included; a differential fuzz over 20k random task sets with duplicate ids and forced timestamp ties found no divergence across 80k orderings. Deliberately not ported from #35: a memoized sort cache that builds a JSON.stringify signature over every task per frame, which for a ≤100-task widget costs more than the sort it skips. Two behaviour changes fall out of validating what was previously unchecked. An unrecognised hiddenAt indexed the truncation table to undefined and threw on every render — caught by the render guard, so the widget silently showed nothing at all — and now narrows to bottom. An unrecognised sortOrder name selected no comparator and left tasks in storage order; it now sorts by id. CUSTOMIZING.md covers config scopes, presets, specs, recipes and failure modes, linked from the README. Converges #35 (thanks @Minh-Ng) and #54 (thanks @Rizhiy).
Owner
|
Landed this in bce4b88.
For sorting I went with a JSON sort spec instead of a comparator loaded from "sortOrder": [
{ "field": "status", "rank": ["in_progress", "pending", "completed"] },
{ "field": "id" }
]Docs: https://github.com/tintinweb/pi-tasks/blob/master/CUSTOMIZING.md Closing since it's on master. Thanks for the PR. |
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.
Allows
sortOrderto be a comparator function loaded fromtasks-config.cjs, and adds optional completed-task collapsing.Existing defaults, built-in sort behavior, and tests are unchanged. Three tests cover the new options.
Tests: lint, typecheck, 194 tests, build.