feat: sort sidebar projects by name#2061
Conversation
97bff65 to
0828670
Compare
Greptile SummaryThis PR adds a "Project name" sort option to the left sidebar, persists the new value in
Confidence Score: 3/5The project ordering itself works correctly, but selecting 'Project name' silently changes how tasks within projects are ordered, which is an unintended side-effect that could confuse users. The
|
| Filename | Overview |
|---|---|
| src/renderer/features/sidebar/sidebar-store.ts | Adds alphabetical project sorting via compareSidebarProjects and toggles on empty projectOrder; however, compareSidebarTasks silently falls back to updated-at when taskSortBy === 'project-name', unintentionally changing task sort for users who previously had created-at selected. |
| src/renderer/features/sidebar/sidebar-store.test.ts | New test file covering project-name sort and manual-order precedence; does not test that task sort within projects is unaffected when project-name sort is active. |
| src/renderer/features/sidebar/projects-group-label.tsx | Adds a 'Project name' radio item to the sort dropdown; wires onClick to sidebarStore.applySort('project-name') consistently with existing items. |
| src/shared/view-state.ts | Extends SidebarTaskSortBy union type with 'project-name'; backward-compatible change, old snapshots without this value will parse as undefined and fall back to the default. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User selects sort option] --> B{sortBy value}
B -->|'created-at'| C[applySort: set taskSortBy, clear taskOrderByProject]
B -->|'updated-at'| C
B -->|'project-name'| D[applySort: set taskSortBy, clear taskOrderByProject, clear projectOrder]
D --> E[orderedProjects]
C --> E
E --> F{taskSortBy === 'project-name' AND projectOrder.length === 0?}
F -->|Yes| G[Sort real projects via compareSidebarProjects]
F -->|No| H[Sort real projects by projectOrder index]
G --> I[Return unregistered ++ sorted]
H --> I
I --> J[sidebarRows iterates orderedProjects]
J --> K[compareSidebarTasks for tasks within project]
K --> L{taskSortBy === 'created-at'?}
L -->|Yes| M[kind = 'created']
L -->|No — includes 'project-name'!| N[kind = 'updated' — silent fallback]
M --> O[Sort tasks by createdAt]
N --> P[Sort tasks by lastInteractedAt/updatedAt]
style N fill:#f96,stroke:#c33
style P fill:#f96,stroke:#c33
Comments Outside Diff (1)
-
src/renderer/features/sidebar/sidebar-store.ts, line 256-258 (link)Task sort silently changes to
updated-atwhen "Project name" is selectedcompareSidebarTasksderiveskindasthis.taskSortBy === 'created-at' ? 'created' : 'updated'. Because'project-name'is not'created-at', tasks within every project will be sorted bylastInteractedAt(updated-at) the moment the user picks "Project name" — even if they previously had "Created at" task sort active. A user withcreated-attask sort who switches to project-name ordering will see their per-project task lists silently re-sorted, with no indication that the task sort changed.Prompt To Fix With AI
This is a comment left during a code review. Path: src/renderer/features/sidebar/sidebar-store.ts Line: 256-258 Comment: **Task sort silently changes to `updated-at` when "Project name" is selected** `compareSidebarTasks` derives `kind` as `this.taskSortBy === 'created-at' ? 'created' : 'updated'`. Because `'project-name'` is not `'created-at'`, tasks within every project will be sorted by `lastInteractedAt` (updated-at) the moment the user picks "Project name" — even if they previously had "Created at" task sort active. A user with `created-at` task sort who switches to project-name ordering will see their per-project task lists silently re-sorted, with no indication that the task sort changed. How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
src/renderer/features/sidebar/sidebar-store.ts:256-258
**Task sort silently changes to `updated-at` when "Project name" is selected**
`compareSidebarTasks` derives `kind` as `this.taskSortBy === 'created-at' ? 'created' : 'updated'`. Because `'project-name'` is not `'created-at'`, tasks within every project will be sorted by `lastInteractedAt` (updated-at) the moment the user picks "Project name" — even if they previously had "Created at" task sort active. A user with `created-at` task sort who switches to project-name ordering will see their per-project task lists silently re-sorted, with no indication that the task sort changed.
Reviews (1): Last reviewed commit: "feat: sort sidebar projects by name" | Re-trigger Greptile
0828670 to
3e1270d
Compare
Probably not a major but has been fixed! |
Summary
Validation