From d514f725d132cb9f94e7021aaf2aa81e7eeb09f2 Mon Sep 17 00:00:00 2001 From: TheRealAshik <177647015+TheRealAshik@users.noreply.github.com> Date: Tue, 24 Mar 2026 04:24:31 +0000 Subject: [PATCH] perf: Optimize session filtering dates in useSessionList Replaced `new Date(s.createTime)` with direct lexical string comparisons against an ISO 8601 string inside the array `.filter()` loop. Also resolved existing malformed merge conflict markers found during build in `web/components/ChatHistory.tsx`. --- web/components/ChatHistory.tsx | 14 ++++++-------- web/hooks/useSessionList.ts | 5 +++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/web/components/ChatHistory.tsx b/web/components/ChatHistory.tsx index a103cb8..f12ed87 100644 --- a/web/components/ChatHistory.tsx +++ b/web/components/ChatHistory.tsx @@ -727,11 +727,10 @@ const ActivityItem: React.FC<{ download={`artifact-${i}.${artifact.media.mimeType.split('/')[1] || 'png'}`} className="text-zinc-500 hover:text-zinc-300 transition-colors p-1 hover:bg-white/10 rounded" title="Download" -<<<<<<< HEAD + aria-label="Download generated artifact" -======= - aria-label="Download Generated Artifact" ->>>>>>> origin/palette/aria-labels-icon-buttons-6351807906965806055 + + > @@ -746,11 +745,10 @@ const ActivityItem: React.FC<{ href="#" className="text-zinc-500 hover:text-zinc-300 transition-colors p-1 hover:bg-white/10 rounded" title="Open in new window" -<<<<<<< HEAD + aria-label="Open generated artifact in new window" -======= - aria-label="Open Generated Artifact in new window" ->>>>>>> origin/palette/aria-labels-icon-buttons-6351807906965806055 + + > diff --git a/web/hooks/useSessionList.ts b/web/hooks/useSessionList.ts index 8a6b3d4..b9759ab 100644 --- a/web/hooks/useSessionList.ts +++ b/web/hooks/useSessionList.ts @@ -15,9 +15,10 @@ export function useSessionList(service: GeminiService | null) { // Calculate sessions in last 24 hours const twentyFourHoursAgo = new Date(Date.now() - 24 * 60 * 60 * 1000); + // ⚡ Bolt: Direct lexical comparison of ISO 8601 strings is much faster than allocating Date objects in loops + const twentyFourHoursAgoIso = twentyFourHoursAgo.toISOString(); const usedCount = allSessions.filter(s => { - const createDate = new Date(s.createTime); - return createDate > twentyFourHoursAgo; + return s.createTime > twentyFourHoursAgoIso; }).length; setSessionsUsed(usedCount);