Read the sleep & wake list newest first

The merged list ran oldest first, which put last night's sleep at the top and
pushed whatever is happening now further down with every window the day adds —
so the row you look at most often was the one that moved.

Reversed, it matches the history and notes logs: the open row leads, and the
day reads backwards from where you are. The interleaving is untouched, since
alternation survives either direction.

The changelog entry for the merge is corrected rather than answered with a
second one. It walked through an example day in the old direction, and the
build that shipped it is the same one this lands in — nobody has a version
where the list read the other way.
This commit is contained in:
Alexander Heldt
2026-08-31 22:25:19 +00:00
parent 02be8ce3e7
commit 68840847f0
2 changed files with 8 additions and 5 deletions
+7 -4
View File
@@ -1030,14 +1030,17 @@
// Sleep and wake windows are the same boundaries read two ways — a wake
// window is precisely the gap between two sleeps — so they alternate by
// construction and sorting the two sets by start time interleaves them back
// into the day's actual rhythm. Read in order, "45 minutes asleep after two
// and a half hours up" is a single glance instead of a comparison between
// two lists.
// into the day's actual rhythm, "45 minutes asleep after two and a half hours
// up" in one glance instead of a comparison between two lists.
//
// Newest first, like the history and notes logs: the row still running is
// then the first one you see, and today's list grows downward from where you
// are rather than pushing the current state further away with every window.
function sleepWakeWindowsForDay(events, day) {
return [
...sleepWindowsForDay(events, day).map(w => ({ ...w, cls: "sleep-ww", tag: "Asleep" })),
...wakeWindowsForDay(events, day).map(w => ({ ...w, cls: "wake-ww", tag: "Awake" })),
].sort((a, b) => a.start - b.start);
].sort((a, b) => b.start - a.start);
}
function renderSleepWake(events) {