OUT-3494 | Improve default sorting for subtasks#1211
OUT-3494 | Improve default sorting for subtasks#1211arpandhakal wants to merge 3 commits intomainfrom
Conversation
Sort subtasks by status (started, unstarted, completed, backlog, cancelled), then due date ASC nulls last, then createdAt ASC. Applied to the details page (incl. optimistic insert) and the board/list views via subtasksByTaskId. Top-level task sort is unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Deployment failed with the following error: Learn More: https://vercel.link/multiple-function-regions |
Greptile SummaryThis PR introduces a new
Confidence Score: 4/5Safe to merge; the new sort logic is correct and the board/create paths work as described. The sort comparator itself is correct — status priority, due-date ASC nulls last, createdAt ASC, and id tiebreaker are all implemented accurately. The gap is in src/app/detail/ui/Subtasks.tsx — the optimistic-update path doesn't call the new sort, leaving ordering stale after status/due-date changes. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Subtask list needed] --> B{Which view?}
B -->|Details page - create| C[getTempTask\nbuilds temp subtask]
C --> D[sortSubtasksByPriority\ninserted into existing list]
D --> E[optimisticData → mutate\nrevalidate: true]
B -->|Details page - update| F[handleSubTaskUpdate\n.map applies changes]
F --> G[optimisticData — NO re-sort\nrevalidate: false]
G --> H[Stale order until\nnext natural refresh]
B -->|Board / List view| I[subtasksByTaskId memo\naccessibleTasks grouped by parentId]
I --> J[sortSubtasksByPriority\nper group]
J --> K[Rendered in column/row]
subgraph sortSubtasksByPriority
S1[1. Workflow state type priority\nstarted→unstarted→completed→backlog→cancelled]
S2[2. dueDate ASC, nulls last]
S3[3. createdAt ASC]
S4[4. id tiebreaker]
S1 --> S2 --> S3 --> S4
end
|
The details page was rendering subtasks straight from SWR data without client-side sorting, so revalidation reverted the order to the backend's createdAt DESC. Sort the rendered list via useMemo so optimistic and revalidated data both go through the same comparator. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
sortSubtasksByPriority— sorts subtasks by status (started→unstarted→completed→backlog→cancelled), thendueDateASC nulls last, thencreatedAtASC (oldest first), withidas a stability tiebreaker.Subtasks.tsx, including the optimistic-insert path) and on the board/list views viasubtasksByTaskIdinTaskBoard.tsx. List view inherits the order through the same dictionary.sortTaskByDescendingOrder) is unchanged. Templates (Subtemplates.tsx) and the backend orderBy are not touched — every web subtask render path re-sorts client-side, so the DB order is irrelevant for what users see.Linear: https://linear.app/assemblycom/issue/OUT-3494/improve-default-sorting-for-subtasks
Test plan
In Progressitems appear first,Todonext,Doneafter,Backlog/Cancelledlast