Fix NaN comparator skipping tiebreaker in project sorting

When both projects lack timestamps and have no threads, getProjectSortTimestamp
returns NEGATIVE_INFINITY for both. Subtracting NEGATIVE_INFINITY - NEGATIVE_INFINITY
yields NaN, and since NaN !== 0 is true, the comparator returned NaN instead of
falling through to the name/id tiebreaker. Add Number.isNaN guard to the condition.
This commit is contained in:
Cursor Agent committed 2026-03-24 18:49:37 +00:00
1 parent d9ef0ca2ef
commit 659ca5e71b
1 file changed
+1 -1
+1 -1
View File
@@ -270,7 +270,7 @@ export function sortProjectsForSidebar<TProject extends SidebarProject, TThread
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);
});
}