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(dumbbells): say whether a dumbbell weight is per bell or both together (#474)
Duarte Santos2a5146468027
diff --git a/api/sync-stamps.js b/api/sync-stamps.jsindex 291318589..40537ab6c 100644--- a/api/sync-stamps.js+++ b/api/sync-stamps.js@@ -64,7 +64,7 @@ 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', 'dbLoad',]);const PER_KEY = new Set(['week', 'dayPlan', 'exNotes', 'barWeights']);const ENTRY_META = new Set(['id', '_ts', '_f', '_u']);@@ -111,7 +111,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 ['balanceOverrides', 'loadKind', 'plates', 'dbLoad']) {if (isMap(S[f])) for (const v of Object.values(S[f])) see(isMap(v) ? v._ts : 0);}return m;diff --git a/frontend/src/lib/dumbbells.js b/frontend/src/lib/dumbbells.jsnew file mode 100644index 000000000..b18b0f44f--- /dev/null+++ b/frontend/src/lib/dumbbells.js@@ -0,0 +1,162 @@+// Dumbbells and kettlebells: what a logged weight means (issue #474).+//+// A dumbbell bench press logged at 20 kg can mean one 20 kg bell in each hand or two 10s. The+// app never asked, and everything that reads weights took the number at face value: volume is+// weight × reps, the 1RM is estimated from it, records and progression compare it as it stands.+// So the default, 'as', is exactly that and nothing more: "as entered", counted once, the way+// every set logged before this file existed was counted. Nothing in history is reinterpreted.+//+// An exercise can say what it means instead:+// 'each' — the weight of one bell. Volume counts both (× 2), unless the exercise is done one+// arm at a time (per side, or "one arm" / "single arm" in its name): then one bell+// is all there is, and it counts once.+// 'total' — both bells together. Counted once, as today; the label says so.+// The choice lives on the routine's exercise (cfg.dbLoad, routine-specific) or as the exercise's+// own default (S.dbLoad[exId] = { mode, _ts }, stamped like S.loadKind so a sync keeps the last+// choice). A session stamps the meaning it was logged with on the entry's target, so changing+// the setting later applies from then on and never rewrites what a past set meant.+//+// Records, the 1RM and progression compare like with like: a session logged as 'total' read by+// an exercise that is now 'each' is halved first (and the other way round). Sets logged as+// entered are never converted — nothing says which they meant — so they compare as they always+// did.+//+// Only lib/exercises.js is imported, so history.js, progression.js and plates.js can all use+// this file without a cycle.++import { EXIDX } from './exercises.js'++const exOf = exOrId => (typeof exOrId === 'string' ? EXIDX[exOrId] : exOrId)+const isMap = v => !!v && typeof v === 'object' && !Array.isArray(v)+const tidy = w => Math.round(w * 1000) / 1000++/** Equipment you hold one of in each hand. */+export const BELL_EQ = new Set(['dumbbell', 'kettlebell'])+/** Whether the meaning of the weight is worth asking about for this exercise (object or id). */+export const isBellEx = exOrId => BELL_EQ.has(exOf(exOrId)?.eq)++/** A stored meaning ('as' | 'each' | 'total'), or null when there is none. S.dbLoad holds `{ mode, _ts }`. */+export function dbLoadOf(value) {+ const m = isMap(value) ? value.mode : value+ return m === 'each' || m === 'total' || m === 'as' ? m : null+}++/**+ * What a weight means for this exercise right now: the routine's own choice (cfg.dbLoad), else+ * the exercise's default (S.dbLoad), else 'as' (as entered, today's behaviour).+ */+export function dbLoadFor(S, cfgOrId) {+ const cfg = typeof cfgOrId === 'string' ? { id: cfgOrId } : (cfgOrId || {})+ return dbLoadOf(cfg.dbLoad) || dbLoadOf(S?.dbLoad?.[cfg.id]) || 'as'+}++/**+ * S.dbLoad with the exercise's default set to `mode`. Going back to "as entered" is a stamped+ * null rather than a deleted key, so it wins a sync against the other device's older choice.+ */+export const withDbLoad = (map, exId, mode, now = Date.now()) =>+ ({ ...(isMap(map) ? map : {}), [exId]: { mode: mode === 'each' || mode === 'total' ? mode : null, _ts: now } })++// One arm at a time means one bell, whatever the setting says. "Alternating" curls still hold+// two, so only the words that say a single arm or hand count.+const ONE_ARM = /\b(one|single)[- ]?(arm|hand|handed)\b/i++/** Whether this exercise uses a single bell: logged per side, or named one-arm. */+export const isOneArm = cfg => !!cfg?.side || ONE_ARM.test(exOf(cfg?.id)?.n || '')+/** How many bells are lifted at once: 1 for one-arm work, else 2. */+export const bellsIn = cfg => (isOneArm(cfg) ? 1 : 2)++/**+ * A freestyle entry's target with the meaning it is logged in stamped on it, as buildPlannedEntry+ * stamps a planned one: `cfg` as it is when the exercise is "as entered".+ */+export function withMeaning(S, cfg, id = cfg?.id) {+ const m = dbLoadFor(S, { ...(cfg || {}), id })+ return m === 'as' ? { ...cfg } : { ...cfg, dbLoad: m }+}++/** The meaning a logged entry was saved with: its target's stamp, 'as' when it has none. */+export const entryDbLoad = entry => dbLoadOf(entry?.target?.dbLoad) || 'as'+const cfgOfEntry = entry => ({ ...(entry?.target || {}), id: entry?.id })++/** What one logged kilo of this entry is worth in volume: 2 for "each" on two bells, else 1. */+export const volumeFactor = entry =>+ (entryDbLoad(entry) === 'each' ? bellsIn(cfgOfEntry(entry)) : 1)++/**+ * The factor that turns a weight meant as `from` into the same load meant as `to`. Only the two+ * explicit meanings convert; "as entered" is taken at face value both ways, and a one-arm+ * exercise has one bell, so each and total are the same number there.+ */+export function meaningFactor(from, to, cfg) {+ if (from === to || from === 'as' || to === 'as' || !from || !to) return 1+ const n = bellsIn(cfg)+ if (n === 1) return 1+ return from === 'each' ? n : 1 / n+}++const scaleRow = (row, f) => {+ if (!isMap(row)) return row+ const out = { ...row }+ if (Number.isFinite(Number(row.w)) && row.w != null) out.w = tidy(Number(row.w) * f)+ if (Array.isArray(row.drops)) out.drops = row.drops.map(d => (isMap(d) ? { ...d, w: tidy((Number(d.w) || 0) * f) } : d))+ if (isMap(row.sides)) out.sides = Object.fromEntries(Object.entries(row.sides).map(([k, s]) => [k, scaleRow(s, f)]))+ return out+}++/**+ * The entry with its weights read as `to`: a scaled copy when the meanings differ (see+ * meaningFactor), the entry itself otherwise. For comparing, never for storing.+ */+export function entryAs(entry, to) {+ const from = entryDbLoad(entry)+ const f = meaningFactor(from, to, cfgOfEntry(entry))+ if (f === 1) return entry+ const out = { ...entry, target: { ...(entry.target || {}), dbLoad: to }, sets: (entry.sets || []).map(s => scaleRow(s, f)) }+ if (Number(entry.topW) > 0) out.topW = tidy(entry.topW * f)+ return out+}++/** A workout with every entry of `exId` read as `to` (entryAs); the workout itself when nothing changes. */+export function workoutAs(w, exId, to) {+ if (!to || to === 'as' || !Array.isArray(w?.entries)) return w+ let changed = false+ const entries = w.entries.map(e => {+ if (e?.id !== exId) return e+ const next = entryAs(e, to)+ if (next !== e) changed = true+ return next+ })+ return changed ? { ...w, entries } : w+}++/**+ * The state with one exercise's history read as `to`, for the readers that compare it: records,+ * the 1RM, the progression that builds today's rows. The state itself when nothing converts,+ * which is always the case for an exercise that never chose a meaning.+ */+export function historyAs(S, exId, to) {+ if (!S || !to || to === 'as' || !Array.isArray(S.workouts)) return S+ let changed = false+ const workouts = S.workouts.map(w => {+ const next = workoutAs(w, exId, to)+ if (next !== w) changed = true+ return next+ })+ return changed ? { ...S, workouts } : S+}++/**+ * The meaning an exercise's history is read in when no session is asking: the exercise's own+ * default, else the meaning it was last logged with, else 'as'.+ */+export function currentDbLoad(S, exId) {+ const own = dbLoadOf(S?.dbLoad?.[exId])+ if (own) return own+ const ws = Array.isArray(S?.workouts) ? S.workouts : []+ for (let i = ws.length - 1; i >= 0; i--) {+ const list = Array.isArray(ws[i]?.entries) ? ws[i].entries : []+ for (let j = list.length - 1; j >= 0; j--) if (list[j]?.id === exId && list[j]?.target?.dbLoad) return entryDbLoad(list[j])+ }+ return 'as'+}diff --git a/frontend/src/lib/dumbbells.test.js b/frontend/src/lib/dumbbells.test.jsnew file mode 100644index 000000000..59cd7bf16--- /dev/null+++ b/frontend/src/lib/dumbbells.test.js@@ -0,0 +1,235 @@+// What a dumbbell weight means (issue #474): as entered by default, counted once exactly as every+// set before the setting was; per bell (both bells counted, one-arm work once) or both together+// when an exercise says so; stamped on the session it was logged in; compared like with like.+import { describe, expect, it } from 'vitest'+import {+ dbLoadOf, dbLoadFor, withDbLoad, isBellEx, isOneArm, bellsIn, entryDbLoad, volumeFactor,+ meaningFactor, entryAs, historyAs, currentDbLoad, withMeaning,+} from './dumbbells.js'+import { workoutVolume, setLabel, bestWeightFor, freestyleConfig } from './history.js'+import { best1RM, is1RMRecord, e1rmSeries } from './onerm.js'+import { exerciseHistory, bestSetFor } from './exercise-history.js'+import { buildPlannedEntry } from './session-start.js'+import { mergeStates, stampChange } from './sync-merge.js'+import { buildPlanBundle, parsePlan } from './plan-share.js'+import { EXIDX } from './exercises.js'++const BENCH = '0289' // dumbbell bench press: two bells+const ROW = '0292' // dumbbell one arm bent-over row: one bell+const CURL = '0294' // dumbbell biceps curl+const KB = '0517' // a kettlebell exercise+const SQUAT = '0043' // barbell++const set = (w, r, extra = {}) => ({ w, r, done: true, ...extra })+const entry = (id, sets, target = {}) => ({ id, sets, target: { sets: sets.length, reps: 8, mode: 'reps', ...target } })+const workout = (d, entries, extra = {}) => ({ id: 'w' + d, d, start: new Date(d + 'T10:00:00').getTime(), entries, ...extra })+const state = (workouts = [], extra = {}) => ({ unit: 'kg', workouts, routines: [], exWeights: {}, ...extra })++describe('the exercises this file assumes', () => {+ it('are what the tests below need', () => {+ expect(EXIDX[BENCH].eq).toBe('dumbbell')+ expect(EXIDX[ROW].eq).toBe('dumbbell')+ expect(EXIDX[ROW].n).toMatch(/one arm/)+ expect(EXIDX[CURL].eq).toBe('dumbbell')+ expect(EXIDX[KB].eq).toBe('kettlebell')+ expect(EXIDX[SQUAT].eq).toBe('barbell')+ })+})++describe('the setting', () => {+ it('is offered for dumbbells and kettlebells only', () => {+ expect(isBellEx(BENCH)).toBe(true)+ expect(isBellEx(KB)).toBe(true)+ expect(isBellEx(SQUAT)).toBe(false)+ })++ it('reads as entered unless a routine slot or the exercise says otherwise', () => {+ expect(dbLoadFor(state(), BENCH)).toBe('as')+ const S = state([], { dbLoad: withDbLoad({}, BENCH, 'each', 5) })+ expect(S.dbLoad[BENCH]).toEqual({ mode: 'each', _ts: 5 })+ expect(dbLoadFor(S, BENCH)).toBe('each')+ // The routine's own choice wins over the exercise's default, an explicit "as entered" too.+ expect(dbLoadFor(S, { id: BENCH, dbLoad: 'total' })).toBe('total')+ expect(dbLoadFor(S, { id: BENCH, dbLoad: 'as' })).toBe('as')+ // Junk reads as nothing.+ expect(dbLoadOf('both')).toBe(null)+ expect(dbLoadFor({ dbLoad: { [BENCH]: { mode: 'x' } } }, BENCH)).toBe('as')+ })++ it('goes back to as entered as a stamped null, so it wins a sync', () => {+ const map = withDbLoad(withDbLoad({}, BENCH, 'each', 1), BENCH, 'as', 2)+ expect(map[BENCH]).toEqual({ mode: null, _ts: 2 })+ expect(dbLoadFor({ dbLoad: map }, BENCH)).toBe('as')+ })++ it('knows one-arm work holds one bell', () => {+ expect(isOneArm({ id: ROW })).toBe(true)+ expect(isOneArm({ id: BENCH })).toBe(false)+ expect(isOneArm({ id: CURL, side: true })).toBe(true)+ expect(bellsIn({ id: BENCH })).toBe(2)+ expect(bellsIn({ id: ROW })).toBe(1)+ })+})++describe('volume', () => {+ it('counts every set saved before the setting existed exactly as before', () => {+ const w = workout('2026-10-01', [entry(BENCH, [set(20, 10), set(20, 8)])])+ expect(entryDbLoad(w.entries[0])).toBe('as')+ expect(workoutVolume(w)).toBe(360)+ })++ it('counts both bells for a per-bell entry, once for both-together', () => {+ const each = workout('2026-10-01', [entry(BENCH, [set(20, 10)], { dbLoad: 'each' })])+ const total = workout('2026-10-01', [entry(BENCH, [set(40, 10)], { dbLoad: 'total' })])+ expect(volumeFactor(each.entries[0])).toBe(2)+ expect(workoutVolume(each)).toBe(400)+ expect(workoutVolume(total)).toBe(400)+ })++ it('counts a one-arm exercise once, per bell or not', () => {+ const row = workout('2026-10-01', [entry(ROW, [set(30, 10)], { dbLoad: 'each' })])+ expect(workoutVolume(row)).toBe(300)+ })++ it('doubles the drops of a per-bell drop-set too, and leaves warm-ups out', () => {+ const w = workout('2026-10-01', [entry(BENCH, [+ set(10, 10, { phase: 'warmup', warmup: true }),+ set(20, 8, { type: 'dropset', drops: [{ w: 16, r: 5 }] }),+ ], { dbLoad: 'each' })])+ expect(workoutVolume(w)).toBe((20 * 8 + 16 * 5) * 2)+ })++ it('reaches the exercise history sheet', () => {+ const S = state([workout('2026-10-01', [entry(BENCH, [set(20, 10)], { dbLoad: 'each' })])])+ expect(exerciseHistory(S, BENCH).sessions[0].volume).toBe(400)+ })+})++describe('the set label', () => {+ it('says what the number means when the exercise said', () => {+ expect(setLabel(BENCH, set(20, 8), { id: BENCH, mode: 'reps', dbLoad: 'each' })).toBe('20 each × 8')+ expect(setLabel(BENCH, set(40, 8), { id: BENCH, mode: 'reps', dbLoad: 'total' })).toBe('40 total × 8')+ })++ it('reads as always as entered, and for one-arm work', () => {+ expect(setLabel(BENCH, set(20, 8), { id: BENCH, mode: 'reps' })).toBe('20×8')+ expect(setLabel(ROW, set(30, 8), { id: ROW, mode: 'reps', dbLoad: 'each' })).toBe('30×8')+ })+})++describe('like with like', () => {+ it('converts only between the two explicit meanings', () => {+ expect(meaningFactor('total', 'each', { id: BENCH })).toBe(0.5)+ expect(meaningFactor('each', 'total', { id: BENCH })).toBe(2)+ expect(meaningFactor('as', 'each', { id: BENCH })).toBe(1)+ expect(meaningFactor('each', 'as', { id: BENCH })).toBe(1)+ expect(meaningFactor('total', 'each', { id: ROW })).toBe(1)+ })++ it('reads an entry in another meaning as a copy, weights, sides and drops included', () => {+ const e = entry(BENCH, [set(40, 8, { type: 'dropset', drops: [{ w: 30, r: 4 }] })], { dbLoad: 'total' })+ e.topW = 40+ const as = entryAs(e, 'each')+ expect(as).not.toBe(e)+ expect(as.sets[0].w).toBe(20)+ expect(as.sets[0].drops[0].w).toBe(15)+ expect(as.topW).toBe(20)+ expect(as.target.dbLoad).toBe('each')+ // The stored entry is untouched.+ expect(e.sets[0].w).toBe(40)+ expect(entryAs(e, 'total')).toBe(e)+ })++ it('leaves the state alone when nothing converts', () => {+ const S = state([workout('2026-10-01', [entry(BENCH, [set(20, 8)])])])+ expect(historyAs(S, BENCH, 'each')).toBe(S)+ expect(historyAs(S, BENCH, 'as')).toBe(S)+ })++ it('judges records in the session\'s meaning', () => {+ // 40 kg total last week is 20 a hand. 22 each beats it; read raw, it would look 18 kg short.+ const S = state([workout('2026-10-01', [entry(BENCH, [set(40, 8)], { dbLoad: 'total' })])])+ expect(bestWeightFor(S, BENCH)).toBe(40)+ expect(bestWeightFor(S, BENCH, 'each')).toBe(20)+ const today = entry(BENCH, [set(22, 8)], { dbLoad: 'each' })+ expect(is1RMRecord(S, BENCH, today)).not.toBe(null)+ expect(best1RM(S, BENCH, 'epley', 'each').w).toBe(20)+ })++ it('draws one curve across a switch, in the exercise\'s current meaning', () => {+ const S = state([+ workout('2026-10-01', [entry(BENCH, [set(40, 1)], { dbLoad: 'total' })]),+ workout('2026-10-08', [entry(BENCH, [set(22, 1)], { dbLoad: 'each' })]),+ ])+ expect(currentDbLoad(S, BENCH)).toBe('each')+ expect(e1rmSeries(S, BENCH).map(p => p.y)).toEqual([20, 22])+ expect(exerciseHistory(S, BENCH).best).toBe(22)+ expect(bestSetFor(S, BENCH, 'reps', 'each').set.w).toBe(22)+ })++ it('never converts sets logged as entered', () => {+ const S = state([+ workout('2026-10-01', [entry(BENCH, [set(40, 1)])]),+ workout('2026-10-08', [entry(BENCH, [set(22, 1)], { dbLoad: 'each' })]),+ ])+ expect(e1rmSeries(S, BENCH).map(p => p.y)).toEqual([40, 22])+ })+})++describe('a session', () => {+ it('stamps the meaning it is logged in, and only when there is one', () => {+ const plain = buildPlannedEntry(state(), { id: BENCH, sets: 2, reps: 8, weight: 20, mode: 'reps' }, null)+ expect(plain.target.dbLoad).toBeUndefined()+ const S = state([], { dbLoad: withDbLoad({}, BENCH, 'each', 1) })+ expect(buildPlannedEntry(S, { id: BENCH, sets: 2, reps: 8, weight: 20, mode: 'reps' }, null).target.dbLoad).toBe('each')+ expect(withMeaning(S, { sets: 2 }, BENCH)).toEqual({ sets: 2, dbLoad: 'each' })+ expect(withMeaning(state(), { sets: 2 }, BENCH)).toEqual({ sets: 2 })+ })++ it('starts from last time read in today\'s meaning after a switch', () => {+ // Logged as 40 total; the slot now logs per bell. Linear progression adds a step to 20 each,+ // not to 40 a hand.+ const S = state([workout('2026-10-01', [entry(BENCH, [set(40, 8), set(40, 8)], { dbLoad: 'total', reps: 8, sets: 2 })])])+ const built = buildPlannedEntry(S, { id: BENCH, sets: 2, reps: 8, weight: 0, mode: 'reps', dbLoad: 'each', inc: 2 }, null)+ expect(built.sets.map(s => s.w)).toEqual([22, 22])+ expect(built.target.dbLoad).toBe('each')+ })++ it('keeps today\'s numbers for an exercise that never chose', () => {+ const S = state([workout('2026-10-01', [entry(BENCH, [set(40, 8), set(40, 8)], { reps: 8, sets: 2 })])])+ const built = buildPlannedEntry(S, { id: BENCH, sets: 2, reps: 8, weight: 0, mode: 'reps', inc: 2 }, null)+ expect(built.sets.map(s => s.w)).toEqual([42, 42])+ })++ it('freestyle follows the exercise\'s setting now, not the stamp of last time', () => {+ const S = state([workout('2026-10-01', [entry(BENCH, [set(20, 8)], { dbLoad: 'each' })])])+ expect(freestyleConfig(S, { id: BENCH }).dbLoad).toBeUndefined()+ })+})++describe('sync and sharing', () => {+ it('keeps the exercise default chosen last on either device', () => {+ const a = { ...state(), _ts: 10, dbLoad: withDbLoad({}, BENCH, 'each', 10) }+ const b = { ...state(), _ts: 20, dbLoad: withDbLoad({ [CURL]: { mode: 'total', _ts: 3 } }, BENCH, 'total', 5) }+ const merged = mergeStates(a, b)+ expect(merged.dbLoad[BENCH]).toEqual({ mode: 'each', _ts: 10 })+ expect(merged.dbLoad[CURL]).toEqual({ mode: 'total', _ts: 3 })+ })++ it('re-stamps a changed default after every stamp the copy has seen', () => {+ const prev = { ...state(), _ts: 50, dbLoad: {} }+ const next = { ...prev, dbLoad: withDbLoad({}, BENCH, 'each', 1) }+ const now = stampChange(prev, next, 1)+ expect(next.dbLoad[BENCH]._ts).toBe(now)+ expect(now).toBeGreaterThan(50)+ })++ it('travels with a shared plan', () => {+ const S = state([], { routines: [{ id: 'r1', name: 'Push', ex: [{ id: BENCH, sets: 3, reps: 10, weight: 20, mode: 'reps', dbLoad: 'each' }, { id: CURL, sets: 3, reps: 10, weight: 10, mode: 'reps' }] }] })+ const list = buildPlanBundle(S, 'Push').routines[0].ex+ expect(list[0].dbLoad).toBe('each')+ expect(list[1].dbLoad).toBeUndefined()+ const back = parsePlan(JSON.stringify(buildPlanBundle(S, 'Push')), 'kg')+ expect(back.routines[0].ex[0].dbLoad).toBe('each')+ })+})diff --git a/frontend/src/lib/exercise-history.js b/frontend/src/lib/exercise-history.jsindex 40272fc4f..f7376a0c1 100644--- a/frontend/src/lib/exercise-history.js+++ b/frontend/src/lib/exercise-history.js@@ -2,6 +2,7 @@ import { metricEntriesForExercise, metricRowsForEntry, bestWeightForEntry, complimport { completedVolumeOf } from './workout-model.js'import { bestSetOf } from './onerm.js'import { beatsWeight } from './exercises.js'+import { currentDbLoad, historyAs, volumeFactor, workoutAs } from './dumbbells.js'// One exercise's past, read back for the history sheet (issue #43): a chart series and the// last few sessions, derived in a single pass over the log so the sheet can memoise the@@ -23,10 +24,13 @@ export const HISTORY_SESSIONS = 10// Volume of the exercise in one session: main set plus its drops/bursts, reps mode only —// there is no honest tonnage for a hold or a run.-const entryVolume = rows => rows.reduce((v, s) => v + completedVolumeOf(s), 0)+// A dumbbell entry logged per bell counts both bells (lib/dumbbells.js volumeFactor).+const entryVolume = (rows, en) => rows.reduce((v, s) => v + completedVolumeOf(s), 0) * volumeFactor(en)export function exerciseHistory(S, exId, { limit = HISTORY_SESSIONS } = {}) {- const workouts = S?.workouts || []+ // Dumbbell weights are read in the exercise's current meaning (lib/dumbbells.js), so the curve,+ // the best and the sessions compare like with like after a switch between each and total.+ const workouts = historyAs(S, exId, currentDbLoad(S, exId))?.workouts || []// Chronological pairs of (workout, entry); the sort covers backfilled sessions, which are// inserted by date rather than appended.const logged = []@@ -70,7 +74,7 @@ export function exerciseHistory(S, exId, { limit = HISTORY_SESSIONS } = {}) {if (e1rm != null) e1rmPoints.push({ t, d: w.d, y: e1rm })sessions.push({id: w.id, d: w.d, t, mode: m, target: en.target || null, sets: rows, value, e1rm,- volume: m === 'reps' ? entryVolume(rows) : null,+ volume: m === 'reps' ? entryVolume(rows, en) : null,})})// The "first reached" rule only holds for records above zero: a bodyweight session with@@ -95,9 +99,11 @@ export function exerciseHistory(S, exId, { limit = HISTORY_SESSIONS } = {}) {* Unlike "Last time" this looks across every routine: a record belongs to the exercise, not to* the slot it was set in. Only sets logged in `mode` count, so a hold is never measured against* a rep set. A tie keeps the first time it was reached, as the PR marker does.+ * `as` reads dumbbell weights in that meaning (lib/dumbbells.js): the session's own, so a past+ * "40 total" is held against today's sets as the "20 each" it was.* Returns { d, set, target } or null.*/-export function bestSetFor(S, exId, mode = modeOf({ id: exId })) {+export function bestSetFor(S, exId, mode = modeOf({ id: exId }), as) {const keys = s => mode === 'cardio' ? [Number(s.min) || 0, Number(s.speed) || 0]: mode === 'time' ? [Number(s.sec) || 0, Number(s.w) || 0]: [Number(s.w) || 0, Number(s.r) || 0]@@ -113,7 +119,8 @@ export function bestSetFor(S, exId, mode = modeOf({ id: exId })) {// until it is filed again), so a tie is settled by the start time, not by which came first// in the array; within one session the set logged first keeps it.let best = null- for (const w of S?.workouts || []) {+ for (const stored of S?.workouts || []) {+ const w = as ? workoutAs(stored, exId, as) : storedlet t = nullfor (const en of w.entries || []) {if (en.id !== exId) continuediff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.jsindex 5f0290b6e..4ceec94f7 100644--- a/frontend/src/lib/history.js+++ b/frontend/src/lib/history.js@@ -6,6 +6,7 @@ import { isCardio, isBodyweightEq, isAssisted, betterWeight } from './exercises.import { barWeightFor } from './bar.js'import { phaseForSet, modeForSet, modeForEntry, isWarmupRow, isDropSet, isRestPauseSet, normalizeMode, completedVolumeOf, hasCompletedWork, nextDropWeight, splitBurstReps, makeSideSet, isSideSet, syncSideAggregate, WEIGHT_ORIGIN_MANUAL, dropsOf, clustersOf } from './workout-model.js'import { backoffAt, backoffStepOf, backoffWeights } from './backoff.js'+import { dbLoadOf, bellsIn, volumeFactor, historyAs } from './dumbbells.js'const objectOf = value => value && typeof value === 'object' && !Array.isArray(value) ? value : {}// Completed-state-independent work rows whose authoritative mode matches the requested mode.const workRowsForMode = (entry = {}, mode = 'reps') => {@@ -151,7 +152,15 @@ export function setLabel(id, s, cfg, speedUnit) {if (mode === 'cardio') return `${s.min || 0} min @ ${fmtSpeed(s.speed || 0, speedUnit)}`if (mode === 'time') return fmtSec(s.sec) + (s.w > 0 ? ` · ${fmtNum(s.w)}` : '')const bw = isBw(c)- const load = (w, reps) => (bw ? (w > 0 ? `+${fmtNum(w)} × ` : '') + reps : `${fmtNum(w || 0)}×${reps}`)+ // A dumbbell weight that says what it means (lib/dumbbells.js, issue #474) says it here too:+ // "20 each × 8" is one 20 in each hand, "40 total × 8" both together. Spaced like the "+10 × 12"+ // of added weight, since the number is no longer the whole load on its own. As entered, and a+ // one-arm exercise (one bell, so both meanings are the same number), read as they always did.+ const meaning = !bw && bellsIn(c) === 2 ? dbLoadOf(c.dbLoad) : null+ const load = (w, reps) => (bw ? (w > 0 ? `+${fmtNum(w)} × ` : '') + reps+ : meaning === 'each' ? `${t('{0} each', fmtNum(w || 0))} × ${reps}`+ : meaning === 'total' ? `${t('{0} total', fmtNum(w || 0))} × ${reps}`+ : `${fmtNum(w || 0)}×${reps}`)// A rest-pause set's reps read as its bursts, "60×10+4+2", the way the protocol is written// down. The row's own `r` is the total either way; a planned set's bursts already add up to it// (applyIntensifierPlan), while bursts added live sit on top of the activation set, which is@@ -415,17 +424,24 @@ export const exNoteFor = (S, exId) => ((S?.exNotes || {})[exId] || '').trim() ||export function freestyleConfig(S, cfg) {const last = lastEntryFor(S, cfg.id)if (!last) return { ...cfg }+ // What a dumbbell weight meant last time is that session's stamp, not a choice to copy: a+ // freestyle add follows the exercise's own setting as it is now (lib/dumbbells.js).+ const { dbLoad: _meant, ...lastTarget } = last.target || {}return {...cfg,- ...(last.target || {}),+ ...lastTarget,id: cfg.id,sets: Math.max(1, last.sets.length)}}-export function bestWeightFor(S, exId) {+export function bestWeightFor(S, exId, as) {+ // `as`: the meaning of a dumbbell weight to compare in (lib/dumbbells.js) — the session's own+ // when a set is judged as a record — so a past "40 total" is the 20 each it was. Without one,+ // every weight counts as logged, as it always did.+ const H = as ? historyAs(S, exId, as) : S// 0 means "nothing logged with a load yet" and must not win a min() for an assisted machine.let best = 0- S.workouts.forEach(w => w.entries.forEach(e => {+ H.workouts.forEach(w => w.entries.forEach(e => {if (e.id !== exId) returnconst entryBest = bestWeightForEntry(e)if (entryBest > 0) best = best > 0 ? betterWeight(exId, best, entryBest) : entryBest@@ -696,9 +712,14 @@ export function workoutVolume(w) {// A per-side row's mirror is `w = max(L, R), r = L + R` (workout-model syncSideAggregate) —// right for a headline, wrong for a product: 14×10 left and 12.5×6 right is 215, not 14×16.// Each side is its own weight × reps, with its own drops and bursts.- ;(Array.isArray(w?.entries) ? w.entries : []).forEach(e => (Array.isArray(e?.sets) ? e.sets : []).forEach(s => {- if (!isWarmupRow(s)) v += completedVolumeOf(s)- }))+ // A dumbbell entry logged per bell counts both bells (volumeFactor, lib/dumbbells.js); every+ // other entry, and every one saved before the setting existed, counts its weight once.+ ;(Array.isArray(w?.entries) ? w.entries : []).forEach(e => {+ const f = volumeFactor(e)+ ;(Array.isArray(e?.sets) ? e.sets : []).forEach(s => {+ if (!isWarmupRow(s)) v += completedVolumeOf(s) * f+ })+ })return v}// Finished sessions carry their canonical local calendar day in `d`. Keep it aligned withdiff --git a/frontend/src/lib/onerm.js b/frontend/src/lib/onerm.jsindex 45e1e5008..c4b54a2c8 100644--- a/frontend/src/lib/onerm.js+++ b/frontend/src/lib/onerm.js@@ -1,6 +1,7 @@import { isAssisted } from './exercises.js'import { isSideSet } from './workout-model.js'import { entriesForExercise, metricRowsForEntry, workoutAt } from './history.js'+import { currentDbLoad, entryDbLoad, workoutAs } from './dumbbells.js'// Estimated one-rep max (issue #18, extended issue #155).//// Deliberately knows nothing about the exercise database: an estimate needs a weight AND a@@ -164,11 +165,13 @@ function bestSetOfEntries(entries, formula = DEFAULT_FORMULA) {// One point per workout in which the exercise produced an estimate — feeds the trend chart.// Chronological, matching the order workouts are appended in.-export function e1rmSeries(S, exId, formula = formulaOf(S)) {+// `as` is the meaning a dumbbell weight is read in (lib/dumbbells.js): the exercise's own by+// default, so a session logged as "40 total" sits on the same curve as one logged as "20 each".+export function e1rmSeries(S, exId, formula = formulaOf(S), as = currentDbLoad(S, exId)) {if (isAssisted(exId)) return []const pts = [];(S.workouts || []).forEach(w => {- const best = bestSetOfEntries(entriesForExercise(w, exId), formula)+ const best = bestSetOfEntries(entriesForExercise(workoutAs(w, exId, as), exId), formula)if (best) pts.push({ t: workoutAt(w), d: w.d, y: best.est, w: best.w, r: best.r })})return pts@@ -176,9 +179,9 @@ export function e1rmSeries(S, exId, formula = formulaOf(S)) {// All-time best estimate for an exercise, with the set and date it came from — the source// matters, because "142.5 kg est. from 100×10" is a very different claim from "from 140×1".-export function best1RM(S, exId, formula = formulaOf(S)) {+export function best1RM(S, exId, formula = formulaOf(S), as) {let best = null- e1rmSeries(S, exId, formula).forEach(p => { if (!best || p.y > best.est) best = { est: p.y, w: p.w, r: p.r, d: p.d, t: p.t } })+ e1rmSeries(S, exId, formula, as ?? currentDbLoad(S, exId)).forEach(p => { if (!best || p.y > best.est) best = { est: p.y, w: p.w, r: p.r, d: p.d, t: p.t } })return best}@@ -187,7 +190,8 @@ export function best1RM(S, exId, formula = formulaOf(S)) {export function is1RMRecord(S, exId, entry, formula = formulaOf(S)) {const now = bestSetOf(entry, formula)if (!now) return null- const prev = best1RM(S, exId, formula)+ // Held against history read the way this session logged its weight (lib/dumbbells.js).+ const prev = best1RM(S, exId, formula, entryDbLoad(entry))return !prev || now.est > prev.est ? { ...now, prev: prev ? prev.est : 0 } : null}diff --git a/frontend/src/lib/plan-share.js b/frontend/src/lib/plan-share.jsindex ecb40573d..8403a8a28 100644--- a/frontend/src/lib/plan-share.js+++ b/frontend/src/lib/plan-share.js@@ -14,6 +14,7 @@ import { modeOf, exLine, MAX_PLANNED_WARMUPS } from './history.js'import { deriveSessionName } from './session-merge.js'import { isPyramid, normalizePyramid, normalizePyramidRest, normalizePyramidWeight } from './pyramid.js'import { isBackoff } from './backoff.js'+import { dbLoadOf } from './dumbbells.js'import { uid, todayISO, DAYN, weekOrder, weekStartOf, exCount } from './format.js'import { t, exerciseNameFor, exerciseNameClass, getLang, RTL_LANGS } from './i18n-core.js'import { convertWeight } from './units.js'@@ -103,6 +104,9 @@ function cleanEx(e) {// Epley deload factor is a per-occurrence progression setting. Omit the default so older// exports remain compact and importing them preserves the default 90% behaviour.if (e.deloadFactor != null && Number(e.deloadFactor) !== 0.9) o.deloadFactor = e.deloadFactor+ // What a dumbbell weight means in this slot (lib/dumbbells.js): without it "20 each" arrives+ // as a bare 20 and the other end counts half the volume.+ if (dbLoadOf(e.dbLoad)) o.dbLoad = dbLoadOf(e.dbLoad)if (e.repsMin != null) o.repsMin = e.repsMinif (e.repsMax != null) o.repsMax = e.repsMax// The exercise's own rest (issue #10) is part of how it is prescribed, so it travels too —diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.jsindex 0d1b6d87f..2722523ad 100644--- a/frontend/src/lib/pt-br-locale.test.js+++ b/frontend/src/lib/pt-br-locale.test.js@@ -41,7 +41,7 @@ describe('Brazilian Portuguese locale', () => {// has to be taught is a number nobody reads. What the numbers stood for is asserted above.// If the hash fails, review the changed keys and wording before accepting a new one. From// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('27bc223129eafceba71df28ed1b4d61c1a5ea62a006e766f590dc6af476431e2')+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('1522e74abfb1a3335b95586d7bd6d3e52e4e4dc02dccb895a757d00f06e4ca8a')})// pt-PT labelled Unpair 'Desfazer': Undo, in Portuguese (it is pt-BR's Undo), on the button thatdiff --git a/frontend/src/lib/session-start.js b/frontend/src/lib/session-start.jsindex d207e9f9a..a2ae62f28 100644--- a/frontend/src/lib/session-start.js+++ b/frontend/src/lib/session-start.js@@ -8,6 +8,7 @@ import { isWarmupRow } from './workout-model.js'import { nextPrescription, applyPrescription, defaultIncrement, weightIncrement, plannedOf } from './progression.js'import { dropGrid } from './plates.js'import { backoffStepOf, applyBackoff } from './backoff.js'+import { dbLoadFor, historyAs } from './dumbbells.js'/*** Where a planned session's reps come from (Settings → During a workout). 'plan', the default:@@ -26,7 +27,12 @@ export const startsFromLast = st => st?.startFrom === 'last'* the exercise is planned in: its own history comes first (#216) and its policy applies.* `noProg` builds the routine's own numbers with no prescription, as an excluded routine does.*/-export function buildPlannedEntry(st, cfg, routine, { noProg = false } = {}) {+export function buildPlannedEntry(stored, cfg, routine, { noProg = false } = {}) {+ // What a dumbbell weight means for this exercise today (lib/dumbbells.js): the history it+ // progresses from is read in that meaning, so a switch from "40 total" to per bell opens at+ // 20, not at 40 a hand. Only a switch between the two explicit meanings converts anything.+ const meaning = dbLoadFor(stored, cfg)+ const st = historyAs(stored, cfg.id, meaning)// `plan` is kept on the entry purely so the workout can explain the number it chose.const plan = noProg ? { policy: 'off', kind: 'off' } : nextPrescription(st, cfg, routine)// The warm-up ramp and the prescription snap to the exercise's own increment (1.25 kg@@ -40,6 +46,8 @@ export function buildPlannedEntry(st, cfg, routine, { noProg = false } = {}) {const rows = backoffStep ? applyBackoff(built, backoffStep) : builtconst sets = applyIntensifierPlan(rows, cfg, dropGrid(st, cfg))const target = { ...cfg }+ // Stamped on the session, so the meaning it was logged with stays with it (dumbbells.js).+ if (meaning !== 'as') target.dbLoad = meaningif (plan.weight != null) target.weight = plan.weightif (plan.reps != null) target.reps = plan.repsif (plan.sec != null) target.sec = plan.secdiff --git a/frontend/src/lib/sync-merge.js b/frontend/src/lib/sync-merge.jsindex 3b38f278b..e6cae5a2d 100644--- a/frontend/src/lib/sync-merge.js+++ b/frontend/src/lib/sync-merge.js@@ -36,7 +36,7 @@* 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+ * - balanceOverrides, loadKind, plates, dbLoad: 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* - `_ts`: the later of the two; `_rev` dropped (the server sets it); `active` left to the caller@@ -397,7 +397,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', 'balanceOverrides', 'loadKind', 'plates', 'dbLoad']/** 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 +457,7 @@ export function sinceReset(S, at, ids) {out.favEx = []out.exNotes = {}out.barWeights = {}- for (const f of ['balanceOverrides', 'loadKind', 'plates']) {+ for (const f of ['balanceOverrides', 'loadKind', 'plates', 'dbLoad']) {out[f] = Object.fromEntries(Object.entries(isMap(S[f]) ? S[f] : {}).filter(([, v]) => after(stampOf(v))))}}@@ -607,7 +607,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', 'dbLoad',])// 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 +844,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 ['balanceOverrides', 'loadKind', 'plates', 'dbLoad']) {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 +967,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 ['balanceOverrides', 'loadKind', 'plates', 'dbLoad']) {if (!isMap(next[f])) continuefor (const [k, v] of Object.entries(next[f])) {if (!isMap(v)) continue@@ -1003,7 +1003,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 ['balanceOverrides', 'loadKind', 'plates', 'dbLoad']) 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 +1025,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 ['balanceOverrides', 'loadKind', 'plates', 'dbLoad']) {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 = nowdiff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex 7b002676a..b00abc287 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -2213,4 +2213,17 @@ export default {// --- search: similar exercises ---'Similar exercises': 'تمارين مشابهة','No exact match. These come close:': 'لا تطابق تام. هذه قريبة:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '{0} لكل واحد',+ '{0} total': '{0} إجمالًا',+ 'Each ({0})': 'لكل واحد ({0})',+ 'Both ({0})': 'معًا ({0})',+ 'As entered': 'كما أُدخل',+ 'Each': 'لكل واحد',+ 'Both': 'معًا',+ 'Weight means': 'معنى الوزن',+ 'The weight of the one you hold. One arm, so it counts once.': 'وزن الواحد الذي تمسكه. ذراع واحدة، لذا يُحسب مرة واحدة.',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'وزن الواحد، أي أن 20 تعني 20 في كل يد. الحجم يحسب الاثنين.',+ 'Both together, so 40 means two 20s.': 'الاثنان معًا، أي أن 40 تعني اثنين بوزن 20.',+ 'Counted as you type it, the way it always was.': 'يُحسب كما تكتبه، كما كان دائمًا.',}diff --git a/frontend/src/locales/bn.js b/frontend/src/locales/bn.jsindex 39745f383..68e1e7659 100644--- a/frontend/src/locales/bn.js+++ b/frontend/src/locales/bn.js@@ -2237,4 +2237,17 @@ export default {// --- search: similar exercises ---'Similar exercises': 'একই ধরনের ব্যায়াম','No exact match. These come close:': 'হুবহু মিল নেই। এগুলো কাছাকাছি:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': 'প্রতিটি {0}',+ '{0} total': 'মোট {0}',+ 'Each ({0})': 'প্রতিটি ({0})',+ 'Both ({0})': 'দুটো মিলে ({0})',+ 'As entered': 'যেমন লেখা',+ 'Each': 'প্রতিটি',+ 'Both': 'দুটো মিলে',+ 'Weight means': 'ওজনের মানে',+ 'The weight of the one you hold. One arm, so it counts once.': 'হাতে থাকা একটির ওজন। এক হাত, তাই একবার গোনা হয়।',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'একটির ওজন, তাই 20 মানে প্রতি হাতে 20। ভলিউমে দুটোই গোনা হয়।',+ 'Both together, so 40 means two 20s.': 'দুটো মিলে, তাই 40 মানে দুটো 20।',+ 'Counted as you type it, the way it always was.': 'যেমন লেখেন তেমনই গোনা হয়, আগের মতোই।',}diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex a54996bf8..fbdb5adf5 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -2178,4 +2178,17 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Ähnliche Übungen','No exact match. These come close:': 'Kein genauer Treffer. Die hier kommen nah ran:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '{0} je',+ '{0} total': '{0} gesamt',+ 'Each ({0})': 'Je Hantel ({0})',+ 'Both ({0})': 'Beide ({0})',+ 'As entered': 'Wie eingegeben',+ 'Each': 'Je Hantel',+ 'Both': 'Beide',+ 'Weight means': 'Gewicht bedeutet',+ 'The weight of the one you hold. One arm, so it counts once.': 'Das Gewicht der einen Hantel in deiner Hand. Ein Arm, also zählt sie einmal.',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'Das Gewicht einer Hantel: 20 heißt 20 in jeder Hand. Das Volumen zählt beide.',+ 'Both together, so 40 means two 20s.': 'Beide zusammen: 40 heißt zwei 20er.',+ 'Counted as you type it, the way it always was.': 'Gezählt, wie du es eintippst, so wie immer.',}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex fbfa422c9..fd7bcb87a 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -2158,4 +2158,17 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Ejercicios parecidos','No exact match. These come close:': 'Nada exacto. Estos se acercan:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '{0} cada una',+ '{0} total': '{0} en total',+ 'Each ({0})': 'Cada una ({0})',+ 'Both ({0})': 'Ambas ({0})',+ 'As entered': 'Tal cual',+ 'Each': 'Cada una',+ 'Both': 'Ambas',+ 'Weight means': 'El peso es',+ 'The weight of the one you hold. One arm, so it counts once.': 'El peso de la que sostienes. Un solo brazo, así que cuenta una vez.',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'El peso de una, así que 20 son 20 en cada mano. El volumen cuenta las dos.',+ 'Both together, so 40 means two 20s.': 'Las dos juntas, así que 40 son dos de 20.',+ 'Counted as you type it, the way it always was.': 'Se cuenta tal como lo escribes, como siempre.',}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 6dd9b5430..ea564b212 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -2158,4 +2158,17 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Exercices similaires','No exact match. These come close:': 'Rien d’exact. Ceux-ci s’en approchent :',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '{0} chacun',+ '{0} total': '{0} au total',+ 'Each ({0})': 'Chacun ({0})',+ 'Both ({0})': 'Les deux ({0})',+ 'As entered': 'Tel que saisi',+ 'Each': 'Chacun',+ 'Both': 'Les deux',+ 'Weight means': 'Le poids indique',+ 'The weight of the one you hold. One arm, so it counts once.': 'Le poids de celui que tu tiens. Un seul bras, donc il compte une fois.',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'Le poids d’un seul, donc 20 veut dire 20 dans chaque main. Le volume compte les deux.',+ 'Both together, so 40 means two 20s.': 'Les deux ensemble, donc 40 veut dire deux de 20.',+ 'Counted as you type it, the way it always was.': 'Compté comme tu le tapes, comme toujours.',}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex 57b07f370..e303c4c14 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -2158,4 +2158,17 @@ export default {// --- search: similar exercises ---'Similar exercises': 'मिलते-जुलते व्यायाम','No exact match. These come close:': 'सटीक मेल नहीं मिला। ये करीब हैं:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '{0} हर एक',+ '{0} total': '{0} कुल',+ 'Each ({0})': 'हर एक ({0})',+ 'Both ({0})': 'दोनों ({0})',+ 'As entered': 'जैसा लिखा',+ 'Each': 'हर एक',+ 'Both': 'दोनों',+ 'Weight means': 'वज़न का मतलब',+ 'The weight of the one you hold. One arm, so it counts once.': 'हाथ में एक का वज़न। एक हाथ है, इसलिए एक बार गिना जाता है।',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'एक का वज़न, यानी 20 मतलब हर हाथ में 20। वॉल्यूम दोनों को गिनता है।',+ 'Both together, so 40 means two 20s.': 'दोनों मिलाकर, यानी 40 मतलब दो 20 वाले।',+ 'Counted as you type it, the way it always was.': 'जैसा आप लिखते हैं वैसा ही गिना जाता है, हमेशा की तरह।',}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex a496dfb81..3b75fbb9e 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -2161,4 +2161,17 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Hasonló gyakorlatok','No exact match. These come close:': 'Nincs pontos találat. Ezek közel állnak:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '{0} darabonként',+ '{0} total': '{0} összesen',+ 'Each ({0})': 'Darabonként ({0})',+ 'Both ({0})': 'Együtt ({0})',+ 'As entered': 'Ahogy beírtad',+ 'Each': 'Darabonként',+ 'Both': 'Együtt',+ 'Weight means': 'A súly jelentése',+ 'The weight of the one you hold. One arm, so it counts once.': 'Annak az egynek a súlya, amit tartasz. Egy kar, így egyszer számít.',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'Egy darab súlya, tehát a 20 kezenként 20-at jelent. A volumen mindkettőt számolja.',+ 'Both together, so 40 means two 20s.': 'A kettő együtt, tehát a 40 két 20-ast jelent.',+ 'Counted as you type it, the way it always was.': 'Úgy számít, ahogy beírod, mint eddig mindig.',}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 8c3d96f6f..f8338fcc5 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -2158,4 +2158,17 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Esercizi simili','No exact match. These come close:': 'Niente di esatto. Questi ci vanno vicino:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '{0} ciascuno',+ '{0} total': '{0} in totale',+ 'Each ({0})': 'Ciascuno ({0})',+ 'Both ({0})': 'Entrambi ({0})',+ 'As entered': 'Come inserito',+ 'Each': 'Ciascuno',+ 'Both': 'Entrambi',+ 'Weight means': 'Il peso indica',+ 'The weight of the one you hold. One arm, so it counts once.': 'Il peso di quello che tieni. Un braccio solo, quindi conta una volta.',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'Il peso di uno, quindi 20 vuol dire 20 in ogni mano. Il volume li conta entrambi.',+ 'Both together, so 40 means two 20s.': 'Entrambi insieme, quindi 40 vuol dire due da 20.',+ 'Counted as you type it, the way it always was.': 'Contato come lo scrivi, come sempre.',}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex c906b2b53..46f237edf 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -2158,4 +2158,17 @@ export default {// --- search: similar exercises ---'Similar exercises': '비슷한 운동','No exact match. These come close:': '정확히 일치하는 항목이 없어요. 이건 비슷해요:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '개당 {0}',+ '{0} total': '합계 {0}',+ 'Each ({0})': '개당 ({0})',+ 'Both ({0})': '합계 ({0})',+ 'As entered': '입력한 그대로',+ 'Each': '개당',+ 'Both': '합계',+ 'Weight means': '무게 기준',+ 'The weight of the one you hold. One arm, so it counts once.': '들고 있는 하나의 무게예요. 한 팔이라 한 번만 셉니다.',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': '하나의 무게라서 20은 양손에 20씩이에요. 볼륨은 두 개를 셉니다.',+ 'Both together, so 40 means two 20s.': '두 개를 합친 무게라서 40은 20짜리 두 개예요.',+ 'Counted as you type it, the way it always was.': '입력한 그대로 계산해요. 늘 그랬듯이.',}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex 0525f3041..06d07145f 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -2158,4 +2158,17 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Podobne ćwiczenia','No exact match. These come close:': 'Brak dokładnego dopasowania. Te są blisko:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '{0} na sztukę',+ '{0} total': '{0} łącznie',+ 'Each ({0})': 'Na sztukę ({0})',+ 'Both ({0})': 'Razem ({0})',+ 'As entered': 'Jak wpisano',+ 'Each': 'Na sztukę',+ 'Both': 'Razem',+ 'Weight means': 'Ciężar to',+ 'The weight of the one you hold. One arm, so it counts once.': 'Ciężar tej jednej w dłoni. Jedna ręka, więc liczy się raz.',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'Ciężar jednej sztuki: 20 to 20 w każdej dłoni. Objętość liczy obie.',+ 'Both together, so 40 means two 20s.': 'Obie razem: 40 to dwie po 20.',+ 'Counted as you type it, the way it always was.': 'Liczone tak, jak wpisano, jak zawsze.',}diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 9f283b0d1..546076cf0 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -1331,6 +1331,12 @@ 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:',+ // --- dumbbell weight meaning (#474) ---+ 'As entered': 'Como digitado',+ 'The weight of the one you hold. One arm, so it counts once.': 'O peso do que você segura. Um braço só, então conta uma vez.',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'O peso de um, então 20 significa 20 em cada mão. O volume conta os dois.',+ 'Both together, so 40 means two 20s.': 'Os dois juntos, então 40 significa dois de 20.',+ 'Counted as you type it, the way it always was.': 'Contado como você digita, como sempre foi.',}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 31486ba97..ab4d75bae 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -2158,4 +2158,17 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Exercícios semelhantes','No exact match. These come close:': 'Nada exato. Estes andam perto:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '{0} cada',+ '{0} total': '{0} no total',+ 'Each ({0})': 'Cada ({0})',+ 'Both ({0})': 'Ambos ({0})',+ 'As entered': 'Como escrito',+ 'Each': 'Cada',+ 'Both': 'Ambos',+ 'Weight means': 'O peso é',+ 'The weight of the one you hold. One arm, so it counts once.': 'O peso do que seguras. Um só braço, por isso conta uma vez.',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'O peso de um, por isso 20 quer dizer 20 em cada mão. O volume conta os dois.',+ 'Both together, so 40 means two 20s.': 'Os dois juntos, por isso 40 quer dizer dois de 20.',+ 'Counted as you type it, the way it always was.': 'Contado como o escreves, como sempre foi.',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 9bbf9caa1..8692e1f38 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -2162,4 +2162,17 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Похожие упражнения','No exact match. These come close:': 'Точного совпадения нет. Вот что близко:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '{0} каждая',+ '{0} total': '{0} всего',+ 'Each ({0})': 'Каждая ({0})',+ 'Both ({0})': 'Обе ({0})',+ 'As entered': 'Как введено',+ 'Each': 'Каждая',+ 'Both': 'Обе',+ 'Weight means': 'Вес означает',+ 'The weight of the one you hold. One arm, so it counts once.': 'Вес той, что у вас в руке. Одна рука, поэтому считается один раз.',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'Вес одной: 20 значит по 20 в каждой руке. В объём идут обе.',+ 'Both together, so 40 means two 20s.': 'Обе вместе: 40 значит две по 20.',+ 'Counted as you type it, the way it always was.': 'Считается так, как вы вводите, как и всегда.',}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 475397099..e1e879e8e 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -2169,4 +2169,17 @@ export default {// --- search: similar exercises ---'Similar exercises': 'ท่าที่คล้ายกัน','No exact match. These come close:': 'ไม่พบที่ตรงทั้งหมด ท่าเหล่านี้ใกล้เคียง:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '{0} ต่อข้าง',+ '{0} total': 'รวม {0}',+ 'Each ({0})': 'ต่อข้าง ({0})',+ 'Both ({0})': 'รวม ({0})',+ 'As entered': 'ตามที่กรอก',+ 'Each': 'ต่อข้าง',+ 'Both': 'รวม',+ 'Weight means': 'น้ำหนักหมายถึง',+ 'The weight of the one you hold. One arm, so it counts once.': 'น้ำหนักของอันที่ถืออยู่ แขนเดียว จึงนับครั้งเดียว',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'น้ำหนักของหนึ่งอัน 20 คือมือละ 20 ปริมาณรวมนับทั้งสองอัน',+ 'Both together, so 40 means two 20s.': 'ทั้งสองอันรวมกัน 40 คือ 20 สองอัน',+ 'Counted as you type it, the way it always was.': 'นับตามที่คุณกรอก เหมือนที่ผ่านมา',}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex edf569226..00c7432dc 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -2158,4 +2158,17 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Benzer egzersizler','No exact match. These come close:': 'Tam eşleşme yok. Bunlar yakın:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '{0} tanesi',+ '{0} total': '{0} toplam',+ 'Each ({0})': 'Tanesi ({0})',+ 'Both ({0})': 'İkisi ({0})',+ 'As entered': 'Girildiği gibi',+ 'Each': 'Tanesi',+ 'Both': 'İkisi',+ 'Weight means': 'Ağırlığın anlamı',+ 'The weight of the one you hold. One arm, so it counts once.': 'Tuttuğun tek ağırlığın kilosu. Tek kol, yani bir kez sayılır.',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'Bir tanesinin ağırlığı, yani 20 her elde 20 demek. Hacim ikisini de sayar.',+ 'Both together, so 40 means two 20s.': 'İkisi birlikte, yani 40 iki tane 20 demek.',+ 'Counted as you type it, the way it always was.': 'Yazdığın gibi sayılır, her zamanki gibi.',}diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex fad71d4f9..662b252b6 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -2155,4 +2155,17 @@ export default {// --- search: similar exercises ---'Similar exercises': 'Схожі вправи','No exact match. These come close:': 'Точного збігу немає. Ось що близько:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '{0} кожна',+ '{0} total': '{0} разом',+ 'Each ({0})': 'Кожна ({0})',+ 'Both ({0})': 'Обидві ({0})',+ 'As entered': 'Як введено',+ 'Each': 'Кожна',+ 'Both': 'Обидві',+ 'Weight means': 'Вага означає',+ 'The weight of the one you hold. One arm, so it counts once.': 'Вага тієї, що в руці. Одна рука, тож рахується один раз.',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': 'Вага однієї: 20 означає 20 у кожній руці. В обсяг ідуть обидві.',+ 'Both together, so 40 means two 20s.': 'Обидві разом: 40 означає дві по 20.',+ 'Counted as you type it, the way it always was.': 'Рахується так, як ти вводиш, як завжди.',}diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.jsindex ad7411e1d..fc0156148 100644--- a/frontend/src/locales/zh-TW.js+++ b/frontend/src/locales/zh-TW.js@@ -2151,4 +2151,17 @@ export default {// --- search: similar exercises ---'Similar exercises': '相似動作','No exact match. These come close:': '沒有完全符合,這些比較接近:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '每支 {0}',+ '{0} total': '共 {0}',+ 'Each ({0})': '每支 ({0})',+ 'Both ({0})': '兩支合計 ({0})',+ 'As entered': '依輸入',+ 'Each': '每支',+ 'Both': '合計',+ 'Weight means': '重量代表',+ 'The weight of the one you hold. One arm, so it counts once.': '你手上那一支的重量。單臂,所以只算一次。',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': '一支的重量,20 就是每隻手 20。訓練量會算兩支。',+ 'Both together, so 40 means two 20s.': '兩支加起來,40 就是兩支 20。',+ 'Counted as you type it, the way it always was.': '照你輸入的算,一直都是這樣。',}diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex c7b7277d9..5fff2bf2c 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -2158,4 +2158,17 @@ export default {// --- search: similar exercises ---'Similar exercises': '相似动作','No exact match. These come close:': '没有完全匹配,这些比较接近:',+ // --- dumbbell weight meaning (#474) ---+ '{0} each': '每只 {0}',+ '{0} total': '共 {0}',+ 'Each ({0})': '每只 ({0})',+ 'Both ({0})': '两只合计 ({0})',+ 'As entered': '按输入',+ 'Each': '每只',+ 'Both': '合计',+ 'Weight means': '重量表示',+ 'The weight of the one you hold. One arm, so it counts once.': '你手里那一只的重量。单臂,所以只算一次。',+ 'The weight of one, so 20 means 20 in each hand. Volume counts both.': '一只的重量,20 就是每只手 20。容量会算两只。',+ 'Both together, so 40 means two 20s.': '两只加起来,40 就是两只 20。',+ 'Counted as you type it, the way it always was.': '按你输入的算,一直都是这样。',}diff --git a/frontend/src/sheets.dbload.test.jsx b/frontend/src/sheets.dbload.test.jsxnew file mode 100644index 000000000..17a42fa4b--- /dev/null+++ b/frontend/src/sheets.dbload.test.jsx@@ -0,0 +1,87 @@+// @vitest-environment happy-dom+// What a dumbbell weight means (issue #474), where it is picked: the exercise's own default on its+// detail sheet (S.dbLoad, stamped), a routine slot's own choice on the exercise settings+// (cfg.dbLoad, written only when it differs from the exercise's default).+import React, { act } from 'react'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { createRoot } from 'react-dom/client'+import { EXIDX } from './lib/exercises.js'+import { useStore, DEF } from './store/useStore.js'+import { useUI } from './store/useUI.js'+import { exConfigSheet, exerciseDetailSheet } from './sheets.jsx'+import { withDbLoad } from './lib/dumbbells.js'++const BENCH = EXIDX['0289'] // dumbbell bench press+const SQUAT = EXIDX['0043'] // barbell+const mounted = []+function render(sheet) {+ const host = document.createElement('div')+ document.body.appendChild(host)+ const root = createRoot(host)+ mounted.push([root, host])+ act(() => root.render(sheet.render(() => useUI.getState().closeSheet(sheet.id))))+ return host+}+const S = () => useStore.getState().S+const segButton = (host, text) => [...host.querySelectorAll('.seg button')].find(b => b.textContent.trim() === text)+const button = (host, text) => [...host.querySelectorAll('button')].find(b => b.textContent.trim() === text)++describe('weight means', () => {+ beforeEach(() => {+ globalThis.IS_REACT_ACT_ENVIRONMENT = true+ useUI.setState({ sheets: [], toasts: [] })+ useStore.setState({ S: { ...JSON.parse(JSON.stringify(DEF)), unit: 'kg' }, user: null })+ document.body.innerHTML = ''+ })+ afterEach(() => { act(() => { mounted.splice(0).forEach(([root, host]) => { root.unmount(); host.remove() }) }) })++ it('the detail sheet sets the exercise default, stamped, and shows As entered until then', () => {+ exerciseDetailSheet(BENCH)+ const host = render(useUI.getState().sheets.at(-1))+ expect(host.textContent).toContain('Weight means')+ expect(segButton(host, 'As entered').classList.contains('on')).toBe(true)+ expect(host.textContent).toContain('Counted as you type it, the way it always was.')+ act(() => segButton(host, 'Each').click())+ expect(S().dbLoad[BENCH.id]).toEqual({ mode: 'each', _ts: expect.any(Number) })+ expect(host.textContent).toContain('Volume counts both.')+ act(() => segButton(host, 'As entered').click())+ expect(S().dbLoad[BENCH.id]).toEqual({ mode: null, _ts: expect.any(Number) })+ })++ it('is not offered for a barbell', () => {+ exerciseDetailSheet(SQUAT)+ const host = render(useUI.getState().sheets.at(-1))+ expect(host.textContent).not.toContain('Weight means')+ })++ it('a routine slot saves its own pick and nothing when it follows the exercise', () => {+ const onSave = vi.fn()+ exConfigSheet(BENCH, { sets: 3, reps: 10, weight: 20, mode: 'reps' }, onSave)+ let host = render(useUI.getState().sheets.at(-1))+ act(() => button(host, 'Save').click())+ expect(onSave.mock.calls[0][0]).not.toHaveProperty('dbLoad')++ exConfigSheet(BENCH, { sets: 3, reps: 10, weight: 20, mode: 'reps' }, onSave)+ host = render(useUI.getState().sheets.at(-1))+ act(() => segButton(host, 'Both').click())+ act(() => button(host, 'Save').click())+ expect(onSave.mock.calls[1][0].dbLoad).toBe('total')+ })++ it('a slot whose exercise means per bell can still say as entered, and repeating the default drops the key', () => {+ useStore.setState(s => ({ S: { ...s.S, dbLoad: withDbLoad({}, BENCH.id, 'each', 1) } }))+ const onSave = vi.fn()+ // A session target stamped with the exercise's own meaning is not the slot's choice.+ exConfigSheet(BENCH, { sets: 3, reps: 10, weight: 20, mode: 'reps', dbLoad: 'each' }, onSave)+ let host = render(useUI.getState().sheets.at(-1))+ expect(segButton(host, 'Each').classList.contains('on')).toBe(true)+ act(() => button(host, 'Save').click())+ expect(onSave.mock.calls[0][0]).not.toHaveProperty('dbLoad')++ exConfigSheet(BENCH, { sets: 3, reps: 10, weight: 20, mode: 'reps' }, onSave)+ host = render(useUI.getState().sheets.at(-1))+ act(() => segButton(host, 'As entered').click())+ act(() => button(host, 'Save').click())+ expect(onSave.mock.calls[1][0].dbLoad).toBe('as')+ })+})diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsxindex 7c6846f22..5b29561dd 100644--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@ -35,6 +35,7 @@ import { importHevyData, HevyApiError, HEVY_DEV_SETTINGS, mergeHevyRoutines } frimport { buildPlanBundle, parsePlan, mergePlan, printPlan, planPrintHTML } from './lib/plan-share.js'import { estimate1RM, best1RM, is1RMRecord, REP_CAP, formulaOf, FORMULA_NAMES } from './lib/onerm.js'import { exerciseHistory } from './lib/exercise-history.js'+import { isBellEx, dbLoadOf, dbLoadFor, withDbLoad, withMeaning, historyAs, entryDbLoad, currentDbLoad, isOneArm } from './lib/dumbbells.js'import { policyFor, defaultIncrement, POLICIES_FOR, POLICY_NAME, POLICY_DESC, MAX_BW_SETS, weightIncrement } from './lib/progression.js'import { normalizeRepRange } from './lib/rep-range.js'import { isBackoff, backoffWeights } from './lib/backoff.js'@@ -807,6 +808,23 @@ function BarWeightEditor({ ex, cfg, extra }) {</>}+// What a dumbbell or kettlebell weight means (issue #474, lib/dumbbells.js): as entered (the+// default, how every set before this was counted), one bell, or both together. `value` is the+// meaning in force and `onChange` stores a pick; the caller decides where (the routine's slot or+// the exercise's own default). The line under it says what the pick does to the numbers.+function DbLoadPicker({ ex, cfg, value, onChange }) {+ const one = isOneArm({ ...(cfg || {}), id: ex.id })+ return <>+ <Segmented className="seg-inline" value={value} onChange={onChange}+ options={[{ value: 'as', label: t('As entered') }, { value: 'each', label: t('Each') }, { value: 'total', label: t('Both') }]} />+ <div className="small dim" style={{ margin: '8px 0 18px' }}>+ {value === 'each' ? (one ? t('The weight of the one you hold. One arm, so it counts once.') : t('The weight of one, so 20 means 20 in each hand. Volume counts both.'))+ : value === 'total' ? t('Both together, so 40 means two 20s.')+ : t('Counted as you type it, the way it always was.')}+ </div>+ </>+}+// Mid-workout sheet behind the ⋯ menu's "Plate loading" — same values, same editor.function BarWeightSheet({ exId, cfg, close }) {const ex = exOr(exId)@@ -911,7 +929,7 @@ function ExerciseDetail({ ex, close }) {useLang() // the description and steps arrive in their own chunk the first time a sheet asksconst st = useStore(s => s.S)const last = lastEntryFor(st, ex.id)- const best = bestWeightFor(st, ex.id)+ const best = bestWeightFor(st, ex.id, currentDbLoad(st, ex.id))const fav = isFav(st, ex.id)const flipFav = () => {let on = false@@ -942,6 +960,13 @@ function ExerciseDetail({ ex, close }) {<h4 className="sec">{t('Plate loading')}</h4><BarWeightEditor ex={ex} extra={t('You still log the total weight. This only feeds the plate line under each set.')} /></>}+ {/* The exercise's own default meaning of its weight (S.dbLoad), stamped like the loading+ above. A routine can still pick its own on the exercise's settings. */}+ {isBellEx(ex) && <>+ <h4 className="sec">{t('Weight means')}</h4>+ <DbLoadPicker ex={ex} value={dbLoadFor(st, ex.id)}+ onChange={v => update(s => { s.dbLoad = withDbLoad(s.dbLoad, ex.id, v) })} />+ </>}{/* No one-rep max on an assistance machine: the load is the help you were given, so thecalculator would answer "your 1RM is 23 kg" about a number that gets smaller as you getstronger (issue #232). Cardio has none for the same kind of reason. */}@@ -1351,8 +1376,10 @@ export function swapActiveWorkoutExercise(index) {// Built from what came before the session's day when it is logged into the past (sessionHistory).const step = modeOf(full) === 'reps' ? weightIncrement(full, st.unit) : defaultIncrement(ex.id, st.unit)const past = sessionHistory(st)+ // A freestyle swap logs dumbbell weights the way the exercise means them now, and starts+ // from last time read in that meaning (lib/dumbbells.js), as a planned one does.const built = freestyle- ? { target: { ...cfg }, plan: null, sets: applyIntensifierPlan(buildSets(past, full, { step, preferLast: true }), full, dropGrid(st, full)) }+ ? { target: withMeaning(st, cfg, ex.id), plan: null, sets: applyIntensifierPlan(buildSets(historyAs(past, ex.id, dbLoadFor(st, full)), full, { step, preferLast: true }), full, dropGrid(st, full)) }: buildPlannedEntry(past, full, slotRoutine, { noProg: builtOutOfProgression(current, slotRoutine) })const replacement = {id: ex.id,@@ -1548,6 +1575,9 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, iconst seed = existing || initial || defaultConfig(ex.id)const [c, setC] = useState(() => {const cfg = { ...seed }+ // A session's target carries the meaning of its dumbbell weight as a stamp (lib/dumbbells.js);+ // one that only repeats the exercise's own default is not the slot's choice, so it is not kept.+ if (cfg.dbLoad != null && dbLoadOf(cfg.dbLoad) === dbLoadFor(st, ex.id)) delete cfg.dbLoadreturn policyFor({ ...cfg, id: ex.id }, routine, modeOf({ ...cfg, id: ex.id })) === 'double'? { ...cfg, ...normalizeRepRange(cfg.reps, cfg.repsMin, isPerSide(cfg) ? 2 : 1) }: cfg@@ -1609,8 +1639,12 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i// was. Mode-independent — a heavy triple, a plank and a cardio interval all rest.const restSec = Math.max(0, Math.round(c.restSec) || 0)const withRest = restSec ? { restSec } : {}+ // What a dumbbell weight means in this slot (lib/dumbbells.js): written only when the slot+ // picked its own, so every other config stays the shape it was.+ const dbLoad = isBellEx(ex) && !bw ? dbLoadOf(c.dbLoad) : null+ const withMeant = dbLoad ? { dbLoad } : {}if (cardio) onSave({ sets, min: Math.max(1, Math.round(c.min) || 20), speed: Math.max(0, c.speed || 8), ...withNote, ...withRest })- else if (mode === 'time') onSave({ sets, mode: 'time', sec: Math.max(1, Math.round(c.sec) || 45), weight: Math.max(0, c.weight || 0), ...flags, ...(perSide ? { side: true } : {}), ...prog, ...withNote, ...withWarmups, ...withRest })+ else if (mode === 'time') onSave({ sets, mode: 'time', sec: Math.max(1, Math.round(c.sec) || 45), weight: Math.max(0, c.weight || 0), ...flags, ...(perSide ? { side: true } : {}), ...prog, ...withNote, ...withWarmups, ...withRest, ...withMeant })else {// A unilateral target is stored even: the split has to divide, and a typed 15 would// otherwise plan seven reps on one side and eight on the other, every session.@@ -1622,7 +1656,7 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, irange = normalizeRepRange(reps, c.repsMin, stride)reps = range.reps}- const out = { sets, mode: 'reps', reps, weight: Math.max(0, c.weight || 0), ...flags, ...(perSide ? { side: true } : {}), ...prog, ...withNote, ...withWarmups, ...withRest }+ const out = { sets, mode: 'reps', reps, weight: Math.max(0, c.weight || 0), ...flags, ...(perSide ? { side: true } : {}), ...prog, ...withNote, ...withWarmups, ...withRest, ...withMeant }// The list is the prescription; sets and reps follow it, so everything that reads the// flat target (a config sheet reopened with the toggle off, older builds) still makes sense.const list = pyramid ? normalizePyramid(c.pyramid, stride) : []@@ -1863,6 +1897,13 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i: t('Every set becomes rest-pause: {0} reps to start, then {1} more split into short bursts, {2}s rest before each, roughly halving each time.', c.reps || 0, c.intensifier.totalReps, c.intensifier.restSec)}</div>}</>}+ {/* What a dumbbell weight means, for this routine's slot (cfg.dbLoad). Picking what the+ exercise already means drops the key, so the slot follows the exercise's default again. */}+ {isBellEx(ex) && !bw && mode !== 'cardio' && <>+ <h4 className="sec">{t('Weight means')}</h4>+ <DbLoadPicker ex={ex} cfg={c} value={dbLoadFor(st, { ...c, id: ex.id })}+ onChange={v => setC(x => ({ ...x, dbLoad: v === dbLoadFor(st, ex.id) ? undefined : v }))} />+ </>}{/* How the weight is plate-loaded and what the bar weighs — per exercise, not per plan, soit sits apart from the config fields above and writes straight to S.barWeights/S.loadKind. */}{mode === 'reps' && <>@@ -3141,7 +3182,8 @@ function doFinishWorkout() {if (!past) A.entries.forEach(e => {const loads = e.sets.filter(s => s.done && !isWarmupRow(s)).map(s => s.w).filter(w => w > 0)const mx = loads.length ? loads.reduce((a, b) => betterWeight(e.id, a, b)) : 0- if (beatsWeight(e.id, mx, bestWeightFor(st, e.id))) prs.push(e.id)+ // Held against history read the way this session logged a dumbbell weight (lib/dumbbells.js).+ if (beatsWeight(e.id, mx, bestWeightFor(st, e.id, entryDbLoad(e)))) prs.push(e.id)// A heavier estimate without a heavier top set is its own kind of progress —// same weight for more reps. Reported separately so it can't be read as a load PR.const rec = is1RMRecord(st, e.id, e)diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.jsindex 0650de78a..9a99a9029 100644--- a/frontend/src/store/useStore.js+++ b/frontend/src/store/useStore.js@@ -162,6 +162,10 @@ export const DEF = {// leg press is 'single'; a barbell you never load plates on is 'none'. Absent or null = derived// from the equipment. Stamped like the plate list, for the same reason.loadKind: {},+ // What a dumbbell or kettlebell weight means, keyed by exercise id: { mode: 'each' | 'total' |+ // null, _ts } (lib/dumbbells.js). Absent or null = as entered, counted once, which is how every+ // set was read before the choice existed. A routine slot can say its own (cfg.dbLoad).+ dbLoad: {},// Gym check-in cards (see views/CheckIn.jsx). Each is a membership// code shown as a QR/barcode at the gym's turnstile — added by typing it, importing a photo// of the card, or scanning it. We only ever keep the code's VALUE, never a photo: the imagediff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsxindex 8a83be88d..5c46b36fb 100644--- a/frontend/src/views/Stats.jsx+++ b/frontend/src/views/Stats.jsx@@ -16,6 +16,7 @@ import { fatigueOf, strengthOf, STRENGTH_FLOOR, LB_TO_KG } from '../lib/recoveryimport { strengthExerciseRowsForMuscle } from '../lib/strength-exercises.js'import { fatigueStateOf } from '../lib/recovery-view.js'import { e1rmSeries, best1RM, formulaOf } from '../lib/onerm.js'+import { currentDbLoad, workoutAs } from '../lib/dumbbells.js'import { maxRepsSeries } from '../lib/pyramid.js'import { perSetSessions, perSetLines, dropOffSet } from '../lib/per-set.js'import {@@ -421,8 +422,11 @@ export default function Stats() {const workouts = S.workoutsconst monthW = workouts.filter(w => workoutDay(w)?.slice(0, 7) === todayISO().slice(0, 7)).length+ // Dumbbell weights are read in each exercise's current meaning (lib/dumbbells.js), so the+ // chart and its best compare like with like across a switch between per bell and total.+ const meantIn = {}const metricDataOf = (workout, id) => {- const entries = metricEntriesForExercise(workout, id)+ const entries = metricEntriesForExercise(workoutAs(workout, id, meantIn[id] ??= currentDbLoad(S, id)), id)const mode = entries.at(-1)?.mode || nullconst sameMode = entries.filter(item => item.mode === mode)const best = mode === 'reps' ? sameMode.reduce((value, item) => {diff --git a/frontend/src/views/Workout.dumbbells.test.jsx b/frontend/src/views/Workout.dumbbells.test.jsxnew file mode 100644index 000000000..6ea334bb4--- /dev/null+++ b/frontend/src/views/Workout.dumbbells.test.jsx@@ -0,0 +1,62 @@+// @vitest-environment happy-dom+// Dumbbells on the workout screen: the weight column says what the number means when the exercise+// said (issue #474), and stays "Weight" for one-arm work and for everything as entered.+import React, { act } from 'react'+import { createRoot } from 'react-dom/client'+import { MemoryRouter } from 'react-router-dom'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import Workout from './Workout.jsx'+import { DEF, useStore } from '../store/useStore.js'+import { useUI } from '../store/useUI.js'+import { EXIDX } from '../lib/exercises.js'++vi.mock('../lib/sound.js', () => ({ beep: vi.fn(), vibrate: vi.fn(), alertBuzz: vi.fn(), unlock: vi.fn(), restOver: vi.fn() }))+vi.mock('../lib/api.js', () => ({ api: vi.fn(() => Promise.resolve({})) }))++globalThis.IS_REACT_ACT_ENVIRONMENT = true+const clone = value => JSON.parse(JSON.stringify(value))++const BENCH = '0289' // dumbbell bench press+const ROW = '0292' // dumbbell one arm bent-over row++const work = w => ({ w, r: 8, done: false })+const entry = (id, sets, target = {}) => ({ id, target: { sets: sets.length, reps: 8, mode: 'reps', ...target }, sets })++let root, container+beforeEach(() => { useUI.setState({ sheets: [], toastMsg: '', timer: null, work: null }) })+afterEach(() => {+ if (root) act(() => root.unmount())+ if (container) container.remove()+ root = container = null+})++function mount(entries, patch = {}) {+ const S = clone(DEF)+ S.unit = 'kg'+ S.workoutView = 'list'+ Object.assign(S, patch)+ S.active = { id: 'db-test', d: '2026-10-09', start: Date.now(), routineId: null, name: 'Dumbbells', bw: null, cur: 0, entries, workoutView: S.workoutView }+ useStore.setState({ S, user: null })+ container = document.createElement('div')+ document.body.appendChild(container)+ root = createRoot(container)+ act(() => root.render(<MemoryRouter><Workout /></MemoryRouter>))+}+const heads = () => [...container.querySelectorAll('.sethead .w-sp')].map(el => el.textContent)++describe('dumbbell weight column', () => {+ it('the exercises used here are what the test assumes', () => {+ expect(EXIDX[BENCH].eq).toBe('dumbbell')+ expect(EXIDX[ROW].n).toMatch(/one arm/)+ })++ it('names the meaning the session logs in', () => {+ mount([entry(BENCH, [work(20)], { dbLoad: 'each' }), entry(BENCH, [work(40)], { dbLoad: 'total' })])+ expect(heads()).toEqual(['Each (kg)', 'Both (kg)'])+ })++ it('stays Weight as entered and for one-arm work', () => {+ mount([entry(BENCH, [work(20)]), entry(ROW, [work(30)], { dbLoad: 'each' })])+ expect(heads()).toEqual(['Weight (kg)', 'Weight (kg)'])+ })+})diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex 2843f697f..344a95400 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -43,6 +43,7 @@ import { canMoveActiveWorkoutUnit, moveActiveWorkoutUnit, canMoveActiveWorkoutEnimport { nextOpenSet, workoutKeyAction } from '../lib/workout-keys.js'import { MUSCLE_NAME } from '../lib/muscles.js'import FocusView from './FocusView.jsx'+import { withMeaning, historyAs, dbLoadFor, entryDbLoad, bellsIn } from '../lib/dumbbells.js'// How long after a key starts a hold the same key is not yet its "Done" (#133). A USB button// that bounces, or a double press, sends two presses a moment apart: the first starts the hold,@@ -188,7 +189,10 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi// The number is the heaviest logged set, or the working weight you kept.// On an assistance machine the best is the least help, and a 0 on either side means "nothing// logged" rather than a record (issue #232).- const bestHist = bestWeightFor(H, entry.id)+ // Read in the meaning this session logs a dumbbell weight in (lib/dumbbells.js), so a past+ // "40 total" is not a record a "22 each" set has to beat.+ const meaning = entryDbLoad(entry)+ const bestHist = bestWeightFor(H, entry.id, meaning)const bestKept = (H.exWeights[entry.id] || {}).w || 0const best = cardio ? 0: bestHist > 0 && bestKept > 0 ? betterWeight(entry.id, bestHist, bestKept) : Math.max(bestHist, bestKept)@@ -224,7 +228,7 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi// the number to beat. Tapping the line switches between the two, and the choice is the// profile's (S.logRef), so every exercise and the next session follow it.const refBest = S.logRef === 'best'- const ref = refBest ? bestSetFor(H, entry.id, mode) : last+ const ref = refBest ? bestSetFor(H, entry.id, mode, meaning) : last// An exercise logged before only in another mode (reps then, a hold today) has a last time but// no best set to hold today's rows against. The line stays and says so: gone, it took the// switch back to "Last time" with it, reachable then only from Settings or another card.@@ -255,7 +259,11 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi// R sub-row, each with its own weight/reps/effort and done tick. Warm-ups stay single.const perSide = mode === 'reps' && isPerSide(cfg)const loadStep = mode === 'reps' ? weightIncrement(cfg, S.unit) : 2.5- const loadCol = { f: 'w', step: loadStep, dec: true, hd: bw ? t('Added ({0})', S.unit) : t('Weight ({0})', S.unit) }+ // The weight column says what a dumbbell weight means when the exercise has said (#474): one+ // bell or both together. A one-arm exercise holds one bell, so its plain heading is already true.+ const bells = !bw && bellsIn(cfg) === 2 ? meaning : 'as'+ const loadCol = { f: 'w', step: loadStep, dec: true, hd: bw ? t('Added ({0})', S.unit)+ : bells === 'each' ? t('Each ({0})', S.unit) : bells === 'total' ? t('Both ({0})', S.unit) : t('Weight ({0})', S.unit) }// The reps column is the total in every mode, unilateral included — the stepper walks in// twos there so the number you land on is one you can actually split evenly.const repCol = { f: 'r', step: repStep(cfg), dec: false, hd: t('Reps') }@@ -1351,8 +1359,10 @@ function ActiveWorkout() {// source, target); freestyle reproduces what you did last time.// Read from before the session's day when it is logged into the past (sessionHistory).const past = sessionHistory(s)+ // Freestyle stamps the meaning of a dumbbell weight and reads last time in it, the way+ // buildPlannedEntry does for a planned exercise (lib/dumbbells.js).const built = freestyle- ? { target: { ...cfg }, plan: null, sets: applyIntensifierPlan(buildSets(past, full, {+ ? { target: withMeaning(s, cfg, ex.id), plan: null, sets: applyIntensifierPlan(buildSets(historyAs(past, ex.id, dbLoadFor(s, full)), full, {step: modeOf(full) === 'reps' ? weightIncrement(full, s.unit) : defaultIncrement(ex.id, s.unit), preferLast: true,}), full, dropGrid(s, full)) }: buildPlannedEntry(past, full, routine, { noProg })