Revert "Add waking → pee and meal → poo rows to the Timing panel"

Waking → pee was hard to read with a puppy who takes lots of short naps. This reverts commit baccdbd.
This commit is contained in:
Alexander Heldt committed 2026-09-30 07:33:12 +00:00
1 parent baccdbd826
commit 533aa1cc34
3 files changed
+27 -110

No files matched your search

+25 -96
View File
@@ -1064,115 +1064,44 @@
// the last one. The marker is free to sit outside the band — just went (left
// of shortest) or overdue (right of typical) — which is the reading that
// decides whether to take the puppy out now.
//
// The last two rows measure a response rather than a rhythm: from waking to
// the pee after it, and from a meal to the poo after it. Those are what say
// when to take him out, where the plain gaps only say how often.
const TIMING_ROWS = [
{ id: "pee", type: "pee", label: "Pees", noun: "pee", cls: "tm-pee" },
{ id: "poo", type: "poo", label: "Poos", noun: "poo", cls: "tm-poo" },
{ id: "eat", type: "eat", label: "Meals", noun: "meal", cls: "tm-eat" },
{ id: "wake-pee", label: "Waking → pee", cls: "tm-pee",
from: "sleep-end", to: "pee", until: "sleep-start",
between: "from waking to a pee", sinceText: "since he woke",
nowLabel: (d) => `awake ${d}`,
empty: "No pee logged after a wake-up" },
{ id: "eat-poo", label: "Meal → poo", cls: "tm-poo",
from: "eat", to: "poo", until: "eat",
between: "from a meal to a poo", sinceText: "since the last meal",
nowLabel: (d) => `ate ${d} ago`,
empty: "No poo logged after a meal" },
{ type: "pee", label: "Pees", noun: "pee", cls: "tm-pee" },
{ type: "poo", label: "Poos", noun: "poo", cls: "tm-poo" },
{ type: "eat", label: "Meals", noun: "meal", cls: "tm-eat" },
];
// Time from each `from` event to the first `to` after it, for the rows that
// measure a response. A `from` gets no gap if an `until` comes first — he
// went back to sleep without a pee, or ate again before the poo — since the
// `to` that follows can't be told apart from a response to the later one.
// Same-day only, like gapsBetween: a meal at nine and the next morning's poo
// are not cause and effect.
//
// `pending` is the wait in progress: the latest `from` today with nothing
// after it yet. That is when the marker is worth showing; once the pee has
// happened there is nothing to wait for, so the row shows the band alone.
function gapsAfter(events, { from, to, until }, days = chartDays()) {
const cutoff = startOfDay(new Date());
cutoff.setDate(cutoff.getDate() - (days - 1));
// A `to` logged in the same minute as its `from` (a quick-logged pee on
// waking) must sort after it to be counted as the response.
const rank = (t) => (t === from ? 0 : 1);
const evs = events
.filter(e => e.type === from || e.type === to || e.type === until)
.sort((a, b) => a.at - b.at || rank(a.type) - rank(b.type));
const gaps = [];
let open = null;
for (const e of evs) {
if (open != null && e.type === to) {
if (open >= cutoff.getTime() && !spansExcluded(open, e.at) &&
ymd(new Date(open)) === ymd(new Date(e.at))) {
gaps.push(e.at - open);
}
open = null;
} else if (e.type === from) {
open = e.at;
} else if (e.type === until) {
open = null;
}
}
const pending = open != null && ymd(new Date(open)) === ymd(new Date()) && !isExcluded(new Date(open))
? Math.max(0, Date.now() - open) : null;
return { gaps: gaps.sort((a, b) => a - b), pending };
}
function renderTiming(events) {
for (const row of TIMING_ROWS) {
const svg = document.getElementById(`timing-chart-${row.id}`);
const note = document.getElementById(`timing-note-${row.id}`);
const svg = document.getElementById(`timing-chart-${row.type}`);
const note = document.getElementById(`timing-note-${row.type}`);
if (!svg || !note) continue;
if (row.from) {
const { gaps, pending } = gapsAfter(events, row);
const empty = `${row.empty} in the last ${chartDays()} days yet.` +
(pending == null ? "" : ` It has been ${formatDuration(pending)} ${row.sinceText}.`);
drawTimingChart(svg, note, row, gaps, pending, empty);
continue;
}
const gaps = gapsBetween(events, row.type);
const last = lastEventOfType(events, row.type);
const since = last ? Math.max(0, Date.now() - last.at) : null;
drawTimingChart(svg, note, row, gaps, since, timingEmptyNote(events, row, since));
drawTimingChart(svg, note, row, gaps, last ? Math.max(0, Date.now() - last.at) : null, events);
}
}
// Why a plain-gap row has nothing to draw. Several logged but none sharing a
// day (one meal a day, say) is a different case from one logged: every gap
// there was overnight.
function timingEmptyNote(events, row, since) {
const cutoff = startOfDay(new Date());
cutoff.setDate(cutoff.getDate() - (chartDays() - 1));
const inWindow = events.filter(e => e.type === row.type && e.at >= cutoff.getTime()).length;
return since == null
? `No ${row.noun}s logged in the last ${chartDays()} days.`
: inWindow >= 2
? `No two ${row.noun}s on the same day in the last ${chartDays()} days — the gap overnight isn't counted, so there is nothing to measure yet.`
: `One ${row.noun} logged, ${formatDuration(since)} ago — log another to see the typical gap.`;
}
function drawTimingChart(svg, note, row, gaps, since, emptyText) {
function drawTimingChart(svg, note, row, gaps, since, events) {
const typical = median(gaps);
const shortest = gaps[0] ?? null;
const longest = gaps[gaps.length - 1] ?? null;
// The words differ between a rhythm row ("between pees") and a response
// row ("from waking to a pee"); the chart itself doesn't.
const between = row.between ?? `between ${row.noun}s`;
const sinceText = row.sinceText ?? `since the last ${row.noun}`;
const nowLabel = row.nowLabel ?? ((d) => `${d} ago`);
// No gap in the window means nothing to draw, so the row falls back to a
// sentence rather than an axis with nothing on it.
// Fewer than two events in the window means there is no gap to draw, so the
// row falls back to a sentence rather than an axis with nothing on it.
if (typical == null) {
svg.innerHTML = "";
svg.style.display = "none";
note.hidden = false;
note.textContent = emptyText;
// Several logged but none sharing a day (one meal a day, say) is a
// different case from one logged: every gap there was overnight.
const cutoff = startOfDay(new Date());
cutoff.setDate(cutoff.getDate() - (chartDays() - 1));
const inWindow = events.filter(e => e.type === row.type && e.at >= cutoff.getTime()).length;
note.textContent = since == null
? `No ${row.noun}s logged in the last ${chartDays()} days.`
: inWindow >= 2
? `No two ${row.noun}s on the same day in the last ${chartDays()} days — the gap overnight isn't counted, so there is nothing to measure yet.`
: `One ${row.noun} logged, ${formatDuration(since)} ago — log another to see the typical gap.`;
return;
}
svg.style.display = "";
@@ -1216,9 +1145,9 @@
const parts = [
`<rect class="tm-track" x="${ML}" y="${trackY}" width="${innerW}" height="${trackH}" rx="${trackH / 2}"/>`,
bandRect(`tm-range ${row.cls}`, xShort, xLong,
`<title>${escapeText(`${formatDuration(shortest)}–${formatDuration(longest)} ${between} over the last ${chartDays()} days`)}</title>`),
`<title>${escapeText(`${formatDuration(shortest)}–${formatDuration(longest)} between ${row.noun}s over the last ${chartDays()} days`)}</title>`),
bandRect(`tm-band ${row.cls}`, xShort, xTypical,
`<title>${escapeText(`Typically ${formatDuration(typical)} ${between}`)}</title>`),
`<title>${escapeText(`Typically ${formatDuration(typical)} between ${row.noun}s`)}</title>`),
];
// Ticks tie the summary line under the track to the three points it names.
@@ -1254,7 +1183,7 @@
parts.push(`<line class="tm-now-ring" x1="${x.toFixed(1)}" y1="${y1}" x2="${x.toFixed(1)}" y2="${y2}"/>`);
parts.push(
`<line class="tm-now" x1="${x.toFixed(1)}" y1="${y1}" x2="${x.toFixed(1)}" y2="${y2}">` +
`<title>${escapeText(`${formatDuration(since)} ${sinceText}`)}</title></line>`
`<title>${escapeText(`${formatDuration(since)} since the last ${row.noun}`)}</title></line>`
);
if (over) {
parts.push(
@@ -1265,15 +1194,15 @@
const anchor = x < ML + 55 ? "start" : (x > W - MR - 55 ? "end" : "middle");
parts.push(
`<text class="tm-now-label" x="${x.toFixed(1)}" y="11" text-anchor="${anchor}">` +
`${escapeText(nowLabel(formatDuration(since)))}</text>`
`${escapeText(`${formatDuration(since)} ago`)}</text>`
);
}
svg.innerHTML = parts.join("");
svg.setAttribute("aria-label",
`${row.label}: typically ${formatDuration(typical)} ${between}, ` +
`${row.label}: typically ${formatDuration(typical)} between ${row.noun}s, ` +
`shortest ${formatDuration(shortest)}, longest ${formatDuration(longest)}` +
(since == null ? "" : `, ${formatDuration(since)} ${sinceText}`) + ".");
(since == null ? "" : `, ${formatDuration(since)} since the last one`) + ".");
}
function renderLasts(events) {
+1 -1
View File
@@ -1,5 +1,5 @@
[
{ "date": "2026-09-29", "text": "The Timing panel on Habits has two new rows, Waking → pee and Meal → poo, for the question the plain gaps can't answer: not how often he goes, but how soon after waking up or eating. Each measures from a wake-up to the next pee, or from a meal to the next poo, over the same 7 / 14 / 30 days as the rest of the panel, and shows the shortest, typical and longest wait. If he naps again before peeing, or eats again before pooing, that one isn't counted, since there is no telling which it was a response to; nor is anything that runs past midnight. While you are waiting on one — he woke up and hasn't peed, or he has eaten and hasn't pooed — a marker shows how long it has been (“awake 12m”, “ate 25m ago”), so a marker past the typical point means now is the time to go out. Once the pee or poo is logged the marker goes away until the next wake-up or meal" },
{ "date": "2026-09-30", "text": "The Waking → pee and Meal → poo rows are gone from the Timing panel again. With a puppy who takes lots of short naps, most wake-ups were followed by another nap before any pee, so Waking → pee was built from a handful of odd cases and was hard to make sense of. The Pees, Poos and Meals rows are unchanged" },
{ "date": "2026-09-29", "text": "The Walks chart (minutes per day) has a trend line too, with a sentence under it in the same style as the sleep one: “daily walking is up about 20m — from roughly 35m a day to 55m”, or roughly steady with the average when the days vary more than they move. A day with no walk counts as a real zero — a rest day is a real figure — but the days before the very first walk you logged are left out, so starting to track walks partway through the window doesn't read as a sudden climb. Today and days marked “not counted” are left out as on every other trend" },
{ "date": "2026-09-29", "text": "The Sleep chart on the Sleep tab has a trend line through it, like the Food (grams) chart, so you can see whether he is sleeping less as he grows — the day-to-day bars vary enough to hide a steady change. A line under the chart puts it in figures: “daily sleep is down about 1.5h — from roughly 17h a day to 15.5h”, or, when the days scatter more than they move, that it is roughly steady and what the average is. Today is left out until it's over, as are days marked “not counted” and days with no sleep logged at all, which the sentence mentions so an empty bar isn't mistaken for a night without sleep. It follows the 7 / 14 / 30 day picker like the rest of the charts" },
{ "date": "2026-09-29", "text": "The Timing panel no longer counts the night. The gap from each day's last pee, poo or meal to the next morning's first was being measured like any other, so every window held several eight-hour-plus “gaps” that were really just bedtime — the longest figure was a sleep figure and the typical gap was pulled up with it. Only gaps within a single day are measured now, so the bars show how often he needs to go out while he's up and about. The “since the last one” marker is unchanged, so first thing in the morning it still reads as overdue — which, before the first trip out, it is" },
+1 -13
View File
@@ -384,22 +384,10 @@
<svg id="timing-chart-eat" class="timing-chart" viewBox="0 0 320 50" role="img"></svg>
<p class="muted-note timing-note" id="timing-note-eat" hidden></p>
</div>
<!-- Response times rather than rhythms: how soon after waking he
pees, and after eating he poos — see gapsAfter. -->
<div class="timing-item">
<div class="timing-name">Waking → pee</div>
<svg id="timing-chart-wake-pee" class="timing-chart" viewBox="0 0 320 50" role="img"></svg>
<p class="muted-note timing-note" id="timing-note-wake-pee" hidden></p>
</div>
<div class="timing-item">
<div class="timing-name">Meal → poo</div>
<svg id="timing-chart-eat-poo" class="timing-chart" viewBox="0 0 320 50" role="img"></svg>
<p class="muted-note timing-note" id="timing-note-eat-poo" hidden></p>
</div>
</div>
<!-- The axis is stretched (see drawTimingChart), so say what the middle
of a bar means rather than leave it to be inferred. -->
<p class="muted-note">The middle of every bar is that type's typical gap: left of it is sooner than usual, right of it is longer, and the faded stretch runs out to the longest gap in the window. The gap overnight, from each day's last to the next day's first, isn't counted. Waking → pee and Meal → poo measure from each wake-up to the pee after it, and each meal to the poo after it, unless he naps or eats again first; their marker only shows while you're still waiting on one.</p>
<p class="muted-note">The middle of every bar is that type's typical gap: left of it is sooner than usual, right of it is longer, and the faded stretch runs out to the longest gap in the window. The gap overnight, from each day's last to the next day's first, isn't counted.</p>
</section>
<!-- One panel for the three views of the same events: how many a day,