set_status: add status_set_at timestamp (mtime of status file)

This commit is contained in:
damocles 2026-05-23 01:08:50 +02:00 committed by Mara
parent fe2933b213
commit 8e8e8a771f
7 changed files with 75 additions and 14 deletions

View file

@ -17,6 +17,8 @@
// ─── helpers ────────────────────────────────────────────────────────────
const $ = (id) => document.getElementById(id);
const fmtAgeSecs = (s) => s < 60 ? `${s}s` : s < 3600 ? `${Math.floor(s/60)}m`
: s < 86400 ? `${Math.floor(s/3600)}h` : `${Math.floor(s/86400)}d`;
const esc = (s) => String(s).replace(/[&<>"]/g, (c) =>
({ '&':'&amp;', '<':'&lt;', '>':'&gt;', '"':'&quot;' }[c])
);
@ -729,9 +731,16 @@
// ── agent status text ─────────────────────────────────────────
if (c.status_text) {
body.append(el('div', { class: 'agent-status', title: 'agent self-reported status' },
const nowUnix = Math.floor(Date.now() / 1000);
const ageStr = c.status_set_at != null
? ` (set ${fmtAgeSecs(nowUnix - c.status_set_at)} ago)` : '';
body.append(el('div', {
class: 'agent-status',
title: `agent self-reported status${ageStr}`,
},
el('span', { class: 'status-icon' }, '◈ '),
c.status_text,
el('span', { class: 'status-age' }, ageStr),
));
}