Fix false stale Fleet reports caused by clock skew
This commit is contained in:
@@ -154,9 +154,9 @@
|
||||
|
||||
let hasDiagnosticIssue = $derived(effectiveHealth !== 'online' && effectiveHealth !== 'starting');
|
||||
|
||||
function ago(iso: string | null): string {
|
||||
function ago(iso: string | null, now: number): string {
|
||||
if (!iso) return 'never';
|
||||
const d = Date.now() - new Date(iso).getTime();
|
||||
const d = now - new Date(iso).getTime();
|
||||
if (d < 60_000) return `${Math.max(1, Math.floor(d / 1000))}s ago`;
|
||||
if (d < 3_600_000) return `${Math.floor(d / 60_000)}m ago`;
|
||||
if (d < 86_400_000) return `${Math.floor(d / 3_600_000)}h ago`;
|
||||
@@ -270,7 +270,7 @@
|
||||
{/if}
|
||||
{#if effectiveHealth !== 'online'}
|
||||
<div class="metric-cell">
|
||||
<Stat label="Last seen" value={ago(effectiveSeen)} size="md" tween={false} />
|
||||
<Stat label="Last seen" value={ago(effectiveSeen, $uiNow)} size="md" tween={false} />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -517,7 +517,7 @@
|
||||
{/if}
|
||||
</span>
|
||||
<span class="hist-files">{mine.files_changed} file{mine.files_changed === 1 ? '' : 's'}</span>
|
||||
<span class="hist-when">{ago(d.started_at)}</span>
|
||||
<span class="hist-when">{ago(d.started_at, $uiNow)}</span>
|
||||
{#if mine.error}<span class="hist-err">{mine.error}</span>{/if}
|
||||
</a>
|
||||
{/each}
|
||||
|
||||
Reference in New Issue
Block a user