Sort sidebar projects and threads by recency#1372
Conversation
- Add configurable project and thread sidebar sort orders - Keep manual project reordering when enabled - Animate sidebar list updates and cover new sort logic with tests
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
- Avoid cloning thread arrays before sorting - Cache loaded project favicons across sidebar renders - Update sidebar sort labels for clearer wording
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: NaN comparator skips tiebreaker in project sorting
- Added a
!Number.isNaN(byTimestamp)guard to the comparator condition so that when both projects resolve to NEGATIVE_INFINITY the NaN result falls through to the name/id tiebreaker.
- Added a
Or push these changes by commenting:
@cursor push 659ca5e71b
Preview (659ca5e71b)
diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.ts
--- a/apps/web/src/components/Sidebar.logic.ts
+++ b/apps/web/src/components/Sidebar.logic.ts
@@ -270,7 +270,7 @@
const byTimestamp =
getProjectSortTimestamp(right, threadsByProjectId.get(right.id) ?? [], sortOrder) -
getProjectSortTimestamp(left, threadsByProjectId.get(left.id) ?? [], sortOrder);
- if (byTimestamp !== 0) return byTimestamp;
+ if (byTimestamp !== 0 && !Number.isNaN(byTimestamp)) return byTimestamp;
return left.name.localeCompare(right.name) || left.id.localeCompare(right.id);
});
}- Keep the current thread visible in folded project thread lists - Extract shared visible-thread selection logic and cover it with tests
- Treat missing or invalid timestamps as absent instead of zero - Fall back to name and id ordering when projects have no sortable dates - Add coverage for timestamp-less project sorting
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: NaN from NEGATIVE_INFINITY subtraction breaks sort tiebreaker
- Replaced subtraction-based comparison with explicit equality/greater-than checks (matching sortProjectsForSidebar), so two NEGATIVE_INFINITY values correctly produce 0 and fall through to the ID tiebreaker.
Or push these changes by commenting:
@cursor push e09809f495
Preview (e09809f495)
diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.ts
--- a/apps/web/src/components/Sidebar.logic.ts
+++ b/apps/web/src/components/Sidebar.logic.ts
@@ -270,8 +270,10 @@
T extends Pick<Thread, "id" | "createdAt" | "updatedAt" | "messages">,
>(threads: readonly T[], sortOrder: SidebarThreadSortOrder): T[] {
return threads.toSorted((left, right) => {
+ const rightTimestamp = getThreadSortTimestamp(right, sortOrder);
+ const leftTimestamp = getThreadSortTimestamp(left, sortOrder);
const byTimestamp =
- getThreadSortTimestamp(right, sortOrder) - getThreadSortTimestamp(left, sortOrder);
+ rightTimestamp === leftTimestamp ? 0 : rightTimestamp > leftTimestamp ? 1 : -1;
if (byTimestamp !== 0) return byTimestamp;
return right.id.localeCompare(left.id);
});- Rename the sort timestamp test to better describe the no-threads fallback - No behavior change
- Preserve deterministic id ordering when timestamps are missing - Add coverage for updated_at sort fallback
Merged upstream improvements while preserving fork identity: - Claude Code adapter support (pingdotgg#179) - Context window usage meter (pingdotgg#1351) - Sidebar project/thread sorting by recency (pingdotgg#1372) - Git action progress streaming (pingdotgg#1214, pingdotgg#1388) - Terminal history ANSI preservation (pingdotgg#1367) - Word wrapping setting (pingdotgg#1326) - Resizable chat sidebar (pingdotgg#1347) - Configurable timestamp format (pingdotgg#855) - Selective file staging in commit dialog (pingdotgg#872) - Fuzzy workspace search (pingdotgg#256) - Scroll-to-bottom pill (pingdotgg#619) - Numerous bug fixes and improvements Preserved fork customizations: - Fatma branding (all @t3tools -> @fatma) - Mobile UI (swipe gestures, bottom nav, mobile shells) - VSCode-like source control (staged/unstaged, file diffs) - PWA support - Custom CI/CD workflows Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>


Summary
Testing
apps/web/src/components/Sidebar.logic.test.ts.apps/web/src/appSettings.test.tsand store coverage inapps/web/src/store.test.ts.Note
Medium Risk
Changes sidebar ordering behavior and gates drag-and-drop reordering behind a new setting, which could affect navigation expectations and any code relying on previous stable ordering.
Overview
Adds configurable sidebar sorting for projects and threads. New app settings
sidebarProjectSortOrderandsidebarThreadSortOrder(defaultupdated_at) are introduced and covered by tests.Sidebar rendering now uses shared helpers (
sortProjectsForSidebar,sortThreadsForSidebar) to order by latest user message recency with fallbacks toupdatedAt/createdAt(or manual order for projects), and ensures the active thread stays visible in the collapsed preview.Projects/threads now carry
createdAt/updatedAtfrom the server read model into localProject/Threadstate, the sidebar UI adds a sort menu, disables drag reordering unless inmanualmode, and animates list changes via@formkit/auto-animate.Written by Cursor Bugbot for commit a3bb36c. This will update automatically on new commits. Configure here.
Note
Sort sidebar projects and threads by recency with configurable sort order
sortProjectsForSidebarandsortThreadsForSidebarfunctions in Sidebar.logic.ts that order items by latest user message timestamp, falling back toupdatedAt/createdAt.sidebarProjectSortOrderandsidebarThreadSortOrderapp settings (defaultupdated_at) with a newProjectSortMenuUI in the sidebar header to change them.createdAt/updatedAtfrom the server read model intoProjectandThreadstate objects so sort timestamps are available.@formkit/auto-animateto animate list reordering; drag-and-drop manual reordering is disabled unless the sort order is set toManual.Macroscope summarized a3bb36c.