Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
feat(days): a note on a day you didn't train, and the missed-day nudge lets that day go (#261)
Duarte Santos99fefdcf5751
diff --git a/api/nudge.js b/api/nudge.jsindex c260fb9fd..b9e0bb476 100644--- a/api/nudge.js+++ b/api/nudge.js@@ -36,9 +36,17 @@ export function nudgeWindowOpen(reminderTime, hhmm) {const dayBefore = iso => new Date(Date.parse(iso + 'T12:00:00Z') - 86400000).toISOString().slice(0, 10);const records = v => (Array.isArray(v) ? v.filter(x => x && typeof x === 'object') : []);const logged = (S, iso) => S.workouts.some(w => w.d === iso);+// A day with a note on it (frontend lib/day-notes.js: a quick pick or a line of text) is excused:+// never a missed day, never nudged or reminded about.+const DAY_NOTE_TAGS = ['sick', 'travel', 'rest', 'injured'];+export function excusedOn(S, iso) {+ const e = S?.dayNotes && typeof S.dayNotes === 'object' ? S.dayNotes[iso] : null;+ if (!e || typeof e !== 'object' || Array.isArray(e)) return false;+ return DAY_NOTE_TAGS.includes(e.tag) || (typeof e.text === 'string' && e.text.trim() !== '');+}function missed(S, iso) {- if (logged(S, iso)) return null;+ if (logged(S, iso) || excusedOn(S, iso)) return null;const rid = effectiveRoutineId(S, iso);if (!rid) return null;if (queueLiveOn(S, iso) && logged(S, dayBefore(iso))) return null;diff --git a/api/server.js b/api/server.jsindex 1d23a9185..938fca7dc 100644--- a/api/server.js+++ b/api/server.js@@ -34,7 +34,7 @@ import { createMediaStore, mediaLimits, mediaConfig, MediaError, HASH_RE } fromimport { effectiveRoutineId } from './queue.js';import { stampPut } from './sync-stamps.js';import { atomicWrite as durableWrite } from './durable.js';-import { nudgeFor, nudgeWindowOpen, toneOf } from './nudge.js';+import { excusedOn, nudgeFor, nudgeWindowOpen, toneOf } from './nudge.js';const PORT = +(process.env.PORT || 3000);const DATA = process.env.DATA_DIR || '/data';@@ -513,6 +513,7 @@ setInterval(() => {if (!(late >= 0 && late <= REMINDER_WINDOW_MIN)) continue;if (user.lastReminder === now.date) continue;if ((S.workouts || []).some(w => w?.d === now.date)) continue;+ if (excusedOn(S, now.date)) continue; // noted as sick, away, … (nudge.js excusedOn)const rid = effectiveRoutineId(S, now.date);if (!rid) continue; // rest day — nothing plannedconst routine = (S.routines || []).find(r => r?.id === rid);diff --git a/api/sync-stamps.js b/api/sync-stamps.jsindex 291318589..cc6538bc5 100644--- a/api/sync-stamps.js+++ b/api/sync-stamps.js@@ -64,9 +64,12 @@ const capStamps = m => {const OWN_MERGE = new Set(['_ts', '_rev', '_wid', '_wids', '_unstamped', '_prior', 'active', 'unit', 'unitSet', 'resetAt', 'resetIds', 'deleted', 'edited', 'undone', 'routineOrder','workouts', 'routines', 'customEx', 'equipProfiles', 'gymCards', 'bodyweight', 'measurements', 'favEx',- 'exWeights', 'balanceOverrides', 'loadKind', 'plates',+ 'exWeights', 'balanceOverrides', 'loadKind', 'plates', 'dayNotes',]);const PER_KEY = new Set(['week', 'dayPlan', 'exNotes', 'barWeights']);+// The maps whose every entry carries its own edit time (sync-merge.js STAMPED_MAPS): merged per+// key by the app, so never stamped here as a whole setting. dayNotes is a note per day off.+export const STAMPED_MAPS = ['balanceOverrides', 'loadKind', 'plates', 'dayNotes'];const ENTRY_META = new Set(['id', '_ts', '_f', '_u']);const ENTRY_LISTS = ['routines', 'customEx', 'equipProfiles', 'gymCards', 'workouts'];@@ -111,7 +114,7 @@ export function highestStamp(S) {if (isMap(x._f)) for (const v of Object.values(x._f)) see(v);}}- for (const f of ['balanceOverrides', 'loadKind', 'plates']) {+ for (const f of STAMPED_MAPS) {if (isMap(S[f])) for (const v of Object.values(S[f])) see(isMap(v) ? v._ts : 0);}return m;diff --git a/api/test/nudge.test.js b/api/test/nudge.test.jsindex f280bcb10..f0f3c9774 100644--- a/api/test/nudge.test.js+++ b/api/test/nudge.test.js@@ -2,7 +2,7 @@// in server.js is covered end to end in server-nudge.test.js; the rules themselves are here.import { test } from 'node:test';import assert from 'node:assert/strict';-import { nudgeFor, nudgeMinute, nudgeWindowOpen, toneOf, lineIndex } from '../nudge.js';+import { excusedOn, nudgeFor, nudgeMinute, nudgeWindowOpen, toneOf, lineIndex } from '../nudge.js';import { nudgePush } from '../push-messages.js';import { NUDGE_COPY } from '../nudge-copy.js';@@ -61,6 +61,18 @@ test('coach week / rotation: the day right after a workout is rest, the second dassert.equal(nudgeFor(s, '2026-09-09'), 'pull', 'two days off in a row');});+// #261, the mirror of frontend/src/lib/nudge.test.js: a day with a note on it is excused.+test('a noted day is excused: not nudged, and not counted towards the back-off', () => {+ const notes = { '2026-09-07': { tag: 'sick', _ts: 1 } };+ assert.equal(nudgeFor(S({ workouts: [w('2026-09-04')], dayNotes: notes }), '2026-09-07'), null);+ assert.equal(nudgeFor(S({ workouts: [w('2026-09-04')], dayNotes: { '2026-09-07': { text: 'Flight to Lisbon', _ts: 1 } } }), '2026-09-07'), null);+ assert.equal(nudgeFor(S({ workouts: [w('2026-09-04')], dayNotes: { '2026-09-07': { _ts: 2 } } }), '2026-09-07'), 'push', 'a cleared note is no excuse');+ const s = S({ workouts: [w('2026-09-04')], dayNotes: notes });+ assert.deepEqual(['2026-09-09', '2026-09-11', '2026-09-14', '2026-09-16'].map(d => !!nudgeFor(s, d)), [true, true, true, false]);+ assert.equal(excusedOn(S({ dayNotes: { '2026-09-07': { tag: 'nope', text: ' ' } } }), '2026-09-07'), false);+ assert.equal(excusedOn({ dayNotes: 'x' }, '2026-09-07'), false);+});+test('a malformed state reads as nothing to nudge about', () => {assert.equal(nudgeFor({}, '2026-09-07'), null);assert.equal(nudgeFor({ workouts: 'x', routines: null, week: { 1: 'push' } }, '2026-09-07'), null);diff --git a/api/test/server-reminder.test.js b/api/test/server-reminder.test.jsindex 28135fbf8..451f81fcb 100644--- a/api/test/server-reminder.test.js+++ b/api/test/server-reminder.test.js@@ -157,6 +157,10 @@ test('a reminder 20 minutes past is not delivered late, and a day already trainefs.writeFileSync(file, goodState(late.hhmm, { workouts: [{ id: 'w1', d: today }] }));await wait(1500);assert.equal(firings(h.log), 0, `a trained day must stay silent:\n${h.log}`);+ // inside the window, nothing logged, but today carries a day note (#261): excused, silent+ fs.writeFileSync(file, goodState(late.hhmm, { dayNotes: { [today]: { tag: 'sick', _ts: 1 } } }));+ await wait(1500);+ assert.equal(firings(h.log), 0, `a day noted as sick must stay silent:\n${h.log}`);});/* A null entry inside an otherwise fine list is not a shape the tick can refuse at the door:diff --git a/frontend/src/components/Heatmap.jsx b/frontend/src/components/Heatmap.jsxindex 077bce5ca..45ba9958d 100644--- a/frontend/src/components/Heatmap.jsx+++ b/frontend/src/components/Heatmap.jsx@@ -4,6 +4,7 @@ import { workoutDay, workoutDuration, workoutVolume } from '../lib/history.js'import { t, tn } from '../lib/i18n.js'import { tappable } from '../lib/use-sheet-keyboard.js'import { Segmented } from './ui.jsx'+import { dayNoteOf, dayNoteLine } from '../lib/day-notes.js'const normalizeMetric = value => value === 'vol' ? 'vol' : 'time'@@ -67,10 +68,13 @@ export default function Heatmap({ S, onDay, metric: selectedMetric, onMetricChanconst day = new Date(colStart); day.setDate(colStart.getDate() + d)const key = isoOf(day)const a = agg[key]- const cls = 'hm-c l' + level(a) + (key === todayISO() ? ' today' : '') + (day > today ? ' future' : '')+ // A day off with a note (#261): outlined, its note in the tooltip, and tappable like a+ // trained day so the note can be read (and changed) on a phone too.+ const note = !a && dayNoteOf(S, key)+ const cls = 'hm-c l' + level(a) + (note ? ' noted' : '') + (key === todayISO() ? ' today' : '') + (day > today ? ' future' : '')cells.push(<div key={d} className={cls}- title={key + (a ? ` · ${tn('{0} workout', '{0} workouts', a.n)} · ${t('{0} min', a.min)} · ${fmtVol(a.vol, S.unit)}` : '')}- {...tappable(a ? () => onDay?.(key) : undefined)} />)+ title={key + (a ? ` · ${tn('{0} workout', '{0} workouts', a.n)} · ${t('{0} min', a.min)} · ${fmtVol(a.vol, S.unit)}` : note ? ` · ${dayNoteLine(note, t)}` : '')}+ {...tappable(a || note ? () => onDay?.(key) : undefined)} />)}cols.push(<div key={wk} className="hm-col">{cells}</div>)}diff --git a/frontend/src/index.css b/frontend/src/index.cssindex 3b1a7318f..f951e2b44 100644--- a/frontend/src/index.css+++ b/frontend/src/index.css@@ -472,6 +472,8 @@ h4.sec{.wday .dot.plan{background:var(--label-3)}.wday .dot.ovr{background:var(--orange)}.wday .dot.done{background:var(--acc)}+/* a day off with a note on it (#261, lib/day-notes.js): the same colour on every calendar */+.wday .dot.noted{background:var(--indigo)}.wday:active{background:var(--surface-2)}.wday.today .num{background:var(--acc);color:var(--on-acc);font-weight:600;@@ -1622,6 +1624,7 @@ body.no-tabbar #timer.working{box-shadow:inset 0 var(--hair) 0 var(--acc),0 -10p.hm-c.l4{background:var(--acc)}.hm-c.today{box-shadow:0 0 0 1.5px var(--acc)}.hm-c.future{opacity:.3}+.hm-c.noted{box-shadow:inset 0 0 0 1.5px var(--indigo)}.hm-legend{display:flex;align-items:center;gap:4px;justify-content:flex-end;margin-top:9px;font-size:11px;color:var(--label-3);@@ -1749,6 +1752,7 @@ body.no-tabbar.resting #toast{bottom:calc(100px + var(--sab))}.cal-d i.done{background:var(--acc)}.cal-d i.plan{background:var(--label-3)}.cal-d i.ovr{background:var(--orange)}+.cal-d i.noted{background:var(--indigo)}.cal-legend{display:flex;gap:14px;justify-content:center;margin-top:12px;font-size:12px;color:var(--label-3)}.cal-legend i{display:inline-block;width:6px;height:6px;border-radius:50%;margin-inline-end:5px}diff --git a/frontend/src/lib/day-notes.js b/frontend/src/lib/day-notes.jsnew file mode 100644index 000000000..393152cd9--- /dev/null+++ b/frontend/src/lib/day-notes.js@@ -0,0 +1,61 @@+// A note on a day you did not train (#261): "Sick", "Travelling", a line of your own. A day that+// carries one is excused: the missed-day nudge (lib/nudge.js, and its server copy api/nudge.js)+// and the workout-day reminder leave it alone, and the calendar, the heatmap and the week strip+// show it instead of an empty planned day.+//+// Stored per day, the way a plate-loading choice is (lib/plates.js):+//+// S.dayNotes = { '2026-10-08': { tag: 'sick', text: 'Flu, back Monday', _ts }, … }+//+// Each day is one entry with the time it was last written, so two devices that each noted a+// different day keep both, and the same day keeps the later note (lib/sync-merge.js+// mergeStampedMap). Taking a note away is a stamped empty entry (`{ _ts }`), not a deleted key:+// a delete would come straight back from the other device's copy on the next sync.+//+// Only today and the days before can take a note. A note on a future day reads as permission to+// skip it, and the issue asked for nothing that nudges towards procrastination.+import { NOTE_MAX } from './history.js'+import { todayISO } from './format.js'++/** The quick picks, in the order the sheet shows them. Labels are English source strings. */+export const DAY_NOTE_TAGS = ['sick', 'travel', 'rest', 'injured']+export const DAY_NOTE_LABEL = { sick: 'Sick', travel: 'Travelling', rest: 'Rest day', injured: 'Injured' }+// Icons the set already has (components/Icon.jsx): under the weather, away, asleep, ouch.+export const DAY_NOTE_ICON = { sick: 'cloud', travel: 'globe', rest: 'moon', injured: 'warning' }++const isMap = v => !!v && typeof v === 'object' && !Array.isArray(v)+const ISO = /^\d{4}-\d{2}-\d{2}$/++/** A stored entry read back: { tag, text } with the junk left out, or null for none or a cleared one. */+export function readDayNote(entry) {+ if (!isMap(entry)) return null+ const tag = DAY_NOTE_TAGS.includes(entry.tag) ? entry.tag : null+ const text = typeof entry.text === 'string' ? entry.text.trim().slice(0, NOTE_MAX) : ''+ return tag || text ? { tag, text } : null+}++/** The note on `iso`, or null. */+export const dayNoteOf = (S, iso) => readDayNote(isMap(S?.dayNotes) ? S.dayNotes[iso] : null)++/** Whether `iso` is excused: it carries a note. The nudge and the reminder skip such a day. */+export const excusedOn = (S, iso) => dayNoteOf(S, iso) != null++/** Whether `iso` can take a note at all: a real date, today or earlier. */+export const canNoteDay = (iso, today = todayISO()) => ISO.test(String(iso || '')) && iso <= today++/**+ * S.dayNotes with `iso` set to `note` ({ tag, text }), stamped `now`. An empty note (no tag, no+ * text) is written as a cleared entry, so the removal syncs (see the top of this file).+ */+export function withDayNote(map, iso, note, now = Date.now()) {+ const clean = readDayNote(note)+ const entry = clean ? { ...(clean.tag ? { tag: clean.tag } : {}), ...(clean.text ? { text: clean.text } : {}), _ts: now } : { _ts: now }+ return { ...(isMap(map) ? map : {}), [iso]: entry }+}++/** The label a note reads as in a list or a tooltip: its quick pick, its text, or both. */+export function dayNoteLine(note, tr = s => s) {+ if (!note) return ''+ const label = note.tag ? tr(DAY_NOTE_LABEL[note.tag]) : ''+ return label && note.text ? `${label} · ${note.text}` : label || note.text+}diff --git a/frontend/src/lib/day-notes.test.js b/frontend/src/lib/day-notes.test.jsnew file mode 100644index 000000000..6f2861329--- /dev/null+++ b/frontend/src/lib/day-notes.test.js@@ -0,0 +1,136 @@+// #261: a note on a day you did not train. The helpers, how two devices merge their notes, and+// that the server's copy of the sync rules (api/sync-stamps.js) treats the map the same way.+import { describe, expect, it } from 'vitest'+import * as Server from '../../../api/sync-stamps.js'+import { DAY_NOTE_TAGS, DAY_NOTE_LABEL, DAY_NOTE_ICON, canNoteDay, dayNoteLine, dayNoteOf, excusedOn, readDayNote, withDayNote } from './day-notes.js'+import { highestStamp, localExtras, mergeStates, resetIdsOf, stampChange, STAMPED_MAPS } from './sync-merge.js'+import { NOTE_MAX } from './history.js'+import { buildReminderNotifications } from './mobile.js'++const base = (over = {}) => ({+ unit: 'kg', week: {}, dayPlan: {}, workouts: [], routines: [], bodyweight: [], customEx: [], favEx: [],+ exWeights: {}, exNotes: {}, barWeights: {}, equipProfiles: [], gymCards: [], _ts: 0, ...over,+})+const clone = o => JSON.parse(JSON.stringify(o))++describe('day notes: reading and writing', () => {+ it('reads a quick pick, a text, or both; junk and cleared entries read as none', () => {+ expect(readDayNote({ tag: 'sick', _ts: 1 })).toEqual({ tag: 'sick', text: '' })+ expect(readDayNote({ text: ' Flight ', _ts: 1 })).toEqual({ tag: null, text: 'Flight' })+ expect(readDayNote({ tag: 'travel', text: 'Lisbon' })).toEqual({ tag: 'travel', text: 'Lisbon' })+ expect(readDayNote({ tag: 'hungover', text: ' ' })).toBeNull()+ expect(readDayNote({ _ts: 5 })).toBeNull()+ for (const junk of [null, undefined, 'sick', 3, ['sick']]) expect(readDayNote(junk)).toBeNull()+ expect(readDayNote({ text: 'x'.repeat(NOTE_MAX + 50) }).text).toHaveLength(NOTE_MAX)+ })++ it('every quick pick has a label and an icon', () => {+ for (const k of DAY_NOTE_TAGS) { expect(DAY_NOTE_LABEL[k]).toBeTruthy(); expect(DAY_NOTE_ICON[k]).toBeTruthy() }+ })++ it('writes a stamped entry per day, and an empty note as a stamped clear', () => {+ const m = withDayNote({ '2026-10-01': { tag: 'rest', _ts: 3 } }, '2026-10-02', { tag: 'sick', text: ' flu ' }, 10)+ expect(m).toEqual({ '2026-10-01': { tag: 'rest', _ts: 3 }, '2026-10-02': { tag: 'sick', text: 'flu', _ts: 10 } })+ const cleared = withDayNote(m, '2026-10-02', { tag: null, text: ' ' }, 11)+ expect(cleared['2026-10-02']).toEqual({ _ts: 11 })+ expect(withDayNote(undefined, '2026-10-03', null, 12)).toEqual({ '2026-10-03': { _ts: 12 } })+ expect(dayNoteOf({ dayNotes: cleared }, '2026-10-02')).toBeNull()+ expect(excusedOn({ dayNotes: cleared }, '2026-10-01')).toBe(true)+ expect(excusedOn({}, '2026-10-01')).toBe(false)+ })++ it('only today and earlier days take a note', () => {+ expect(canNoteDay('2026-10-09', '2026-10-09')).toBe(true)+ expect(canNoteDay('2026-09-30', '2026-10-09')).toBe(true)+ expect(canNoteDay('2026-10-10', '2026-10-09')).toBe(false)+ expect(canNoteDay('nope', '2026-10-09')).toBe(false)+ })++ it('reads as one line: the pick, the text, or both', () => {+ expect(dayNoteLine({ tag: 'sick', text: '' })).toBe('Sick')+ expect(dayNoteLine({ tag: null, text: 'Wedding' })).toBe('Wedding')+ expect(dayNoteLine({ tag: 'travel', text: 'Lisbon' }, s => s.toUpperCase())).toBe('TRAVELLING · Lisbon')+ expect(dayNoteLine(null)).toBe('')+ })+})++describe('day notes across devices', () => {+ it('notes written on different days on two devices are both kept', () => {+ const phone = base({ _ts: 100, dayNotes: withDayNote({}, '2026-10-01', { tag: 'sick' }, 90) })+ const desk = base({ _ts: 200, workouts: [{ id: 'w', d: '2026-10-03', start: 1, entries: [] }], dayNotes: withDayNote({}, '2026-10-02', { tag: 'travel' }, 20) })+ for (const m of [mergeStates(phone, desk), mergeStates(desk, phone)]) {+ expect(dayNoteOf(m, '2026-10-01')).toEqual({ tag: 'sick', text: '' })+ expect(dayNoteOf(m, '2026-10-02')).toEqual({ tag: 'travel', text: '' })+ expect(m.workouts.map(w => w.id)).toEqual(['w'])+ }+ })++ it('the same day keeps the note written last, whichever copy is newer as a whole', () => {+ const phone = base({ _ts: 100, dayNotes: withDayNote({}, '2026-10-01', { tag: 'injured', text: 'knee' }, 90) })+ const desk = base({ _ts: 300, dayNotes: withDayNote({}, '2026-10-01', { tag: 'rest' }, 40) })+ for (const m of [mergeStates(phone, desk), mergeStates(desk, phone)]) expect(dayNoteOf(m, '2026-10-01')).toEqual({ tag: 'injured', text: 'knee' })+ })++ it('a removed note stays removed against the other device\'s older copy, and a later note beats the removal', () => {+ const removed = base({ _ts: 100, dayNotes: withDayNote({}, '2026-10-01', null, 80) })+ const stale = base({ _ts: 300, dayNotes: withDayNote({}, '2026-10-01', { tag: 'sick' }, 40) })+ for (const m of [mergeStates(removed, stale), mergeStates(stale, removed)]) expect(dayNoteOf(m, '2026-10-01')).toBeNull()+ const later = base({ _ts: 50, dayNotes: withDayNote({}, '2026-10-01', { text: 'actually travelling' }, 95) })+ expect(dayNoteOf(mergeStates(removed, later), '2026-10-01')).toEqual({ tag: null, text: 'actually travelling' })+ })++ it('a copy from before notes existed (no dayNotes at all) loses none of them', () => {+ const mine = base({ _ts: 100, dayNotes: withDayNote({}, '2026-10-01', { tag: 'sick' }, 90) })+ const old = base({ _ts: 500 })+ for (const m of [mergeStates(mine, old), mergeStates(old, mine)]) expect(excusedOn(m, '2026-10-01')).toBe(true)+ })++ it('a change that writes a note stamps it after everything the copy has seen', () => {+ const prev = base({ _ts: 1000, dayNotes: withDayNote({}, '2026-10-01', { tag: 'rest' }, 900) })+ const next = clone(prev)+ next.dayNotes = withDayNote(next.dayNotes, '2026-10-02', { tag: 'sick' }, 5) // a clock far behind+ const at = stampChange(prev, next, 5)+ expect(at).toBeGreaterThan(1000)+ expect(next.dayNotes['2026-10-02']._ts).toBe(at)+ expect(next.dayNotes['2026-10-01']._ts).toBe(900)+ expect(highestStamp(next)).toBe(at)+ })++ it('"Reset everything" wipes the notes of a copy that has not seen the reset', () => {+ const before = base({ _ts: 1000, dayNotes: withDayNote({}, '2026-10-01', { tag: 'sick' }, 900) })+ const reset = base({ _ts: 2000, resetAt: 2000, resetIds: resetIdsOf(before) })+ expect(reset.resetIds.dayNotes).toEqual(['2026-10-01'])+ const stale = clone(before); stale._ts = 2100+ for (const m of [mergeStates(reset, stale), mergeStates(stale, reset)]) expect(dayNoteOf(m, '2026-10-01')).toBeNull()+ })++ it('sign-in counts notes the device has that the server does not', () => {+ const server = base({ dayNotes: withDayNote({}, '2026-10-01', { tag: 'sick' }, 5) })+ const local = base({ dayNotes: { ...withDayNote({}, '2026-10-01', { tag: 'rest' }, 9), ...withDayNote({}, '2026-10-02', { tag: 'travel' }, 9), '2026-10-03': { _ts: 9 } } })+ expect(localExtras(local, server).setup).toBe(1)+ })++ it('the server\'s sync rules know the map: same list, same highest stamp, never stamped as a setting', () => {+ expect(Server.STAMPED_MAPS).toEqual(STAMPED_MAPS)+ const doc = { _ts: 5, dayNotes: { '2026-10-01': { tag: 'sick', _ts: 77 } } }+ expect(Server.highestStamp(doc)).toBe(77)+ expect(highestStamp(doc)).toBe(77)+ // an older app (no stamps of its own) pushing over a copy with notes: the notes come back+ // from the stored copy, and no `edited.dayNotes` stamp is made up for them+ const cur = { _ts: 10, unit: 'kg', workouts: [], dayNotes: { '2026-10-01': { tag: 'sick', _ts: 9 } } }+ const next = { _ts: 11, unit: 'kg', workouts: [], restSec: 60 }+ Server.stampPut(cur, next, { overRead: true, now: 20 })+ expect(next.dayNotes).toEqual(cur.dayNotes)+ expect(next.edited?.dayNotes).toBeUndefined()+ })+})++describe('the workout-day reminder on a noted day (mobile)', () => {+ it('skips today once it carries a note', () => {+ const S = base({ routines: [{ id: 'r', name: 'Push', ex: [] }], week: { 0: 'r', 1: 'r', 2: 'r', 3: 'r', 4: 'r', 5: 'r', 6: 'r' }, reminder: { on: true, time: '18:00' } })+ const now = new Date(2026, 9, 9, 9, 0)+ expect(buildReminderNotifications(S, now)[0].schedule.at.getDate()).toBe(9)+ const noted = { ...S, dayNotes: withDayNote({}, '2026-10-09', { tag: 'sick' }, 1) }+ expect(buildReminderNotifications(noted, now)[0].schedule.at.getDate()).toBe(10)+ })+})diff --git a/frontend/src/lib/mobile.js b/frontend/src/lib/mobile.jsindex 0fc835a52..347c570c0 100644--- a/frontend/src/lib/mobile.js+++ b/frontend/src/lib/mobile.js@@ -13,6 +13,7 @@ import { t, tn } from './i18n-core.js'import { isoOf, todayISO } from './format.js'import { effectiveRoutineIds } from './history.js'import { NUDGE_COPY, lineIndex, nudgeFor, nudgeMinute, toneOf } from './nudge.js'+import { excusedOn } from './day-notes.js'export const MOBILE = import.meta.env.VITE_MOBILE === '1'@@ -108,7 +109,8 @@ export function buildReminderNotifications(S, now = new Date()) {const day = new Date(date)day.setDate(date.getDate() + offset)const iso = isoOf(day)- if (completed.has(iso)) continue+ // A day you noted as sick or away (lib/day-notes.js) is off the hook, reminder included.+ if (completed.has(iso) || excusedOn(S, iso)) continue// A weekday can hold several routines; name them all, or fall back to a count. Each day is// asked as if it were today: a coach week's next session is due every day until it is done,// so it is reminded every day (the app re-syncs these after every workout and on open).diff --git a/frontend/src/lib/nudge.js b/frontend/src/lib/nudge.jsindex f34fecfd0..940852b61 100644--- a/frontend/src/lib/nudge.js+++ b/frontend/src/lib/nudge.js@@ -11,7 +11,8 @@// reads, coach week/rotation included) and no workout dated on it. A floating coach// week or rotation names a session every day until it is done, so on such a day the// day right after a workout is a rest day, not a miss — only the second day off in a-// row counts.+// row counts. A day you left a note on (lib/day-notes.js: sick, travelling, …) is+// excused, never missed: it is not nudged about and does not count towards the back-off.// HOW OFTEN — back-off: the missed days since the last workout are counted (14 days back at// most). After 3 of them the nudge goes quiet until the next workout is logged, so a// break never turns into a daily nag. No counter is stored anywhere: it is read off@@ -23,6 +24,7 @@import { isoOf } from './format.js'import { effectiveRoutineIds } from './history.js'import { queueLiveOn } from './queue.js'+import { excusedOn } from './day-notes.js'export const NUDGE_TONES = ['friendly', 'guilt', 'drill']export const NUDGE_MAX_MISSES = 3@@ -86,7 +88,7 @@ const norm = S => ({// The routine ids `iso` missed, or [] when it is not a missed day. Each date is asked as if it// were today, as the reminder does: a coach week's session is due every day until it is done.function missed(S, iso) {- if (logged(S, iso)) return []+ if (logged(S, iso) || excusedOn(S, iso)) return []const ids = effectiveRoutineIds(S, iso, iso)if (!ids.length) return []if (queueLiveOn(S, iso, iso) && logged(S, dayBefore(iso))) return []diff --git a/frontend/src/lib/nudge.test.js b/frontend/src/lib/nudge.test.jsindex ca129237f..ae13ece6b 100644--- a/frontend/src/lib/nudge.test.js+++ b/frontend/src/lib/nudge.test.js@@ -33,6 +33,18 @@ describe('nudgeFor', () => {expect(nudgeFor(s, '2026-09-09')).toEqual(['pull'])})+ // #261: a day with a note on it (sick, travelling, …) is excused, not missed.+ it('leaves a noted day alone, and a noted day does not count towards the back-off', () => {+ const notes = { '2026-09-07': { tag: 'sick', _ts: 1 } }+ expect(nudgeFor(S({ workouts: [w('2026-09-04')], dayNotes: notes }), '2026-09-07')).toBeNull()+ expect(nudgeFor(S({ workouts: [w('2026-09-04')], dayNotes: { '2026-09-07': { text: 'Flight to Lisbon', _ts: 1 } } }), '2026-09-07')).toBeNull()+ // a cleared note (a stamped empty entry) is no excuse+ expect(nudgeFor(S({ workouts: [w('2026-09-04')], dayNotes: { '2026-09-07': { _ts: 2 } } }), '2026-09-07')).toEqual(['push'])+ // Monday excused: Wednesday, Friday and the next Monday are the three misses that count+ const s = S({ workouts: [w('2026-09-04')], dayNotes: notes })+ expect(['2026-09-09', '2026-09-11', '2026-09-14', '2026-09-16'].map(d => !!nudgeFor(s, d))).toEqual([true, true, true, false])+ })+it('times the evening and reads the tone tolerantly', () => {expect(nudgeMinute('08:00')).toBe(1200)expect(nudgeMinute('19:15')).toBe(1275)@@ -66,6 +78,10 @@ describe('buildNudgeNotifications (mobile)', () => {const live = buildNudgeNotifications(S({ workouts: [w('2026-09-04')], active: { rid: 'push' } }), now)expect(live[0].schedule.at.getDate()).toBe(9)})+ it('skips today once it carries a day note (#261)', () => {+ const n = buildNudgeNotifications(S({ workouts: [w('2026-09-04')], dayNotes: { '2026-09-07': { tag: 'travel', _ts: 1 } } }), now)+ expect(n[0].schedule.at.getDate()).toBe(9)+ })it('takes the tone, and runs 2 hours after a late reminder', () => {const n = buildNudgeNotifications(S({ workouts: [w('2026-09-04')], reminder: { on: true, time: '19:00', nudge: true, tone: 'drill' } }), now)expect(n[0].title).toBe(NUDGE_COPY.drill.title)diff --git a/frontend/src/lib/sync-merge.js b/frontend/src/lib/sync-merge.jsindex 3b38f278b..74b9cbc73 100644--- a/frontend/src/lib/sync-merge.js+++ b/frontend/src/lib/sync-merge.js@@ -36,9 +36,10 @@* is the exception: the edit may have taken away the set the kept weight came from, so it* is the best of the merged history and of the editing copy's own, and the other copy's* can no longer bring a corrected typo back. exNotes, barWeights: key union- * - balanceOverrides, loadKind, plates: key union; of a key both have, the entry set last by- * its own `_ts`, a clear included (mergeStampedMap), the newer copy's on a tie. For plates the- * key is the unit, so the inventory of one unit is kept whole, as last edited+ * - balanceOverrides, loadKind, plates, dayNotes: key union; of a key both have, the entry set+ * last by its own `_ts`, a clear included (mergeStampedMap), the newer copy's on a tie. For+ * plates the key is the unit, so the inventory of one unit is kept whole, as last edited; for+ * dayNotes the key is the date, so each day's note is its own* - `_ts`: the later of the two; `_rev` dropped (the server sets it); `active` left to the caller** Two rules come before all of these:@@ -76,9 +77,13 @@ import { beatsWeight } from './exercises.js'import { bestWeightForEntry } from './history.js'import { convertStateUnit, convertBodyWeight } from './units.js'import { sanitizeAccent } from './accent.js'+import { readDayNote as readNote } from './day-notes.js'const clone = o => JSON.parse(JSON.stringify(o))const list = v => (Array.isArray(v) ? v : [])+// The maps whose every entry carries its own edit time (mergeStampedMap). dayNotes is a day's+// note on a day off (lib/day-notes.js), one entry per date.+export const STAMPED_MAPS = ['balanceOverrides', 'loadKind', 'plates', 'dayNotes']/** The copy with the later `_ts`; on a tie the first argument (callers pass local first). */export const newerOf = (a, b) => ((b?._ts || 0) > (a?._ts || 0) ? b : a)@@ -397,7 +402,7 @@ const RESET_LISTS = {workouts: workoutKey, routines: x => x?.id, customEx: x => x?.id, bodyweight: bodyweightKey,measurements: bodyweightKey, gymCards: x => x?.id, equipProfiles: x => x?.id, favEx: x => x,}-const RESET_MAPS = ['exNotes', 'barWeights', 'balanceOverrides', 'loadKind', 'plates']+const RESET_MAPS = ['exNotes', 'barWeights', ...STAMPED_MAPS]/** An entry's name in resetIds: a workout's id (or day and start), a weigh-in's day and time, … */export const entryKey = (field, x) => String(RESET_LISTS[field](x))// Per field, the most names a reset keeps — far more workouts than anyone logs, and a bound on@@ -457,7 +462,7 @@ export function sinceReset(S, at, ids) {out.favEx = []out.exNotes = {}out.barWeights = {}- for (const f of ['balanceOverrides', 'loadKind', 'plates']) {+ for (const f of STAMPED_MAPS) {out[f] = Object.fromEntries(Object.entries(isMap(S[f]) ? S[f] : {}).filter(([, v]) => after(stampOf(v))))}}@@ -607,7 +612,7 @@ function applyDeletions(S, deleted) {const OWN_MERGE = new Set(['_ts', '_rev', '_wid', '_wids', '_unstamped', '_prior', 'active', 'unit', 'unitSet', 'resetAt', 'resetIds', 'deleted', 'edited', 'undone', 'routineOrder','workouts', 'routines', 'customEx', 'equipProfiles', 'gymCards', 'bodyweight', 'measurements', 'favEx',- 'exWeights', 'balanceOverrides', 'loadKind', 'plates',+ 'exWeights', 'balanceOverrides', 'loadKind', 'plates', 'dayNotes',])// Stamped per key instead of whole: one day of the plan, one exercise's note or bar.const PER_KEY = new Set(['week', 'dayPlan', 'exNotes', 'barWeights'])@@ -844,7 +849,7 @@ export function mergeStates(a0, b0, { prefer } = {}) {// The plate-loading choices (lib/plates.js) are stamped the same way: an exercise's loading and// a unit's plate inventory are each one choice, made on one device, that a later set logged on// the other must not undo.- for (const f of ['balanceOverrides', 'loadKind', 'plates']) {+ for (const f of STAMPED_MAPS) {if (n[f] || o[f]) out[f] = clone(mergeStampedMap(n[f], o[f], prefer))}// Each stamped setting and plan day from the copy that changed it last (the `edited` section@@ -967,7 +972,7 @@ export function stampReplace(next, others = [], now = Date.now()) {x._ts = Math.max(Number(x._ts) || 0, now)}}- for (const f of ['balanceOverrides', 'loadKind', 'plates']) {+ for (const f of STAMPED_MAPS) {if (!isMap(next[f])) continuefor (const [k, v] of Object.entries(next[f])) {if (!isMap(v)) continue@@ -1003,7 +1008,7 @@ export function highestStamp(S) {if (isMap(x._f)) for (const v of Object.values(x._f)) see(v)}}- for (const f of ['balanceOverrides', 'loadKind', 'plates']) if (isMap(S[f])) for (const v of Object.values(S[f])) see(stampOf(v))+ for (const f of STAMPED_MAPS) if (isMap(S[f])) for (const v of Object.values(S[f])) see(stampOf(v))for (const e of [...list(S.bodyweight), ...list(S.measurements)]) if (e && typeof e === 'object') see(e.t)return m}@@ -1025,7 +1030,7 @@ export function stampChange(prev, next, wall = Date.now()) {}// Settings maps whose entries carry their own stamp (mergeStampedMap): an entry the change// re-stamped takes the change's time.- for (const f of ['balanceOverrides', 'loadKind', 'plates']) {+ for (const f of STAMPED_MAPS) {const p = isMap(prev?.[f]) ? prev[f] : {}, n = isMap(next[f]) ? next[f] : nullif (!n) continuefor (const [k, v] of Object.entries(n)) if (isMap(v) && v._ts != null && stampOf(v) !== stampOf(p[k])) v._ts = now@@ -1121,6 +1126,7 @@ export function localExtras(local, server) {const measured = new Set(list(server?.measurements).map(e => e?.d))const setup = ['gymCards', 'equipProfiles'].reduce((n, f) => n + list(local?.[f]).filter(x => x && x.id != null && !ids(f).has(x.id)).length, 0) +list(local?.measurements).filter(e => e && e.d != null && !measured.has(e.d)).length ++ Object.entries(isMap(local?.dayNotes) ? local.dayNotes : {}).filter(([k, v]) => readNote(v) && !readNote(server?.dayNotes?.[k])).length +keysNew('week') + keysNew('dayPlan') + keysNew('exNotes')return {workouts: list(local?.workouts).filter(w => !have.has(workoutKey(w))).length,diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex 7b002676a..8006d220f 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -2213,4 +2213,15 @@ export default {// --- search: similar exercises ---'Similar exercises': 'تمارين مشابهة','No exact match. These come close:': 'لا تطابق تام. هذه قريبة:',+ // --- day notes (#261) ---+ 'Sick': 'مريض',+ 'Travelling': 'مسافر',+ 'Injured': 'مصاب',+ 'Day note': 'ملاحظة اليوم',+ 'Add a note for this day': 'أضف ملاحظة لهذا اليوم',+ 'Noted. See you next session!': 'تم التسجيل. نراك في الحصة القادمة!',+ 'Note removed': 'تمت إزالة الملاحظة',+ 'Remove note': 'إزالة الملاحظة',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'الحياة تحدث. اترك لنفسك ملاحظة، وسيترك تذكير الأيام الفائتة هذا اليوم وشأنه.',+ 'Anything else? (optional)': 'أي شيء آخر؟ (اختياري)',}diff --git a/frontend/src/locales/bn.js b/frontend/src/locales/bn.jsindex 39745f383..acb212c24 100644--- a/frontend/src/locales/bn.js+++ b/frontend/src/locales/bn.js@@ -2237,4 +2237,15 @@ export default {// --- search: similar exercises ---'Similar exercises': 'একই ধরনের ব্যায়াম','No exact match. These come close:': 'হুবহু মিল নেই। এগুলো কাছাকাছি:',+ // --- day notes (#261) ---+ 'Sick': 'অসুস্থ',+ 'Travelling': 'ভ্রমণে',+ 'Injured': 'আহত',+ 'Day note': 'দিনের নোট',+ 'Add a note for this day': 'এই দিনের জন্য একটি নোট যোগ করুন',+ 'Noted. See you next session!': 'নোট হলো। পরের সেশনে দেখা হবে!',+ 'Note removed': 'নোট সরানো হয়েছে',+ 'Remove note': 'নোট সরান',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'জীবনে এমন হয়। নিজের জন্য একটি নোট রাখুন, আর মিস করা দিনের রিমাইন্ডার এই দিনটিকে ছেড়ে দেবে।',+ 'Anything else? (optional)': 'আর কিছু? (ঐচ্ছিক)',}diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex a54996bf8..eda15e5da 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -2178,4 +2178,15 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Ähnliche Übungen','No exact match. These come close:': 'Kein genauer Treffer. Die hier kommen nah ran:',+ // --- day notes (#261) ---+ 'Sick': 'Krank',+ 'Travelling': 'Unterwegs',+ 'Injured': 'Verletzt',+ 'Day note': 'Tagesnotiz',+ 'Add a note for this day': 'Notiz für diesen Tag',+ 'Noted. See you next session!': 'Notiert. Bis zum nächsten Training!',+ 'Note removed': 'Notiz entfernt',+ 'Remove note': 'Notiz entfernen',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'Das Leben passiert. Hinterlass dir eine Notiz, und die Erinnerung an verpasste Tage lässt diesen hier in Ruhe.',+ 'Anything else? (optional)': 'Sonst noch was? (optional)',}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex fbfa422c9..ef22a5bee 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -2158,4 +2158,15 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Ejercicios parecidos','No exact match. These come close:': 'Nada exacto. Estos se acercan:',+ // --- day notes (#261) ---+ 'Sick': 'Enfermo',+ 'Travelling': 'De viaje',+ 'Injured': 'Lesionado',+ 'Day note': 'Nota del día',+ 'Add a note for this day': 'Añadir una nota a este día',+ 'Noted. See you next session!': 'Anotado. ¡Nos vemos en la próxima sesión!',+ 'Note removed': 'Nota eliminada',+ 'Remove note': 'Eliminar nota',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'La vida pasa. Déjate una nota y el aviso de días perdidos dejará este en paz.',+ 'Anything else? (optional)': '¿Algo más? (opcional)',}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 6dd9b5430..5302677ff 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -2158,4 +2158,15 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Exercices similaires','No exact match. These come close:': 'Rien d’exact. Ceux-ci s’en approchent :',+ // --- day notes (#261) ---+ 'Sick': 'Malade',+ 'Travelling': 'En voyage',+ 'Injured': 'Blessé',+ 'Day note': 'Note du jour',+ 'Add a note for this day': 'Ajouter une note pour ce jour',+ 'Noted. See you next session!': 'C’est noté. À la prochaine séance !',+ 'Note removed': 'Note supprimée',+ 'Remove note': 'Supprimer la note',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'La vie, ça arrive. Laisse-toi une note, et le rappel des jours manqués laissera celui-ci tranquille.',+ 'Anything else? (optional)': 'Autre chose ? (facultatif)',}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex 57b07f370..c7e6cdfcb 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -2158,4 +2158,15 @@ export default {// --- search: similar exercises ---'Similar exercises': 'मिलते-जुलते व्यायाम','No exact match. These come close:': 'सटीक मेल नहीं मिला। ये करीब हैं:',+ // --- day notes (#261) ---+ 'Sick': 'बीमार',+ 'Travelling': 'सफ़र में',+ 'Injured': 'चोटिल',+ 'Day note': 'दिन का नोट',+ 'Add a note for this day': 'इस दिन के लिए नोट जोड़ें',+ 'Noted. See you next session!': 'नोट हो गया। अगले सेशन में मिलते हैं!',+ 'Note removed': 'नोट हटाया गया',+ 'Remove note': 'नोट हटाएँ',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'ज़िंदगी है, होता है। अपने लिए एक नोट छोड़ दें, और छूटे दिन की याद दिलाने वाला इस दिन को छोड़ देगा।',+ 'Anything else? (optional)': 'और कुछ? (वैकल्पिक)',}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex a496dfb81..efe05c06f 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -2161,4 +2161,15 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Hasonló gyakorlatok','No exact match. These come close:': 'Nincs pontos találat. Ezek közel állnak:',+ // --- day notes (#261) ---+ 'Sick': 'Beteg',+ 'Travelling': 'Úton',+ 'Injured': 'Sérült',+ 'Day note': 'Napi jegyzet',+ 'Add a note for this day': 'Jegyzet ehhez a naphoz',+ 'Noted. See you next session!': 'Feljegyezve. Találkozunk a következő edzésen!',+ 'Note removed': 'Jegyzet törölve',+ 'Remove note': 'Jegyzet törlése',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'Az élet közbeszól. Hagyj magadnak egy jegyzetet, és a kihagyott napok emlékeztetője ezt a napot békén hagyja.',+ 'Anything else? (optional)': 'Még valami? (nem kötelező)',}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 8c3d96f6f..24f25bb34 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -2158,4 +2158,15 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Esercizi simili','No exact match. These come close:': 'Niente di esatto. Questi ci vanno vicino:',+ // --- day notes (#261) ---+ 'Sick': 'Malato',+ 'Travelling': 'In viaggio',+ 'Injured': 'Infortunato',+ 'Day note': 'Nota del giorno',+ 'Add a note for this day': 'Aggiungi una nota per questo giorno',+ 'Noted. See you next session!': 'Annotato. Alla prossima sessione!',+ 'Note removed': 'Nota rimossa',+ 'Remove note': 'Rimuovi nota',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'Capita. Lasciati una nota e il promemoria dei giorni saltati lascerà stare questo.',+ 'Anything else? (optional)': 'Altro? (facoltativo)',}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex c906b2b53..fba6262cf 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -2158,4 +2158,15 @@ export default {// --- search: similar exercises ---'Similar exercises': '비슷한 운동','No exact match. These come close:': '정확히 일치하는 항목이 없어요. 이건 비슷해요:',+ // --- day notes (#261) ---+ 'Sick': '아픔',+ 'Travelling': '여행 중',+ 'Injured': '부상',+ 'Day note': '하루 메모',+ 'Add a note for this day': '이 날에 메모 추가',+ 'Noted. See you next session!': '기록했어요. 다음 세션에서 만나요!',+ 'Note removed': '메모를 삭제했어요',+ 'Remove note': '메모 삭제',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': '그런 날도 있죠. 메모를 남겨 두면 놓친 날 알림이 이 날은 그냥 넘어가요.',+ 'Anything else? (optional)': '더 남길 말이 있나요? (선택)',}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex 0525f3041..3a84389db 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -2158,4 +2158,15 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Podobne ćwiczenia','No exact match. These come close:': 'Brak dokładnego dopasowania. Te są blisko:',+ // --- day notes (#261) ---+ 'Sick': 'Choroba',+ 'Travelling': 'W podróży',+ 'Injured': 'Kontuzja',+ 'Day note': 'Notatka dnia',+ 'Add a note for this day': 'Dodaj notatkę do tego dnia',+ 'Noted. See you next session!': 'Zapisane. Do następnego treningu!',+ 'Note removed': 'Notatka usunięta',+ 'Remove note': 'Usuń notatkę',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'Życie się zdarza. Zostaw sobie notatkę, a przypomnienie o pominiętych dniach odpuści ten dzień.',+ 'Anything else? (optional)': 'Coś jeszcze? (opcjonalnie)',}diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 9f283b0d1..a91da25bf 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -1331,6 +1331,17 @@ export const PT_BR_OVERRIDES = {'Where an exercise is drawn on both figures. Your workouts stay exactly as they are.': 'Que figura mostra um exercício quando está desenhado nas duas. Seus treinos ficam exatamente como estão.','Enter the address of the server this token is for': 'Informe o endereço do servidor a que este token pertence','No exact match. These come close:': 'Nada exato. Estes chegam perto:',+ // --- day notes (#261) ---+ 'Sick': 'Doente',+ 'Travelling': 'Viajando',+ 'Injured': 'Machucado',+ 'Day note': 'Nota do dia',+ 'Add a note for this day': 'Adicionar uma anotação a este dia',+ 'Noted. See you next session!': 'Anotado. Até a próxima sessão!',+ 'Note removed': 'Anotação removida',+ 'Remove note': 'Remover anotação',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'A vida acontece. Deixe uma anotação e o lembrete de dias perdidos deixa este em paz.',+ 'Anything else? (optional)': 'Mais alguma coisa? (opcional)',}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 31486ba97..9922f160b 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -2158,4 +2158,15 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Exercícios semelhantes','No exact match. These come close:': 'Nada exato. Estes andam perto:',+ // --- day notes (#261) ---+ 'Sick': 'Doente',+ 'Travelling': 'Em viagem',+ 'Injured': 'Lesionado',+ 'Day note': 'Nota do dia',+ 'Add a note for this day': 'Adicionar uma nota a este dia',+ 'Noted. See you next session!': 'Anotado. Até à próxima sessão!',+ 'Note removed': 'Nota removida',+ 'Remove note': 'Remover nota',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'A vida acontece. Deixa-te uma nota e o lembrete de dias falhados deixa este em paz.',+ 'Anything else? (optional)': 'Mais alguma coisa? (opcional)',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 9bbf9caa1..0ee130f92 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -2162,4 +2162,15 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Похожие упражнения','No exact match. These come close:': 'Точного совпадения нет. Вот что близко:',+ // --- day notes (#261) ---+ 'Sick': 'Болею',+ 'Travelling': 'В поездке',+ 'Injured': 'Травма',+ 'Day note': 'Заметка дня',+ 'Add a note for this day': 'Добавить заметку к этому дню',+ 'Noted. See you next session!': 'Записано. До следующей тренировки!',+ 'Note removed': 'Заметка удалена',+ 'Remove note': 'Удалить заметку',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'Всякое бывает. Оставьте себе заметку, и напоминание о пропущенных днях оставит этот день в покое.',+ 'Anything else? (optional)': 'Что-нибудь ещё? (необязательно)',}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 475397099..ef31937ff 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -2169,4 +2169,15 @@ export default {// --- search: similar exercises ---'Similar exercises': 'ท่าที่คล้ายกัน','No exact match. These come close:': 'ไม่พบที่ตรงทั้งหมด ท่าเหล่านี้ใกล้เคียง:',+ // --- day notes (#261) ---+ 'Sick': 'ป่วย',+ 'Travelling': 'เดินทาง',+ 'Injured': 'บาดเจ็บ',+ 'Day note': 'บันทึกประจำวัน',+ 'Add a note for this day': 'เพิ่มบันทึกสำหรับวันนี้',+ 'Noted. See you next session!': 'จดไว้แล้ว เจอกันเซสชันหน้า!',+ 'Note removed': 'ลบบันทึกแล้ว',+ 'Remove note': 'ลบบันทึก',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'ชีวิตก็แบบนี้ ทิ้งบันทึกไว้ให้ตัวเอง แล้วการเตือนวันที่พลาดจะปล่อยวันนี้ไป',+ 'Anything else? (optional)': 'มีอะไรอีกไหม (ไม่บังคับ)',}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex edf569226..b097beaee 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -2158,4 +2158,15 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Benzer egzersizler','No exact match. These come close:': 'Tam eşleşme yok. Bunlar yakın:',+ // --- day notes (#261) ---+ 'Sick': 'Hasta',+ 'Travelling': 'Seyahatte',+ 'Injured': 'Sakat',+ 'Day note': 'Gün notu',+ 'Add a note for this day': 'Bu güne not ekle',+ 'Noted. See you next session!': 'Not edildi. Bir sonraki antrenmanda görüşürüz!',+ 'Note removed': 'Not silindi',+ 'Remove note': 'Notu sil',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'Hayat bu. Kendine bir not bırak, kaçırılan gün hatırlatıcısı bu günü rahat bıraksın.',+ 'Anything else? (optional)': 'Başka bir şey? (isteğe bağlı)',}diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex fad71d4f9..dc5222054 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -2155,4 +2155,15 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Схожі вправи','No exact match. These come close:': 'Точного збігу немає. Ось що близько:',+ // --- day notes (#261) ---+ 'Sick': 'Хворію',+ 'Travelling': 'У подорожі',+ 'Injured': 'Травма',+ 'Day note': 'Нотатка дня',+ 'Add a note for this day': 'Додати нотатку до цього дня',+ 'Noted. See you next session!': 'Записано. До наступного тренування!',+ 'Note removed': 'Нотатку видалено',+ 'Remove note': 'Видалити нотатку',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': 'Всяке буває. Залиште собі нотатку, і нагадування про пропущені дні дасть цьому дню спокій.',+ 'Anything else? (optional)': 'Щось іще? (необов’язково)',}diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.jsindex ad7411e1d..bccd87dff 100644--- a/frontend/src/locales/zh-TW.js+++ b/frontend/src/locales/zh-TW.js@@ -2151,4 +2151,15 @@ export default {// --- search: similar exercises ---'Similar exercises': '相似動作','No exact match. These come close:': '沒有完全符合,這些比較接近:',+ // --- day notes (#261) ---+ 'Sick': '生病',+ 'Travelling': '旅行中',+ 'Injured': '受傷',+ 'Day note': '當日備註',+ 'Add a note for this day': '為這一天新增備註',+ 'Noted. See you next session!': '記下了,下次訓練見!',+ 'Note removed': '備註已刪除',+ 'Remove note': '刪除備註',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': '生活總有意外。給自己留個備註,錯過訓練的提醒就會放過這一天。',+ 'Anything else? (optional)': '還有別的嗎?(選填)',}diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex c7b7277d9..b8cb04486 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -2158,4 +2158,15 @@ export default {// --- search: similar exercises ---'Similar exercises': '相似动作','No exact match. These come close:': '没有完全匹配,这些比较接近:',+ // --- day notes (#261) ---+ 'Sick': '生病',+ 'Travelling': '出行',+ 'Injured': '受伤',+ 'Day note': '当日备注',+ 'Add a note for this day': '为这一天添加备注',+ 'Noted. See you next session!': '记下了,下次训练见!',+ 'Note removed': '备注已删除',+ 'Remove note': '删除备注',+ 'Life happens. Leave yourself a note, and the missed-day nudge lets this one go.': '生活总有意外。给自己留个备注,错过训练的提醒就会放过这一天。',+ 'Anything else? (optional)': '还有别的吗?(可选)',}diff --git a/frontend/src/sheets.day-note.test.jsx b/frontend/src/sheets.day-note.test.jsxnew file mode 100644index 000000000..01642177f--- /dev/null+++ b/frontend/src/sheets.day-note.test.jsx@@ -0,0 +1,175 @@+// @vitest-environment happy-dom+// #261: "I want to write a note why I missed today, and see it in the heatmap." The day sheet+// offers a note on today and past days with nothing logged, the note sheet saves a quick pick+// and a line of text (or takes it away), and the calendar, heatmap, week strip and History show it.+import React, { act } from 'react'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { createRoot } from 'react-dom/client'+import { MemoryRouter } from 'react-router-dom'+import { DEF, useStore } from './store/useStore.js'+import { useUI } from './store/useUI.js'+import { dayOverrideSheet, dayNoteSheet, calendarSheet } from './sheets.jsx'+import Heatmap from './components/Heatmap.jsx'+import History, { historyRows } from './views/History.jsx'+import { withDayNote, dayNoteOf } from './lib/day-notes.js'++const clone = v => JSON.parse(JSON.stringify(v))+const S = () => useStore.getState().S+const mounted = []++function mount(el) {+ const host = document.createElement('div')+ document.body.appendChild(host)+ const root = createRoot(host)+ mounted.push(root)+ act(() => root.render(el))+ return host+}+const mountTopSheet = () => {+ const sheet = useUI.getState().sheets.at(-1)+ return mount(sheet.render(() => useUI.getState().closeSheet(sheet.id)))+}+const button = (host, text) => [...host.querySelectorAll('button')].find(b => b.textContent.trim() === text)+const type = (el, value) => {+ Object.getOwnPropertyDescriptor(el.constructor.prototype, 'value').set.call(el, value)+ el.dispatchEvent(new Event('input', { bubbles: true }))+}++function install(extra = {}) {+ const st = clone(DEF)+ Object.assign(st, {+ routines: [{ id: 'A', name: 'Push', emoji: 'dumbbell', ex: [] }],+ week: { 1: ['A'], 5: ['A'] }, dayPlan: {}, active: null, workouts: [], weighIn: false,+ }, extra)+ useStore.setState({ S: st, user: null })+}++beforeEach(() => {+ // Wednesday 16 September 2026, midday.+ vi.useFakeTimers({ toFake: ['Date'] })+ vi.setSystemTime(new Date('2026-09-16T12:00:00'))+ globalThis.IS_REACT_ACT_ENVIRONMENT = true+ localStorage.clear()+ useUI.setState({ sheets: [], toasts: [] })+ document.body.innerHTML = ''+ install()+})+afterEach(() => {+ act(() => { mounted.splice(0).forEach(root => root.unmount()) })+ vi.useRealTimers()+})++describe('the day sheet offers a note', () => {+ const offered = iso => {+ useUI.setState({ sheets: [] })+ dayOverrideSheet(iso)+ return mountTopSheet().textContent.includes('Add a note for this day')+ }+ it('on today and past days with nothing logged, never on a future day or a trained one', () => {+ expect(offered('2026-09-14')).toBe(true) // Monday, missed+ expect(offered('2026-09-15')).toBe(true) // Tuesday, a rest day: any day can say why+ expect(offered('2026-09-16')).toBe(true) // today+ expect(offered('2026-09-18')).toBe(false) // Friday, still to come+ install({ workouts: [{ id: 'w', d: '2026-09-14', start: 1, end: 2, name: 'Push', entries: [], prs: [] }] })+ expect(offered('2026-09-14')).toBe(false)+ })++ it('shows a note that is there, and opens it for editing', () => {+ install({ dayNotes: withDayNote({}, '2026-09-14', { tag: 'sick', text: 'Flu' }, 5) })+ dayOverrideSheet('2026-09-14')+ const host = mountTopSheet()+ expect(host.textContent).toContain('Sick')+ expect(host.textContent).toContain('Flu')+ expect(host.textContent).not.toContain('Add a note for this day')+ act(() => { host.querySelector('.day-note-row').click() })+ expect(useUI.getState().sheets).toHaveLength(2)+ const note = mountTopSheet()+ expect(note.querySelector('textarea').value).toBe('Flu')+ expect(button(note, 'Sick').getAttribute('aria-pressed')).toBe('true')+ })+})++describe('the note sheet', () => {+ it('saves a quick pick with a line of text, stamped, and excuses the day', () => {+ dayNoteSheet('2026-09-14')+ const host = mountTopSheet()+ act(() => { button(host, 'Travelling').click() })+ act(() => { type(host.querySelector('textarea'), ' Lisbon, back Thursday ') })+ act(() => { button(host, 'Save').click() })+ expect(dayNoteOf(S(), '2026-09-14')).toEqual({ tag: 'travel', text: 'Lisbon, back Thursday' })+ expect(S().dayNotes['2026-09-14']._ts).toBeGreaterThan(0)+ expect(useUI.getState().sheets).toHaveLength(0)+ })++ it('a second tap on a pick takes it off again; text alone is a note', () => {+ dayNoteSheet('2026-09-14')+ const host = mountTopSheet()+ act(() => { button(host, 'Sick').click() })+ act(() => { button(host, 'Sick').click() })+ act(() => { type(host.querySelector('textarea'), 'Wedding') })+ act(() => { button(host, 'Save').click() })+ expect(dayNoteOf(S(), '2026-09-14')).toEqual({ tag: null, text: 'Wedding' })+ })++ it('saving nothing on a day without a note writes nothing', () => {+ dayNoteSheet('2026-09-14')+ const host = mountTopSheet()+ act(() => { button(host, 'Save').click() })+ expect(S().dayNotes).toEqual({})+ })++ it('Remove takes the note away as a stamped clear, so the removal syncs', () => {+ install({ dayNotes: withDayNote({}, '2026-09-14', { tag: 'injured' }, 5) })+ dayNoteSheet('2026-09-14')+ const host = mountTopSheet()+ act(() => { button(host, 'Remove note').click() })+ expect(dayNoteOf(S(), '2026-09-14')).toBeNull()+ expect(S().dayNotes['2026-09-14']._ts).toBeGreaterThan(5)+ })+})++describe('where a noted day shows', () => {+ const notes = withDayNote({}, '2026-09-14', { tag: 'sick', text: 'Flu' }, 5)++ it('the calendar marks it, with the note as its tooltip and a legend entry', () => {+ install({ dayNotes: notes })+ calendarSheet('2026-09-01')+ const host = mountTopSheet()+ const cell = [...host.querySelectorAll('.cal-d')].find(b => b.textContent === '14')+ expect(cell.className).toContain('noted')+ expect(cell.querySelector('i').className).toBe('noted')+ expect(cell.getAttribute('title')).toBe('Sick · Flu')+ expect(host.querySelector('.cal-legend').textContent).toContain('Day note')+ // a month without notes has no legend entry for them+ install()+ useUI.setState({ sheets: [] })+ calendarSheet('2026-09-01')+ expect(mountTopSheet().querySelector('.cal-legend').textContent).not.toContain('Day note')+ })++ it('the heatmap outlines it and lets you tap it', () => {+ install({ dayNotes: notes })+ const onDay = vi.fn()+ const host = mount(<Heatmap S={S()} onDay={onDay} />)+ const cell = [...host.querySelectorAll('.hm-c')].find(c => c.getAttribute('title')?.startsWith('2026-09-14'))+ expect(cell.className).toContain('noted')+ expect(cell.getAttribute('title')).toBe('2026-09-14 · Sick · Flu')+ act(() => { cell.click() })+ expect(onDay).toHaveBeenCalledWith('2026-09-14')+ })++ it('History lists it between the workouts, newest first; a trained day keeps only its workout', () => {+ const w = (id, d) => ({ id, d, start: Date.parse(d + 'T10:00:00'), end: Date.parse(d + 'T11:00:00'), name: 'Push', entries: [], prs: [] })+ install({+ workouts: [w('a', '2026-09-11'), w('b', '2026-09-15'), w('c', '2026-09-15')],+ dayNotes: { ...notes, ...withDayNote({}, '2026-09-15', { tag: 'rest' }, 6), '2026-09-12': { _ts: 7 } },+ })+ expect(historyRows(S()).map(r => r.w ? r.w.id : 'note ' + r.d)).toEqual(['c', 'b', 'note 2026-09-14', 'a'])+ const host = mount(<MemoryRouter><History /></MemoryRouter>)+ const row = host.querySelector('.day-note-row')+ expect(row.textContent).toContain('Sick')+ expect(row.textContent).toContain('Flu')+ act(() => { row.click() })+ expect(useUI.getState().sheets).toHaveLength(1)+ })+})diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsxindex 7c6846f22..6fc08f48d 100644--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@ -63,6 +63,7 @@ import { workoutText } from './lib/workout-text.js'import { workoutCardModel, layoutWorkoutCard, drawWorkoutCard, viewAspect, CARD_FONT } from './lib/workout-card.js'import { copyText } from './lib/clipboard.js'import { queueRemaining, pinState } from './lib/queue.js'+import { DAY_NOTE_TAGS, DAY_NOTE_LABEL, DAY_NOTE_ICON, dayNoteOf, dayNoteLine, canNoteDay, withDayNote } from './lib/day-notes.js'const S = () => useStore.getState().Sconst update = (...a) => useStore.getState().update(...a)@@ -2103,6 +2104,10 @@ function DayOverride({ iso, close }) {// that date with the day's routines picked, where the time and the duration can still change.const missed = iso < todayISO() && effIds.length > 0 && !workoutsOn(st, iso).lengthconst logIt = () => { close(); logPastWorkoutSheet({ iso, routineIds: effIds }) }+ // A note on a day off (#261, lib/day-notes.js): offered on today and past days with nothing+ // logged, kept in view on any day that already has one. Quiet on purpose: a row, not a button.+ const note = dayNoteOf(st, iso)+ const canNote = !!note || (canNoteDay(iso) && !workoutsOn(st, iso).length)// The coach week's sessions still to do come first, in slot order: picking one here pins it// to this day — the same per-date override, read back by queueNext (lib/queue.js). A session// already pinned to another day says so in place of its exercise count. Done sessions and@@ -2128,6 +2133,15 @@ function DayOverride({ iso, close }) {<h3>{fmtDate(iso, true)}</h3><div className="muted small" style={{ marginBottom: 12 }}>{t('Weekly plan:')} {weeklyNames.length ? deriveSessionName(weeklyNames) : t('Rest')}{changed && <span style={{ color: 'var(--orange)' }}> · {t('changed for this day')}</span>}<br />{t('Sick, missed a day or want a different session? Pick what to train instead.')}</div>{missed && <div style={{ marginBottom: 14 }}><Button variant="primary" icon="checkCircle" onClick={logIt}>{t('Log this workout')}</Button></div>}+ {canNote && <div className="day-note" style={{ marginBottom: 14 }}>+ <div className="item day-note-row" {...tappable(() => dayNoteSheet(iso))}>+ <span className="lrow-i" style={{ background: 'var(--surface-3)' }}><Icon name={note?.tag ? DAY_NOTE_ICON[note.tag] : 'note'} /></span>+ <div className="grow">{note+ ? <><div className="tt">{note.tag ? t(DAY_NOTE_LABEL[note.tag]) : t('Day note')}</div>{note.text && <div className="ss" style={{ whiteSpace: 'pre-wrap' }}>{note.text}</div>}</>+ : <div className="tt">{t('Add a note for this day')}</div>}</div>+ <Icon name={note ? 'pencil' : 'plus'} className="chev" />+ </div>+ </div>}{coach.length > 0 && <><h4 className="sec" style={{ marginTop: 0 }}>{ownLoop ? t('Your loop') : t('Coach week')}</h4><div className="list" style={{ marginBottom: 8 }}>{coach.map(row)}</div>@@ -2141,6 +2155,43 @@ function DayOverride({ iso, close }) {}export const dayOverrideSheet = iso => ui().openSheet(close => <DayOverride iso={iso} close={close} />)+// Why a day went without training (#261): one quick pick, a line of text, or both. Saving an+// empty note takes it away (a stamped clear, lib/day-notes.js withDayNote), and so does Remove.+function DayNote({ iso, close }) {+ const noteRef = useRef(null)+ const onNoteFocus = useSheetKeyboard(noteRef)+ const st = useStore(s => s.S)+ const had = dayNoteOf(st, iso)+ const [tag, setTag] = useState(had?.tag || null)+ const [text, setText] = useState(had?.text || '')+ const write = v => {+ update(s => { s.dayNotes = withDayNote(s.dayNotes, iso, v) })+ close()+ }+ const save = () => {+ const clean = text.trim().slice(0, NOTE_MAX)+ if (!tag && !clean && !had) { close(); return }+ write({ tag, text: clean })+ toast(tag || clean ? t('Noted. See you next session!') : t('Note removed'))+ }+ const remove = () => { write(null); toast(t('Note removed')) }+ return <>+ <h3>{fmtDate(iso, true)}</h3>+ <div className="muted small" style={{ marginBottom: 12 }}>{t('Life happens. Leave yourself a note, and the missed-day nudge lets this one go.')}</div>+ <div className="chips" style={{ margin: '0 0 12px' }}>+ {DAY_NOTE_TAGS.map(k => <button key={k} className={'chip nocap' + (tag === k ? ' on' : '')} aria-pressed={tag === k}+ onClick={() => setTag(tag === k ? null : k)}><Icon name={DAY_NOTE_ICON[k]} /> {t(DAY_NOTE_LABEL[k])}</button>)}+ </div>+ <textarea ref={noteRef} className="input" rows={3} maxLength={NOTE_MAX} value={text}+ placeholder={t('Anything else? (optional)')}+ onFocus={onNoteFocus} onChange={e => setText(e.target.value)} />+ <div style={{ height: 18 }} />+ <Button variant="primary" onClick={save}>{t('Save')}</Button>+ {had && <><div style={{ height: 10 }} /><Button variant="ghost" icon="trash" onClick={remove}>{t('Remove note')}</Button></>}+ </>+}+export const dayNoteSheet = iso => ui().openSheet(close => <DayNote iso={iso} close={close} />)+// Plan → Schedule → a weekday. One sheet for the whole day: tap routines to put them on it or// take them off (two or more make a combined day, docs/dev/COMBINE_ROUTINES.md), in the order// tapped, which is the order the session runs them; "Rest day" clears it. The sheet stays open@@ -2509,8 +2560,12 @@ function Calendar({ start, close }) {const iso = y + '-' + String(mo + 1).padStart(2, '0') + '-' + String(d).padStart(2, '0')// A fulfilled pin (a coach session pinned here and since done) reads as no override, as it does everywhere else.const ws = byDay[iso], planned = effectiveRoutineIds(st, iso).length > 0, ovr = st.dayPlan[iso] !== undefined && pinState(st, st.dayPlan[iso]) !== 'done'- const dotCls = ws ? 'done' : ovr && planned ? 'ovr' : planned ? 'plan' : ''- cells.push(<button key={d} className={'cal-d' + (ws ? ' has' : '') + (iso === todayISO() ? ' today' : '')} onClick={() => {+ // A day off with a note on it (#261) shows the note's dot instead of the plan's, and its+ // note as the tooltip; tapping it opens the day sheet, where the note is.+ const note = !ws && dayNoteOf(st, iso)+ const dotCls = ws ? 'done' : note ? 'noted' : ovr && planned ? 'ovr' : planned ? 'plan' : ''+ cells.push(<button key={d} className={'cal-d' + (ws ? ' has' : '') + (note ? ' noted' : '') + (iso === todayISO() ? ' today' : '')}+ title={note ? dayNoteLine(note, t) : undefined} onClick={() => {if (!ws) { close(); dayOverrideSheet(iso); return }if (ws.length === 1) { close(); workoutDetailSheet(ws[0]); return }close(); ui().openSheet(c2 => <><h3>{fmtDate(iso, true)}</h3><div className="list">{ws.map(w => <WorkoutRow key={w.id} w={w} onClick={() => { c2(); workoutDetailSheet(w) }} />)}</div></>)@@ -2528,6 +2583,8 @@ function Calendar({ start, close }) {<span><i style={{ background: 'var(--acc)' }} />{t('Trained')}</span><span><i style={{ background: 'var(--label-3)' }} />{t('Planned')}</span><span><i style={{ background: 'var(--orange)' }} />{t('Rescheduled')}</span>+ {Object.keys(st.dayNotes || {}).some(k => k.startsWith(y + '-' + String(mo + 1).padStart(2, '0')) && dayNoteOf(st, k)) &&+ <span><i style={{ background: 'var(--indigo)' }} />{t('Day note')}</span>}</div><div className="small dim" style={{ textAlign: 'center', marginTop: 10 }}>{t('Tap a trained day for details · tap any other day to plan a session')}</div></>@@ -2549,6 +2606,16 @@ export function WorkoutRow({ w, onClick }) {</div>}+/* a day off with a note (#261), as History lists it between the workouts */+export function DayNoteRow({ iso, note }) {+ return <div className="item day-note-row" {...tappable(() => dayNoteSheet(iso))}>+ <span className="lrow-i" style={{ width: 34, height: 34, borderRadius: 8, fontSize: 19, background: 'var(--surface-3)' }}><Icon name={note.tag ? DAY_NOTE_ICON[note.tag] : 'note'} /></span>+ <div className="grow"><div className="tt">{note.tag ? t(DAY_NOTE_LABEL[note.tag]) : t('Day note')}</div>+ <div className="ss">{[fmtDate(iso, true), note.text].filter(Boolean).join(' · ')}</div></div>+ <Icon name="chevronRight" className="chev" />+ </div>+}+/* ============================ workout lifecycle ============================ */// `routineIds` accepts `string | string[] | null` — `[r.id]` for one routine,// `effectiveRoutineIds(...)` for today's planned session, `[]` / null for explicit freestyle.diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.jsindex 0650de78a..a153eb381 100644--- a/frontend/src/store/useStore.js+++ b/frontend/src/store/useStore.js@@ -88,6 +88,9 @@ export const DEF = {unit: 'kg', restSec: 90, restPauseSec: 15, sound: true, soundOnSilent: false, vibrateOnSilent: false, timerFlash: false, timedSetOvertime: false, keepAwake: true, lang: 'en',theme: 'dark', accent: 'lime', body: 'male', targetW: null,bodyweight: [], routines: [], week: {}, dayPlan: {},+ // A note per day off (#261): { [iso]: { tag, text, _ts } } (lib/day-notes.js). A noted day is+ // excused from the missed-day nudge; each day merges on its own stamp (lib/sync-merge.js).+ dayNotes: {},// Body measurements (#82): one check-in per day, values in cm whatever the weight unit// (lib/measurements.js); merged across devices like weigh-ins (lib/sync-merge.js).measurements: [], measurementEnabled: null, customMeasurements: [],diff --git a/frontend/src/views/History.jsx b/frontend/src/views/History.jsxindex 3656cd542..ac0c8d232 100644--- a/frontend/src/views/History.jsx+++ b/frontend/src/views/History.jsx@@ -1,18 +1,32 @@import { useNavigate } from 'react-router-dom'import { useStore } from '../store/useStore.js'import { t, tn } from '../lib/i18n.js'-import { WorkoutRow, workoutDetailSheet, logPastWorkoutSheet } from '../sheets.jsx'+import { WorkoutRow, DayNoteRow, workoutDetailSheet, logPastWorkoutSheet } from '../sheets.jsx'import { Button } from '../components/ui.jsx'import Icon from '../components/Icon.jsx'+import { dayNoteOf } from '../lib/day-notes.js'++// Newest first: every workout, and in between them the days off you left a note on (#261). A+// note on a day that has a workout too stays in the day sheet; the workout speaks for that day.+export function historyRows(S) {+ const trained = new Set((S.workouts || []).map(w => w?.d))+ const notes = Object.keys(S.dayNotes || {}).filter(d => !trained.has(d)).map(d => ({ d, note: dayNoteOf(S, d) })).filter(x => x.note)+ const rows = [...(S.workouts || []).map(w => ({ d: w.d, w })), ...notes]+ // Stable, so workouts keep the order they are stored in (by day, then start) within a day.+ return rows.map((r, i) => [r, i]).sort((a, b) => (a[0].d < b[0].d ? 1 : a[0].d > b[0].d ? -1 : b[1] - a[1])).map(([r]) => r)+}export default function History() {const nav = useNavigate()const S = useStore(s => s.S)+ const rows = historyRows(S)return <><div className="hdr"><button className="iconbtn" onClick={() => nav('/stats')} aria-label={t('Stats')}><Icon name="chevronLeft" /></button><div style={{ flex: 1, marginInlineStart: 12 }}><h1>{t('History')}</h1><div className="sub">{tn('{0} workout', '{0} workouts', S.workouts.length)}</div></div></div><Button icon="plus" onClick={logPastWorkoutSheet} style={{ marginBottom: 12 }}>{t('Log a past workout')}</Button>- {S.workouts.length ? <div className="list">{[...S.workouts].reverse().map(w => <WorkoutRow key={w.id} w={w} onClick={() => workoutDetailSheet(w)} />)}</div>+ {rows.length ? <div className="list">{rows.map(r => r.w+ ? <WorkoutRow key={r.w.id} w={r.w} onClick={() => workoutDetailSheet(r.w)} />+ : <DayNoteRow key={'note-' + r.d} iso={r.d} note={r.note} />)}</div>: <div className="empty"><div className="ico"><Icon name="history" /></div>{t('No workouts yet. Your first one will land here.')}</div>}</>}diff --git a/frontend/src/views/Home.jsx b/frontend/src/views/Home.jsxindex 5eb143a3b..0ffeec0fa 100644--- a/frontend/src/views/Home.jsx+++ b/frontend/src/views/Home.jsx@@ -14,6 +14,7 @@ import { useConnectionTrouble } from '../components/SyncBanner.jsx'import { Button } from '../components/ui.jsx'import { tappable } from '../lib/use-sheet-keyboard.js'import { glyphOf } from '../lib/glyphs.js'+import { dayNoteOf } from '../lib/day-notes.js'// Home = what to do now + a quick glance. Deep charts & history live in Stats.export default function Home() {@@ -60,7 +61,8 @@ export default function Home() {const d = new Date(wkStart); d.setDate(wkStart.getDate() + i)const iso = isoOf(d)const eff = effectiveRoutineIds(S, iso).length > 0, ovr = S.dayPlan[iso] !== undefined, done = doneDays.has(iso)- const dot = done ? ' done' : ovr && eff ? ' ovr' : eff ? ' plan' : ''+ // A day off with a note (#261) reads as excused, not as a plan that went by.+ const dot = done ? ' done' : dayNoteOf(S, iso) ? ' noted' : ovr && eff ? ' ovr' : eff ? ' plan' : ''strip.push(<div key={i} className={'wday' + (iso === todayISO() ? ' today' : '')} {...tappable(() => dayOverrideSheet(iso))}><div className="lbl">{t(DAYS[d.getDay()])}</div><div className="num">{d.getDate()}</div><div className={'dot' + dot} /></div>)}diff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsxindex 8a83be88d..3504c1bbd 100644--- a/frontend/src/views/Stats.jsx+++ b/frontend/src/views/Stats.jsx@@ -6,7 +6,7 @@ import { lastBW, streakWeeks, setLabel, modeOf, effortOf, entriesForExercise, meimport { fmtNum, fmtDate, fmtVol, todayISO, isoOf, weekKey, weekStartOf, exerciseNameText } from '../lib/format.js'import { speedUnitOf, speedLabel, toSpeed } from '../lib/speed.js'import { t, exerciseNameFor, exerciseNameClass, getLang } from '../lib/i18n.js'-import { bwSheet, goalSheet, calendarSheet, workoutDetailSheet, exerciseHistorySheet, WorkoutRow, bwDeltaColor, weighInsSheet } from '../sheets.jsx'+import { bwSheet, goalSheet, calendarSheet, dayOverrideSheet, workoutDetailSheet, exerciseHistorySheet, WorkoutRow, bwDeltaColor, weighInsSheet } from '../sheets.jsx'import LineChart from '../components/LineChart.jsx'import Heatmap from '../components/Heatmap.jsx'import Icon from '../components/Icon.jsx'@@ -624,7 +624,7 @@ export default function Stats() {S={S}metric={S.heatmapMetric === 'vol' ? 'vol' : 'time'}onMetricChange={metric => useStore.getState().update(s => { s.heatmapMetric = metric })}- onDay={iso => { const ws = workouts.filter(w => workoutDay(w) === iso); if (ws.length === 1) workoutDetailSheet(ws[0]); else if (ws.length) calendarSheet(iso) }}+ onDay={iso => { const ws = workouts.filter(w => workoutDay(w) === iso); if (ws.length === 1) workoutDetailSheet(ws[0]); else if (ws.length) calendarSheet(iso); else dayOverrideSheet(iso) }}/></div>