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.

Merge #263: feat(history): edit the date and start time of a saved workout (#218) (Parth-Vasave)

Duarte Santos6e0fa3dbab10
diff --cc frontend/src/lib/sync-merge.test.js
index 613483c0b,b96b7d09f..dccb6dbf3
--- a/frontend/src/lib/sync-merge.test.js
+++ b/frontend/src/lib/sync-merge.test.js
@@@ -1,5 -1,6 +1,6 @@@
import { describe, expect, it } from 'vitest'
-import { localExtras, mergeBodyweight, mergeStates, newerOf, unionById } from './sync-merge.js'
+import { localExtras, mergeBodyweight, mergeStates, newerOf, stampRoutines, unionById } from './sync-merge.js'
+ import { retimeWorkout } from './workout-date.js'
const workout = (id, d = '2026-09-01', start = 1) => ({ id, d, start, entries: [] })
const routine = (id, name = id) => ({ id, name, ex: [] })
diff --cc frontend/src/sheets.jsx
index 838a79aa2,f312f796d..057297905
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@@ -35,9 -34,10 +35,10 @@@ import { nextUnfinishedUnit } from './l
import { swapActiveExercise } from './lib/active-exercise-swap.js'
import { useSheetKeyboard, useRevealActiveChip, tappable } from './lib/use-sheet-keyboard.js'
import { isFav, toggleFav, sortFavouritesFirst } from './lib/favourites.js'
-import { buildSessionEntries } from './lib/session-start.js'
+import { buildSessionEntries, buildPlannedEntry } from './lib/session-start.js'
import { buildCombinedEntries, deriveSessionName } from './lib/session-merge.js'
import { workoutsOn, backfillStart, backfillEnd, completeBackfill } from './lib/backfill.js'
+ import { moveWorkout, sameWorkout, startTimeOf } from './lib/workout-date.js'
const S = () => useStore.getState().S
const update = (...a) => useStore.getState().update(...a)
@@@ -1755,19 -1726,13 +1791,26 @@@ function WorkoutDetail({ w, close })
placeholder={t('How the session went as a whole.')}
onFocus={onNoteFocus} onChange={e => setNote(e.target.value)} onBlur={saveNote} />
<div style={{ height: 14 }} />
+ {/* The note lives in a textarea that only writes on blur, and moving the workout re-keys a
+ legacy record — so flush it first and stop the unmount hook writing it a second time. */}
+ <Button icon="calendar" style={{ marginBottom: 8 }} onClick={() => {
+ saveNote()
+ initial.current = latest.current.trim().slice(0, NOTE_MAX)
+ workoutDateSheet(w, close)
+ }}>{t('Change date & time')}</Button>
+ <Button icon="plus" onClick={() => confirmSheet({
+ title: t('Save as routine?'),
+ message: t('Create an independent routine from these exercise targets. Your workout history is kept.'),
+ confirmText: t('Save'),
+ onConfirm: () => {
+ let id
+ try { update(s => { id = saveSessionAsRoutine(s, w, w.name) }) }
+ catch (e) { toast(t(e.message)); return }
+ close()
+ nav('/plan/r/' + id)
+ }
+ })}>{t('Save as routine')}</Button>
+ <div style={{ height: 10 }} />
<Button variant="danger" onClick={() => confirmSheet({ title: t('Delete workout?'), message: t('This removes it from your history for good.'), confirmText: t('Delete'), danger: true, onConfirm: () => { update(s => { s.workouts = s.workouts.filter(x => x.id !== w.id) }); close(); toast(t('Workout deleted')) } })}>{t('Delete workout')}</Button>
</>
}