From dcbc71e683aa0f49ca843275c611754cac18d414 Mon Sep 17 00:00:00 2001 From: Thomas Faour Date: Wed, 22 Jul 2026 11:35:38 -0400 Subject: [PATCH] Show "Not enough data yet" instead of hiding the battery-estimate row Previously the row just disappeared whenever battery_estimate_s couldn't be computed yet, which looked like the feature was gone. Now it always shows once there's any battery reading at all, with a placeholder until enough discharge history accumulates (matches the "Not enough data yet." wording battery_chart.js already uses for the same situation on the chart). --- server/app/static/device_status_bar.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/server/app/static/device_status_bar.js b/server/app/static/device_status_bar.js index 79657ea..3c53b79 100644 --- a/server/app/static/device_status_bar.js +++ b/server/app/static/device_status_bar.js @@ -26,9 +26,16 @@ function renderDeviceStatusBar(device) { } if (device.battery) { rows.push(['Battery', `${device.battery.percent}%`, false]); - } - if (device.battery_estimate_s !== null && device.battery_estimate_s !== undefined) { - rows.push(['Est. battery life left', `~${formatDuration(device.battery_estimate_s)}`, false]); + // Shown as soon as there's any battery reading at all, even before + // battery_estimate_s can compute a rate (needs 2h+ span and a 2%+ + // drop within the current discharge cycle -- see common.py) -- so + // it's clear the number is coming, not that the feature is broken. + const hasEstimate = device.battery_estimate_s !== null && device.battery_estimate_s !== undefined; + rows.push([ + 'Est. battery life left', + hasEstimate ? `~${formatDuration(device.battery_estimate_s)}` : 'Not enough data yet', + false, + ]); } for (const [label, value, alert] of rows) { const stat = document.createElement('span');