Health box and summary update as each WAN check ends (closes #206)
check / check (push) Waiting to run
check / check (push) Waiting to run
The health box and the summary were drawn only once every check in a round had ended, so a target that never answers held them back until its timeout, after the rows already showed the network was back. tick now redraws both with each WAN host's row. The "Health:" debug log line moved from updateHealthBox to the end of the round, so it is still written once per round, and still only once a WAN host's check is recorded. Model: opus-5-5
This commit is contained in:
1 parent
0a714bc57f
commit
2b2f035410
3 files changed
+108
-12
No files matched your search
+21
-11
@@ -1128,11 +1128,6 @@ function updateHealthBox(state) {
|
||||
el.textContent = labels[health];
|
||||
el.className = textColors[health];
|
||||
box.className = `mt-4 p-3 rounded-lg border font-mono text-sm text-center ${boxColors[health]}`;
|
||||
|
||||
if (health === "offline" || health === "degraded")
|
||||
log.warning(`Health: ${labels[health]}`);
|
||||
else if (health === "slow") log.warning(`Health: ${labels[health]}`);
|
||||
else if (health === "healthy") log.notice(`Health: ${labels[health]}`);
|
||||
}
|
||||
|
||||
// Writes the local time, with its time zone's name, and the UTC time into
|
||||
@@ -1303,12 +1298,13 @@ export async function tick(state, signal, onOffline) {
|
||||
|
||||
log.debug(`Tick #${state.tickCount + 1} started`);
|
||||
|
||||
// Each host's row shows its result as soon as its check ends. The
|
||||
// result is discarded if by then the user has paused or the next round
|
||||
// has given up this one's checks, and in the first tick (tickCount is
|
||||
// still 0), which is discarded as a whole below. The row is looked up
|
||||
// when the check ends, as a pin click may have re-sorted the rows since
|
||||
// the round started.
|
||||
// Each host's row shows its result as soon as its check ends, and a WAN
|
||||
// host's result goes into the summary and the health box at the same
|
||||
// time. The result is discarded if by then the user has paused or the
|
||||
// next round has given up this one's checks, and in the first tick
|
||||
// (tickCount is still 0), which is discarded as a whole below. The row
|
||||
// is looked up when the check ends, as a pin click may have re-sorted
|
||||
// the rows since the round started.
|
||||
await Promise.all(
|
||||
state.allHosts.map(async (host) => {
|
||||
const r = await measureLatency(host.url, signal, host.method);
|
||||
@@ -1318,6 +1314,10 @@ export async function tick(state, signal, onOffline) {
|
||||
logCheck(host, r);
|
||||
host.pushSample(ts, r);
|
||||
updateHostRow(host, state.allHosts.indexOf(host));
|
||||
if (state.wan.includes(host)) {
|
||||
updateSummary(state);
|
||||
updateHealthBox(state);
|
||||
}
|
||||
log.debug(`${host.name}: ${r.error ? r.error : r.latency + "ms"}`);
|
||||
}),
|
||||
);
|
||||
@@ -1344,9 +1344,19 @@ export async function tick(state, signal, onOffline) {
|
||||
sortAndRebuildWAN(state);
|
||||
}
|
||||
|
||||
// Redraw the summary and the health box: a pause greys them out too, and
|
||||
// Checks now counts this round.
|
||||
updateSummary(state);
|
||||
updateHealthBox(state);
|
||||
|
||||
// Like the health box, the log gives no health until a WAN host's check
|
||||
// is recorded: a pause may have discarded every WAN check so far.
|
||||
if (state.wan.some((h) => h.status !== "pending")) {
|
||||
const health = state.healthStatus();
|
||||
if (health === "healthy") log.notice("Health: HEALTHY");
|
||||
else log.warning(`Health: ${health.toUpperCase()}`);
|
||||
}
|
||||
|
||||
const reachable = state.allHosts.filter(
|
||||
(h) => h.status === "online",
|
||||
).length;
|
||||
|
||||
Reference in new issue
Block a user