Skip to content

Commit 088361e

Browse files
committed
Sort sidebar projects alphabetically
1 parent f8fd9cd commit 088361e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/app/api/projects/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export async function GET(request: NextRequest) {
1313
`SELECT id, title, system_prompt AS "systemPrompt", created_at AS "createdAt", updated_at AS "updatedAt"
1414
FROM projects
1515
WHERE user_id = $1
16-
ORDER BY updated_at DESC`,
16+
ORDER BY LOWER(title) ASC`,
1717
[userId],
1818
);
1919
return NextResponse.json(rows);

src/app/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ export default function Home() {
246246
const prevDisplayingProjectManagementIdRef = useRef<number | null>(null);
247247

248248
const isThinkingSupported = useMemo(() => !!getThinkingConfigForModel(selectedModel?.name), [selectedModel]);
249+
250+
const sortedProjects = useMemo(() => {
251+
return [...allProjects].sort((a, b) => a.title.localeCompare(b.title));
252+
}, [allProjects]);
249253

250254
const showToast = useCallback((message: string, type: ToastProps["type"] = "error") => {
251255
setToast({ message, type });
@@ -1675,7 +1679,7 @@ export default function Home() {
16751679
</AnimatePresence>
16761680
<Sidebar
16771681
chats={allChats}
1678-
projects={allProjects}
1682+
projects={sortedProjects}
16791683
activeChatId={activeChatId}
16801684
activeProjectId={displayingProjectManagementId}
16811685
onNewChat={handleNewChat}

0 commit comments

Comments
 (0)