Compare commits

..
15 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
12 changed files with 829 additions and 229 deletions

No files matched your search

+17
View File
@@ -136,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
@@ -347,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");
}
{
+45 -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"),
+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)
+592 -178
View File
File diff suppressed because it is too large. Load diff
+10
View File
@@ -1,4 +1,14 @@
[
{ "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" },
+32 -9
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>
@@ -273,7 +284,7 @@
<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>
@@ -283,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>
@@ -301,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>
@@ -332,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>
@@ -383,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,
@@ -572,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>
+34 -1
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;
@@ -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; }