Skip to content

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.

feat: sets to failure

Duarte Santos4dc65a970d96
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1023daec3..d9673464b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,15 @@
## Unreleased
+**Training**
+
+- **Sets to failure**: mark any set as taken to failure from its set menu and it gets a little
+ purple "F". It counts as RIR 0 in your effort stats and the fatigue map (unless you rated it
+ yourself) and stays a normal work set for volume and records. Plan it too: "Last set to failure"
+ in an exercise's settings makes the final set an all-out one every session, and Greyskull
+ switches it on for you. The "F" shows in history, the finish summary and Copy as text, and Hevy
+ and CSV imports keep it.
+
**Languages**
- 🇵🇱 **Polish exercise names**: all 1,324 of them, with the same switch to show the English name
diff --git a/api/coach/core/payload.js b/api/coach/core/payload.js
index f03616f0e..493cb4180 100644
--- a/api/coach/core/payload.js
+++ b/api/coach/core/payload.js
@@ -349,8 +349,9 @@ function trainedIds(S, workouts) {
// while stalls and trends already live in `aggregates`, computed over the full window.
export const FULL_DETAIL_SESSIONS = 3;
+// A set taken to failure (the app's "F", `failure: true`) is RIR 0 when nothing was rated.
const fmtSet = s => {
- const eff = s.rir != null ? '@RIR' + s.rir : s.rpe != null ? '@RPE' + s.rpe : '';
+ const eff = s.rir != null ? '@RIR' + s.rir : s.rpe != null ? '@RPE' + s.rpe : s.failure === true && !isWarmupSet(s) ? '@failure' : '';
if (s.sec != null) return s.sec + 's' + eff;
if (s.min != null) return s.min + 'min' + (s.speed != null ? '/' + s.speed : '') + eff;
return (s.w != null ? s.w + 'x' : '') + (s.r != null ? s.r : '?') + eff;
@@ -360,6 +361,7 @@ const fmtSet = s => {
function cleanSet(s) {
const o = { done: !!s.done };
if (isWarmupSet(s)) o.warmup = true;
+ else if (s.failure === true) o.failure = true;
for (const k of ['w', 'r', 'sec', 'min', 'speed', 'rir', 'rpe']) if (num(s[k]) !== undefined) o[k] = s[k];
return o;
}
diff --git a/api/test/payload.test.js b/api/test/payload.test.js
index 2fc0fb0fd..e2cd95a15 100644
--- a/api/test/payload.test.js
+++ b/api/test/payload.test.js
@@ -231,6 +231,19 @@ test('a debrief payload carries one session, its predecessors of the same routin
assert.ok(p.bodyweight.series.every(b => b.d <= '2026-07-20'));
});
+test('a set taken to failure reaches the coach as failure, a warm-up never does', () => {
+ const S = debriefState();
+ const w2 = S.workouts.find(w => w.id === 'w2');
+ w2.entries[0].sets[0].failure = true;
+ w2.entries[0].sets[2].failure = true;
+ const p = payload.build(S, { handle: handleFor('u'), kind: 'debrief', workoutId: 'w2' });
+ const sets = p.session.entries[0].sets;
+ assert.equal(sets[0].warmup, true);
+ assert.equal('failure' in sets[0], false);
+ assert.equal('failure' in sets[1], false);
+ assert.equal(sets[2].failure, true);
+});
+
test('an unknown workout id falls back to the latest session', () => {
const p = payload.build(debriefState(), { handle: handleFor('u'), kind: 'debrief', workoutId: 'nope' });
assert.equal(p.session.id, 'w2');
diff --git a/docs/dev/SET_TYPES.md b/docs/dev/SET_TYPES.md
index 771b9cc0f..211d342a6 100644
--- a/docs/dev/SET_TYPES.md
+++ b/docs/dev/SET_TYPES.md
@@ -186,3 +186,23 @@ All new strings are translated in `locales/es.js` (the other ten locales fall ba
- Planning which *specific* sets of an exercise get the intensifier — it's all-or-nothing per
exercise (every set), which is what was asked for; a "last set only" option would need a
per-row opt-out on top of this.
+
+## Sets to failure (v1.4.0)
+
+A third, independent mark: `failure: true` on a row (written only when on), for a set taken to
+failure. It is not a `type`, because a drop-set or a rest-pause set can be taken to failure too.
+
+- `isFailureSet(set)` / `toggleFailure(set)` in `workout-model.js`. A warm-up is never one, even
+ if it carries the key.
+- Effort: `effort.js rirOf` reads a failure set as RIR 0 when nothing was rated by hand, so the
+ effort stats, the "hard sets" filter and the fatigue model (`recovery.js resolveSetRir`, which
+ calls `rirOf` first) all agree. A logged RIR/RPE wins.
+- Everything that reads `w`/`r` is unchanged: volume, records, 1RM and progression treat it as the
+ work set it is.
+- Shown as an "F": on the set number in the workout (cards, list, compact), on the focus card, in
+ `setLabel` (history, text export, the set menu, MCP labels) and on the finish summary.
+- Planned with `cfg.lastToFailure: true` ("Last set to failure" in `ExConfig`): `applyFailurePlan`
+ in `history.js`, run inside `applyIntensifierPlan`, marks the last work row (both halves of a
+ timed per-side pair) of a freshly built exercise. Choosing Greyskull in the sheet turns it on.
+- Imports: a Hevy or CSV "failure" set type becomes `failure: true`.
+
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 3b1a7318f..941bf68cd 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -1327,6 +1327,9 @@ body.chips-dragging *{cursor:inherit}
.plateline .moves{margin-inline-start:auto;color:var(--label-3);font-variant-numeric:tabular-nums;white-space:nowrap}
/* The number is the set's menu (drop / burst / remove); a 24px circle needs a finger-sized hit area. */
.setrow .n::before{content:'';position:absolute;inset:-10px}
+/* A set taken to failure: a small "F" on the number's corner, in the colour the effort scale
+ gives "nothing left" (effort.js EFFORT_BANDS). */
+.setrow .n .failmark,.setrow-side>.n .failmark{position:absolute;top:-5px;inset-inline-end:-6px;min-width:13px;height:13px;padding:0 2px;border-radius:7px;background:var(--purple);color:#fff;font-size:9px;font-weight:700;line-height:13px;text-align:center;pointer-events:none}
/* No +/- buttons: the number field takes the whole cell and is the tap target. */
.stp.plain{grid-template-columns:1fr}
.stp.plain .val{width:100%}
diff --git a/frontend/src/lib/effort.js b/frontend/src/lib/effort.js
index 6254cfd68..3e5e57596 100644
--- a/frontend/src/lib/effort.js
+++ b/frontend/src/lib/effort.js
@@ -8,7 +8,7 @@
// floor of 6 is only a convention about which sets are worth rating. RPE 8 == RIR 2.
import { EFFORT, effortOf, workoutAt } from './history.js'
import { weekKey, weekStartOf, startOfWeek } from './format.js'
-import { isWarmupRow } from './workout-model.js'
+import { isWarmupRow, isFailureSet } from './workout-model.js'
import { isAssisted } from './exercises.js'
// At or below this a set is close enough to failure to be the kind that drives adaptation.
@@ -19,9 +19,13 @@ export const HARD_RIR = 3
// like a finding when it is one tap, so the callers show a dash instead.
export const MIN_RATED = 5
-/** A set's effort in RIR, or null when it was never rated. 0 is a rating, not "empty". */
+/**
+ * A set's effort in RIR, or null when it was never rated. 0 is a rating, not "empty". A set
+ * marked as taken to failure (workout-model isFailureSet) is RIR 0 by definition, so it reads as
+ * one when nothing was rated; a rating typed in by hand still wins, it is the more exact of the two.
+ */
export const rirOf = s =>
- !s ? null : s.rir != null ? s.rir : s.rpe != null ? 10 - s.rpe : null
+ !s ? null : s.rir != null ? s.rir : s.rpe != null ? 10 - s.rpe : isFailureSet(s) ? 0 : null
/** RIR → the scale being displayed. The reverse of rirOf, for one number. */
export const toScale = (kind, rir) =>
diff --git a/frontend/src/lib/failure-sets.test.js b/frontend/src/lib/failure-sets.test.js
new file mode 100644
index 000000000..781a57943
--- /dev/null
+++ b/frontend/src/lib/failure-sets.test.js
@@ -0,0 +1,184 @@
+import { describe, it, expect } from 'vitest'
+import { isFailureSet, toggleFailure, makeSideSet } from './workout-model.js'
+import { rirOf, effortSummary, effortHistogram, isHardSet, hasEffort } from './effort.js'
+import { resolveSetRir, anchorsByWorkout } from './recovery.js'
+import { setLabel, workoutVolume, applyFailurePlan, applyIntensifierPlan, copyRowAt, makeWarmupAt } from './history.js'
+import { buildSessionEntries } from './session-start.js'
+import { readSession, nextPrescription } from './progression.js'
+import { workoutText } from './workout-text.js'
+import { finishCompare } from './finish-compare.js'
+import { buildPlanBundle, parsePlan, planPrintHTML } from './plan-share.js'
+
+// Sets to failure (Discord request, roadmap v1.4.2 "a universal AMRAP / to failure flag"): an
+// optional `failure: true` on a row, and `lastToFailure: true` on a planned exercise.
+const work = rows => rows.filter(s => s.phase !== 'warmup')
+
+describe('the to-failure mark on a row', () => {
+ it('is only ever on a work set, and toggles off to the row it was', () => {
+ expect(isFailureSet({ w: 60, r: 8, failure: true })).toBe(true)
+ expect(isFailureSet({ w: 60, r: 8 })).toBe(false)
+ expect(isFailureSet({ w: 40, r: 8, failure: true, phase: 'warmup' })).toBe(false)
+ expect(isFailureSet(null)).toBe(false)
+ const row = { w: 60, r: 8, done: true }
+ const on = toggleFailure(row)
+ expect(on).toEqual({ w: 60, r: 8, done: true, failure: true })
+ expect(toggleFailure(on)).toEqual(row)
+ expect('failure' in toggleFailure(on)).toBe(false)
+ })
+
+ it('survives on a per-side row and is copied with the set, but not into a warm-up', () => {
+ const side = { ...makeSideSet({ w: 20, r: 16 }), failure: true }
+ expect(isFailureSet(side)).toBe(true)
+ const copied = copyRowAt([{ w: 60, r: 8, done: true, failure: true }], 0)
+ expect(copied[1]).toEqual({ w: 60, r: 8, done: false, failure: true })
+ const warm = makeWarmupAt([{ w: 60, r: 8 }, { w: 60, r: 8, failure: true }], 1)
+ expect(warm[0].failure).toBeUndefined()
+ })
+})
+
+describe('effort reads a failure set as RIR 0', () => {
+ it('when nothing was rated, and a logged rating still wins', () => {
+ expect(rirOf({ w: 60, r: 8, failure: true })).toBe(0)
+ expect(rirOf({ w: 60, r: 8, failure: true, rir: 1 })).toBe(1)
+ expect(rirOf({ w: 60, r: 8, failure: true, rpe: 9 })).toBe(1)
+ expect(rirOf({ w: 60, r: 8 })).toBeNull()
+ // A warm-up carrying the key is still not a failure set.
+ expect(rirOf({ w: 40, r: 8, failure: true, phase: 'warmup' })).toBeNull()
+ expect(isHardSet({ w: 60, r: 8, failure: true })).toBe(true)
+ })
+
+ it('counts in the effort summary and histogram as rated sets at 0', () => {
+ const sets = [1, 2, 3, 4, 5].map(() => ({ w: 60, r: 8, done: true, failure: true }))
+ const S = { workouts: [{ d: '2026-10-01', start: Date.now(), entries: [{ id: '0025', sets: [{ w: 60, r: 8, done: true }, ...sets] }] }] }
+ expect(hasEffort(S)).toBe(true)
+ const sum = effortSummary(S, 0)
+ expect(sum).toMatchObject({ done: 6, rated: 5, est: 0, hard: 5, avg: 0 })
+ expect(effortHistogram(S, 0)[0].n).toBe(5)
+ })
+
+ it('feeds the fatigue model as a logged RIR 0, ahead of the load estimate', () => {
+ const entry = { id: '0025', sets: [{ w: 100, r: 5, done: true }, { w: 60, r: 8, done: true, failure: true }] }
+ const workout = { d: '2026-10-01', start: Date.parse('2026-10-01T10:00:00'), entries: [entry] }
+ const anchors = anchorsByWorkout([workout]).get(workout)
+ const plain = resolveSetRir({ w: 60, r: 8, done: true }, null, entry, workout, anchors)
+ expect(plain.source).not.toBe('logged')
+ expect(plain.rir).toBeGreaterThan(0)
+ const failed = entry.sets[1]
+ expect(resolveSetRir(failed, failed, entry, workout, anchors)).toEqual({ rir: 0, source: 'logged' })
+ expect(resolveSetRir({ ...failed, rir: 2 }, failed, entry, workout, anchors)).toEqual({ rir: 2, source: 'logged' })
+ })
+})
+
+describe('a failure set stays a work set', () => {
+ it('for volume and for progression', () => {
+ const plain = { entries: [{ id: '0025', sets: [{ w: 60, r: 8, done: true }, { w: 60, r: 8, done: true }] }] }
+ const failed = { entries: [{ id: '0025', sets: [{ w: 60, r: 8, done: true }, { w: 60, r: 8, done: true, failure: true }] }] }
+ expect(workoutVolume(failed)).toBe(workoutVolume(plain))
+ const target = { sets: 2, reps: 8, weight: 60 }
+ expect(readSession({ id: '0025', target, sets: failed.entries[0].sets }, target))
+ .toEqual(readSession({ id: '0025', target, sets: plain.entries[0].sets }, target))
+ })
+
+ it('Greyskull still reads the planned last set as its AMRAP', () => {
+ const cfg = { id: '0025', sets: 3, reps: 5, weight: 60, prog: 'greyskull', lastToFailure: true }
+ const sets = [5, 5, 10].map((r, i) => ({ w: 60, r, done: true, ...(i === 2 ? { failure: true } : {}) }))
+ const S = { unit: 'kg', workouts: [{ d: '2026-10-01', entries: [{ id: '0025', target: { ...cfg }, sets }] }] }
+ const p = nextPrescription(S, cfg, null)
+ expect(p.kind).toBe('up')
+ expect(p.weight).toBe(65)
+ })
+})
+
+describe('"Last set to failure" in a plan', () => {
+ const st = { unit: 'kg', workouts: [], exWeights: {}, routines: [] }
+
+ it('marks only the last work set of a freshly built exercise', () => {
+ const r = { id: 'r', prog: 'off', ex: [{ id: '0025', sets: 3, reps: 5, weight: 60, warmupSets: 2, lastToFailure: true }] }
+ const [entry] = buildSessionEntries(st, r)
+ expect(entry.sets.filter(s => s.failure)).toHaveLength(1)
+ expect(entry.sets.at(-1).failure).toBe(true)
+ expect(entry.sets.filter(s => s.phase === 'warmup' && s.failure)).toHaveLength(0)
+ expect(entry.target.lastToFailure).toBe(true)
+ })
+
+ it('leaves a plan without it exactly as it built before', () => {
+ const r = { id: 'r', prog: 'off', ex: [{ id: '0025', sets: 3, reps: 5, weight: 60 }] }
+ const [entry] = buildSessionEntries(st, r)
+ expect(entry.sets.some(s => 'failure' in s)).toBe(false)
+ })
+
+ it('marks the last set a progression added, not the one it copied (bodyweight sets)', () => {
+ const cfg = { id: '0001', sets: 2, reps: 10, repsMax: 10, bodyweight: true, weight: 0, prog: 'linear', lastToFailure: true }
+ const done = [10, 10].map(r => ({ w: 0, r, done: true }))
+ const S = { ...st, workouts: [{ d: '2026-10-01', entries: [{ id: '0001', target: { ...cfg }, planned: { sets: 2, reps: 10 }, sets: done }] }] }
+ const [entry] = buildSessionEntries(S, { id: 'r', ex: [cfg] })
+ const rows = work(entry.sets)
+ expect(rows).toHaveLength(3)
+ expect(rows.map(s => !!s.failure)).toEqual([false, false, true])
+ })
+
+ it('takes both halves of a timed per-side hold, never a logged row, never cardio', () => {
+ const timed = applyFailurePlan([{ sec: 30, side: 'L' }, { sec: 30, side: 'R' }, { sec: 30, side: 'L' }, { sec: 30, side: 'R' }], { id: '0025', mode: 'time', side: true, lastToFailure: true })
+ expect(timed.map(s => !!s.failure)).toEqual([false, false, true, true])
+ const logged = applyFailurePlan([{ w: 60, r: 5 }, { w: 60, r: 5, done: true }], { id: '0025', lastToFailure: true })
+ expect(logged[1].failure).toBeUndefined()
+ const cardio = [{ min: 20, speed: 8 }]
+ expect(applyFailurePlan(cardio, { id: '0025', mode: 'cardio', lastToFailure: true })).toBe(cardio)
+ })
+
+ it('marks the rest-pause work set of a rest-pause plan', () => {
+ const rows = applyIntensifierPlan([{ w: 60, r: 8 }], { id: '0025', reps: 8, intensifier: { type: 'restpause', totalReps: 12, restSec: 15 }, lastToFailure: true })
+ expect(rows.map(s => !!s.failure)).toEqual([false, true])
+ })
+
+ it('travels with a shared plan and reads on its printout', () => {
+ const S = { unit: 'kg', week: {}, customEx: [], routines: [{ id: 'r1', name: 'Push', ex: [{ id: '0025', sets: 3, reps: 5, weight: 100, lastToFailure: true }] }] }
+ const bundle = buildPlanBundle(S, 'Plan')
+ expect(bundle.routines[0].ex[0].lastToFailure).toBe(true)
+ expect(parsePlan(JSON.stringify(bundle)).routines[0].ex[0].lastToFailure).toBe(true)
+ const off = buildPlanBundle({ ...S, routines: [{ ...S.routines[0], ex: [{ id: '0025', sets: 3, reps: 5, weight: 100 }] }] }, 'Plan')
+ expect('lastToFailure' in off.routines[0].ex[0]).toBe(false)
+ expect(planPrintHTML(S, 'Me')).toContain('Last set to failure')
+ })
+})
+
+describe('where set types show', () => {
+ it('the set label carries an F, ahead of the effort tail', () => {
+ expect(setLabel('0025', { w: 60, r: 8, done: true, failure: true }, { mode: 'reps' })).toBe('60×8 F')
+ expect(setLabel('0025', { w: 60, r: 8, done: true, failure: true, rir: 1 }, { mode: 'reps' })).toBe('60×8 F (RIR 1)')
+ expect(setLabel('0025', { sec: 45, done: true, failure: true }, { mode: 'time' })).toBe('0:45 F')
+ const side = { ...makeSideSet({ w: 20, r: 16 }), failure: true }
+ expect(setLabel('0025', side, { mode: 'reps', side: true })).toMatch(/ F$/)
+ expect(setLabel('0025', { w: 60, r: 8, done: true }, { mode: 'reps' })).toBe('60×8')
+ })
+
+ it('the text export lists it', () => {
+ const w = { d: '2026-10-01', start: 0, end: 0, name: 'Push', entries: [{ id: 'bench', target: { mode: 'reps' }, sets: [{ w: 60, r: 8, done: true }, { w: 60, r: 11, done: true, failure: true }] }] }
+ expect(workoutText(w, { unit: 'kg', nameOf: () => 'bench' })).toContain('60×8, 60×11 F')
+ })
+
+ it('the finish summary keeps the mark on today’s sets', () => {
+ const now = { id: 'w1', d: '2026-10-03', start: 1, end: 2, entries: [{ id: 'bench', target: { mode: 'reps' }, sets: [{ w: 60, r: 5, done: true }, { w: 60, r: 9, done: true, failure: true }] }] }
+ const [row] = finishCompare({ unit: 'kg', routines: [], workouts: [now] }, now)
+ expect(row.today).toEqual([{ w: 60, r: 5 }, { w: 60, r: 9, f: true }])
+ })
+})
+
+describe('imports keep a failure set', () => {
+ it('from a CSV set type and from Hevy', async () => {
+ const { parseWorkoutCSV } = await import('./import-csv.js')
+ const csv = ['Date,Exercise,Weight,Reps,Set Type', '2026-08-08,Bench Press,80,5,normal', '2026-08-08,Bench Press,80,7,failure'].join('\n')
+ const [plain, failed] = parseWorkoutCSV(csv, { unit: 'kg' }).workouts[0].entries[0].sets
+ expect('failure' in plain).toBe(false)
+ expect(failed.failure).toBe(true)
+ const { parseHevyWorkouts } = await import('./import-hevy.js')
+ const workout = { id: 'h', title: 'Push', start_time: '2026-08-25T10:00:00+00:00', end_time: '2026-08-25T11:00:00+00:00', exercises: [
+ { index: 0, title: 'Bench', exercise_template_id: '79D0BB3A', sets: [
+ { index: 0, type: 'normal', weight_kg: 60, reps: 8 },
+ { index: 1, type: 'failure', weight_kg: 60, reps: 10 },
+ ] },
+ ] }
+ const sets = parseHevyWorkouts([workout], [], { unit: 'kg' }).workouts[0].entries[0].sets
+ expect(sets.map(s => !!s.failure)).toEqual([false, true])
+ })
+})
diff --git a/frontend/src/lib/finish-compare.js b/frontend/src/lib/finish-compare.js
index e71c835c2..955a07f3c 100644
--- a/frontend/src/lib/finish-compare.js
+++ b/frontend/src/lib/finish-compare.js
@@ -2,13 +2,14 @@
// previous session of the same exercise, and what the next session will open at. "Next" has no
// rule of its own: it is buildPlannedEntry, the same call Start makes, run on the state right
// after this workout was saved, so the summary cannot promise a number the next session won't.
-import { isWarmupRow } from './workout-model.js'
+import { isWarmupRow, isFailureSet } from './workout-model.js'
import { buildPlannedEntry } from './session-start.js'
import { workoutAt, modeOf } from './history.js'
const workSets = entry => (Array.isArray(entry?.sets) ? entry.sets : [])
.filter(s => s && s.done && !isWarmupRow(s) && Number(s.r) > 0)
- .map(s => ({ w: Number(s.w) || 0, r: Math.round(Number(s.r)) }))
+ // `f`: taken to failure, so the summary can mark it; written only when true.
+ .map(s => ({ w: Number(s.w) || 0, r: Math.round(Number(s.r)), ...(isFailureSet(s) ? { f: true } : {}) }))
const top = sets => sets.reduce((m, s) => Math.max(m, s.w), 0)
const reps = sets => sets.reduce((n, s) => n + s.r, 0)
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.js
index 5f0290b6e..174566e03 100644
--- a/frontend/src/lib/history.js
+++ b/frontend/src/lib/history.js
@@ -4,7 +4,7 @@ import { todayISO, isoOf, weekKey, weekStartOf, fmtNum } from './format.js'
import { fmtSpeed } from './speed.js'
import { isCardio, isBodyweightEq, isAssisted, betterWeight } from './exercises.js'
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 { phaseForSet, modeForSet, modeForEntry, isWarmupRow, isFailureSet, 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'
const objectOf = value => value && typeof value === 'object' && !Array.isArray(value) ? value : {}
// Completed-state-independent work rows whose authoritative mode matches the requested mode.
@@ -149,7 +149,10 @@ export function setLabel(id, s, cfg, speedUnit) {
// to the volume those same sets still count. A set with reps and nothing cardio was a rep set.
if (!EXPLICIT_MODES.has(cfg?.mode) && mode !== 'reps' && s.r > 0 && !(s.min > 0 || s.speed > 0 || s.sec > 0)) mode = 'reps'
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)}` : '')
+ // A set taken to failure carries its "F" behind the numbers, the mark lifting logs use for it;
+ // the history, the text export and the set menu all read it from here.
+ const fail = isFailureSet(s) ? ' ' + t('F') : ''
+ if (mode === 'time') return fmtSec(s.sec) + (s.w > 0 ? ` · ${fmtNum(s.w)}` : '') + fail
const bw = isBw(c)
const load = (w, reps) => (bw ? (w > 0 ? `+${fmtNum(w)} × ` : '') + 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
@@ -184,11 +187,11 @@ export function setLabel(id, s, cfg, speedUnit) {
return ['L', 'R'].map(key => {
const side = s.sides[key]
return `${t(key)} ${partial && !side.done ? '–' : oneSide(side) + effortTail(side)}`
- }).join(' · ')
+ }).join(' · ') + fail
}
// Bodyweight reads as what you did — "12", or "+10 × 12" once there is a belt involved —
// rather than "0×12", which says a set was performed with no weight and means nothing.
- return oneSide(s) + effortTail(s)
+ return oneSide(s) + fail + effortTail(s)
}
// Default config for a freshly added exercise.
export function defaultConfig(id, mode) {
@@ -636,6 +639,27 @@ function seedSideFromLast(row, prev, planReps) {
* drops sitting underneath it. `grid` puts each drop on a loadable weight (nextDropWeight).
*/
export function applyIntensifierPlan(sets, cfg, grid) {
+ return applyFailurePlan(shapeRows(sets, cfg, grid), cfg)
+}
+
+/**
+ * "Last set to failure" (`cfg.lastToFailure`, written only when on): the last work row of a
+ * freshly built exercise is marked as taken to failure, the way Greyskull's final set is an
+ * AMRAP. Only that one row, and only a row not logged yet; every other row keeps what it had, so
+ * a plan without the flag builds exactly the rows it always did. Runs inside applyIntensifierPlan,
+ * the step every way of building an exercise's rows ends with, so none of them can forget it.
+ */
+export function applyFailurePlan(sets, cfg) {
+ if (!cfg || cfg.lastToFailure !== true || modeOf(cfg) === 'cardio') return sets
+ let last = -1
+ sets.forEach((s, i) => { if (!isWarmupRow(s)) last = i })
+ // A timed per-side hold is an L row and an R row that read as one set: both halves are the set.
+ const from = last > 0 && sets[last]?.side === 'R' && sets[last - 1]?.side === 'L' ? last - 1 : last
+ if (last < 0) return sets
+ return sets.map((s, i) => (i >= from && i <= last && !s.done ? { ...s, failure: true } : s))
+}
+
+function shapeRows(sets, cfg, grid) {
const kind = cfg && cfg.intensifier && cfg.intensifier.type
if (kind !== 'dropset' && kind !== 'restpause') return sets
if (kind === 'dropset') {
diff --git a/frontend/src/lib/import-csv.js b/frontend/src/lib/import-csv.js
index 0246b7ac7..7d340a624 100644
--- a/frontend/src/lib/import-csv.js
+++ b/frontend/src/lib/import-csv.js
@@ -579,6 +579,9 @@ export function parseWorkoutCSV(text, { unit = 'kg', customEx = [] } = {}) {
: isCardio
? { min: mins || 0, speed: mins > 0 ? Math.round(km / (mins / 60) * 10) / 10 : 0, done: true, ...(warmup ? { phase: 'warmup' } : {}) }
: { w, r: reps || 0, done: true, u: rowUnit, ...(warmup ? { phase: 'warmup' } : {}) }
+ // A "failure" set type (Hevy's CSV writes one) is the app's set taken to failure; not on
+ // cardio, which has no effort to read it as.
+ if (!warmup && !isCardio && /^(f|fail|failure)$/i.test(String(cell(r, 'setType') || '').trim())) set.failure = true
// Effort rides along only where the app can show it again: a weighted rep set. A treadmill
// row with an RPE would have nowhere to put it. A set is kept on one scale, so a file
// carrying both columns is read as RIR — the same precedence setLabel reads them back with.
diff --git a/frontend/src/lib/import-hevy.js b/frontend/src/lib/import-hevy.js
index 8df1b4150..fbbd63f1d 100644
--- a/frontend/src/lib/import-hevy.js
+++ b/frontend/src/lib/import-hevy.js
@@ -265,6 +265,8 @@ export function parseHevyWorkouts(workouts, templates, { unit = 'kg', customEx =
const set = isCardio
? { min: mins, speed: mins > 0 ? Math.round(km / (mins / 60) * 10) / 10 : 0, done: true, ...(warmup ? { phase: 'warmup' } : {}) }
: { w: wgt, r: reps || 0, done: true, ...(warmup ? { phase: 'warmup' } : {}) }
+ // Hevy's "failure" set type is the app's set taken to failure (workout-model isFailureSet).
+ if (!isCardio && !warmup && /fail/i.test(String(s.type || ''))) set.failure = true
if (!isCardio && s.rpe != null && isFinite(Number(s.rpe)) && Number(s.rpe) > 0) {
set.rpe = Math.min(10, Math.round(Number(s.rpe) * 100) / 100)
diff --git a/frontend/src/lib/plan-share.js b/frontend/src/lib/plan-share.js
index ecb40573d..d011de41e 100644
--- a/frontend/src/lib/plan-share.js
+++ b/frontend/src/lib/plan-share.js
@@ -100,6 +100,8 @@ function cleanEx(e) {
if (e.inc > 0) o.inc = e.inc
// Back-off sets step down by that same step; written only when on (lib/backoff.js).
if (isBackoff(e)) o.backoff = true
+ // "Last set to failure" is how the exercise is prescribed too; only when on, never on cardio.
+ if (e.lastToFailure === true && mode !== 'cardio') o.lastToFailure = true
// 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
@@ -328,8 +330,8 @@ function scheme(e, unit, speedUnit) {
return sets > 1 ? `${sets} × ${body}` : body
}
const line = exLine({ ...e, reps: e.reps ?? 10 }, unit, speedUnit)
- const intens = intensifierLine(e.intensifier)
- return intens ? `${line} · ${intens}` : line
+ const extras = [intensifierLine(e.intensifier), e.lastToFailure === true ? t('Last set to failure') : ''].filter(Boolean)
+ return [line, ...extras].join(' · ')
}
// A drop-set or rest-pause is how the exercise is prescribed, so the printout names it — the
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js
index 0d1b6d87f..f064a106f 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('9e21f49f0eb1920abe8c205818ccf1da3c7790e7e4574df9945788afca77cfd9')
})
// pt-PT labelled Unpair 'Desfazer': Undo, in Portuguese (it is pt-BR's Undo), on the button that
diff --git a/frontend/src/lib/workout-model.js b/frontend/src/lib/workout-model.js
index 9e92da058..c27184c20 100644
--- a/frontend/src/lib/workout-model.js
+++ b/frontend/src/lib/workout-model.js
@@ -34,6 +34,25 @@ export function setType(set) {
export const isDropSet = set => setType(set) === 'dropset'
export const isRestPauseSet = set => setType(set) === 'restpause'
+// A set taken to failure (Discord request, roadmap "a universal AMRAP / to failure flag"). Not a
+// third `type`: a drop-set or a rest-pause set can be taken to failure as well, so it is its own
+// optional `failure: true` on the row, written only when on. Everything that reads `w`/`r` keeps
+// treating the row as the work set it is (volume, records, progression); only effort reads it, as
+// RIR 0 when nothing was rated by hand (effort.js rirOf). A warm-up is never one, whatever it
+// carries: the phase decides first, the way it does for every other reader.
+export const isFailureSet = set => {
+ const source = objectOf(set)
+ return source.failure === true && !isWarmupRow(source)
+}
+
+/** Flip a row's to-failure mark, dropping the key when it goes off so the row is what it was. */
+export function toggleFailure(set) {
+ const out = { ...objectOf(set) }
+ if (out.failure === true) delete out.failure
+ else out.failure = true
+ return out
+}
+
/** A drop-set's weight drops, oldest first; empty for anything else. */
export function dropsOf(set) {
const source = objectOf(set)
diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.js
index 7b002676a..ede5f9066 100644
--- a/frontend/src/locales/ar.js
+++ b/frontend/src/locales/ar.js
@@ -2213,4 +2213,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'تمارين مشابهة',
'No exact match. These come close:': 'لا تطابق تام. هذه قريبة:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': 'حتى الفشل العضلي',
+ 'Nothing left in the tank': 'لم يبقَ شيء في الخزان',
+ 'Last set to failure': 'المجموعة الأخيرة حتى الفشل',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'تستمر المجموعة الأخيرة حتى لا يبقى شيء، وتُحسب كأقصى جهد ما لم تقيّمها بنفسك.',
+ 'Plan the final set as an all-out one.': 'خطّط للمجموعة الأخيرة بكل ما لديك.',
}
diff --git a/frontend/src/locales/bn.js b/frontend/src/locales/bn.js
index 39745f383..e0695f125 100644
--- a/frontend/src/locales/bn.js
+++ b/frontend/src/locales/bn.js
@@ -2237,4 +2237,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'একই ধরনের ব্যায়াম',
'No exact match. These come close:': 'হুবহু মিল নেই। এগুলো কাছাকাছি:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': 'ফেইলিওর পর্যন্ত',
+ 'Nothing left in the tank': 'ট্যাঙ্কে আর কিছু নেই',
+ 'Last set to failure': 'শেষ সেট ফেইলিওর পর্যন্ত',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'শেষ সেট চলবে যতক্ষণ না আর কিছু বাকি থাকে, আর আপনি নিজে রেট না করলে এটি সর্বোচ্চ প্রচেষ্টা হিসেবে গণ্য হবে।',
+ 'Plan the final set as an all-out one.': 'শেষ সেটটি পুরো শক্তি দিয়ে পরিকল্পনা করুন।',
}
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index a54996bf8..197eb335d 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -2178,4 +2178,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Ähnliche Übungen',
'No exact match. These come close:': 'Kein genauer Treffer. Die hier kommen nah ran:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': 'Bis zum Versagen',
+ 'Nothing left in the tank': 'Nichts mehr im Tank',
+ 'Last set to failure': 'Letzter Satz bis zum Versagen',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'Der letzte Satz geht, bis nichts mehr geht, und zählt als volle Anstrengung, solange du ihn nicht selbst bewertest.',
+ 'Plan the final set as an all-out one.': 'Plane den letzten Satz als Vollgas-Satz.',
}
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index fbfa422c9..f23836a4c 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -2158,4 +2158,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Ejercicios parecidos',
'No exact match. These come close:': 'Nada exacto. Estos se acercan:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': 'Al fallo',
+ 'Nothing left in the tank': 'No queda nada en el depósito',
+ 'Last set to failure': 'Última serie al fallo',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'La última serie va hasta que no quede nada y cuenta como esfuerzo máximo, salvo que la valores tú.',
+ 'Plan the final set as an all-out one.': 'Planea la última serie a tope.',
}
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index 6dd9b5430..8424673af 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -2158,4 +2158,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Exercices similaires',
'No exact match. These come close:': 'Rien d’exact. Ceux-ci s’en approchent :',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': 'Jusqu’à l’échec',
+ 'Nothing left in the tank': 'Plus rien dans le réservoir',
+ 'Last set to failure': 'Dernière série jusqu’à l’échec',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'La dernière série va jusqu’à ce qu’il ne reste rien, et compte comme un effort maximal, sauf si tu la notes toi-même.',
+ 'Plan the final set as an all-out one.': 'Prévois la dernière série à fond.',
}
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index 57b07f370..e0a6b0ba5 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -2158,4 +2158,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'मिलते-जुलते व्यायाम',
'No exact match. These come close:': 'सटीक मेल नहीं मिला। ये करीब हैं:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': 'फेलियर तक',
+ 'Nothing left in the tank': 'टंकी में कुछ नहीं बचा',
+ 'Last set to failure': 'आख़िरी सेट फेलियर तक',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'आख़िरी सेट तब तक चलता है जब तक कुछ न बचे, और जब तक आप ख़ुद रेट न करें, इसे पूरी ताक़त वाला प्रयास माना जाता है।',
+ 'Plan the final set as an all-out one.': 'आख़िरी सेट को पूरी ताक़त वाला बनाएँ।',
}
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index a496dfb81..a7cc0f1a1 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -2161,4 +2161,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Hasonló gyakorlatok',
'No exact match. These come close:': 'Nincs pontos találat. Ezek közel állnak:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': 'Bukásig',
+ 'Nothing left in the tank': 'Üres a tank',
+ 'Last set to failure': 'Utolsó sorozat bukásig',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'Az utolsó sorozat addig tart, amíg semmi sem marad, és teljes erőbedobásnak számít, hacsak nem értékeled magad.',
+ 'Plan the final set as an all-out one.': 'Tervezd az utolsó sorozatot teljes erővel.',
}
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index 8c3d96f6f..5f1a2da93 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -2158,4 +2158,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Esercizi simili',
'No exact match. These come close:': 'Niente di esatto. Questi ci vanno vicino:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': 'A cedimento',
+ 'Nothing left in the tank': 'Serbatoio vuoto',
+ 'Last set to failure': 'Ultima serie a cedimento',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'L’ultima serie va finché non resta niente e conta come sforzo massimo, a meno che tu non la valuti.',
+ 'Plan the final set as an all-out one.': 'Pianifica l’ultima serie a tutta.',
}
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index c906b2b53..f091b8dc3 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -2158,4 +2158,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': '비슷한 운동',
'No exact match. These come close:': '정확히 일치하는 항목이 없어요. 이건 비슷해요:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': '실패 지점까지',
+ 'Nothing left in the tank': '남은 힘 없음',
+ 'Last set to failure': '마지막 세트는 실패 지점까지',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': '마지막 세트는 힘이 남지 않을 때까지 하고, 직접 평가하지 않으면 최대 노력으로 계산돼요.',
+ 'Plan the final set as an all-out one.': '마지막 세트를 전력으로 계획해요.',
}
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index 0525f3041..4826b409f 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -2158,4 +2158,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Podobne ćwiczenia',
'No exact match. These come close:': 'Brak dokładnego dopasowania. Te są blisko:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': 'Do upadku',
+ 'Nothing left in the tank': 'Bak pusty',
+ 'Last set to failure': 'Ostatnia seria do upadku',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'Ostatnia seria trwa, aż nic nie zostanie, i liczy się jako maksymalny wysiłek, chyba że dasz jej własną ocenę.',
+ 'Plan the final set as an all-out one.': 'Zaplanuj ostatnią serię na maksa.',
}
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index 9f283b0d1..5cefbd9e2 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:',
+ // --- sets to failure (v1.4.0) ---
+ 'Taken to failure': 'Até a falha',
+ 'Nothing left in the tank': 'Tanque vazio',
+ 'Last set to failure': 'Última série até a falha',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'A última série vai até não sobrar nada e conta como esforço máximo, a menos que você dê uma nota.',
+ 'Plan the final set as an all-out one.': 'Planeje a última série com tudo.',
}
export default { ...pt, ...PT_BR_OVERRIDES }
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index 31486ba97..8fe210429 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -2158,4 +2158,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Exercícios semelhantes',
'No exact match. These come close:': 'Nada exato. Estes andam perto:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': 'Até à falha',
+ 'Nothing left in the tank': 'Depósito vazio',
+ 'Last set to failure': 'Última série até à falha',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'A última série vai até não sobrar nada e conta como esforço máximo, a menos que lhe dês uma nota.',
+ 'Plan the final set as an all-out one.': 'Planeia a última série a fundo.',
}
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index 9bbf9caa1..59063553e 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -2162,4 +2162,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Похожие упражнения',
'No exact match. These come close:': 'Точного совпадения нет. Вот что близко:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': 'До отказа',
+ 'Nothing left in the tank': 'Бак пуст',
+ 'Last set to failure': 'Последний подход до отказа',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'Последний подход идёт, пока не останется сил, и считается максимальным усилием, если вы не оцените его сами.',
+ 'Plan the final set as an all-out one.': 'Запланируйте последний подход на максимум.',
}
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index 475397099..c167b7645 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -2169,4 +2169,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'ท่าที่คล้ายกัน',
'No exact match. These come close:': 'ไม่พบที่ตรงทั้งหมด ท่าเหล่านี้ใกล้เคียง:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': 'จนหมดแรง',
+ 'Nothing left in the tank': 'หมดถังแล้ว',
+ 'Last set to failure': 'เซ็ตสุดท้ายจนหมดแรง',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'เซ็ตสุดท้ายเล่นจนไม่เหลือแรง และนับเป็นความพยายามเต็มที่ เว้นแต่คุณจะให้คะแนนเอง',
+ 'Plan the final set as an all-out one.': 'วางแผนเซ็ตสุดท้ายแบบสุดแรง',
}
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index edf569226..f8ec5f8be 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -2158,4 +2158,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Benzer egzersizler',
'No exact match. These come close:': 'Tam eşleşme yok. Bunlar yakın:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': 'Tükenişe kadar',
+ 'Nothing left in the tank': 'Depoda bir şey kalmadı',
+ 'Last set to failure': 'Son set tükenişe kadar',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'Son set hiçbir şey kalmayana kadar sürer ve sen puanlamadıkça tam efor sayılır.',
+ 'Plan the final set as an all-out one.': 'Son seti tam gaz planla.',
}
diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.js
index fad71d4f9..43b2b03b1 100644
--- a/frontend/src/locales/uk.js
+++ b/frontend/src/locales/uk.js
@@ -2155,4 +2155,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Схожі вправи',
'No exact match. These come close:': 'Точного збігу немає. Ось що близько:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': 'До відмови',
+ 'Nothing left in the tank': 'Бак порожній',
+ 'Last set to failure': 'Останній підхід до відмови',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': 'Останній підхід триває, доки не залишиться сил, і рахується як максимальне зусилля, якщо ти не оціниш його.',
+ 'Plan the final set as an all-out one.': 'Заплануй останній підхід на максимум.',
}
diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.js
index ad7411e1d..f0b6b8731 100644
--- a/frontend/src/locales/zh-TW.js
+++ b/frontend/src/locales/zh-TW.js
@@ -2151,4 +2151,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': '相似動作',
'No exact match. These come close:': '沒有完全符合,這些比較接近:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': '做到力竭',
+ 'Nothing left in the tank': '油箱見底了',
+ 'Last set to failure': '最後一組做到力竭',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': '最後一組做到一點不剩,除非你自己評分,否則按全力計算。',
+ 'Plan the final set as an all-out one.': '把最後一組安排成全力組。',
}
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index c7b7277d9..908001131 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -2158,4 +2158,11 @@ export default {
// --- search: similar exercises ---
'Similar exercises': '相似动作',
'No exact match. These come close:': '没有完全匹配,这些比较接近:',
+ // --- sets to failure (v1.4.0) ---
+ 'F': 'F',
+ 'Taken to failure': '做到力竭',
+ 'Nothing left in the tank': '油箱见底了',
+ 'Last set to failure': '最后一组做到力竭',
+ 'The last set goes until nothing is left, and counts as all-out effort unless you rate it.': '最后一组做到一点不剩,除非你自己打分,否则按全力计算。',
+ 'Plan the final set as an all-out one.': '把最后一组安排成全力组。',
}
diff --git a/frontend/src/sheets.config-failure.test.jsx b/frontend/src/sheets.config-failure.test.jsx
new file mode 100644
index 000000000..feaabb5d6
--- /dev/null
+++ b/frontend/src/sheets.config-failure.test.jsx
@@ -0,0 +1,77 @@
+// @vitest-environment happy-dom
+import React, { act } from 'react'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { createRoot } from 'react-dom/client'
+import { EXDB } from './lib/exercises.js'
+import { useStore } from './store/useStore.js'
+import { useUI } from './store/useUI.js'
+import { exConfigSheet, setsLine } from './sheets.jsx'
+import { bindUI } from './components/ui.jsx'
+
+// Sets to failure: "Last set to failure" on the exercise's settings, written only when on.
+const ex = EXDB.find(e => e.id === '0009')
+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 open = (cfg, onSave) => {
+ exConfigSheet(ex, { sets: 3, reps: 5, weight: 40, mode: 'reps', ...cfg }, onSave)
+ return render(useUI.getState().sheets.at(-1))
+}
+const rowNamed = (host, title) => [...host.querySelectorAll('.lrow')].find(r => r.querySelector('.lrow-t')?.textContent === title)
+const save = host => act(() => [...host.querySelectorAll('button')].find(b => b.textContent.trim() === 'Save').click())
+
+describe('exercise settings: last set to failure', () => {
+ beforeEach(() => {
+ globalThis.IS_REACT_ACT_ENVIRONMENT = true
+ bindUI(useUI)
+ useUI.setState({ sheets: [] })
+ useStore.setState(s => ({ S: { ...s.S, unit: 'kg' } }))
+ document.body.innerHTML = ''
+ })
+ afterEach(() => { act(() => { mounted.splice(0).forEach(([root, host]) => { root.unmount(); host.remove() }) }) })
+
+ it('is off by default and saves nothing then', () => {
+ const onSave = vi.fn()
+ const host = open({}, onSave)
+ expect(rowNamed(host, 'Last set to failure').querySelector('[role="switch"]').getAttribute('aria-checked')).toBe('false')
+ save(host)
+ expect('lastToFailure' in onSave.mock.calls[0][0]).toBe(false)
+ })
+
+ it('switched on, it saves the flag and says what it does', () => {
+ const onSave = vi.fn()
+ const host = open({}, onSave)
+ act(() => rowNamed(host, 'Last set to failure').querySelector('[role="switch"]').click())
+ expect(host.textContent).toContain('counts as all-out effort unless you rate it')
+ save(host)
+ expect(onSave.mock.calls[0][0].lastToFailure).toBe(true)
+ })
+
+ it('comes on with Greyskull, whose last set is an AMRAP, unless it was already decided', () => {
+ const onSave = vi.fn()
+ const host = open({}, onSave)
+ act(() => rowNamed(host, 'Rule').click())
+ const picker = render(useUI.getState().sheets.at(-1))
+ act(() => [...picker.querySelectorAll('button.lrow')].find(el => el.querySelector('.lrow-t')?.textContent === 'Greyskull LP').click())
+ expect(rowNamed(host, 'Last set to failure').querySelector('[role="switch"]').getAttribute('aria-checked')).toBe('true')
+ save(host)
+ expect(onSave.mock.calls[0][0]).toMatchObject({ prog: 'greyskull', lastToFailure: true })
+ })
+
+ it('is not offered on a pyramid, which has its own Max set', () => {
+ const host = open({ pyramid: [12, 8, 0] })
+ expect(rowNamed(host, 'Last set to failure')).toBeUndefined()
+ })
+
+ it('the finish summary line marks a failure set', () => {
+ expect(setsLine([{ w: 60, r: 5 }, { w: 60, r: 9, f: true }], 'kg')).toBe('60 kg × 5, 9 F')
+ expect(setsLine([{ w: 60, r: 5 }, { w: 65, r: 4, f: true }], 'kg')).toBe('60×5 · 65×4 F')
+ })
+})
diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx
index 7c6846f22..2d47e650c 100644
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@ -1482,6 +1482,10 @@ function ProgressionFields({ ex, mode, c, setC, routine, unit, perSide, bw }) {
const deloadPercent = Math.round((c.deloadFactor != null && Number.isFinite(Number(c.deloadFactor)) ? Number(c.deloadFactor) : 0.9) * 100)
const setRule = v => setC(x => {
const next = { ...x, prog: v || undefined }
+ // Greyskull's final set is taken to failure by design, so choosing it here switches "Last set
+ // to failure" on too, unless it was already decided. Only the sheet's draft: nothing is
+ // written until Save, and a plan saved before stays what it was.
+ if (v === 'greyskull' && next.lastToFailure == null) next.lastToFailure = true
return policyFor({ ...next, id: ex.id }, routine, mode) === 'double'
? { ...next, ...normalizeRepRange(next.reps, next.repsMin, stride) }
: next
@@ -1609,8 +1613,10 @@ 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 } : {}
+ // "Last set to failure": written only when on, so a plan that never asked keeps its shape.
+ const withFailure = c.lastToFailure === true ? { lastToFailure: true } : {}
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, ...withFailure })
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.
@@ -1639,6 +1645,8 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i
if (!list.length && c.intensifier && c.intensifier.type) out.intensifier = intensifierToSave(c.intensifier)
// Back-off sets: written only when on, and only where the sheet offered them.
if (c.backoff === true && backoffOffered(out, 'reps', ex, bw) && isBackoff({ ...out, backoff: true })) out.backoff = true
+ // A pyramid has its own Max set for this, so the flag is not offered (or kept) there.
+ if (!list.length) Object.assign(out, withFailure)
onSave(out)
}
}
@@ -1796,6 +1804,13 @@ function ExConfig({ ex, existing, onSave, onDelete, onReplace, close, routine, i
</Row>}
{/* Off keeps the list as `pyramidDraft`, so a stray tap does not lose it before Save
(save writes neither field unless the toggle is on). */}
+ {/* The last work set of every session is marked as taken to failure, like Greyskull's
+ final AMRAP set (workout-model isFailureSet, history.js applyFailurePlan). A pyramid
+ already has its Max set for that. */}
+ {!pyramid && <Row icon="gauge" iconTint="var(--purple)" title={t('Last set to failure')}
+ subtitle={c.lastToFailure ? t('The last set goes until nothing is left, and counts as all-out effort unless you rate it.') : t('Plan the final set as an all-out one.')}>
+ <Switch checked={c.lastToFailure === true} onChange={v => setC(x => ({ ...x, lastToFailure: v || undefined }))} />
+ </Row>}
{mode === 'reps' && <Row icon="steps" iconTint="var(--acc)" title={t('Pyramid sets')}
subtitle={t('A different rep target for each set, e.g. 12 · 8 · 6 · Max · 12.')}>
<Switch checked={pyramid} onChange={v => setC(x => (v
@@ -3039,14 +3054,15 @@ export function exitWorkoutEdit(onExit = () => nav('/history')) {
}
// "60 kg × 5, 5, 4", or "60×5 · 62.5×5" when the weight changed between sets; a bodyweight lift
-// without load is just its reps.
-function setsLine(sets, unit) {
+// without load is just its reps. A set taken to failure keeps its "F", as it does in the history.
+export function setsLine(sets, unit) {
const ws = new Set(sets.map(s => s.w))
+ const reps = s => s.r + (s.f ? ' ' + t('F') : '')
if (ws.size === 1) {
const w0 = sets[0].w
- return (w0 > 0 ? fmtNum(w0) + ' ' + unit + ' × ' : '') + sets.map(s => s.r).join(', ')
+ return (w0 > 0 ? fmtNum(w0) + ' ' + unit + ' × ' : '') + sets.map(reps).join(', ')
}
- return sets.map(s => (s.w > 0 ? fmtNum(s.w) + '×' : '') + s.r).join(' · ')
+ return sets.map(s => (s.w > 0 ? fmtNum(s.w) + '×' : '') + reps(s)).join(' · ')
}
const TREND = { 1: ['arrowUp', 'var(--green)'], 0: ['minus', 'var(--text-2)'], [-1]: ['arrowDown', 'var(--orange)'] }
function LastAndNext({ st, w }) {
diff --git a/frontend/src/views/FocusView.css b/frontend/src/views/FocusView.css
index 9106ea3bd..ce52dd915 100644
--- a/frontend/src/views/FocusView.css
+++ b/frontend/src/views/FocusView.css
@@ -11,6 +11,8 @@
.focus-card-header{display:flex;align-items:center;gap:6px;padding-bottom:12px;border-bottom:var(--hair) solid var(--sep)}
.focus-card-header h2{flex:1;font-size:20px;line-height:1.2;text-transform:capitalize}
.focus-warmup{font-size:16px}
+/* The set on screen is taken to failure: the same purple "F" the set rows wear. */
+.focus-failure{display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;padding:0 4px;border-radius:10px;background:var(--purple);color:#fff;font-size:12px;font-weight:700}
.focus-context{display:grid;gap:5px;margin-top:10px}
.focus-tags{display:flex;flex-wrap:wrap;gap:5px}
.focus-note,.focus-last,.focus-guidance{color:var(--label-2);font-size:12px;line-height:1.35}
diff --git a/frontend/src/views/FocusView.jsx b/frontend/src/views/FocusView.jsx
index 9239056c7..59445ff25 100644
--- a/frontend/src/views/FocusView.jsx
+++ b/frontend/src/views/FocusView.jsx
@@ -9,7 +9,7 @@ import { effortColor, rirOf } from '../lib/effort.js'
import { progressionGuidance } from '../lib/progression-copy.js'
import {
addCluster, addDrop, addSideCluster, addSideDrop, clustersOf, dropsOf,
- isSideSet, isWarmupRow, nextBurstReps, nextDropWeight, setClusterAt,
+ isFailureSet, isSideSet, isWarmupRow, nextBurstReps, toggleFailure, nextDropWeight, setClusterAt,
setDropAt, setSideClusterAt, setSideDropAt, setSideField,
} from '../lib/workout-model.js'
import { weightIncrement, stepWeight } from '../lib/progression.js'
@@ -38,7 +38,12 @@ const toggleWarmup = row => {
if (isWarmupRow(next)) {
delete next.phase
delete next.warmup
- } else next.phase = 'warmup'
+ } else {
+ next.phase = 'warmup'
+ // A warm-up is never taken to failure (isFailureSet ignores it anyway); dropping the mark
+ // keeps it from coming back if the row is made a work set again.
+ delete next.failure
+ }
return next
}
@@ -229,6 +234,7 @@ export default function FocusView({
{ icon: 'flame', label: isWarmupRow(set) ? t('Mark as work set') : t('Mark as warm-up'), onClick: () => onMutateSet(setIdx, toggleWarmup) },
{ icon: 'arrowDown', label: t('Add drop set'), onClick: () => onMutateSet(setIdx, row => addDropTo(row, entry.target)) },
{ icon: 'bolt', label: t('Add burst'), onClick: () => onMutateSet(setIdx, row => addBurstTo(row, entry.target?.intensifier?.type === 'restpause' ? entry.target.intensifier.restSec : (S.restPauseSec || 15))) },
+ !isWarmupRow(set) && mode !== 'cardio' && { icon: 'gauge', label: t('Taken to failure'), sub: t('Nothing left in the tank'), on: isFailureSet(set), onClick: () => onMutateSet(setIdx, toggleFailure) },
{ icon: 'trash', label: t('Delete set'), danger: true, disabled: entry.sets.length <= 1, onClick: () => onRemoveSetAt(setIdx) },
],
})
@@ -249,6 +255,7 @@ export default function FocusView({
<h2>{exerciseNameFor(ex)}</h2>
<button className="iconbtn" aria-label={t('Details')} onClick={() => exerciseDetailSheet(ex)}><Icon name="info" /></button>
{isWarmupRow(set) && <span className="focus-warmup" aria-label={t('Warm-up')}>🔥</span>}
+ {isFailureSet(set) && <span className="focus-failure" role="img" aria-label={t('Taken to failure')}>{t('F')}</span>}
<button className="iconbtn" aria-label={t('More')} onClick={openExerciseMenu}><Icon name="more" /></button>
</header>
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index 2843f697f..7c03b422c 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -38,7 +38,7 @@ import { sessionNoProg, setSessionNoProg, setEntryNoProg, joinSessionNoProg } fr
import { glyphOf } from '../lib/glyphs.js'
import { markAllSetsDone, sessionHistory } from '../lib/backfill.js'
import { bestSetFor } from '../lib/exercise-history.js'
-import { isWarmupRow, isDropSet, isRestPauseSet, dropsOf, clustersOf, addDrop, addCluster, removeDropAt, removeClusterAt, setDropAt, setClusterAt, nextDropWeight, nextBurstReps, isSideSet, makeSideSet, setSideField, toggleSide, addSideDrop, removeSideDropAt, setSideDropAt, addSideCluster, removeSideClusterAt, setSideClusterAt, WEIGHT_ORIGIN_MANUAL } from '../lib/workout-model.js'
+import { isWarmupRow, isFailureSet, toggleFailure, isDropSet, isRestPauseSet, dropsOf, clustersOf, addDrop, addCluster, removeDropAt, removeClusterAt, setDropAt, setClusterAt, nextDropWeight, nextBurstReps, isSideSet, makeSideSet, setSideField, toggleSide, addSideDrop, removeSideDropAt, setSideDropAt, addSideCluster, removeSideClusterAt, setSideClusterAt, WEIGHT_ORIGIN_MANUAL } from '../lib/workout-model.js'
import { canMoveActiveWorkoutUnit, moveActiveWorkoutUnit, canMoveActiveWorkoutEntry, moveActiveWorkoutEntry } from '../lib/active-workout-order.js'
import { nextOpenSet, workoutKeyAction } from '../lib/workout-keys.js'
import { MUSCLE_NAME } from '../lib/muscles.js'
@@ -118,6 +118,12 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi
const e = s.active.entries[entryIdx]
e.sets = warm ? makeWarmupAt(e.sets, i) : makeWorkAt(e.sets, i)
}, true)
+ const toggleFailureAt = i => update(s => {
+ const e = s.active.entries[entryIdx]
+ const [start, count] = setSpanAt(e.sets, i)
+ const on = !isFailureSet(e.sets[i])
+ for (let j = start; j < start + count; j++) if (isFailureSet(e.sets[j]) !== on) e.sets[j] = toggleFailure(e.sets[j])
+ }, true)
const addDropRow = i => mutSet(i, row => {
// A unilateral set drops per side (issue #60): addSideDrop seeds each side from its own weight.
if (isSideSet(row)) {
@@ -420,6 +426,10 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi
{ items: [
!warm && mode === 'reps' && canBeWarmup(s) && entry.sets.some((x, j) => j !== i && !isWarmupRow(x)) && { icon: 'sunrise', label: t('Make it a warm-up set'), onClick: () => setPhaseAt(i, true) },
warm && mode === 'reps' && !perSide && { icon: 'dumbbell', label: t('Count it as a working set'), onClick: () => setPhaseAt(i, false) },
+ // Taken to failure: a toggle with its check, like the menu's other on/off rows. It counts
+ // as RIR 0 wherever effort is read, unless a rating was logged on the set. A timed
+ // per-side pair is one set, so both halves get it.
+ !warm && mode !== 'cardio' && { icon: 'gauge', label: t('Taken to failure'), sub: t('Nothing left in the tank'), on: isFailureSet(s), onClick: () => toggleFailureAt(i) },
] },
{ title: t('Add to this set'), items: [
!warm && mode === 'reps' && !isRestPauseSet(s) && { icon: 'arrowDown', label: t('Drop set'), sub: t('+ Drop'), onClick: () => addDropRow(i) },
@@ -554,9 +564,13 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi
)
// A plain set row (anything but a reps L/R stack). Its own function since a timed per-side
// hold draws two of them, L then R, inside one swipe so the pair slides as the one set it is.
+ // A set taken to failure wears a small "F" on its number, the button every row's menu opens
+ // from. The button's own label speaks for it, so a screen reader hears it with the set number.
+ const failMark = s => isFailureSet(s) ? <span className="failmark" aria-hidden="true">{t('F')}</span> : null
+ const failSay = (s, label) => isFailureSet(s) ? label + ', ' + t('Taken to failure') : label
const plainRow = (s, i) => (
<div ref={el => onSetRowRef?.(i, el)} className={'setrow' + (s.done ? ' done' : '') + (col3 ? ' eff3' : '') + (timed ? ' timed' : '')}>
- <button type="button" className="n" aria-label={sideTagOf(s) ? t('Set {0} ({1})', setNumOf(s, i), sideTagOf(s)) : t('Set {0}', setNumOf(s, i))} aria-describedby={optsId} title={t('More')} onClick={() => openSetMenu(s, i)}>{setNumOf(s, i)}</button>
+ <button type="button" className="n" aria-label={failSay(s, sideTagOf(s) ? t('Set {0} ({1})', setNumOf(s, i), sideTagOf(s)) : t('Set {0}', setNumOf(s, i)))} aria-describedby={optsId} title={t('More')} onClick={() => openSetMenu(s, i)}>{setNumOf(s, i)}{failMark(s)}</button>
{/* Both words sit in the pill's one grid cell (::before/::after, hidden), so Left and
Right are as wide as the longer of the two in every language and the inputs
after them line up (#322). */}
@@ -683,7 +697,7 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi
// ticked on its own (issue #60). Warm-ups split the same way as the work sets they
// ramp toward, so a warm-up side set shows L/R too (#388).
<div ref={el => onSetRowRef?.(i, el)} className={'setrow-side' + (s.done ? ' done' : '')}>
- <button type="button" className="n" aria-label={t('Set {0}', phaseNum)} aria-describedby={optsId} title={t('More')} onClick={() => openSetMenu(s, i)}>{phaseNum}</button>
+ <button type="button" className="n" aria-label={failSay(s, t('Set {0}', phaseNum))} aria-describedby={optsId} title={t('More')} onClick={() => openSetMenu(s, i)}>{phaseNum}{failMark(s)}</button>
<div className="side-rows">
{sideRow(s, i, 'L', col1, col2, col3)}
{sideExtras(s, i, 'L')}
diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsx
index 936eab51e..b808aa60e 100644
--- a/frontend/src/views/Workout.test.jsx
+++ b/frontend/src/views/Workout.test.jsx
@@ -1819,7 +1819,12 @@ describe('workout focus view', () => {
expect(mocks.S.active.entries[0].sets[0].r).toBe(9)
await click(buttonNamed('Set menu'))
const labels = mocks.menuSheet.mock.calls.at(-1)[0].items.filter(Boolean).map(item => item.label)
- expect(labels).toEqual(['Mark as warm-up', 'Add drop set', 'Add burst', 'Delete set'])
+ expect(labels).toEqual(['Mark as warm-up', 'Add drop set', 'Add burst', 'Taken to failure', 'Delete set'])
+ // Taken to failure toggles the mark, and the focus card shows its F.
+ await act(async () => { mocks.menuSheet.mock.calls.at(-1)[0].items.filter(Boolean).find(item => item.label === 'Taken to failure').onClick() })
+ expect(mocks.S.active.entries[0].sets[0].failure).toBe(true)
+ await rerender()
+ expect(container.querySelector('.focus-failure').textContent).toBe('F')
})
it('does not expose a Focus-only set note action', async () => {
@@ -2607,7 +2612,7 @@ describe('workout controls: the more menu and the set menu', () => {
it('opens a per-set menu from the set number with drop, burst and remove', async () => {
await mount([exercise('plain-bench', [false, false])])
await act(async () => { container.querySelector('button[aria-label="Set 2"]').dispatchEvent(new dom.Event('click', { bubbles: true })) })
- expect(menuItemsOf(lastMenu()).map(it => it.label)).toEqual(['Make it a warm-up set', 'Drop set', 'Rest-pause burst', 'Copy this set', 'Remove this set'])
+ expect(menuItemsOf(lastMenu()).map(it => it.label)).toEqual(['Make it a warm-up set', 'Taken to failure', 'Drop set', 'Rest-pause burst', 'Copy this set', 'Remove this set'])
expect(item('Make it a warm-up set').icon).toBe('sunrise')
await act(async () => { item('Drop set').onClick() })
@@ -2618,6 +2623,23 @@ describe('workout controls: the more menu and the set menu', () => {
expect(mocks.S.active.entries[0].sets.length).toBe(1)
})
+ it('marks a set as taken to failure from its menu, with an F on its number, and back', async () => {
+ await mount([exercise('plain-bench', [false, false])])
+ const openSet = async label => { await act(async () => { container.querySelector(`button[aria-label="${label}"]`).dispatchEvent(new dom.Event('click', { bubbles: true })) }) }
+ await openSet('Set 2')
+ expect(item('Taken to failure').on).toBe(false)
+ await act(async () => { item('Taken to failure').onClick() })
+ expect(mocks.S.active.entries[0].sets[1].failure).toBe(true)
+ expect(mocks.S.active.entries[0].sets[0].failure).toBeUndefined()
+ await rerender()
+ const n = container.querySelector('button[aria-label="Set 2, Taken to failure"]')
+ expect(n.querySelector('.failmark').textContent).toBe('F')
+ await openSet('Set 2, Taken to failure')
+ expect(item('Taken to failure').on).toBe(true)
+ await act(async () => { item('Taken to failure').onClick() })
+ expect('failure' in mocks.S.active.entries[0].sets[1]).toBe(false)
+ })
+
it('makes a work set a warm-up and back, and keeps one work set', async () => {
await mount([exercise('plain-bench', [true, false])])
// a warm-up's number button is "Set 1" too, so rows are picked by position
diff --git a/mcp/src/tools.js b/mcp/src/tools.js
index 55317f719..77d68dfd7 100644
--- a/mcp/src/tools.js
+++ b/mcp/src/tools.js
@@ -11,7 +11,7 @@ import {
} from '../../frontend/src/lib/history.js'
import { queueView, queueNext, pinState } from '../../frontend/src/lib/queue.js'
import { exOr, registerCustom } from '../../frontend/src/lib/exercises.js'
-import { isWarmupRow } from '../../frontend/src/lib/workout-model.js'
+import { isWarmupRow, isFailureSet } from '../../frontend/src/lib/workout-model.js'
import {
bestSetOf, best1RM, e1rmSeries, DEFAULT_FORMULA, REP_CAP
} from '../../frontend/src/lib/onerm.js'
@@ -67,6 +67,8 @@ function entryView(e, S) {
sets: (e.sets || []).map(s => ({
done: !!s.done,
label: setLabel(e.id, { ...s, done: undefined }, cfg),
+ // Taken to failure (the app's "F"): RIR 0 for effort when nothing was rated by hand.
+ ...(isFailureSet(s) ? { failure: true } : {}),
w: Number(s.w) || 0,
r: Number(s.r) || 0,
sec: Number(s.sec) || 0,
@@ -605,6 +607,7 @@ export const previewSession = {
opening_sets: rows.map(s => ({
phase: isWarmupRow(s) ? 'warmup' : 'work',
type: s.type || 'straight',
+ ...(isFailureSet(s) ? { failure: true } : {}),
label: setLabel(cfg.id, { ...s, done: undefined }, { ...cfg, id: cfg.id }),
w: Number(s.w) || 0,
r: Number(s.r) || 0,
diff --git a/mcp/test/tools.test.js b/mcp/test/tools.test.js
index 13b9af39f..4cafc6629 100644
--- a/mcp/test/tools.test.js
+++ b/mcp/test/tools.test.js
@@ -536,6 +536,19 @@ describe('get_workout', () => {
expect(w.entries[3].sets[0].label).toBe('20 min @ 8 km/h') // cardio
})
+ test('a set taken to failure says so, in its label and as a flag', () => {
+ S.workouts = [{
+ id: 'synth-f', d: '2026-07-25', start: 0, end: 1800000, routineId: 'x', name: 'Synth',
+ bw: 78, vol: 0, prs: [],
+ entries: [{ id: 'squat', target: { mode: 'reps' }, sets: [{ w: 60, r: 5, done: true }, { w: 60, r: 9, done: true, failure: true }] }]
+ }]
+ const [plain, failed] = call('get_workout', { date: '2026-07-25' }).entries[0].sets
+ expect(plain.label).toBe('60×5')
+ expect('failure' in plain).toBe(false)
+ expect(failed.label).toBe('60×9 F')
+ expect(failed.failure).toBe(true)
+ })
+
test('infers cardio mode from the exercise id when the target has no mode key', () => {
// Reproduces the review bug: the sheet saves a cardio target as {sets, min, speed} with
// no mode and no id. modeOf must fall through to isCardio(id), which needs the id on the