From 9ad4c005fa4c02d2b9ead4cc3db05f0762425dba Mon Sep 17 00:00:00 2001 From: spencrmartin Date: Tue, 18 Nov 2025 10:44:46 -0500 Subject: [PATCH] fix: show more days in force-directed timeline (up to 15 days) - Change from limiting total sessions to limiting sessions per day - Process all sessions first to ensure day diversity - Show up to 15 days with max 8 sessions per day - Prioritize temporal coverage over total session count - Fix issue where only 3 days were showing - Improve force-directed network diversity and exploration --- .../sessions/SessionTimelineView.tsx | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/ui/desktop/src/components/sessions/SessionTimelineView.tsx b/ui/desktop/src/components/sessions/SessionTimelineView.tsx index 7d103c71b1..0da41cdae7 100644 --- a/ui/desktop/src/components/sessions/SessionTimelineView.tsx +++ b/ui/desktop/src/components/sessions/SessionTimelineView.tsx @@ -47,14 +47,13 @@ const SessionTimelineView: React.FC = ({ } // Sort sessions by creation date (newest first) - const sortedSessions = [...sessions] - .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()) - .slice(0, 30); // Limit for performance in force simulation + const allSessions = [...sessions] + .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()); - // Group sessions by day + // Group sessions by day first to ensure we get multiple days const sessionsByDay = new Map(); - sortedSessions.forEach(session => { + allSessions.forEach(session => { const day = new Date(session.created_at).toDateString(); if (!sessionsByDay.has(day)) { sessionsByDay.set(day, []); @@ -75,6 +74,23 @@ const SessionTimelineView: React.FC = ({ }); }); + // Limit sessions per day to keep visualization manageable + // but ensure we show up to 15 days + const maxDays = 15; + const maxSessionsPerDay = 8; + + const sortedDays = Array.from(sessionsByDay.keys()) + .sort((a, b) => new Date(b).getTime() - new Date(a).getTime()) + .slice(0, maxDays); + + // Limit sessions within each day + sortedDays.forEach(day => { + const sessions = sessionsByDay.get(day)!; + if (sessions.length > maxSessionsPerDay) { + sessionsByDay.set(day, sessions.slice(0, maxSessionsPerDay)); + } + }); + // Create root node const rootNode: ForceNode = { id: 'root', @@ -94,10 +110,6 @@ const SessionTimelineView: React.FC = ({ const nodes: ForceNode[] = [rootNode]; const links: ForceLink[] = []; - // Sort days (newest first) - const sortedDays = Array.from(sessionsByDay.keys()) - .sort((a, b) => new Date(b).getTime() - new Date(a).getTime()); - // Create day nodes and session nodes sortedDays.forEach((day) => { const dayDate = new Date(day);