notes and planned warm-ups
Three kinds of note, because they have three different lifetimes and users
asked for all three:
· a session note on an exercise — what happened today, stored on the workout
entry. It carries a PIN, and that is the whole design: only the person
writing knows whether "shoulder twinged" is a diary line or "go narrower"
is a message to their next self. A pinned note surfaces again the next time
that exercise comes up, where the "Last time" line already is; an unpinned
one stays in that day's history. This is deliberately not a global setting:
the answer differs per note, so a single switch would need constant
flipping, while at the moment of writing it is obvious.
· a standing note on the exercise itself (S.exNotes) — seat height, pin
position, a form cue. True every session, shown every session. This is
elchavalico's request, with ten messages of agreement behind it.
· a whole-session note on the workout, editable from its history entry, where
it is easier to say how a session went once you can see what you did.
A routine's own `note` (!14) stays where it is: it belongs to the plan, not to
the day or to the movement.
Planned warm-ups: `warmupSets` on an exercise config, stacked by buildSets
using the same ramp as the in-session button, so the session starts with them
already there instead of you adding them by hand every time. Written only when
non-zero, so an existing plan keeps its exact shape and reads back as 0. They
travel with a shared plan, and stay out of volume, records and progression via
the phase flag that already existed.
This commit is contained in:
1 parent
62b69ea88d
commit
37d6cf895a
5 files changed
+160
-6
No files matched your search
@@ -12,9 +12,19 @@ export function buildCompletedWorkout(active, { end = Date.now(), prs = [], snap
|
||||
if (snapshot && typeof snapshot === 'object' && !Array.isArray(snapshot) && Object.keys(snapshot).length) {
|
||||
completed.muscleSnapshot = { ...snapshot }
|
||||
}
|
||||
// What you typed about this exercise today, and whether you asked to see it again next
|
||||
// time. Written only when there is something to keep, so an untouched entry is byte-for-byte
|
||||
// the shape it always was.
|
||||
const note = (entry.note || '').trim()
|
||||
if (note) {
|
||||
completed.note = note
|
||||
if (entry.notePin) completed.notePin = true
|
||||
}
|
||||
return completed
|
||||
}).filter(entry => entry.sets.some(set => set.done))
|
||||
|
||||
const sessionNote = (active?.note || '').trim()
|
||||
|
||||
return {
|
||||
id: active.id,
|
||||
d: active.d,
|
||||
@@ -25,5 +35,6 @@ export function buildCompletedWorkout(active, { end = Date.now(), prs = [], snap
|
||||
bw: active.bw,
|
||||
entries,
|
||||
prs,
|
||||
...(sessionNote ? { note: sessionNote } : {}),
|
||||
}
|
||||
}
|
||||
@@ -36,3 +36,36 @@ describe('completed workout boundary', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// Notes written during a session have to survive it, or "write a note during your workout"
|
||||
// means "write a note and lose it when you tap Finish".
|
||||
describe('session notes', () => {
|
||||
const active = (entry) => ({
|
||||
id: 'w1', d: '2026-08-25', start: 1, routineId: 'r1', name: 'Push', bw: null,
|
||||
entries: [{ id: '0025', sets: [{ w: 100, r: 5, done: true }], ...entry }],
|
||||
})
|
||||
|
||||
it('keeps a per-exercise note and its pin', () => {
|
||||
const w = buildCompletedWorkout(active({ note: ' narrower grip next time ', notePin: true }))
|
||||
expect(w.entries[0].note).toBe('narrower grip next time')
|
||||
expect(w.entries[0].notePin).toBe(true)
|
||||
})
|
||||
|
||||
it('keeps an unpinned note without inventing a pin', () => {
|
||||
const w = buildCompletedWorkout(active({ note: 'shoulder twinged' }))
|
||||
expect(w.entries[0].note).toBe('shoulder twinged')
|
||||
expect('notePin' in w.entries[0]).toBe(false)
|
||||
})
|
||||
|
||||
it('writes no note fields at all when nothing was typed', () => {
|
||||
const w = buildCompletedWorkout(active({ note: ' ', notePin: true }))
|
||||
expect('note' in w.entries[0]).toBe(false)
|
||||
expect('notePin' in w.entries[0]).toBe(false)
|
||||
})
|
||||
|
||||
it('keeps a whole-session note on the workout', () => {
|
||||
const a = active({})
|
||||
expect(buildCompletedWorkout({ ...a, note: 'slept badly' }).note).toBe('slept badly')
|
||||
expect('note' in buildCompletedWorkout(a)).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -46,6 +46,7 @@ function cleanEx(e) {
|
||||
if (e.repsMax != null) o.repsMax = e.repsMax
|
||||
if (e.sg) o.sg = e.sg
|
||||
if (e.note) o.note = e.note
|
||||
if (e.warmupSets) o.warmupSets = e.warmupSets
|
||||
return o
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user