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.

Pin two more plan-vs-session cases: "Last time" reads the routine's own session, and imported history starts a routine from its own plan

Duarte Santos2a609bcbdacb
diff --git a/frontend/src/lib/session-start.plan.test.js b/frontend/src/lib/session-start.plan.test.js
index 720762b90..9b113a26b 100644
--- a/frontend/src/lib/session-start.plan.test.js
+++ b/frontend/src/lib/session-start.plan.test.js
@@ -138,6 +138,16 @@ describe('a planned session opens at the plan\'s reps', () => {
}
})
+describe('a routine whose only history is freestyle or imported', () => {
+ it('starts from its own sets × reps at the last weight, not from the other session\'s shape', () => {
+ const st = state([{ id: 'A', name: 'A', ex: [{ id: BENCH, sets: 2, reps: 10, weight: 50, mode: 'reps' }] }])
+ st.workouts.push({ id: 'imp', d: '2026-09-01', routineId: null, entries: [{ id: BENCH, sets: [{ w: 30, r: 15, done: true }, { w: 30, r: 15, done: true }, { w: 30, r: 15, done: true }] }] })
+ const [e] = start(st, ['A'])
+ expect(work(e).map(s => [s.w, s.r])).toEqual([[30, 10], [30, 10]])
+ expect(e.plan.why[0]).toBe('First time in this routine — starting from its own target.')
+ })
+})
+
describe('an edited routine starts again from its new plan', () => {
it('holds the weight at the new reps under the default policy', () => {
const st = state([{ id: 'A', name: 'A', ex: [{ id: BENCH, sets: 2, reps: 15, weight: 50 }] }])
diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsx
index 5599be4aa..d312a16bd 100644
--- a/frontend/src/views/Workout.test.jsx
+++ b/frontend/src/views/Workout.test.jsx
@@ -1293,6 +1293,13 @@ describe('the plan line', () => {
expect(container.textContent).not.toContain('Last time')
})
+ it('sits next to a "Last time" that reads this routine\'s own last session (#216)', async () => {
+ const session = (d, rid, w, r) => ({ d, routineIds: [rid], entries: [{ id: 'plain-bench', rid, target: { reps: r, weight: w }, sets: [{ w, r, done: true }] }] })
+ await mount([planned({ rid: 'A' })], 0, { workouts: [session('2026-08-24', 'A', 60, 10), session('2026-08-26', 'B', 40, 15)] })
+ expect(container.textContent).toContain('60×10')
+ expect(container.textContent).not.toContain('40×15')
+ })
+
it('is not there for an entry with no plan (freestyle, or started before plans were kept)', async () => {
await mount([exercise('plain-bench', [false])])
expect(container.querySelector('.planline')).toBeNull()