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
Import: bring the RPE other apps already recorded
Duarte Santos54fb14be13ad
diff --git a/frontend/src/lib/import-csv.js b/frontend/src/lib/import-csv.jsindex 4ee04ec58..125ca588c 100644--- a/frontend/src/lib/import-csv.js+++ b/frontend/src/lib/import-csv.js@@ -66,6 +66,10 @@ const COLUMNS = [['weight', ['weight']],['weightUnit', ['weight unit', 'unit']],['reps', ['reps', 'repetitions']],+ // Hevy and Strong both write an RPE per set. Nothing mainstream exports RIR, but read it+ // when it is there rather than dropping the column on the floor.+ ['rpe', ['rpe', 'rpe rating']],+ ['rir', ['rir', 'reps in reserve']],['distanceKm', ['distance km']],['distance', ['distance']],['distanceUnit', ['distance unit']],@@ -226,6 +230,18 @@ const CATEGORY_BP = {/* ----------------------------------------------------------- conversion --- */const num = v => { const n = parseFloat(String(v ?? '').replace(',', '.')); return isFinite(n) ? n : 0 }+// An effort rating out of someone else's export. A blank cell means "not rated" and has to+// stay absent rather than becoming 0 — and 0 itself means opposite things on the two scales:+// RIR 0 is a set taken to failure and worth keeping, while RPE has no 0 (the scale is 1–10),+// so an app writing 0 for "nothing here" must not be read as an effort. Ratings above the+// scale are capped rather than dropped — the set was still rated, just written oddly.+const effortNum = (raw, zeroMeansRated) => {+ const s = String(raw ?? '').trim()+ if (!s) return null+ const n = parseFloat(s.replace(',', '.'))+ if (!isFinite(n) || n < 0 || (n === 0 && !zeroMeansRated)) return null+ return Math.min(10, Math.round(n * 100) / 100)+}const LB_TO_KG = 0.45359237const p2 = n => String(n).padStart(2, '0')const MON = { jan: 1, feb: 2, mar: 3, apr: 4, may: 5, jun: 6, jul: 7, aug: 8, sep: 9, oct: 10, nov: 11, dec: 12 }@@ -288,7 +304,7 @@ export function parseWorkoutCSV(text, { unit = 'kg' } = {}) {const byDate = new Map()const created = new Map()const unmatched = new Set()- let sets = 0, skipped = 0, matched = 0, warmups = 0+ let sets = 0, skipped = 0, matched = 0, warmups = 0, rpeSets = 0, rirSets = 0let sawLb = false, sawKg = falseconst cell = (r, f) => (map[f] === undefined ? '' : String(r[map[f]] ?? '').trim())@@ -343,6 +359,15 @@ export function parseWorkoutCSV(text, { unit = 'kg' } = {}) {const set = isCardio? { min: mins || 0, speed: mins > 0 ? Math.round(km / (mins / 60) * 10) / 10 : 0, done: true }: { w, r: reps || 0, done: true, u: rowUnit }+ // 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.+ if (!isCardio) {+ const rir = effortNum(cell(r, 'rir'), true)+ const rpe = rir == null ? effortNum(cell(r, 'rpe'), false) : null+ if (rir != null) { set.rir = rir; rirSets++ }+ else if (rpe != null) { set.rpe = rpe; rpeSets++ }+ }let day = byDate.get(when.d)if (!day) {@@ -401,7 +426,7 @@ export function parseWorkoutCSV(text, { unit = 'kg' } = {}) {matched: new Set([...resolved.values()].filter(Boolean)).size,matchedSets: matched,created: created.size, unmatchedNames: [...unmatched].sort(),- sets, skipped, warmups, fileUnit, mixedUnits, converted,+ sets, skipped, warmups, fileUnit, mixedUnits, converted, rpeSets, rirSets,from: dates[0] || null, to: dates[dates.length - 1] || null,}}diff --git a/frontend/src/lib/import-effort.test.js b/frontend/src/lib/import-effort.test.jsnew file mode 100644index 000000000..f7dafb393--- /dev/null+++ b/frontend/src/lib/import-effort.test.js@@ -0,0 +1,148 @@+import { describe, it, expect } from 'vitest'+import { parseWorkoutCSV } from './import-csv.js'+import { setLabel, effortOf } from './history.js'++// Headers as the real exports write them, trimmed to the columns that matter here.+const HEVY = 'title,start_time,end_time,exercise_title,set_index,set_type,weight_kg,reps,rpe'+const STRONG = 'Date,Workout Name,Exercise Name,Set Order,Weight,Reps,Seconds,RPE'+const FITNOTES = 'Date,Exercise,Category,Weight,Reps,Distance,Distance Unit,Time'++const rows = (head, ...lines) => parseWorkoutCSV([head, ...lines].join('\n'), { unit: 'kg' })+// every set of the first workout, in file order+const setsOf = p => p.workouts.flatMap(w => w.entries.flatMap(e => e.sets))++describe('importing effort from another app', () => {+ it('reads the RPE Hevy writes per set', () => {+ const p = rows(HEVY,+ 'Push,"12 Jan 2026, 18:00","12 Jan 2026, 19:00",Bench Press (Barbell),0,normal,60,10,8',+ 'Push,"12 Jan 2026, 18:00","12 Jan 2026, 19:00",Bench Press (Barbell),1,normal,60,8,9.5')+ expect(p.error).toBeUndefined()+ expect(setsOf(p).map(s => s.rpe)).toEqual([8, 9.5])+ expect(p.rpeSets).toBe(2)+ expect(p.rirSets).toBe(0)+ })++ it('reads the RPE Strong writes per set', () => {+ const p = rows(STRONG,+ '2026-01-12 18:00:00,Push,Bench Press (Barbell),1,60,10,0,7.5')+ expect(setsOf(p)[0].rpe).toBe(7.5)+ expect(p.rpeSets).toBe(1)+ })++ it('reads an RIR column when a file has one', () => {+ const p = rows('Date,Exercise,Weight,Reps,RIR',+ '2026-01-12,Bench Press,60,10,2',+ '2026-01-12,Bench Press,60,6,0') // 0 RIR is a real rating: taken to failure+ expect(setsOf(p).map(s => s.rir)).toEqual([2, 0])+ expect(p.rirSets).toBe(2)+ expect(setsOf(p).every(s => s.rpe === undefined)).toBe(true)+ })++ it('treats a blank rating as not rated, not as zero', () => {+ const p = rows(HEVY,+ 'Push,"12 Jan 2026, 18:00",,Bench Press (Barbell),0,normal,60,10,',+ 'Push,"12 Jan 2026, 18:00",,Bench Press (Barbell),1,normal,60,10,8')+ const s = setsOf(p)+ expect('rpe' in s[0]).toBe(false) // the key is absent, so the set reads as unrated+ expect(s[1].rpe).toBe(8)+ expect(p.rpeSets).toBe(1)+ })++ it('does not read a written-out 0 as an RPE', () => {+ // RPE runs 1–10, so a 0 in that column is an app saying "nothing here". Reading it as a+ // rating would stamp an effort on every unrated set in the file.+ const p = rows(STRONG, '2026-01-12 18:00:00,Push,Bench Press (Barbell),1,60,10,0,0')+ expect('rpe' in setsOf(p)[0]).toBe(false)+ expect(p.rpeSets).toBe(0)+ })++ it('caps a rating that overruns the scale instead of dropping the set', () => {+ const p = rows(STRONG, '2026-01-12 18:00:00,Push,Bench Press (Barbell),1,60,10,0,12')+ expect(setsOf(p)[0].rpe).toBe(10)+ })++ it('ignores junk in the rating column', () => {+ const p = rows(STRONG,+ '2026-01-12 18:00:00,Push,Bench Press (Barbell),1,60,10,0,hard',+ '2026-01-12 18:00:00,Push,Bench Press (Barbell),2,60,10,0,-3')+ expect(setsOf(p).every(s => !('rpe' in s))).toBe(true)+ expect(p.rpeSets).toBe(0)+ expect(p.sets).toBe(2) // the sets still import, just unrated+ })++ it('keeps one scale per set when a file carries both columns', () => {+ const p = rows('Date,Exercise,Weight,Reps,RPE,RIR',+ '2026-01-12,Bench Press,60,10,8,2')+ const s = setsOf(p)[0]+ expect(s.rir).toBe(2)+ expect('rpe' in s).toBe(false)+ // and it reads back on the scale it was stored with+ expect(setLabel('0025', s)).toBe('60×10 (RIR 2)')+ })++ it('puts no effort on a cardio row', () => {+ // a treadmill row has no third stepper to show it in+ const p = rows('Date,Exercise,Distance,Distance Unit,Time,RPE',+ '2026-01-12,Running,5,km,00:30:00,7')+ const s = setsOf(p)[0]+ expect(s.min).toBe(30)+ expect('rpe' in s).toBe(false)+ expect(p.rpeSets).toBe(0)+ })++ it('leaves a file without any rating column exactly as it was', () => {+ const p = rows(FITNOTES, '2026-01-12,Bench Press,Chest,60,10,,,')+ const s = setsOf(p)[0]+ expect(s).toEqual({ w: 60, r: 10, done: true })+ expect(p.rpeSets + p.rirSets).toBe(0)+ })++ it('carries the rating through the unit conversion', () => {+ // lb -> kg rewrites the weight; the rating must survive that pass untouched+ const p = parseWorkoutCSV([+ 'Date,Exercise,Weight,Weight Unit,Reps,RPE',+ '2026-01-12,Bench Press,135,lbs,10,8',+ ].join('\n'), { unit: 'kg' })+ const s = setsOf(p)[0]+ expect(s.w).toBe(61.2)+ expect(s.rpe).toBe(8)+ expect('u' in s).toBe(false) // the row's unit marker never reaches the set+ })+})++// The backup is the whole state serialised, so effort travels with it by construction. This+// pins that it stays true — a set losing its rating on a backup round trip would be silent.+describe('effort in a backup', () => {+ // what Settings does on import: the file spread over the defaults. DEF cannot be imported+ // here (the store reaches for `navigator` at load), so its shape is reproduced literally.+ const DEF_LIKE = { unit: 'kg', workouts: [], routines: [], effort: null }+ const roundTrip = S => Object.assign({ ...DEF_LIKE }, JSON.parse(JSON.stringify(S)))++ it('exports and re-imports both scales and the setting', () => {+ const S = {+ unit: 'kg', effort: 'rpe', routines: [],+ workouts: [{+ d: '2026-01-12', entries: [{ id: '0025', sets: [+ { w: 60, r: 10, rpe: 8, done: true },+ { w: 60, r: 8, rir: 1, done: true },+ { w: 60, r: 12, done: true },+ ] }],+ }],+ }+ const back = roundTrip(S)+ expect(effortOf(back)).toBe('rpe')+ const [a, b, c] = back.workouts[0].entries[0].sets+ expect(a.rpe).toBe(8)+ expect(b.rir).toBe(1)+ expect('rpe' in c || 'rir' in c).toBe(false)+ expect(setLabel('0025', a)).toBe('60×10 (RPE 8)')+ expect(setLabel('0025', b)).toBe('60×8 (RIR 1)')+ expect(setLabel('0025', c)).toBe('60×12')+ })++ it('restores a backup written before the setting existed', () => {+ // the old flag survives the round trip and still decides the column+ expect(effortOf(roundTrip({ showRir: true, workouts: [], routines: [] }))).toBe('rir')+ expect(effortOf(roundTrip({ workouts: [], routines: [] }))).toBe('none')+ })+})diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex de8d5c26d..8801aebd1 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -513,6 +513,8 @@ export default {'Bodyweight — same target again until every set is clean.': 'Körpergewicht — dieselbe Vorgabe, bis jeder Satz sauber sitzt.',// --- effort per set (RIR / RPE) ---+ '{0} sets bring an {1} with them — switch on Effort per set in Settings to see it.': '{0} Sätze bringen ein {1} mit — schalte in den Einstellungen „Anstrengung pro Satz“ ein, um es zu sehen.',+ '{0} sets bring an {1} with them.': '{0} Sätze bringen ein {1} mit.','RIR': 'RIR','RPE': 'RPE','Effort per set': 'Anstrengung pro Satz',diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex daffa7551..c515af336 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -495,6 +495,8 @@ export default {'Bodyweight — same target again until every set is clean.': 'Peso corporal: el mismo objetivo hasta que todas las series salgan limpias.',// --- effort per set (RIR / RPE) ---+ '{0} sets bring an {1} with them — switch on Effort per set in Settings to see it.': '{0} series traen un {1} — activa «Esfuerzo por serie» en Ajustes para verlo.',+ '{0} sets bring an {1} with them.': '{0} series traen un {1}.','RIR': 'RIR','RPE': 'RPE','Effort per set': 'Esfuerzo por serie',diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 6909b09fa..7f1e07691 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -495,6 +495,8 @@ export default {'Bodyweight — same target again until every set is clean.': 'Poids du corps — même objectif jusqu’à ce que chaque série soit propre.',// --- effort per set (RIR / RPE) ---+ '{0} sets bring an {1} with them — switch on Effort per set in Settings to see it.': '{0} séries arrivent avec un {1} — active « Effort par série » dans les réglages pour le voir.',+ '{0} sets bring an {1} with them.': '{0} séries arrivent avec un {1}.','RIR': 'RIR','RPE': 'RPE','Effort per set': 'Effort par série',diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex 126412486..4e77deacf 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -495,6 +495,8 @@ export default {'Bodyweight — same target again until every set is clean.': 'बॉडीवेट — जब तक हर सेट साफ़ न हो, वही लक्ष्य।',// --- effort per set (RIR / RPE) ---+ '{0} sets bring an {1} with them — switch on Effort per set in Settings to see it.': '{0} सेट अपने साथ {1} लाते हैं — इसे देखने के लिए सेटिंग्स में “प्रति सेट मेहनत” चालू करें।',+ '{0} sets bring an {1} with them.': '{0} सेट अपने साथ {1} लाते हैं।','RIR': 'RIR','RPE': 'RPE','Effort per set': 'हर सेट की मेहनत',diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 2a44b9ca6..12834d234 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -495,6 +495,8 @@ export default {'Bodyweight — same target again until every set is clean.': 'Corpo libero — stesso obiettivo finché ogni serie non è pulita.',// --- effort per set (RIR / RPE) ---+ '{0} sets bring an {1} with them — switch on Effort per set in Settings to see it.': '{0} serie portano con sé un {1} — attiva «Sforzo per serie» nelle impostazioni per vederlo.',+ '{0} sets bring an {1} with them.': '{0} serie portano con sé un {1}.','RIR': 'RIR','RPE': 'RPE','Effort per set': 'Sforzo per serie',diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 8cb8d22a8..78dac2b02 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -495,6 +495,8 @@ export default {'Bodyweight — same target again until every set is clean.': '맨몸 운동 — 모든 세트가 깔끔해질 때까지 같은 목표로.',// --- effort per set (RIR / RPE) ---+ '{0} sets bring an {1} with them — switch on Effort per set in Settings to see it.': '{0}개 세트에 {1}이(가) 함께 들어 있습니다 — 설정에서 ‘세트당 강도’를 켜면 보입니다.',+ '{0} sets bring an {1} with them.': '{0}개 세트에 {1}이(가) 함께 들어 있습니다.','RIR': 'RIR','RPE': 'RPE','Effort per set': '세트당 강도',diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex 3253f1732..e0acc3709 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -495,6 +495,8 @@ export default {'Bodyweight — same target again until every set is clean.': 'Masa własna — ten sam cel, dopóki każda seria nie będzie czysta.',// --- effort per set (RIR / RPE) ---+ '{0} sets bring an {1} with them — switch on Effort per set in Settings to see it.': '{0} serii ma zapisane {1} — włącz „Wysiłek w serii” w ustawieniach, aby to zobaczyć.',+ '{0} sets bring an {1} with them.': '{0} serii ma zapisane {1}.','RIR': 'RIR','RPE': 'RPE','Effort per set': 'Wysiłek na serię',diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 1b098d3f8..124442fef 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -495,6 +495,8 @@ export default {'Bodyweight — same target again until every set is clean.': 'Peso do corpo — o mesmo objetivo até todas as séries saírem limpas.',// --- effort per set (RIR / RPE) ---+ '{0} sets bring an {1} with them — switch on Effort per set in Settings to see it.': '{0} séries trazem um {1} — liga «Esforço por série» nas definições para o veres.',+ '{0} sets bring an {1} with them.': '{0} séries trazem um {1}.','RIR': 'RIR','RPE': 'RPE','Effort per set': 'Esforço por série',diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 99de94887..c0d4ee39f 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -495,6 +495,8 @@ export default {'Bodyweight — same target again until every set is clean.': 'Собственный вес — та же цель, пока все подходы не станут чистыми.',// --- effort per set (RIR / RPE) ---+ '{0} sets bring an {1} with them — switch on Effort per set in Settings to see it.': '{0} подходов несут с собой {1} — включите «Усилие в подходе» в настройках, чтобы увидеть.',+ '{0} sets bring an {1} with them.': '{0} подходов несут с собой {1}.','RIR': 'RIR','RPE': 'RPE','Effort per set': 'Усилие в подходе',diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 02d0f8f67..13b767734 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -495,6 +495,8 @@ export default {'Bodyweight — same target again until every set is clean.': 'Vücut ağırlığı — her set temiz çıkana kadar aynı hedef.',// --- effort per set (RIR / RPE) ---+ '{0} sets bring an {1} with them — switch on Effort per set in Settings to see it.': '{0} set beraberinde bir {1} getiriyor — görmek için Ayarlar’da «Set başına efor» seçeneğini aç.',+ '{0} sets bring an {1} with them.': '{0} set beraberinde bir {1} getiriyor.','RIR': 'RIR','RPE': 'RPE','Effort per set': 'Set başına zorluk',diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex f4e656ee0..a3e2d8cad 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -495,6 +495,8 @@ export default {'Bodyweight — same target again until every set is clean.': '徒手动作——保持同样的目标,直到每组都做干净。',// --- effort per set (RIR / RPE) ---+ '{0} sets bring an {1} with them — switch on Effort per set in Settings to see it.': '{0} 组自带 {1}——在设置中打开“每组强度”即可看到。',+ '{0} sets bring an {1} with them.': '{0} 组自带 {1}。','RIR': 'RIR','RPE': 'RPE','Effort per set': '每组强度',diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsxindex 6acae99a5..f815fc4f2 100644--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@ -3,7 +3,7 @@ import { useStore } from './store/useStore.js'import { useUI } from './store/useUI.js'import { EXDB, EXIDX, BODYPARTS, isCardio, allExercises, equipmentOf } from './lib/exercises.js'import { fmtDate, fmtNum, fmtVol, fmtDur, durPart, todayISO, uid, exCount, DAYN, MONTHS_LONG, ACCENTS } from './lib/format.js'-import { lastEntryFor, bestWeightFor, buildSets, effectiveRoutineId, workoutVolume, setsDone, setsDoneActive, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf } from './lib/history.js'+import { lastEntryFor, bestWeightFor, buildSets, effectiveRoutineId, workoutVolume, setsDone, setsDoneActive, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf, effortOf } from './lib/history.js'import { beep, vibrate } from './lib/sound.js'import { t, instrFor, getLang, INSTR_LANGS } from './lib/i18n.js'import { nav } from './lib/nav.js'@@ -181,6 +181,14 @@ function ImportSummary({ parsed, close }) {{have > 0 && <div className="small dim" style={{ marginBottom: 10 }}>{t('{0} days already have data here and will be left alone.', have)}</div>}+ {/* The file rated its sets. Say so: the column is off by default, so the ratings would+ otherwise arrive invisibly and look like they had been dropped. */}+ {!isBW && (parsed.rirSets + parsed.rpeSets) > 0 && <div className="small dim" style={{ marginBottom: 10 }}>+ {t(effortOf(st) === 'none'+ ? '{0} sets bring an {1} with them — switch on Effort per set in Settings to see it.'+ : '{0} sets bring an {1} with them.',+ parsed.rirSets || parsed.rpeSets, parsed.rirSets ? 'RIR' : 'RPE')}+ </div>}{!isBW && parsed.unmatchedNames.length > 0 && <><h4 className="sec">{t('Not in the library — added as your own exercises')}</h4><div className="mchips" style={{ marginBottom: 12 }}>