feat: sidebar redesign — activity feed, grouped nav, AI split #107

Merged
chihlasm merged 20 commits from design/sidebar-icon-concepts into main 2026-03-16 05:35:16 +00:00
Showing only changes of commit 021d62784e - Show all commits

View File

@@ -18,19 +18,21 @@ function formatDuration(totalSeconds: number): string {
return m > 0 ? `${h}h ${m}m` : `${h}h`
}
function parseUTCTimestamp(st: string): number {
// Backend returns naive UTC timestamps without 'Z' suffix.
// JS Date() treats bare strings as local time, so append Z to force UTC.
return new Date(st.endsWith('Z') ? st : st + 'Z').getTime()
}
function calcActiveSeconds(startTimes: string[]): number {
const now = Date.now()
return startTimes.reduce((sum, st) => {
const elapsed = Math.floor((now - new Date(st).getTime()) / 1000)
const elapsed = Math.floor((now - parseUTCTimestamp(st)) / 1000)
return sum + Math.max(0, elapsed)
}, 0)
}
export function SidebarStatsBar({ resolved, active, completedMinutes, activeSessionStartTimes }: SidebarStatsBarProps) {
// Debug: remove after fixing
if (activeSessionStartTimes.length > 0) {
console.log('[SidebarStats] startTimes:', activeSessionStartTimes, 'calcSeconds:', calcActiveSeconds(activeSessionStartTimes), 'now:', Date.now(), 'parsed:', activeSessionStartTimes.map(st => new Date(st).getTime()))
}
const [liveSeconds, setLiveSeconds] = useState(() => calcActiveSeconds(activeSessionStartTimes))
// Tick every second to keep the timer in sync with the session timer