Skip to content

feat: sort sidebar projects by name#2061

Open
MRL-00 wants to merge 1 commit into
generalaction:mainfrom
MRL-00:emdash/audit-3nr41
Open

feat: sort sidebar projects by name#2061
MRL-00 wants to merge 1 commit into
generalaction:mainfrom
MRL-00:emdash/audit-3nr41

Conversation

@MRL-00
Copy link
Copy Markdown

@MRL-00 MRL-00 commented May 17, 2026

Summary

  • add a Project name option to the left sidebar sort menu
  • persist the new sidebar sort value
  • sort projects alphabetically when selected while preserving manual drag order after reordering
  • add focused SidebarStore coverage for project-name sorting

Validation

  • pnpm run format:check
  • pnpm run lint
  • pnpm run typecheck
  • pnpm run test

@MRL-00 MRL-00 force-pushed the emdash/audit-3nr41 branch from 97bff65 to 0828670 Compare May 17, 2026 02:17
@MRL-00 MRL-00 marked this pull request as ready for review May 17, 2026 02:17
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 17, 2026

Greptile Summary

This PR adds a "Project name" sort option to the left sidebar, persists the new value in SidebarSnapshot, and extends SidebarTaskSortBy with the 'project-name' variant. Alphabetical sorting is implemented via localeCompare with sensitivity: 'base' and numeric: true, with a clean fallback to manual drag order when projectOrder is non-empty.

  • sidebar-store.ts: orderedProjects branches on taskSortBy === 'project-name' && projectOrder.length === 0 for alphabetical project sort; applySort('project-name') resets projectOrder to [] to trigger the alpha path.
  • projects-group-label.tsx: Adds a "Project name" DropdownMenuRadioItem wired to applySort, consistent with the existing "Created at" and "Last used" items.
  • sidebar-store.test.ts: New focused tests verify alphabetical ordering (case-insensitive) and that a subsequent drag reorder takes precedence over the name sort.

Confidence Score: 3/5

The 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 compareSidebarTasks function uses taskSortBy directly and only special-cases 'created-at'; with 'project-name' now in the union, it falls into the 'updated' branch and re-sorts all tasks by last-used without any user action or indication. A user who had created-at task sort selected and switches to project-name ordering will silently see their per-project task lists change sort order.

sidebar-store.ts — specifically the compareSidebarTasks method and how it handles the new 'project-name' value of taskSortBy.

Important Files Changed

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
Loading

Comments Outside Diff (1)

  1. src/renderer/features/sidebar/sidebar-store.ts, line 256-258 (link)

    P1 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.

    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

@MRL-00 MRL-00 force-pushed the emdash/audit-3nr41 branch from 0828670 to 3e1270d Compare May 17, 2026 02:23
@MRL-00
Copy link
Copy Markdown
Author

MRL-00 commented May 17, 2026

Comments Outside Diff (1)

1. `src/renderer/features/sidebar/sidebar-store.ts`, line 256-258 ([link](https://github.com/generalaction/emdash/blob/08286705e06e4c82714f488bd861ecd7f6d1a2db/src/renderer/features/sidebar/sidebar-store.ts#L256-L258))
   [![P1](https://camo.githubusercontent.com/c55832478de9ec76ba43f0e9de8efcbadfbbe4ff14662a15ab9e7b9945895a9b/68747470733a2f2f6772657074696c652d7374617469632d6173736574732e73332e616d617a6f6e6177732e636f6d2f6261646765732f70312e7376673f763d38)](#) **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.
   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

Reviews (1): Last reviewed commit: "feat: sort sidebar projects by name" | Re-trigger Greptile

Probably not a major but has been fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant