Compare commits

...
20 Commits
Author SHA1 Message Date
Alexander Heldt a01d74e9d5 Let sleep tracking be switched off
Settings gets a Track sleep switch, stored on the synced profile as
sleepOff (negative, so a profile from before it, or an old client that
doesn't send it, means tracking). Off hides everything marked
data-sleep-only (the sleep log buttons, the Sleep tab, the Sleep/Awake
tiles, Last sleep and the Sleep & wake list) plus the bar timer. The
sleep state also reads as unknown, so a leftover sleep-start can't dim
the log buttons or run a sleep rail through every day's history.

The reminder scheduler treats the state as unknown too. Otherwise a
leftover sleep-start would mute every other rule for good, or a leftover
sleep-end would fire the sleep rule every interval. Nothing logged is
deleted.
2026-11-12 10:27:03 +00:00
Alexander Heldt f98137097c Use stdenv.hostPlatform.system instead of the deprecated pkgs.system 2026-11-02 08:07:27 +00:00
Alexander Heldt 35275e6c2c Step the sleep and walk trend charts by clock hour
Both charts walked the day in fixed hours from midnight, so on a DST day
the curve ended at 23:00 (autumn) or 01:00 the next day (spring), cutting
or padding that day's total and its share of the average, and today's
line ended an hour off the now marker, which reads the clock. Step through
the day with clockHourTs and plot points at their clock hour instead.
2026-10-28 20:03:22 +00:00
Alexander Heldt a7d3575474 Round the puppy's age in days instead of flooring it
The days between two local midnights are an hour short of whole days
once a spring DST switch falls between them, so flooring dropped a day
from the age (and ticked weeks and months over a day late) until the
autumn switch evened it out.
2026-10-28 20:03:17 +00:00
Alexander Heldt e2369f3a3e Place actogram bars by clock time so DST days fit the row
On the day the clocks go back the day is 25 hours long, and bars were
positioned by elapsed time over a fixed 24h, so everything after 3 am
was drawn an hour late and the evening sleep ran past the row's end.
Position bars and the now marker by wall-clock time instead.
2026-10-28 19:54:31 +00:00
Alexander Heldt a37474ab82 Bring the checks up to date with the trend and range changes
The checks had fallen behind three refactors and had stopped running:
foodTrend became dailyTrend (the sleep trend line), the sleep average
moved into averageDays, and the custom date range replaced chartDays
with chartRange/chartSpan and gave the sentences a window phrase.

They now load the current functions. The window check exercises the
real range picker against stored settings, with a new case for a custom
range in the past. No assertion changed meaning; all 223 pass.
2026-10-04 18:23:57 +00:00
Alexander Heldt 7b1b0889c6 Remove the integration feed for schema
schema no longer reads walks and meals from puppy-tracker, so the
read-only /api/integration/events feed, its flags and the module's
integration options go. A config still setting them is told they were
removed.
2026-10-04 18:18:14 +00:00
Alexander Heldt ffa15ff2e7 Add a custom from–to date range for the charts
The chart window was fixed to the last 7/14/30 days. A Custom option
picks any range up to a year, which may end in the past. chartRange()
replaces the day count as the source of truth; every day-window chart,
the timing gaps, the hour heatmap and the average-day curves read it,
and headings and trend sentences name the dates.

Long ranges get tighter bar gaps, date axis labels and thinner actogram
rows. weeklyData now builds sleep/walk intervals and per-day buckets
once instead of rescanning the log per day, and chart date labels use
cached Intl formatters, which together cut a year-long render ~3x.
2026-10-03 11:16:35 +00:00
Alexander Heldt e17856b9fe Open the app from the cached session without waiting on the network
Bootstrap awaited api/me before showing anything, so with the server
unreachable but the device nominally online the app sat blank until the
request gave up. With a cached session it now boots immediately and
verifies api/me in the background: a 401 bounces to login, a different
identity reloads, a network failure changes nothing.
2026-10-01 15:22:18 +00:00
Alexander Heldt 533aa1cc34 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.
2026-09-30 07:33:12 +00:00
Alexander Heldt baccdbd826 Add waking → pee and meal → poo rows to the Timing panel 2026-09-29 21:11:29 +00:00
Alexander Heldt 18aa0686c0 Add a trend line to the Walks chart 2026-09-29 20:56:40 +00:00
Alexander Heldt 5a419b64dd Add a trend line to the Sleep chart 2026-09-29 20:51:04 +00:00
Alexander Heldt 50947d077f Leave the overnight gap out of the Timing panel 2026-09-29 20:34:36 +00:00
Alexander Heldt 15211e32b0 Add a read-only integration feed of walks and meals
GET /api/integration/events?since=<unix ms> returns one account's walk
starts and meals that happened or changed since then, tombstones
included, for other services on the same host. It is authenticated
with a bearer token rather than a session and cannot write anything.

Enabled with -integration-token-file (services.puppy-tracker
.integration.tokenFile); -integration-user picks the account, and
defaults to the only one.
2026-09-29 19:13:28 +00:00
Alexander Heldt b572371666 Scroll to the top when tapping the tab you are already on 2026-09-26 12:39:06 +00:00
Alexander Heldt a0cdc1f669 Create food kinds in Settings only, not from the Ate dialog
Inventing a kind mid-log put list-keeping in the middle of logging, where
the thing you came to do is record that the dog ate. A name typed in a
hurry is also easy to get slightly wrong, and nothing enforces unique
names — so the cost of a typo is a near-duplicate kind that can only be
cleared up by relabelling every meal logged under it first.

The dialog still picks from the kinds that exist, unchanged. This drops
the new-kind row from it, both its handlers, and the guest guard that
existed only to keep that row out of a guest's hands. addFoodKind now has
a single caller, in Settings.

Also drops the sentence advertising the removed box from the changelog
entry that shipped it: that banner is what someone upgrading across
several versions reads, so leaving it would describe a field that is no
longer there.
2026-09-24 13:49:54 +00:00
Alexander Heldt fab0ae1420 Add a Meals log to Habits, with a bulk label for unlabelled meals
A meal's amount and its kind are both optional by design, which is what
makes them easy to lose track of: a meal with no kind sits in the grey
band on the food chart, one with no grams is dropped from it silently,
and there was nowhere to go and see which meals those were.

The panel lists every meal across every day, ignoring the day picker as
the Notes log does — the ones worth finding are spread through history
rather than sitting on the day being viewed. Each filter chip carries
its own count, so the size of the gap reads off the panel without
selecting anything. Rows go through attachRowHandlers, so tapping one
opens the usual edit dialog and long-press still measures.

On the "no kind" filter it also offers to label the whole list at once,
which is what history needs after kinds arrived months into logging.
backfillFoodKind does it in one pass — one save, one sync, one render,
following setDefaultFoodKind rather than calling updateEvent hundreds of
times; sync already posts the whole event list, so it costs nothing
extra on the wire. The optional cut-off date filters the list as well as
the edit, so the number on the button is the rows on screen: labelling
all of history as one kind is wrong if the food was switched partway,
and once labelled the early meals cannot be told apart. There is no
undo, so the guards are the live count, the number on the button and a
confirm. Owner-only; the server's guest rules would refuse it anyway.

Meals are the only event type that gets this — the only one with
optional fields worth filling in afterwards.

Nothing appears until there is a meal to list, and the kind filter and
bulk block wait for a kind to exist, so an account not using kinds is
unchanged.
2026-09-22 15:38:13 +00:00
Alexander Heldt 41827664de Put the day's food breakdown inside the Meals card
The total sat in the Meals card and the per-kind split sat in a row beneath the
whole stats grid, so the two halves of the same figure were in different
places. The split now goes under the total it adds up to.

I argued against this when the row went in, on the grounds that a 90px tile
cannot hold a breakdown. That was true of the shape I had in mind — "Dry 260 g
· Fresh 100 g" inline is about 110px — and not of the one that belongs there:
stacked, a line per kind, it is about 60px.

A single kind gets no line of its own. The total is already that kind's figure,
so the name joins it — "540 g · Dry" — rather than repeating the number
underneath. Same rule the chart's day readout uses, and for the same reason.

A day with no kinds on its meals leaves the tile exactly as it was, which is
the overview anyone not using kinds keeps.

The changelog entry for this has shipped and said the breakdown appears "under
the stat tiles". It does not any more, so it is corrected in place: leaving a
description that is now wrong would be worse than editing an entry some readers
have already seen.
2026-09-22 15:10:51 +00:00
Alexander Heldt cd13efdbed Judge the day readout by the day's kinds, not the window's
A day whose food was all unlabelled read "Fri, Sep 18 — No kind 300 g · 300 g
in total": the number twice, under a label with nothing to distinguish it from.

The guard was on the wrong quantity. It asked whether the *chart* was split,
when what decides this is how many kinds *that day* holds — and a chart split
across other days can still land on a day of one kind. Keying off the day's own
parts fixes the reported case and a second one nobody had hit yet, where a day
of a single named kind read "Dry 300 g · 300 g in total".

So: several kinds keep the total beside them, being what the bar's height shows
and what you would otherwise add up. One kind does not, because it already is
the total. And "No kind" alone drops its label, which was only ever there to
tell it apart from something else.

The new assertions were checked against the old guard, where five of them fail.
The original ones passed throughout, which is the point — they only ever
exercised a chart with one series, and this bug lives on the other axis.
2026-09-22 15:05:02 +00:00
13 changed files with 1369 additions and 309 deletions

No files matched your search

+43
View File
@@ -92,6 +92,32 @@ of them, because logging has to be one tap from wherever you are.
setting — but being module-level is what carries them through the re-render a
background sync causes every minute. Long-press has no keyboard equivalent, so
this is touch and mouse only.
- **The Meals log** in Habits lists every meal across every day, beside the
Food (grams) chart, ignoring the day picker as the Notes log does — the meals
worth finding here are spread through history, not on the day you happen to
be viewing. It exists because a meal's two extras, its amount and its kind,
are both optional by design, which is exactly what makes them easy to lose: an
unlabelled meal sits in a grey band on the chart, one with no grams is dropped
from it silently, and neither was findable. Each filter chip carries its own
count, so the size of the gap reads off the panel without selecting anything.
Rows go through `attachRowHandlers` like every other log, so tapping one opens
the same edit dialog and long-press still measures. The list is capped at
`MEALS_LOG_PAGE` with a *Show more* — a year of logging is a thousand rows,
and `render()` draws every panel on every pass. Meals are the only type that
gets this: they are the only events with optional fields worth filling in
afterwards, a pee being a pee and a weigh-in being refused without a number.
- **Labelling old meals in bulk.** Kinds arrived after months of logging, so
everything recorded before them has none. `backfillFoodKind` sets one kind on
every meal the current filter lists in a single pass — one save, one sync, one
render, following `setDefaultFoodKind` rather than calling `updateEvent`
hundreds of times. It costs nothing extra on the wire either, since sync
already posts the whole event list. The optional *Only before* date is the
part that matters: labelling all of history as one kind is wrong if the food
was switched partway, and once labelled the early meals cannot be told apart
from correctly labelled ones. The cut-off filters the list as well as the
edit, so the number on the button is the rows on screen. There is no undo —
the guards are the live count, the number on the button, and a confirm.
Owner-only, and the server's guest rules would refuse it anyway.
- Each tab is a `.tab-panel` wrapper around the existing sections. The
**wrapper** is what gets hidden, never the sections: `walk-timeline` and
`walk-trend` carry their own `hidden`, set by `renderWalkPatterns` once a walk
@@ -110,6 +136,18 @@ of them, because logging has to be one tap from wherever you are.
why tabbed apps get a reputation for trapping you: flick between tabs fifteen
times and it takes fifteen presses to escape. Two presses, always, from
anywhere.
- **Sleep tracking can be switched off** (Settings → *Track sleep*) by an
account that has stopped logging it. Everything that asks for sleep or shows
it carries `data-sleep-only` and is hidden — the log buttons, the Sleep tab,
the overview's Sleep/Awake tiles and Last sleep row, the Sleep & wake list —
along with the bar timer, and the sleep state reads as unknown, so a
`sleep-start` left over from before can't dim the log buttons or run a sleep
rail through every day's history. Nothing is deleted: sleep events stay in
History, and switching it back on brings the rest back. It is part of the
synced profile rather than a device preference, because the server's
reminders need it and it decides what a guest is asked to log. The field is
the negative `sleepOff`, so a profile from before it existed, or a client too
old to send it, means tracking.
## Layout
@@ -321,6 +359,11 @@ Opt-in push notifications for the two things that are easy to lose track of:
night — and means an overdue rule fires promptly on waking instead. The server
derives sleep state exactly the way `currentSleepState()` does in `app.js`,
tie-break included, so both sides always agree.
- **Unless sleep isn't tracked.** With *Track sleep* off, the sleep state is
unknown whatever boundaries are left in the log: the sleep rule never fires
and the others are never suppressed. Reading the last boundary anyway would
hold the puppy asleep — and every other rule silent — from the day tracking
stopped.
- **One notification per rule.** Every push carries a `tag`, so a repeat replaces
the previous notification instead of stacking another one on the lock screen.
- **Late syncs cancel a reminder retroactively.** Rules measure from the event's
+7 -5
View File
@@ -8,12 +8,14 @@ const app = load({
names: [
"ymd", "startOfDay", "EXCLUDED_TYPE", "ALWAYS_COUNTS", "excludedSet",
"excludedDays", "isExcluded", "countedEvents", "spansExcluded",
"pairWindows", "sleepWindows", "sleepMsInRange", "lastEventOfType",
"pairWindows", "sleepWindows", "sleepIntervals", "msInIntervals", "sleepMsInRange",
"lastEventOfType",
"gapsBetween",
],
lets: ["excludedSet"],
// gapsBetween defaults its window to the chart picker; the checks pass it in.
stubs: { chartDays: () => 7 },
// gapsBetween takes its window from the chart range picker (chartSpan); here
// that is the two weeks up to and including the checks' "now" day.
stubs: { chartSpan: () => ({ from: NOW - 14 * 24 * H, to: NOW + 24 * H }) },
});
const H = 3600_000;
@@ -30,7 +32,7 @@ suite("what a marked day takes out of the numbers");
{ id: "c", type: "pee", at: at(20, 9) },
mark(19),
]);
eq(app.gapsBetween(evs, "pee", 14), [],
eq(app.gapsBetween(evs, "pee"), [],
"a gap reaching across a marked day is discarded rather than measured");
}
{
@@ -41,7 +43,7 @@ suite("what a marked day takes out of the numbers");
{ id: "g", type: "pee", at: at(20, 12) },
mark(19),
]);
eq(app.gapsBetween(evs, "pee", 14), [4 * H, 4 * H],
eq(app.gapsBetween(evs, "pee"), [4 * H, 4 * H],
"…while the gaps either side of it survive");
}
{
+131 -17
View File
@@ -122,46 +122,160 @@ suite("the palette wraps rather than running out");
"…and the palette wraps, so two share rather than one having none");
}
// ---------------------------------------------- the day's split in the overview
// The Meals tile keeps the day's total; this is the breakdown under it. The
// case that matters is the one where it must not appear at all.
// ---------------------------------------------- the day's split in the Meals tile
// The tile holds the day's total; this puts the per-kind figures under it, so
// the parts and the sum they make are read in one place. The case that matters
// is the one where none of it should appear.
{
let kinds = [];
let el = { hidden: false, textContent: "" };
let kindsEl, gramsEl;
const view = load({
names: ["NO_KIND", "renderDayFoodKinds"],
stubs: {
document: { getElementById: () => el },
document: {
getElementById: () => kindsEl,
createElement: () => ({ textContent: "", appendChild() {} }),
},
liveFoodKinds: () => kinds,
foodKindNames: () => new Map(kinds.map(k => [k.id, k.name])),
},
});
const meal = (grams, foodKindId = "") => ({ type: "eat", grams, foodKindId });
const show = (evs) => { el = { hidden: false, textContent: "" }; view.renderDayFoodKinds(evs); return el; };
const show = (evs) => {
const lines = [];
kindsEl = {
hidden: false, textContent: "",
appendChild: (n) => lines.push(n.textContent),
};
gramsEl = { textContent: "" };
const total = evs.filter(e => e.type === "eat" && e.grams > 0)
.reduce((s, e) => s + e.grams, 0);
view.renderDayFoodKinds(evs, gramsEl, total);
return { lines, grams: gramsEl.textContent, hidden: kindsEl.hidden };
};
suite("the day's food split");
suite("the day's food in the Meals tile");
{
kinds = [];
eq(show([meal(180), meal(120)]).hidden, true,
"meals with no kind show no breakdown — the tile's total already says it");
eq(show([]).hidden, true, "a day with no meals shows nothing");
const plain = show([meal(180), meal(120)]);
eq(plain.hidden, true, "meals with no kind add nothing under the total");
eq(plain.grams, "", "…and leave the tile's own total line alone");
eq(show([]).hidden, true, "a day with no meals adds nothing");
kinds = [{ id: "d", name: "Dry" }];
const one = show([meal(300, "d"), meal(240, "d")]);
eq(one.hidden, true, "one kind adds no lines — it would only repeat the total");
eq(one.grams, "540 g · Dry", "…the total carries its name instead");
kinds = [{ id: "d", name: "Dry" }, { id: "f", name: "Fresh" }];
const both = show([meal(200, "d"), meal(100, "f"), meal(60, "d")]);
eq(both.hidden, false, "once a meal carries a kind, the breakdown appears");
eq(both.textContent, "Dry 260 g · Fresh 100 g", "…summed per kind, in the chart's order");
const two = show([meal(200, "d"), meal(100, "f"), meal(60, "d")]);
eq(two.hidden, false, "two kinds do get their own lines");
eq(two.lines, ["Dry 260 g", "Fresh 100 g"], "…summed per kind, in the chart's order");
eq(show([meal(200, "d"), meal(50)]).textContent, "Dry 200 g · No kind 50 g",
"unlabelled food on a day that has kinds is named, not dropped");
eq(show([meal(200, "d"), meal(50)]).lines, ["Dry 200 g", "No kind 50 g"],
"unlabelled food alongside a kind is named, not dropped");
kinds = [];
eq(show([meal(90, "gone")]).textContent, "Deleted kind 90 g",
eq(show([meal(90, "gone")]).grams, "90 g · Deleted kind",
"a kind deleted since still labels its food rather than vanishing");
kinds = [{ id: "d", name: "Dry" }];
eq(show([meal(0, "d"), meal(120, "d")]).textContent, "Dry 120 g",
eq(show([meal(0, "d"), meal(120, "d")]).grams, "120 g · Dry",
"a meal logged without an amount adds nothing to the split");
}
}
// ---------------------------------------------- finding and labelling the gaps
// Both of a meal's extras are optional, so history accumulates meals missing
// one. These are the rules the Meals log filters by, and the one bulk edit it
// offers — the only place in the app where a single tap rewrites hundreds of
// events, which is why the selection is worth pinning down exactly.
{
let saved = null, synced = 0, rendered = 0;
const gaps = load({
names: ["MEAL_GAPS", "mealsMissing", "backfillFoodKind"],
stubs: {
loadAll: () => saved,
saveAll: (v) => { saved = v; },
scheduleSync: () => { synced++; },
render: () => { rendered++; },
},
});
const at = (iso) => new Date(iso).getTime();
const ev = (o) => ({ id: o.id, type: o.type || "eat", at: at(o.at), ...o, at: at(o.at) });
const ids = (list) => list.map(e => e.id);
const log = [
ev({ id: "m1", at: "2026-05-08T08:00:00", grams: 200, foodKindId: "" }),
ev({ id: "m2", at: "2026-05-09T08:00:00", grams: 0, foodKindId: "" }),
ev({ id: "m3", at: "2026-05-10T08:00:00", grams: 180, foodKindId: "dry" }),
ev({ id: "m4", at: "2026-05-11T08:00:00", foodKindId: "" }),
ev({ id: "m5", at: "2026-05-12T08:00:00", grams: 90, foodKindId: "", deleted: true }),
ev({ id: "p1", at: "2026-05-08T09:00:00", type: "pee" }),
ev({ id: "n1", at: "2026-05-08T10:00:00", type: "note", note: "vet" }),
ev({ id: "w1", at: "2026-05-08T11:00:00", type: "weight", weight: 7.2 }),
];
suite("which meals the log picks out");
{
eq(ids(gaps.mealsMissing(log, "all", "")), ["m4", "m3", "m2", "m1"],
"only live meals, newest first — a pee, a note and a weigh-in are not meals");
ok(!ids(gaps.mealsMissing(log, "all", "")).includes("m5"),
"…and a deleted meal is gone for good, not merely unlabelled");
eq(ids(gaps.mealsMissing(log, "kind", "")), ["m4", "m2", "m1"],
"'no kind' skips the meal that has one");
ok(gaps.mealsMissing(log, "kind", "").some(e => e.id === "m4"),
"…and a meal with no amount still counts as one needing a kind");
eq(ids(gaps.mealsMissing(log, "amount", "")), ["m4", "m2"],
"'no amount' takes both a missing grams and a zero one");
eq(gaps.MEAL_GAPS.amount({ grams: 0 }), true, "zero grams is no amount, not an amount of none");
}
suite("the cut-off that makes a bulk label safe");
{
eq(ids(gaps.mealsMissing(log, "kind", "2026-05-10")), ["m2", "m1"],
"takes meals strictly before the start of that day");
eq(ids(gaps.mealsMissing(log, "kind", "2026-05-09")), ["m1"],
"…so a meal on the cut-off day itself is left alone");
eq(ids(gaps.mealsMissing(log, "kind", "")), ["m4", "m2", "m1"],
"no cut-off means all of them");
eq(ids(gaps.mealsMissing(log, "kind", "not-a-date")), ["m4", "m2", "m1"],
"…as does a date that isn't one, rather than silently emptying the list");
}
suite("labelling them in bulk");
{
saved = log.map(e => ({ ...e }));
const before = JSON.stringify(saved.filter(e => e.id !== "m1" && e.id !== "m2" && e.id !== "m4"));
synced = rendered = 0;
const n = gaps.backfillFoodKind("dry", "");
eq(n, 3, "reports how many it changed");
eq(saved.filter(e => e.foodKindId === "dry").map(e => e.id).sort(), ["m1", "m2", "m3", "m4"],
"every unlabelled meal now carries the kind — and the one that had it still does");
eq(JSON.stringify(saved.filter(e => e.id !== "m1" && e.id !== "m2" && e.id !== "m4")), before,
"everything it did not pick is left byte for byte as it was");
ok(saved.find(e => e.id === "m1").updatedAt > 0,
"a relabelled meal is stamped, so it wins last-write-wins on the next sync");
eq([synced, rendered], [1, 1],
"one sync and one render for the lot, not one per meal");
}
suite("a bulk label that would do nothing does nothing");
{
saved = log.map(e => ({ ...e }));
const untouched = JSON.stringify(saved);
synced = rendered = 0;
eq(gaps.backfillFoodKind("", ""), 0, "no kind chosen is not a label to apply");
eq(gaps.backfillFoodKind("dry", "2026-01-01"), 0, "nor is a cut-off with nothing before it");
eq(JSON.stringify(saved), untouched, "…and neither writes anything");
eq([synced, rendered], [0, 0], "…or queues a sync for a change that never happened");
}
}
export default report("food-kinds");
+72 -24
View File
@@ -4,33 +4,52 @@
import { load } from "./extract.mjs";
import { suite, eq, ok, report } from "./assert.mjs";
const app = load({ names: ["foodTrend"] });
const words = load({ names: ["foodTrendSentence"] });
// The food line is dailyTrend fitted to each day's grams. Today is whichever day
// is flagged so, as weeklyData flags it; these days put it last.
const fit = load({ names: ["dailyTrend"] });
const app = { foodTrend: (days) => fit.dailyTrend(days, (d) => d.grams) };
// The window reaches a sentence as the phrase the chart names it by. The
// reason for having no line mentions today only when the window has it.
const words = load({ names: ["noTrendSentence", "foodTrendSentence"], stubs: { chartRange: () => ({ endsToday: true }) } });
const lastDays = (n) => `the last ${n} days`;
// The 7/14/30 picker reaches the trend by deciding how many days weeklyData
// builds — there is no second mechanism, so this is the thing to hold still.
let windowDays = 7;
// The range picker reaches the trend by deciding which days weeklyData builds —
// there is no second mechanism, so this is the thing to hold still. The picker
// is the real one, reading what it stored.
const stored = new Map();
const weekly = load({
names: ["startOfDay", "endOfDay", "ymd", "weeklyData"],
names: [
"CHART_DAYS_KEY", "CHART_RANGE_KEY", "CHART_DAY_CHOICES", "CHART_MAX_DAYS",
"startOfDay", "endOfDay", "ymd", "addDays", "daysBetween", "parseYmd",
"storedCustomRange", "chartRange", "chartDayList",
"NO_KIND", "sleepIntervals", "msInIntervals", "weeklyData",
],
stubs: {
chartDays: () => windowDays,
localStorage: { getItem: (k) => stored.get(k) ?? null },
isExcluded: () => false,
eventsForDay: () => [],
sleepMsInRange: () => 0,
walkMsInRange: () => 0,
walkWindows: () => [],
},
});
suite("the day picker is what sets the trend's window");
suite("the range picker is what sets the trend's window");
for (const n of [7, 14, 30]) {
windowDays = n;
stored.set(weekly.CHART_DAYS_KEY, String(n));
eq(weekly.weeklyData([]).length, n, `picking ${n}d gives the charts ${n} days to fit over`);
}
windowDays = 7;
{
// A custom stretch in the past: its own days, none of them today.
const ago = (n) => weekly.ymd(weekly.addDays(weekly.startOfDay(new Date()), -n));
stored.set(weekly.CHART_DAYS_KEY, "custom");
stored.set(weekly.CHART_RANGE_KEY, JSON.stringify({ from: ago(10), to: ago(3) }));
const days = weekly.weeklyData([]);
eq(days.length, 8, "a custom range gives the charts exactly its days");
eq(days.some((d) => d.isToday), false, "…and one that ends before today has no half-done day to leave out");
}
stored.clear();
// weeklyData's shape, as far as foodTrend reads it. Today is last, as there.
// weeklyData's shape, as far as the fit reads it. Today is last.
const days = (grams, { excluded = [] } = {}) =>
grams.map((g, i) => ({ grams: g, excluded: excluded.includes(i) }));
grams.map((g, i) => ({ grams: g, excluded: excluded.includes(i), isToday: i === grams.length - 1 }));
suite("it declines to fit when there is nothing to fit");
{
@@ -89,7 +108,7 @@ suite("marked days are skipped without shifting the line");
suite("what the sentence is allowed to say");
{
const say = (grams, opts, win = 14) => words.foodTrendSentence(app.foodTrend(days(grams, opts)), win);
const say = (grams, opts, win = 14) => words.foodTrendSentence(app.foodTrend(days(grams, opts)), lastDays(win));
const rising = say([200, 250, 300, 350, 400, 450, 0]);
ok(/up about 250 g/.test(rising), "a clear climb gives the size of the move");
@@ -143,17 +162,19 @@ suite("what the sentence is allowed to say");
{
let kinds = [];
const split = load({
names: ["NO_KIND", "FOOD_COLORS", "foodTrend", "foodTrendSentence",
names: ["NO_KIND", "FOOD_COLORS", "dailyTrend", "noTrendSentence", "foodTrendSentence",
"foodTrendMoves", "foodSeriesSentences", "foodSeriesFor"],
stubs: {
chartRange: () => ({ endsToday: true }),
liveFoodKinds: () => kinds,
loadFoodKinds: () => kinds,
foodKindNames: () => new Map(kinds.map(k => [k.id, k.name])),
},
});
// days carrying a per-kind split, as weeklyData builds them.
const byKind = (rows) => rows.map(r => ({
// days carrying a per-kind split, as weeklyData builds them; the last is today.
const byKind = (rows) => rows.map((r, i) => ({
isToday: i === rows.length - 1,
grams: Object.values(r).reduce((s, v) => s + v, 0),
gramsByKind: r,
excluded: false,
@@ -167,7 +188,7 @@ suite("what the sentence is allowed to say");
const series = split.foodSeriesFor(days);
eq(series.length, 1, "no kinds defined gives exactly one series");
eq(series[0].name, "No kind", "…the unnamed one");
const s = split.foodSeriesSentences(series, 7);
const s = split.foodSeriesSentences(series, lastDays(7));
eq(s.length, 1, "…and one sentence, as before kinds existed");
ok(/daily intake/.test(s[0]), "…phrased as the whole intake, not as a kind");
}
@@ -201,7 +222,7 @@ suite("what the sentence is allowed to say");
// food is real — it has to show under the name the tombstone kept.
kinds = [];
const namesOnly = load({
names: ["NO_KIND", "FOOD_COLORS", "foodTrend", "foodSeriesFor"],
names: ["NO_KIND", "FOOD_COLORS", "dailyTrend", "foodSeriesFor"],
stubs: {
liveFoodKinds: () => [],
// The tombstone: gone from the picker, still carrying name and colour.
@@ -231,7 +252,7 @@ suite("what the sentence is allowed to say");
{ a: 300, b: 50, c: 40, e: 9 }, { a: 0, b: 0, c: 0, e: 0 },
]);
const series = split.foodSeriesFor(days);
const lines = split.foodSeriesSentences(series, 7);
const lines = split.foodSeriesSentences(series, lastDays(7));
ok(lines.some(l => /^Dry:/.test(l)), "the kind that moved gets its own sentence");
ok(lines.length <= 2, `four kinds give at most two lines, got ${lines.length}`);
ok(lines.some(l => /no clear trend/.test(l)),
@@ -245,7 +266,7 @@ suite("what the sentence is allowed to say");
{ a: 200, b: 100 }, { a: 205, b: 98 }, { a: 198, b: 101 },
{ a: 202, b: 99 }, { a: 200, b: 100 }, { a: 0, b: 0 },
]);
const lines = split.foodSeriesSentences(split.foodSeriesFor(days), 7);
const lines = split.foodSeriesSentences(split.foodSeriesFor(days), lastDays(7));
eq(lines.length, 1, "one line when nothing is claimable");
ok(/no kind shows a trend/.test(lines[0]), "…saying so plainly");
}
@@ -259,7 +280,7 @@ suite("what the sentence is allowed to say");
let selected = "2026-09-20";
let el = { hidden: false, textContent: "" };
const info = load({
names: ["NO_KIND", "FOOD_COLORS", "foodTrend", "foodSeriesFor", "renderFoodDayInfo"],
names: ["NO_KIND", "FOOD_COLORS", "dateFormatters", "fmtDate", "dailyTrend", "foodSeriesFor", "renderFoodDayInfo"],
stubs: {
document: { getElementById: () => el },
selectedDay: () => new Date(selected + "T12:00:00"),
@@ -315,6 +336,33 @@ suite("what the sentence is allowed to say");
"a day marked not counted says that instead of reading as empty");
}
suite("a day holding only one kind");
{
// The chart is split — other days have several kinds — but this day's food
// is all one. The total is that one figure, so saying it twice is noise.
kinds = [{ id: "d", name: "Dry", colorIndex: 0 }, { id: "f", name: "Fresh", colorIndex: 1 }];
const days = [day(18, { "": 300 }), day(19, { d: 210, f: 90 }), day(20, { d: 300 })];
selected = "2026-09-18";
const unlabelled = read(days).textContent;
eq(unlabelled, "Fri, Sep 18 — 300 g.",
"a day of unlabelled food gives the bare total, on a split chart too");
ok(!/No kind/.test(unlabelled),
"…without the 'No kind' label, which has nothing to distinguish it from");
ok(!/in total/.test(unlabelled), "…and without saying the number twice");
selected = "2026-09-20";
const oneKind = read(days).textContent;
eq(oneKind, "Sun, Sep 20 — Dry 300 g.",
"a day of one named kind keeps the name, which does say something");
ok(!/in total/.test(oneKind), "…but still does not repeat the figure");
selected = "2026-09-19";
ok(/in total/.test(read(days).textContent),
"two kinds on a day still get the total beside them");
}
suite("an unsplit chart gets the day total too");
{
// No kinds defined: there is still no hover on a phone, so the figure was
+5 -2
View File
@@ -13,12 +13,15 @@ let excluded = new Set();
let windowDays = 7;
const curves = load({
names: ["startOfDay", "pairWindows", "sleepWindows", "sleepTrendCurves"],
names: ["startOfDay", "addDays", "pairWindows", "sleepWindows", "averageDays", "sleepTrendCurves"],
stubs: {
selectedDay: () => SEL,
ymd: (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`,
isExcluded: (d) => excluded.has(d.getDate()),
chartDays: () => windowDays,
// A preset window: the average runs over the N full days before the
// selected one (averageDays). A custom range isn't what's checked here.
chartRange: () => ({ custom: false, days: windowDays }),
chartDayList: () => [],
},
});
+8 -2
View File
@@ -2,10 +2,16 @@ self: { config, lib, pkgs, ... }:
let
cfg = config.services.puppy-tracker;
staticPkg = self.packages.${pkgs.system}.static;
serverPkg = self.packages.${pkgs.system}.server;
staticPkg = self.packages.${pkgs.stdenv.hostPlatform.system}.static;
serverPkg = self.packages.${pkgs.stdenv.hostPlatform.system}.server;
in
{
# The feed schema read walks from is gone; a config that still sets it
# is told so, rather than getting an unknown-option error.
imports = [
(lib.mkRemovedOptionModule [ "services" "puppy-tracker" "integration" ] "The integration feed for schema was removed.")
];
options.services.puppy-tracker = {
enable = lib.mkEnableOption "Puppy Tracker (offline-first puppy tracking app with sync server)";
+23 -7
View File
@@ -84,6 +84,11 @@ type Config struct {
// PedigreeID is the dog's SKK chip or registration number. When set, the app
// unlocks the pedigree view and looks this dog up; empty means no pedigree.
PedigreeID string `json:"pedigreeId"`
// SleepOff means sleep isn't being logged: the app hides its sleep buttons,
// timer and charts, and reminders stop reading the puppy as awake or asleep.
// Negative so that the zero value, and a client too old to send the field,
// both mean "tracking", which is what every profile was before it existed.
SleepOff bool `json:"sleepOff"`
UpdatedAt int64 `json:"updatedAt"`
}
@@ -100,8 +105,8 @@ func (cs *ConfigStore) get(userID string) Config {
// One profile row per user. A missing row is the pre-configuration state,
// so a zero-value Config is the right answer.
err := cs.db.QueryRow(
`SELECT name, birthday, pedigree_id, updated FROM config WHERE user_id = ?`, userID,
).Scan(&c.Name, &c.Birthday, &c.PedigreeID, &c.UpdatedAt)
`SELECT name, birthday, pedigree_id, sleep_off, updated FROM config WHERE user_id = ?`, userID,
).Scan(&c.Name, &c.Birthday, &c.PedigreeID, &c.SleepOff, &c.UpdatedAt)
if err != nil && !errors.Is(err, sql.ErrNoRows) {
log.Printf("config get: %v", err)
}
@@ -111,19 +116,20 @@ func (cs *ConfigStore) get(userID string) Config {
// merge applies an incoming config for one user with last-write-wins by
// UpdatedAt and returns the resulting stored config (which the caller sends back).
func (cs *ConfigStore) merge(userID string, in Config) (Config, error) {
// Name/birthday/updated are last-write-wins: the incoming row replaces the
// Name/birthday/sleep_off/updated are last-write-wins: the incoming row replaces the
// stored one only when strictly newer. The pedigree id is stickier — an empty
// incoming value never clears a stored one, so a clock race between devices
// can't drop it; when both are set, the newer profile's id wins with the rest.
_, err := cs.db.Exec(`
INSERT INTO config (user_id, name, birthday, pedigree_id, updated)
VALUES (?, ?, ?, ?, ?)
INSERT INTO config (user_id, name, birthday, pedigree_id, sleep_off, updated)
VALUES (?, ?, ?, ?, ?, ?)
ON CONFLICT(user_id) DO UPDATE SET
name = excluded.name, birthday = excluded.birthday,
pedigree_id = CASE WHEN excluded.pedigree_id != '' THEN excluded.pedigree_id ELSE config.pedigree_id END,
sleep_off = excluded.sleep_off,
updated = excluded.updated
WHERE excluded.updated > config.updated`,
userID, in.Name, in.Birthday, in.PedigreeID, in.UpdatedAt)
userID, in.Name, in.Birthday, in.PedigreeID, in.SleepOff, in.UpdatedAt)
if err != nil {
return Config{}, err
}
@@ -468,6 +474,7 @@ func openDB(path string) (*sql.DB, error) {
name TEXT NOT NULL DEFAULT '',
birthday TEXT NOT NULL DEFAULT '',
pedigree_id TEXT NOT NULL DEFAULT '',
sleep_off INTEGER NOT NULL DEFAULT 0,
updated INTEGER NOT NULL DEFAULT 0
);
CREATE TABLE IF NOT EXISTS users (
@@ -653,6 +660,15 @@ func migrateSchema(db *sql.DB) error {
return err
}
}
hasSleepOff, err := columnExists(db, "config", "sleep_off")
if err != nil {
return err
}
if !hasSleepOff {
if _, err := db.Exec(`ALTER TABLE config ADD COLUMN sleep_off INTEGER NOT NULL DEFAULT 0`); err != nil {
return err
}
}
return nil
}
@@ -1029,7 +1045,7 @@ func main() {
case http.MethodGet:
writeConfig(configStore.get(userID(r)))
case http.MethodPut, http.MethodPost:
// The profile (name, birthday, pedigree id) is the owner's to set.
// The profile (name, birthday, pedigree id, sleep tracking) is the owner's to set.
// The GET above stays open — a guest needs the name and birthday to
// render the header at all.
if isGuest(r) {
+16 -1
View File
@@ -188,10 +188,25 @@ type sleepState struct {
since int64 // ms epoch of that boundary
}
// sleepStateFor reads that boundary for one user. An account that has switched
// sleep tracking off has no sleep state at all,
// whatever boundaries are left in its log. Reading the last one anyway would
// leave the puppy "asleep" from the day tracking stopped, with every other
// rule silenced for good — or "awake" since then, with the sleep rule firing
// every interval forever.
func (sch *Scheduler) sleepStateFor(userID string) (sleepState, error) {
var off bool
err := sch.db.QueryRow(`SELECT sleep_off FROM config WHERE user_id = ?`, userID).Scan(&off)
if err != nil && !errors.Is(err, sql.ErrNoRows) {
return sleepState{}, err
}
if off {
return sleepState{}, nil
}
var typ string
var at int64
err := sch.db.QueryRow(`
err = sch.db.QueryRow(`
SELECT type, at FROM events
WHERE user_id = ? AND deleted = 0 AND type IN ('sleep-start', 'sleep-end')
ORDER BY at DESC, updated DESC LIMIT 1`, userID).Scan(&typ, &at)
+40
View File
@@ -188,6 +188,46 @@ func TestSleepStateMatchesLatestBoundary(t *testing.T) {
}
}
func TestSleepStateIgnoredWhenTrackingIsOff(t *testing.T) {
sch := testScheduler(t)
now := int64(1_700_000_000_000)
configs := newConfigStore(sch.db)
// Tracking stopped while the log still says asleep.
addEvent(t, sch, "u1", "pee", now-90*minute)
addEvent(t, sch, "u1", "sleep-start", now-600*minute)
if _, err := configs.merge("u1", Config{Name: "Rex", SleepOff: true, UpdatedAt: now}); err != nil {
t.Fatalf("merge: %v", err)
}
if got := configs.get("u1"); !got.SleepOff {
t.Fatal("sleepOff did not round-trip through the config store")
}
s, err := sch.sleepStateFor("u1")
if err != nil {
t.Fatalf("sleepStateFor: %v", err)
}
if s.state != "" {
t.Errorf("state = %q, want none while tracking is off", s.state)
}
// So an overdue pee rule fires rather than waiting for a wake-up that will
// never be logged, and the sleep rule stays quiet.
if _, ok, err := sch.due("u1", Reminder{Kind: "pee", Enabled: true, IntervalMin: 60}, 0, now, s); err != nil || !ok {
t.Errorf("pee: fired = %v (err %v), want a fire", ok, err)
}
if _, ok, err := sch.due("u1", Reminder{Kind: "sleep", Enabled: true, IntervalMin: 45}, 0, now, s); err != nil || ok {
t.Errorf("sleep: fired = %v (err %v), want no fire", ok, err)
}
// Switching it back on reads the log again.
if _, err := configs.merge("u1", Config{Name: "Rex", UpdatedAt: now + 1}); err != nil {
t.Fatalf("merge: %v", err)
}
if s, err := sch.sleepStateFor("u1"); err != nil || s.state != "asleep" {
t.Errorf("tracking back on: state = %q (err %v), want asleep", s.state, err)
}
}
func TestRemindersStoreDefaultsAndClamping(t *testing.T) {
sch := testScheduler(t)
+862 -226
View File
File diff suppressed because it is too large. Load diff
+14 -1
View File
@@ -1,6 +1,19 @@
[
{ "date": "2026-11-12", "text": "Sleep tracking can be switched off. Turn off Track sleep in Settings and the Sleep start / Sleep end buttons, the asleep/awake timer, the Sleep tab, the Sleep and Awake figures and the Sleep & wake list all go away, and nothing is dimmed any more for being “unlikely” while asleep. Reminders stop going quiet while the log says asleep, and the Time to sleep reminder stops firing. Sleep you have already logged is kept, so you can switch it back on for a day whenever you want to track it" },
{ "date": "2026-10-28", "text": "The Sleep trend and Walk trend charts handle the days the clocks change. Their hour axis counted hours from midnight rather than reading the clock, so on the Sunday the clocks go back the day’s line stopped at 11 pm and left out the last hour — taking it off that day’s total and off the average day built from it — and in spring the day ran on into 1 am the next morning. Today’s line also ended an hour away from the “now” marker on those days. Both charts now follow the clock, so every day runs from midnight to midnight whatever its length" },
{ "date": "2026-10-28", "text": "His age is no longer a day short for part of the year. Depending on when he was born, counting the days since his birthday could come up one short between the clocks going forward in spring and going back in autumn, and the week and month counts in “16 weeks (3 months and 3 weeks) old” ticked over a day late" },
{ "date": "2026-10-28", "text": "The When sleeping and When walking grids draw the days the clocks change correctly. On the Sunday the clocks go back the day is 25 hours long, and everything after 3 am was drawn an hour late — the evening sleep ran off the right-hand end of the row. In spring the 23-hour day stopped short of 24h instead. Each nap and walk now sits at the time the clock showed, lining up with the hour lines like every other day, and the “now” marker does the same on those days" },
{ "date": "2026-10-03", "text": "The charts can cover any stretch of dates, not just the last 7, 14 or 30 days. Tap Custom on the “Charts cover” row and pick a from and a to date — up to a year at a time, and the to date can be in the past, so you can look back at, say, May on its own and see how much he slept or walked then. Every chart and panel that follows the 7 / 14 / 30 buttons follows the custom dates too, and their headings and trend sentences name the dates (“Over May 1 – Jun 15, daily sleep is down about 2h”). On a long range the daily bars sit edge to edge and the axis shows dates instead of weekdays, and the When sleeping and When walking grids use thinner rows so a few months still fit on the screen. The “average day” line on the Sleep trend and Walk trend is averaged over the custom dates as well. Tapping 7d, 14d or 30d goes back to the rolling window, and Custom remembers the dates you picked last" },
{ "date": "2026-10-01", "text": "The app opens straight away when you have no connection. It used to check in with the server before showing anything, and on a weak signal or with the server out of reach that check could take a long while to give up, leaving a blank screen even though all your data was already on the phone. It now opens on the account you were last signed in to and checks in the background; if that sign-in has run out you are taken to the login screen as before" },
{ "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" },
{ "date": "2026-09-26", "text": "Tapping the tab you are already on scrolls back to the top of the page, the way it does in most phone apps — handy after scrolling a long way down Habits or the history. Switching to a different tab still leaves you where you were, as before" },
{ "date": "2026-09-24", "text": "Kinds of food are now created in one place only — Settings → Food kinds. The Ate dialog no longer has a box for inventing one on the spot; it still lets you pick from the kinds you have, exactly as before. Making them mid-meal put a bit of list-keeping in the middle of logging, where the thing you actually came to do is record that the dog ate, and a kind typed in a hurry is easy to get slightly wrong — nothing stops two near-identical kinds existing, and clearing one up afterwards means relabelling every meal logged under it first" },
{ "date": "2026-09-22", "text": "Habits has a Meals log beside the Food (grams) chart: every meal you have logged, newest first, across every day rather than just the one you are looking at. It is there because a meal's amount and its kind are both optional — which is what makes them easy to lose track of. A meal with no kind sits in the grey band on the chart, a meal with no amount is quietly left out of it, and until now there was nowhere to go and see which ones those were. The filter chips carry their own counts, so “No kind 412” tells you the size of the gap before you tap anything, and picking a filter lists exactly those meals; tap any row to fill in what it is missing, in the same edit dialog as everywhere else. If you started using food kinds after months of logging, the “No kind” filter also offers to label the whole list at once: choose a kind and it sets it on every meal shown. Tick “Only before” a date first if you switched foods partway, so the older meals take one kind and the newer ones keep what they have — worth getting right, because there is no undo. The panel folds away by tapping its heading like any other, and appears only once you have logged a meal; the “No kind” filter and the bulk label appear only once you have created a kind, so nothing changes for anyone not using them. A guest can see the list but cannot relabel your meals" },
{ "date": "2026-09-22", "text": "Tap a bar in the Food (grams) chart and a line under it spells that day out — “Sat, Sep 20 — 340 g”, or “Dry 260 g · Fresh 100 g · 360 g in total” once you are using kinds. A phone has nothing to hover over, so the amount for a given day was previously only readable by eye off the axis. It follows whichever day is highlighted, so the ← → arrows and the date picker move it too, and it says so plainly when a day has no food logged or is marked as not counted" },
{ "date": "2026-09-22", "text": "Meals can be labelled with a kind of food. Make up your own in Settings → Food kinds — dry, fresh, raw, whatever you feed — and pick one when you log a meal; tap the ★ beside one to have it chosen for you automatically. You can also invent a kind from inside the log dialog if you realise you need it mid-meal. All of it is optional: “No kind” is always offered, every meal you have already logged keeps working untouched, and with no kinds defined the app looks and behaves exactly as it did. Once you are using them, today's overview shows the day's food broken down — “Dry 260 g · Fresh 100 g” — under the stat tiles, and the Food (grams) chart splits each day's bar by kind with a legend, and draws a separate trend line for each, so you can see fresh creeping up while dry comes down. The sentence underneath names only the kinds that are actually moving and folds the rest into one clause, so it stays short however many kinds you have. Renaming a kind updates the meals logged as it; deleting one keeps them readable under the name it had. A guest can label a meal with a kind you have created but cannot add, rename or delete them" },
{ "date": "2026-09-22", "text": "Meals can be labelled with a kind of food. Make up your own in Settings → Food kinds — dry, fresh, raw, whatever you feed — and pick one when you log a meal; tap the ★ beside one to have it chosen for you automatically. All of it is optional: “No kind” is always offered, every meal you have already logged keeps working untouched, and with no kinds defined the app looks and behaves exactly as it did. Once you are using them, today's overview breaks the day's food down inside the Meals card — “Dry 260 g” and “Fresh 100 g” under the total they add up to — and the Food (grams) chart splits each day's bar by kind with a legend, and draws a separate trend line for each, so you can see fresh creeping up while dry comes down. The sentence underneath names only the kinds that are actually moving and folds the rest into one clause, so it stays short however many kinds you have. Renaming a kind updates the meals logged as it; deleting one keeps them readable under the name it had. A guest can label a meal with a kind you have created but cannot add, rename or delete them" },
{ "date": "2026-09-21", "text": "Fixed the figures under the Food (grams) chart contradicting each other. It read like “down about 329 g a week — roughly 460 g a day then, 320 g a day now”, where subtracting the two amounts gives 140 g, not 329 g. The rate was worked out per week while the line itself only covers the complete days in the window — at most five of them on a 7-day window, since today isn't finished — so it was stretched past the days it was measured from. It now gives the change between the two ends, which is a figure you can check by subtracting them: “down about 140 g — from roughly 460 g a day to 320 g”" },
{ "date": "2026-09-21", "text": "You can measure the time between two events. Press and hold one row, press and hold another, and a bar along the bottom shows the gap — “3h 42m · Ate 12:10 → Poo 15:52” — which answers things like how long after a meal he needs to go out. It stays there until you clear it with the ✕, so you can change day in between and pick the second event from another day; when the pair straddles midnight the bar shows the dates too. It works on any row that is a single moment: the history log, the notes log and weigh-ins. Holding a row you already picked unpicks it, and a third pick is ignored until you clear. Tapping a row still opens it for editing as before. One cost: because holding a row now means something, you can no longer select the text of a note to copy it" },
{ "date": "2026-09-21", "text": "A day marked “not counted” no longer appears in the Sleep trend or the Walk trend. It was already left out of the average and out of the “yesterday” comparison, but the day you were actually looking at was still drawn as the boldest line on the chart — so the one day you had said not to trust was the one the panel led with. Now it is left off and its legend chip goes with it, leaving the average and yesterday, which is what you would want to see on a day like that" },
+73 -19
View File
@@ -174,7 +174,9 @@
its own). A row per timed pair, then the two one-tap moments, and
last the three that open a dialog to type a value. -->
<div class="actions">
<div class="action-row">
<!-- data-sleep-only: hidden while sleep tracking is off in Settings,
like everything else so marked (see renderSleepTracking). -->
<div class="action-row" data-sleep-only>
<button class="action sleep" data-type="sleep-start">😴 Sleep start</button>
<button class="action sleep" data-type="sleep-end">⏰ Sleep end</button>
</div>
@@ -199,7 +201,7 @@
above them: logging has to be one tap from wherever you are. -->
<nav class="tabs" role="tablist" aria-label="Sections">
<button type="button" class="tab" role="tab" data-tab="today" id="tab-today" aria-controls="tabpanel-today" aria-selected="false" tabindex="-1">Today</button>
<button type="button" class="tab" role="tab" data-tab="sleep" id="tab-sleep" aria-controls="tabpanel-sleep" aria-selected="false" tabindex="-1">Sleep</button>
<button type="button" class="tab" role="tab" data-tab="sleep" id="tab-sleep" aria-controls="tabpanel-sleep" aria-selected="false" tabindex="-1" data-sleep-only>Sleep</button>
<button type="button" class="tab" role="tab" data-tab="walks" id="tab-walks" aria-controls="tabpanel-walks" aria-selected="false" tabindex="-1">Walks</button>
<button type="button" class="tab" role="tab" data-tab="habits" id="tab-habits" aria-controls="tabpanel-habits" aria-selected="false" tabindex="-1">Habits</button>
<button type="button" class="tab" role="tab" data-tab="growth" id="tab-growth" aria-controls="tabpanel-growth" aria-selected="false" tabindex="-1">Growth</button>
@@ -215,6 +217,15 @@
<button type="button" class="ghost" data-days="7">7d</button>
<button type="button" class="ghost" data-days="14">14d</button>
<button type="button" class="ghost" data-days="30">30d</button>
<button type="button" class="ghost" id="chart-range-custom">Custom</button>
</div>
<!-- Shown only while Custom is picked. Either end may be in the past,
so a stretch of history can be looked at on its own. -->
<div class="chart-range-fields" id="chart-range-fields" hidden>
<input type="date" id="chart-range-from" aria-label="Charts cover from" />
<span aria-hidden="true">–</span>
<input type="date" id="chart-range-to" aria-label="Charts cover to" />
<span class="muted-note" id="chart-range-days"></span>
</div>
</div>
@@ -233,11 +244,11 @@
Not counted in the charts and averages. Everything below is unchanged.
</p>
<div class="stats">
<div class="stat">
<div class="stat" data-sleep-only>
<div class="stat-label">Sleep</div>
<div class="stat-value" id="stat-sleep">0h 0m</div>
</div>
<div class="stat">
<div class="stat" data-sleep-only>
<div class="stat-label">Awake</div>
<div class="stat-value" id="stat-awake">0h 0m</div>
</div>
@@ -250,6 +261,10 @@
<div class="stat-label">Meals</div>
<div class="stat-value" id="stat-meals">0</div>
<div class="stat-sub" id="stat-meals-grams" hidden></div>
<!-- The day's food per kind, under the total it adds up to.
Only when there is more than one kind that day: with one,
the total line already carries its name. -->
<div class="stat-sub stat-kinds" id="stat-meals-kinds" hidden></div>
</div>
<div class="stat">
<div class="stat-label">Pees</div>
@@ -265,17 +280,11 @@
</div>
</div>
<!-- The day's food broken down by kind. Its own line rather than
inside the Meals tile: that tile is about 90px wide, and a
breakdown of two or three kinds will not sit in it. Hidden unless
a meal that day actually carries a kind. -->
<p id="stat-food-kinds" class="muted-note food-kind-split" hidden></p>
<div class="lasts">
<div class="last-row"><span>Last pee</span><span id="last-pee">—</span></div>
<div class="last-row"><span>Last poo</span><span id="last-poo">—</span></div>
<div class="last-row"><span>Last meal</span><span id="last-eat">—</span></div>
<div class="last-row"><span>Last sleep</span><span id="last-sleep">—</span></div>
<div class="last-row" data-sleep-only><span>Last sleep</span><span id="last-sleep">—</span></div>
<div class="last-row"><span>Last walk</span><span id="last-walk">—</span></div>
</div>
</section>
@@ -285,7 +294,7 @@
one alternating list rather than sitting in two panels that each show
half the day. Every row carries its state; the open one keeps the
highlight. -->
<section class="sleepwake" data-panel="sleep-wake">
<section class="sleepwake" data-panel="sleep-wake" data-sleep-only>
<h2>Sleep &amp; wake</h2>
<ul id="sleep-wake-list" class="wake-list"></ul>
<p id="sleep-wake-empty" class="empty">No sleep or wake windows yet for this day.</p>
@@ -303,7 +312,9 @@
<h2>Sleep <span class="muted-note" data-chart-days-label>(last 7 days)</span></h2>
<div class="chart">
<div class="chart-title">Hours per day</div>
<svg id="chart-sleep" class="chart-svg" viewBox="0 0 320 160" role="img" aria-label="Sleep hours per day"></svg>
<svg id="chart-sleep" class="chart-svg" viewBox="0 0 320 160" role="img" aria-label="Sleep hours per day, with a trend line"></svg>
<!-- What the trend line says — see renderSleepTrendNote. -->
<p id="sleep-note" class="muted-note" hidden></p>
</div>
</section>
@@ -334,7 +345,9 @@
<p id="walk-empty" class="empty">No walks yet for this day. Use 🦮 Walk start / 🏁 Walk end to time one.</p>
<div class="chart walk-chart" id="walk-chart-wrap" hidden>
<div class="chart-title">Minutes per day <span data-chart-days-label>(last 7 days)</span></div>
<svg id="chart-walk" class="chart-svg" viewBox="0 0 320 160" role="img" aria-label="Minutes walked per day"></svg>
<svg id="chart-walk" class="chart-svg" viewBox="0 0 320 160" role="img" aria-label="Minutes walked per day, with a trend line"></svg>
<!-- What the trend line says — see renderTrendNote. -->
<p id="walk-note" class="muted-note" hidden></p>
</div>
</section>
@@ -385,7 +398,7 @@
</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.</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,
@@ -414,6 +427,43 @@
see renderFoodTrendNote. -->
<p id="grams-note" class="muted-note" hidden></p>
</div>
<!-- Every meal logged, newest first. Like the Notes log this ignores
the day picker: the meals worth finding here are the ones missing
a kind or an amount, and those are spread across all of history
rather than sitting on the day you happen to be viewing.
Folds on its own h3 (see the data-panel machinery) because the
list grows by one every meal, and the charts above it are what
you usually want left on screen. -->
<div class="subpanel meals-log" data-panel="meals-log" id="meals-log" hidden>
<h3>Meals</h3>
<!-- Counts live on the chips, so how much is unlabelled is legible
without selecting anything. -->
<div class="kind-picker meals-filter" id="meals-log-filter" role="radiogroup" aria-label="Which meals to list">
<button type="button" class="kind-chip active" data-gap="all" role="radio" aria-checked="true">All</button>
<button type="button" class="kind-chip" data-gap="kind" role="radio" aria-checked="false" hidden>No kind</button>
<button type="button" class="kind-chip" data-gap="amount" role="radio" aria-checked="false">No amount</button>
</div>
<!-- The cut-off filters the list, not just the bulk edit, so what
the button acts on is exactly what is drawn beneath it. -->
<label class="meals-cutoff" id="meals-log-cutoff">
<input type="checkbox" id="meals-log-before-on" />
<span>Only before</span>
<input type="date" id="meals-log-before" aria-label="Only meals before this date" />
</label>
<ul id="meals-log-list" class="event-list"></ul>
<p id="meals-log-empty" class="empty" hidden></p>
<button type="button" id="meals-log-more" class="ghost meals-more" hidden></button>
<!-- The bulk label lives on the list rather than in Settings, so the
number on the button is the rows you are looking at. Owner-only:
a guest may not touch the owner's meals. -->
<div class="meals-bulk" id="meals-log-bulk" hidden>
<div class="meals-bulk-head">Label these as</div>
<div id="meals-log-kind-picker" class="kind-picker" role="radiogroup" aria-label="Kind to label these meals as"></div>
<button type="button" id="meals-log-apply" class="ghost meals-apply"></button>
</div>
</div>
<div class="chart">
<div class="chart-title">By hour of day</div>
<svg id="chart-hour-heatmap" class="chart-svg" viewBox="0 0 320 120" role="img" aria-label="Pee, poo and meal frequency by hour of day"></svg>
@@ -537,6 +587,14 @@
placeholder="SKK chip or reg. number (optional)" />
</label>
<p class="settings-hint">Set your dog's SKK chip or registration number to unlock the 🌳 pedigree page.</p>
<!-- Part of the synced profile rather than a device preference: it
decides what a guest is asked to log, and the server needs it so
reminders stop reading a sleep state nobody is keeping up. -->
<label class="toggle-row">
<span>Track sleep</span>
<input type="checkbox" id="settings-sleep" role="switch" class="switch" />
</label>
<p class="settings-hint">Off hides the sleep buttons, timer and charts. Sleep already logged is kept, so you can switch it back on for a day whenever you like.</p>
</div>
<label class="toggle-row">
<span>Dark mode</span>
@@ -674,10 +732,6 @@
<div id="note-kind-field" class="kind-field" hidden>
<span class="kind-label">Kind</span>
<div id="note-kind-picker" class="kind-picker" role="radiogroup" aria-label="Kind of food"></div>
<div id="note-kind-new" class="kind-new" hidden>
<input type="text" id="note-kind-name" maxlength="30" autocomplete="off" placeholder="New kind, e.g. Fresh" />
<button type="button" id="note-kind-add" class="ghost">Add</button>
</div>
</div>
<label>Note
<textarea id="note-input" rows="4" placeholder="e.g. pee was instant, poo took 5min, ate 300g raw food"></textarea>
+75 -5
View File
@@ -17,6 +17,9 @@
flip with the theme; the brights don't. --sleep itself was doing both
jobs and failing the second — 2.6:1 on the timer pill it painted. */
--sleep-ink: #4258cc;
/* Same idea for walks: the green is a fill, and a line drawn over the
green bars needs a shade that stands off them in either theme. */
--walk-ink: #22683d;
--wake: #f2b705;
--wake-ink: #6f4d00;
/* The two timers, on the dark theme, take a near-white with a sixth of the
@@ -47,6 +50,7 @@
--accent: #a690ff;
--accent-soft: #2a2640;
--sleep-ink: #8ba4ff;
--walk-ink: #7fd49c;
--wake-ink: #f5c451;
--wake-timer-ink: #fdf4da;
--border: #2c2a3a;
@@ -61,6 +65,7 @@
--accent: #a690ff;
--accent-soft: #2a2640;
--sleep-ink: #8ba4ff;
--walk-ink: #7fd49c;
--wake-ink: #f5c451;
--wake-timer-ink: #fdf4da;
--border: #2c2a3a;
@@ -884,10 +889,26 @@ dialog menu {
and the buttons sitting on the page background between two cards. */
.chart-window {
display: flex;
flex-wrap: wrap; /* a fourth button leaves no room for the label on a small phone */
align-items: center;
gap: 10px;
gap: 8px 10px;
padding: 0 4px;
}
/* Custom dates get a row of their own under the buttons. */
.chart-range-fields {
flex-basis: 100%;
display: flex;
align-items: center;
gap: 6px;
}
.chart-range-fields input[type="date"] {
flex: 1;
width: auto; /* the global input rule sets 100%, which would push the row */
min-width: 0;
padding: 4px 8px;
font-size: 0.85rem;
}
.chart-range-fields .muted-note { flex: none; white-space: nowrap; }
.chart-window-label {
font-size: 0.75rem;
text-transform: uppercase;
@@ -1110,9 +1131,10 @@ button.linklike:hover { text-decoration: underline; filter: none; }
}
.excluded-note { margin: 8px 0 0; }
/* Sits between the stat tiles and the "last X" rows, so it reads as a
footnote to the Meals tile above it. */
.food-kind-split { margin: -8px 0 14px; }
/* The per-kind lines under the Meals tile's total. Kind names are free
text, so a long one wraps inside the tile rather than widening it. */
.stat-kinds { margin-top: 1px; }
.stat-kinds div { overflow-wrap: anywhere; }
/* Tied to the bar above it, so it sits closer to the chart than the trend
caption below and takes the accent to read as "the highlighted one". */
.food-day-info { margin: 6px 0 0; color: var(--accent); }
@@ -1120,7 +1142,6 @@ button.linklike:hover { text-decoration: underline; filter: none; }
/* The day's own figures stay readable but visibly step back, so "this one is
not in the numbers" is legible from the day as well as from the charts. */
.overview.day-excluded .stats,
.overview.day-excluded .food-kind-split,
.overview.day-excluded .last-row { opacity: 0.55; }
/* The hatch every chart uses for a day that doesn't count. The pattern itself
@@ -1369,6 +1390,18 @@ input.switch:checked::after { transform: translateX(18px); }
stroke-linecap: round;
fill: none;
}
/* The sleep and walk bars are filled with --sleep and --walk, so the fit
through each takes its ink shade — darker in light mode, lighter in dark —
to stay visible where it crosses a bar. */
.chart-svg .sleep-trend,
.chart-svg .walk-trend-line {
stroke: var(--sleep-ink);
stroke-width: 2;
stroke-dasharray: 5 3;
stroke-linecap: round;
fill: none;
}
.chart-svg .walk-trend-line { stroke: var(--walk-ink); }
.legend .sw.food-sw { background: var(--food-color, var(--muted)); }
.kind-field { margin-bottom: 10px; }
@@ -1446,6 +1479,43 @@ button.food-kind-default {
button.food-kind-default.active { color: var(--wake); }
button.food-kind-delete { color: var(--danger); flex: none; }
/* ---------- the meals log ---------- */
/* Beside the food chart in Habits: every meal, across every day, with the
count of what each filter would show carried on its own chip. */
.meals-log .kind-picker { margin-bottom: 8px; }
.meals-cutoff {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
color: var(--muted);
font-size: 0.85rem;
}
.meals-cutoff input[type="checkbox"] { flex: none; }
.meals-cutoff input[type="date"] {
flex: 1;
width: auto; /* the global input rule sets 100%, which would push the row */
min-width: 0;
padding: 4px 8px;
font-size: 0.85rem;
}
button.meals-more { margin-top: 8px; width: 100%; }
/* Set off by a rule, so it reads as an action on the list above rather than
as another row of it. */
.meals-bulk {
margin-top: 12px;
padding-top: 12px;
border-top: 1px solid var(--border);
}
.meals-bulk-head {
color: var(--muted);
font-size: 0.8rem;
font-weight: 600;
margin-bottom: 8px;
}
button.meals-apply { margin-top: 10px; width: 100%; }
button.meals-apply[disabled] { opacity: 0.5; }
/* ---------- measuring between two events ---------- */
/* Fixed at the bottom, near the thumb, and it stays until cleared — the
measurement is the answer to a question you asked, not a notification. */