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.

Progression adds the step the way a stepper tap does — a weight off the increment grid keeps its offset (397 + 10 = 407, not 410; #175); the service worker closes the previous notification of the same kind before showing the next (#172)

Duarte Santosbff87930d8da
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d74b2b00c..3a5ecde0c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -76,6 +76,11 @@ tab bar mid-screen during a workout. Web bundle, APK and API image.
("Leg Day — in progress" in Hungarian); the Language row shows the full pack name; the routine
editor's rows showed a red sliver of the swipe-to-delete button at their corners; FitNotes'
stock "Flat Barbell Bench Press" now matches on import.
+- ⚖️ **A weight off the increment grid keeps its offset when progression raises it** (#175): a sled
+ logged as its own 167 lb plus plates — 397 — with a 10 lb step now goes to 407, the way a stepper
+ tap does, instead of snapping to the grid's 410. Linear, Greyskull and double progression.
+- 🔕 **Rest-timer pushes no longer pile up in the tray on iOS** (#172): the service worker closes the
+ previous notification of the same kind before showing the next one.
- 🔍 **A failed Coach run on the phone says what the provider said.** With your own API key there
is no admin card and no instance owner, so "the instance owner needs to check its setup" was the
diff --git a/frontend/public/sw.js b/frontend/public/sw.js
index 7b21b7215..88444a1fd 100644
--- a/frontend/public/sw.js
+++ b/frontend/public/sw.js
@@ -15,11 +15,16 @@ self.addEventListener('push', e => {
e.waitUntil((async () => {
let data = {}
try { data = e.data ? e.data.json() : {} } catch { data = { body: (() => { try { return e.data.text() } catch { return '' } })() } }
+ // One alert per kind: a new rest-timer push replaces the last one instead of stacking
+ // up in the tray (issue #172). `tag` alone should do that, but iOS keeps every one, so
+ // the previous notification with the same tag is closed by hand first.
+ const tag = data.tag || 'opengym'
+ try { for (const n of await self.registration.getNotifications({ tag })) n.close() } catch {}
await self.registration.showNotification(data.title || 'openGym', {
body: data.body || '',
icon: 'icon-512.png',
badge: 'icon-180.png',
- tag: data.tag || 'opengym',
+ tag,
renotify: true
})
})())
diff --git a/frontend/src/lib/progression.js b/frontend/src/lib/progression.js
index df2dfd0b1..0da7c25aa 100644
--- a/frontend/src/lib/progression.js
+++ b/frontend/src/lib/progression.js
@@ -115,11 +115,19 @@ export function snapWeight(v, step) {
// A tap moves by one step. Snapping to the grid keeps the number identical to what progression
// would prescribe (61.3 → 62.5 with a 1.25 step, not 62.55) — but only when the current value
// already sits on that grid; from 62.5 with a 5 kg step a tap gives 67.5, not 70.
+// Add `step` to a weight the way a stepper tap does: from a weight that sits on the increment's
+// grid the sum is snapped to it, from one off the grid the step is simply added. Progression
+// uses the same rule (issue #175): a sled logged as 397 lb — its own weight plus plates — with
+// a 10 lb step goes to 407, not to the grid's 410.
+export function addStep(w, step, inc) {
+ const v = +w || 0
+ const onGrid = inc > 0 && Math.abs(v - Math.round(v / inc) * inc) <= 0.1
+ const next = v + step
+ return Math.max(0, onGrid ? snapWeight(next, inc) : round1(next))
+}
export function stepWeight(value, step, direction) {
const v = Number(value) || 0
- const onGrid = step > 0 && Math.abs(v - Math.round(v / step) * step) <= 0.1
- const next = v + direction * step
- return Math.max(0, onGrid ? snapWeight(next, step) : round1(next))
+ return addStep(v, direction * step, step)
}
// Back off by a factor, landing on something you can actually load. This remains the old policy
// used by Greyskull and timed progression; linear/double loaded reps use the Epley selector below.
@@ -395,7 +403,7 @@ export function nextPrescription(S, cfg, routine) {
const range = normalizeRepRange(cfg.reps || last.goal || 10, cfg.repsMin, repStep(cfg))
const top = range.reps
const bottom = range.repsMin
- if (last.ok) return { policy, kind: 'up', weight: snapWeight(w + inc, inc), reps: bottom, why: ['Top of the rep range in every set — {0} {1} more, back to {2} reps.', inc, unit, bottom] }
+ if (last.ok) return { policy, kind: 'up', weight: addStep(w, inc, inc), reps: bottom, why: ['Top of the rep range in every set — {0} {1} more, back to {2} reps.', inc, unit, bottom] }
if (stalls >= deloadAt) {
const selected = epleyDeload()
if (selected) return selected
@@ -413,7 +421,7 @@ export function nextPrescription(S, cfg, routine) {
const dbl = policy === 'greyskull' && last.goal > 0 && last.amrap >= last.goal * 2
const step = dbl ? inc * 2 : inc
return {
- policy, kind: 'up', weight: snapWeight(w + step, inc),
+ policy, kind: 'up', weight: addStep(w, step, inc),
why: dbl
? ['Last set hit {0} reps — twice the target, so take a double jump of {1} {2}.', last.amrap, step, unit]
: ['Every rep last time — {0} {1} more.', step, unit]
diff --git a/frontend/src/lib/progression.test.js b/frontend/src/lib/progression.test.js
index 65b4c1466..8c7bdf501 100644
--- a/frontend/src/lib/progression.test.js
+++ b/frontend/src/lib/progression.test.js
@@ -831,3 +831,21 @@ describe('drop-sets and rest-pause sets in progression', () => {
expect(out[1]).toEqual({ type: 'dropset', w: 0, r: 10, done: false })
})
})
+
+describe('a weight off the increment grid keeps its offset when it goes up (issue #175)', () => {
+ it('adds the step instead of snapping the sum to the grid', () => {
+ // A sled logged as its own 167 lb plus plates: 397 with a 10 lb step goes to 407, not 410.
+ const lin = { id: LIFT, sets: 3, reps: 5, weight: 397, prog: 'linear', inc: 10 }
+ const p = nextPrescription(hist(LIFT, [[397, 5, 5, 5]], { sets: 3, reps: 5, weight: 397 }), lin)
+ expect(p.kind).toBe('up')
+ expect(p.weight).toBe(407)
+ const dbl = { id: LIFT, sets: 3, reps: 12, repsMin: 8, weight: 397, prog: 'double', inc: 10 }
+ const d = nextPrescription(hist(LIFT, [[397, 12, 12, 12]], { sets: 3, reps: 12, weight: 397 }), dbl)
+ expect(d.kind).toBe('up')
+ expect(d.weight).toBe(407)
+ })
+ it('still snaps from a weight that sits on the grid', () => {
+ const p = nextPrescription(hist(LIFT, [[60, 5, 5, 5]]), { id: LIFT, sets: 3, reps: 5, weight: 60, prog: 'linear', inc: 2.5 })
+ expect(p.weight).toBe(62.5)
+ })
+})