fix(dashboard): use shared base time for connection timeline events

Connection Timeline sidebar showed only one account because
generateConnectionEvents() used per-account lastUsedAt as the base
timestamp. Accounts with more recent lastUsedAt dominated the
recency-sorted 100-event cap.

Use the maximum lastUsedAt across all accounts so events interleave
proportionally.

Closes #856
This commit is contained in:
Tam Nhu Tran
2026-03-30 09:12:54 -04:00
parent 5160e1d454
commit d76ef5bcb3
+9 -1
View File
@@ -44,8 +44,16 @@ export function formatTimelineTime(date: Date): string {
export function generateConnectionEvents(accounts: AccountData[]): ConnectionEvent[] {
const events: ConnectionEvent[] = [];
// Use a shared base time so events from all accounts interleave in the timeline.
// Without this, accounts with more recent lastUsedAt dominate the sorted output.
const now = Date.now();
const sharedBaseTime = accounts.reduce((latest, a) => {
const t = a.lastUsedAt ? new Date(a.lastUsedAt).getTime() : now;
return Math.max(latest, isNaN(t) ? now : t);
}, now);
accounts.forEach((account) => {
const lastUsed = account.lastUsedAt ? new Date(account.lastUsedAt) : new Date();
const lastUsed = new Date(sharedBaseTime);
// Helper to add events
const addEvents = (count: number, status: 'success' | 'failed') => {