Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 42 additions & 8 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,12 @@ no rebuild. An older plan file may also carry `recommender`, `checkin`, `journal
of it, and every reader goes through it: `climbVolume` (Climbs per week, `climbLine`),
`lengthsIn`, `totalReps`, and the set logs' foot (`climbTotals`). The form says the rest
are "not described, so not counted". A read rule: nothing stored is rewritten, and a row
whose climbs are all described reads as it always did.
whose climbs are all described reads as it always did. The rule is per EXERCISE (#111):
once a climb in any of its sets is described, every set of it with the detail on counts
its described climbs (`anyTold`; callers pass the exercise's rows), or Add set's copied
count read as climbs ("2 described, Add set, 4 routes"). The starter's Bouldering and
Rock climbing exercises declare `addSets: false`: a day of routes is one list, and Add
route is its one door.
- **One climbing line everywhere** (#97): Today's row, "Last time you did this" and the Log
all say `climbLine` ("5 routes · hardest 5.10"), never "1 set". A card's typed "hardest"
field is left out of the form while the session has graded climbs on its ladder
Expand All @@ -704,17 +709,36 @@ no rebuild. An older plan file may also carry `recommender`, `checkin`, `journal
plus, on a planned entry that `isDone` and is dated on or before today, each plan lift
item that no logged row with a number stands for (by uid, else by exercise), as a row
in the runner's shape (holds as seconds, a circuit item once a round). So a run left
after one exercise, or one lift added by hand, covers only what it logged. On the plan's
after one exercise, or one lift added by hand, covers only what it logged. A BLANK
logged row that stands for an item (a circuit's counted exercise, `{ reps: '' }` a
round) is that item, read once, never a second exercise (#111). On the plan's
own day only the sets typed into count (a plan done by one set is not every target
lifted); from the next day on, every set with a number (done as written). Read, never
written. A row names its exercise by `key` (`liftKeyOf` also reads an older row's
`exercise`). A control that says "did this set as planned" must write `typed`: the sheet's
✓ does (`tickSet`, #79), and on a done plan's earlier day the ✓s are read, not toggled,
the way `liftsDone` reads it (`setTicked(s, asWritten)`).
- **Edited is not ticked** (#111). A number typed or stepped writes `typed` (the log,
D11); a ✓ writes `typed` AND `ticked`. The ✓ shows `ticked` (`setTicked`); a set only
edited (`setEdited`) reads as logged everywhere (`setLogged`, `liftsDone`, the Today row's
"k of n sets") and is drawn with an accent ring, and a tap on it TICKS it. Only a tap on a
ticked set takes the tick off, with both marks ("I did not do this one"). Before, the two
were one mark, so "+5, lift, tap ✓" un-logged the set. A set ticked before the mark
existed carries `typed` alone and reads as edited. Doing mode folds an exercise and moves
on by ticks only (`itemTicked`), so tuning every weight first finishes nothing. Every
copy that drops `typed` drops `ticked` (`unmarked`, `withFills`, `crossingSet`, the
server's `newPlanSet`); `keepTyped` keeps both.
- **What crosses to someone else's plan** is `crossingSet` (lib/shared.js, #111): never a
weight or a note, and a lift set the owner typed into or ticked crosses BLANK (it is the
owner's log, and as a target it read on their side as lifted the next day); an untouched
target crosses as written. The server's sync carries no lift numbers at all
(`freshItem`), which `sharedsync.test.js` pins.
- **What a lift's weight means is switched once per exercise** (#58; moved off the set
row in #93). On a card (lift log, planner editor, doing mode; web and phone) it is
one switch beside the implement (`ModeSwitch`, "on the bar ⇆"), and every flip shows
a toast with Undo (`modeFlip`); the runner keeps its 44px pill under the big weight.
a toast with Undo (`modeFlip`); the runner's is the same switch beside the implement
under the exercise's name (#111: it was a pill 6px under the big weight that flipped in
silence), and the big weight says only "lb".
In a set's cell the weight says only its unit (`weightUnit`: "lb"): the switch used
to be the cell's biggest target, and a tap aimed at 90 made it 90 per side. Switched
when the implement has more than one meaning: dumbbell and kettlebell "per hand" / "1 DB"
Expand All @@ -739,7 +763,11 @@ no rebuild. An older plan file may also carry `recommender`, `checkin`, `journal
the lift log (`addLift`, or picking its implement), a new exercise in the
editor (`appendLift`), each lift of a model's FIRST draft (`server/drafts.js`,
which reads the person's own log as the answer lands, `rememberedModes`;
`server/drafts.test.js` holds it to the app's rule).
`server/drafts.test.js` holds it to the app's rule). A lift the model names no
implement for gets one first, as a lift added by hand does (#111): the one it had
on a revision, else `defaultImplement` (`defaultImplementOf` and
`rememberedImplements` on the server, held to the app's by the same test; the
sheet's own revise path, `reviseWeightModes`, too).
- On a revision an exercise the model kept, on the same implement, keeps exactly
what it had, a deliberate default included; only one new in the revision gets
memory (`reviseWeightModes`; on a draft, `server/drafts.js`, so it is on the
Expand Down Expand Up @@ -781,11 +809,16 @@ no rebuild. An older plan file may also carry `recommender`, `checkin`, `journal
between the ±, its unit drawn inside it); in doing mode the ✓ is at the row's start,
where the set's number is when planning, never beside the weight's +. "Last time" is
in `dayWords` ("Fri, Nov 7") and, where this exercise has blank sets, a button that
fills them (`lastTimeFill`: blanks only, the weight only in the same meaning).
fills them (`lastTimeFill`: blanks only, the weight only in the same meaning; on a card
with nothing on it yet that is nobody else's, `grow` also adds the sets last time had
more of, so one tap rebuilds 3 × 10, #111). Last time is before the entry being shown
(`lastLift`, by lib/order.js `before`, the rule `priorSessions` uses), never a later day.
**Copy down** (`copyDownFills`) fills the empty sets under a set with its numbers,
from its own line at the row's right edge (16px clear of every stepper), with Undo
("Copied to 2 sets") that puts back only the sets still as it left them: anything
typed into or ticked since stays (`unfills`). The ✓ is 16px clear of the reps' −. Both are NUMBERS ONLY in one write
typed into or ticked since stays (`unfills`). The ✓ is 16px clear of the reps' −, and the
reps' + 8 from the weight's − (#111: at 2 they read as one strip); the number boxes gave
the width for it (40–42 wide, still 44 tall), so a set is still one row at 390. Copy down is NUMBERS ONLY in one write
(`withFills`): no set added or removed, so a synced workout's structure and the other
person's log are untouched, and a filled set is not `typed`: it is a target, lifted
(D10, D11) only once its ✓ is ticked. A new exercise starts on `defaultImplement`
Expand Down Expand Up @@ -1469,8 +1502,9 @@ pinned in `app/smoke/sheet.jsx` and `app/smoke/editor.jsx`:
- **Doing mode** (`PrescriptionEditor doing`): a planned workout on its day or after opens
on the first exercise with a set still to do (`firstUnticked`), and the next opens as it is
finished. Each card is the name, the implement as one small switch, last time, and per set
reps, weight and a ✓ (`SetTick`; it writes `typed`, so it is the log, D11, and touches a
plan for today, D10). A set with no number cannot be ticked (its ✓ goes to its first box),
reps, weight and a ✓ (`SetTick`; it writes `typed` and `ticked`, so it is the log, D11,
and touches a plan for today, D10; an edited set is a ring a tap ticks, #111). A set with
no number cannot be ticked (its ✓ goes to its first box),
so a ✓ always means logged. A block note is stored when its box is left (`noteDraft`). A done plan's earlier day reads as done as written (`asWritten`). A
day still to come is still planning and gets the planner's editor.
- **Planning is one tap away, never above the sets.** A block's Circuit switch, where it
Expand Down
42 changes: 42 additions & 0 deletions app/editing.dom.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ globalThis.IS_REACT_ACT_ENVIRONMENT = true
const { act, useState } = await import('react')
const { createRoot } = await import('react-dom/client')
const { Modal, FullScreen, Popover, EDIT_SETTLE_MS } = await import('./src/modal.jsx')
const { NumInput } = await import('./src/numinput.jsx')
const { TimeInput, Stepper } = await import('./src/exercises.jsx')

const tests = []
const test = (name, fn) => tests.push([name, fn])
Expand Down Expand Up @@ -107,6 +109,46 @@ test('both layers: a box still focused after the change keeps the footer hidden'
await done()
})

test('#111 B F2: a tap on a number box selects it, so typing replaces the number (as the phone does)', async () => {
const host = document.createElement('div')
document.body.appendChild(host)
const root = createRoot(host)
let got = null
let focused = 0
function Boxes() {
const [v, setV] = useState(0)
got = v
return (
<>
<NumInput aria-label="rest" value={v} onChange={setV} onFocus={() => { focused += 1 }} />
<TimeInput aria-label="time" value={90} onChange={() => {}} />
<Stepper label="lb" value={95} step={5} onChange={() => {}} />
</>
)
}
await act(async () => root.render(<Boxes />))
for (const label of ['rest', 'time', 'lb']) {
const box = host.querySelector(`input[aria-label="${label}"]`)
await act(async () => { box.focus() })
await wait(5)
assert.equal(box.selectionStart, 0, `${label}: the caret is not at the start`)
assert.equal(box.selectionEnd, box.value.length, `${label}: "${box.value}" is not selected, so typing appends to it`)
}
assert.equal(focused, 1, 'the box\'s own onFocus no longer runs')
// "0", tapped, then 2: the box holds 2, not 20.
const rest = host.querySelector('input[aria-label="rest"]')
await act(async () => { rest.focus() })
await wait(5)
await act(async () => {
const v = rest.value.slice(0, rest.selectionStart) + '2' + rest.value.slice(rest.selectionEnd)
Object.getOwnPropertyDescriptor(win.HTMLInputElement.prototype, 'value').set.call(rest, v)
rest.dispatchEvent(new win.Event('input', { bubbles: true }))
})
assert.equal(got, 2, 'tapping 0 and typing 2 stored 20')
await act(() => root.unmount())
host.remove()
})

let failed = 0
for (const [name, fn] of tests) {
try { await fn(); console.log(` PASS ${name}`) } catch (e) { failed++; console.log(` FAIL ${name}\n ${e.message}`) }
Expand Down
54 changes: 53 additions & 1 deletion app/lifts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
weightModesFor, weightModeOf, weightLabelOf, weightPatch, nextWeightMode, rememberedWeightMode,
weightModeWords, liftFieldIn, weightBoxOf, liftMeasure, measureFor, muscleName, blankSet, canSwitchMeasure,
liftsDone, planLifts, liftedLine, implementChoices,
lastTimeFill, lastTimeWhen, withFills, copyDownFills, canCopyDown, unfills, cardKey, cardIdentity, rememberedImplement, defaultImplement, weightUnit, weightMeaning, pickerGroupFor,
lastTimeFill, fillLift, lastTimeWhen, withFills, copyDownFills, canCopyDown, unfills, cardKey, cardIdentity, rememberedImplement, defaultImplement, weightUnit, weightMeaning, pickerGroupFor,
} from './src/lib/lifts.js'
import { isRepeatable, extraEntryId } from './src/lib/store.js'
import { gateResolver, catalogOf as activityCatalog } from './src/lib/activities.js'
Expand Down Expand Up @@ -1106,5 +1106,57 @@ check('#93 copy down on a lift log row: the stored shape, nothing added', () =>
eq(out[0].sets.length, 3, 'a row was added or removed')
})

check('#111 D F2: a circuit\'s counted exercise is one exercise in what was lifted, not two', () => {
const blank = (n) => Array.from({ length: n }, () => ({ reps: '', weight: '' }))
const e = { id: 'c', kind: 'daily', date: '2026-11-07', data: { done: true, plan: { blocks: [{ name: 'C', circuit: { work: 30, rest: 10, rounds: 2 }, items: [
{ id: 'b0i0', uid: 'u0', kind: 'lift', name: 'Bench press', exercise: 'bench-press', sets: [{ id: 'b0i0s0', reps: 10 }] },
{ id: 'b0i1', uid: 'u1', kind: 'lift', name: 'Plank', exercise: 'plank', sets: [{ id: 'b0i1s0', seconds: 30 }] },
{ id: 'b0i2', uid: 'u2', kind: 'lift', name: 'Bent-over row', exercise: 'bent-over-row', sets: [{ id: 'b0i2s0', reps: 8 }] }] }] },
out: { lifts: [{ uid: 'b0i0', key: 'bench-press', name: 'Bench press', sets: blank(2) },
{ uid: 'b0i1', key: 'plank', name: 'Plank', sets: [{ seconds: 30, weight: '' }, { seconds: 30, weight: '' }] },
{ uid: 'b0i2', key: 'bent-over-row', name: 'Bent-over row', sets: blank(2) }] } } }
const rows = liftsDone(e, '2026-11-08')
eq(rows.map(r => r.key), ['bench-press', 'plank', 'bent-over-row'], 'a counted exercise was listed twice')
eq(rows.reduce((n, r) => n + r.sets.length, 0), 6, '3 exercises × 2 rounds is 6 sets')
eq(rows[0].sets[0].reps, 10, 'the plan\'s count is read, done as written, the next day')
// On its own day, untyped, the blank row is what there is: once, not dropped, not doubled.
const today = liftsDone({ ...e, date: '2026-11-08' }, '2026-11-08')
eq(today.filter(r => r.key === 'bench-press').length, 1)
})

check('#111 D F3: "last time" on an earlier day\'s sheet is never a later session', () => {
const lifted = (id, date, weight, extra = {}) => ({ id, kind: 'daily', date, ...extra, data: { done: true, out: { lifts: [{ uid: `${id}-1`, key: 'bent-over-row', name: 'Bent-over row', sets: [{ reps: 10, weight }] }] } } })
const entries = [lifted('nov8', '2026-11-08', 40), lifted('nov7', '2026-11-07', 90), lifted('nov5', '2026-11-05', 85)]
eq(lastLift(entries, 'bent-over-row', 'nov7', liftField, null, '2026-11-08').date, '2026-11-05', 'Nov 7 said last time was Nov 8')
eq(lastLift(entries, 'bent-over-row', 'nov8', liftField, null, '2026-11-08').date, '2026-11-07', 'today\'s last time is the newest before it')
eq(lastLift(entries, 'bent-over-row', null, liftField, null, '2026-11-08').date, '2026-11-08', 'no entry, no bound')
// The same day: the session that came first is the last time of the one after it, never the reverse.
const am = lifted('daily-2026-11-08', '2026-11-08', 50, {})
const pm = { ...lifted('daily-2026-11-08-planned', '2026-11-08', 60), data: { ...lifted('x', '2026-11-08', 60).data, slot: 'extra' } }
eq(lastLift([am, pm], 'bent-over-row', 'daily-2026-11-08', liftField, null, '2026-11-08'), null, 'the morning took the evening as its last time')
eq(lastLift([am, pm], 'bent-over-row', 'daily-2026-11-08-planned', liftField, null, '2026-11-08').date, '2026-11-08')
})

check('#111 C F2: "Use" on an untouched card rebuilds last time\'s sets, and only where it may add one', () => {
const prior = { date: '2026-11-01', row: { implement: 'barbell', sets: [{ reps: 10, weight: 95 }, { reps: 10, weight: 95 }, { reps: 8, weight: 100 }] } }
const card = (sets) => ({ kind: 'lift', implement: 'barbell', sets })
const blank = [{ id: 's0', reps: null, weight: null }]
eq(lastTimeFill(liftField, card(blank), prior).length, 1, 'without grow, a fill never adds a set (a synced workout)')
const fills = lastTimeFill(liftField, card(blank), prior, { grow: true })
eq(fills.map(f => [f.setId, Boolean(f.add), f.patch.reps, f.patch.weight]), [['s0', false, 10, 95], [null, true, 10, 95], [null, true, 8, 100]])
// Laid onto a plan's sets: three sets, the numbers as targets, no marks.
const sets = withFills([{ id: 's0', reps: null, weight: null, unit: null, note: '' }], fills)
eq(sets.map(x => [x.reps, x.weight, x.typed ?? null]), [[10, 95, null], [10, 95, null], [8, 100, null]])
eq(sets.slice(1).every(x => !('id' in x)), true, 'an added set took another set\'s id')
// Laid onto a logged row: three sets too.
const list = [{ uid: 'u1', key: 'back-squat', implement: 'barbell', sets: [{ reps: '', weight: '' }] }]
eq(fillLift(list, 'u1', fills.map((f, i) => (f.add ? f : { ...f, setId: String(i) })))[0].sets, [{ reps: 10, weight: 95 }, { reps: 10, weight: 95 }, { reps: 8, weight: 100 }])
// Anything already on the card: blanks only, no set added.
eq(lastTimeFill(liftField, card([{ id: 's0', reps: 12, weight: null }, { id: 's1', reps: null, weight: null }]), prior, { grow: true }).some(f => f.add), false)
eq(lastTimeFill(liftField, card([{ id: 's0', reps: null, weight: null, typed: true }]), prior, { grow: true }).some(f => f.add), false)
// As many sets as last time already: nothing to add.
eq(lastTimeFill(liftField, card([{ id: 'a' }, { id: 'b' }, { id: 'c' }].map(x => ({ ...x, reps: null, weight: null }))), prior, { grow: true }).some(f => f.add), false)
})

console.log(failed ? `\n${failed} lift/output test(s) failed` : '\nall lift and output tests pass')
process.exit(failed ? 1 : 0)
Loading
Loading