mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-08 18:05:10 +00:00
fix(dashboard): slow HealthStatusBar sync-label tick to 5s (#1211)
useTicker(1000) rendered the masthead once per second to advance the "last sync Xs" label. The label only shifts visibly every few seconds (1s, 6s, 11s..., then m, then h), so the per-second cadence forced the entire dashboard tree through the React reconciler 60 times per minute for a visual change the eye does not see. A 5s tick keeps the label fresh while cutting the wake-up rate by 5x. Name the constant so the trade-off is documented at the call site.
This commit is contained in:
@@ -88,6 +88,11 @@ function useTicker(intervalMs: number): number {
|
||||
return now;
|
||||
}
|
||||
|
||||
// The "last sync Xs" label only shifts visibly every few seconds, so a 5 s
|
||||
// re-render cadence keeps the freshness signal accurate without forcing the
|
||||
// dashboard tree through the reconciler once per second.
|
||||
const SYNC_LABEL_TICK_MS = 5000;
|
||||
|
||||
export function HealthStatusBar({
|
||||
stats,
|
||||
systemStats,
|
||||
@@ -101,7 +106,7 @@ export function HealthStatusBar({
|
||||
[stats, systemStats, notifications],
|
||||
);
|
||||
const config = healthConfig[level];
|
||||
const now = useTicker(1000);
|
||||
const now = useTicker(SYNC_LABEL_TICK_MS);
|
||||
const unreadAlerts = notifications.filter(n => !n.is_read).length;
|
||||
const running = `${stats.active}/${stats.total}`;
|
||||
const cpuLabel = systemStats ? `${parseFloat(systemStats.cpu.usage).toFixed(0)}%` : '--';
|
||||
|
||||
Reference in New Issue
Block a user