diff --git a/hindsight-control-plane/src/components/data-view.tsx b/hindsight-control-plane/src/components/data-view.tsx index 6baaf3b6..859b6efa 100644 --- a/hindsight-control-plane/src/components/data-view.tsx +++ b/hindsight-control-plane/src/components/data-view.tsx @@ -715,20 +715,28 @@ function TimelineView({ data, filteredRows }: { data: any; filteredRows: any[] } const [currentIndex, setCurrentIndex] = useState(0); const timelineRef = useRef(null); - // Filter and sort items that have occurred_start dates (using filtered data) + // Filter and sort items that have dates (occurred_start is only present for events, mentioned_at as fallback - opinions don't tend to be events) const { sortedItems, itemsWithoutDates } = useMemo(() => { if (!filteredRows || filteredRows.length === 0) return { sortedItems: [], itemsWithoutDates: [] }; + const getEffectiveDate = (row: any): string | null => { + return row.occurred_start || row.mentioned_at || null; + }; + const withDates = filteredRows - .filter((row: any) => row.occurred_start) + .filter((row: any) => getEffectiveDate(row)) .sort((a: any, b: any) => { - const dateA = new Date(a.occurred_start).getTime(); - const dateB = new Date(b.occurred_start).getTime(); - return dateA - dateB; - }); + const dateA = new Date(getEffectiveDate(a)!).getTime(); + const dateB = new Date(getEffectiveDate(b)!).getTime(); + return dateB - dateA; // Descending: newest first + }) + .map((row: any) => ({ + ...row, + effective_date: getEffectiveDate(row), + })); - const withoutDates = filteredRows.filter((row: any) => !row.occurred_start); + const withoutDates = filteredRows.filter((row: any) => !getEffectiveDate(row)); return { sortedItems: withDates, itemsWithoutDates: withoutDates }; }, [filteredRows]); @@ -778,7 +786,7 @@ function TimelineView({ data, filteredRows }: { data: any; filteredRows: any[] } const groups: { [key: string]: { items: any[]; date: Date } } = {}; sortedItems.forEach((row: any) => { - const date = new Date(row.occurred_start); + const date = new Date(row.effective_date); const key = getGroupKey(date); if (!groups[key]) { // For week, parse the start date from key @@ -793,7 +801,7 @@ function TimelineView({ data, filteredRows }: { data: any; filteredRows: any[] } }); return Object.entries(groups) - .sort(([a], [b]) => a.localeCompare(b)) + .sort(([a], [b]) => b.localeCompare(a)) .map(([key, { items, date }]) => ({ key, label: getGroupLabel(key, date), @@ -805,8 +813,8 @@ function TimelineView({ data, filteredRows }: { data: any; filteredRows: any[] } // Get date range info const dateRange = useMemo(() => { if (sortedItems.length === 0) return null; - const first = new Date(sortedItems[0].occurred_start); - const last = new Date(sortedItems[sortedItems.length - 1].occurred_start); + const first = new Date(sortedItems[sortedItems.length - 1].effective_date); + const last = new Date(sortedItems[0].effective_date); return { first, last }; }, [sortedItems]); @@ -840,7 +848,7 @@ function TimelineView({ data, filteredRows }: { data: any; filteredRows: any[] }
No Timeline Data
- No memories have occurred_at dates. + No memories have date information. {itemsWithoutDates.length > 0 && ( {itemsWithoutDates.length} memories without dates in Table View. @@ -996,10 +1004,10 @@ function TimelineView({ data, filteredRows }: { data: any; filteredRows: any[] } {/* Date & Time */}
- {formatDateTime(item.occurred_start).date} + {formatDateTime(item.effective_date).date}
- {formatDateTime(item.occurred_start).time} + {formatDateTime(item.effective_date).time}