From bda0d9a6ebff76a1d2c53fb79b6adec2ab0b9e24 Mon Sep 17 00:00:00 2001 From: Dexploarer <211557447+Dexploarer@users.noreply.github.com> Date: Fri, 24 Apr 2026 22:08:16 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20[memoize=20conversation=20s?= =?UTF-8?q?orting]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .jules/bolt.md | 3 +++ apps/app/src/components/ConversationsSidebar.tsx | 15 +++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .jules/bolt.md diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 0000000000..8e01213732 --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2024-04-24 - Initializing Bolt Journal +**Learning:** Establishing the journal to document critical, codebase-specific performance insights. +**Action:** Will document learnings here as they are discovered. diff --git a/apps/app/src/components/ConversationsSidebar.tsx b/apps/app/src/components/ConversationsSidebar.tsx index 75d768bee2..d89edf4da5 100644 --- a/apps/app/src/components/ConversationsSidebar.tsx +++ b/apps/app/src/components/ConversationsSidebar.tsx @@ -2,7 +2,7 @@ * Conversations sidebar component — left sidebar with conversation list. */ -import { useEffect, useRef, useState } from "react"; +import { useEffect, useMemo, useRef, useState } from "react"; import { useApp } from "../AppContext"; interface ConversationsSidebarProps { @@ -54,11 +54,14 @@ export function ConversationsSidebar({ } }, [editingId]); - const sortedConversations = [...conversations].sort((a, b) => { - const aTime = new Date(a.updatedAt).getTime(); - const bTime = new Date(b.updatedAt).getTime(); - return bTime - aTime; - }); + // ⚡ Bolt: Memoize the sorting of conversations to avoid unnecessary Date parsing and array mutations on every render. + const sortedConversations = useMemo(() => { + return [...conversations].sort((a, b) => { + const aTime = new Date(a.updatedAt).getTime(); + const bTime = new Date(b.updatedAt).getTime(); + return bTime - aTime; + }); + }, [conversations]); const handleDoubleClick = (conv: { id: string; title: string }) => { setEditingId(conv.id);