Disable the sleep boundary that repeats the last one

While asleep, tapping "Sleep start" again can only produce a zero-length
sleep window, and likewise "Sleep end" while awake — so renderActionHints
now disables that button outright instead of merely dimming it, with a
title explaining why ("Already asleep" / "Already awake"). Every other
action stays clickable, and a genuinely missed boundary is still fixable
from the event log, which accepts any time. With no sleep history yet,
either boundary remains a valid first event.

Also adds nodejs to the dev shell for `node --check` on src/*.js.
This commit is contained in:
Alexander Heldt
2026-08-18 18:35:14 +00:00
parent f9894abfc9
commit 93d6ea27a7
4 changed files with 32 additions and 5 deletions
+17 -4
View File
@@ -1989,17 +1989,30 @@
}
// Dim the quick actions that don't fit the current sleep state — a nudge
// toward the likely next tap, never a block: everything stays clickable so
// corrections (a missed sleep-end, a mid-nap pee) are always possible.
// toward the likely next tap. The one boundary that would just repeat the
// latest sleep event (a second "sleep start" while already asleep, or a
// second "sleep end" while already awake) is disabled outright, since it
// can only produce a zero-length window. Everything else stays clickable so
// corrections (a mid-nap pee) are never blocked, and a genuinely missed
// boundary is still fixable from the event log, which accepts any time.
function renderActionHints(events) {
const { state } = currentSleepState(events);
document.querySelectorAll("button.action").forEach(btn => {
const type = btn.dataset.type;
const unlikely =
const repeat =
state === "asleep" ? type === "sleep-start"
: state === "awake" ? type === "sleep-end"
: false; // no sleep history yet — either boundary is a fine first event
const unlikely = !repeat && (
state === "asleep" ? type !== "sleep-end"
: state === "awake" ? type === "sleep-end"
: false; // no sleep history yet — no hints to give
: false // no sleep history yet — no hints to give
);
btn.classList.toggle("unlikely", unlikely);
btn.disabled = repeat;
btn.title = repeat
? (type === "sleep-start" ? "Already asleep" : "Already awake")
: "";
});
}