1.3 KiB
Transaction-safe session editing
Status
SESSION_EDIT_PERSISTENCE=IMPLEMENTED
SESSION_EDIT_TUI=IMPLEMENTED
TRAINLOG_FORMAT_V1=FROZEN
DATABASE_SCHEMA_V2=UNCHANGED
This slice adds the persistence foundation required to correct a recorded workout without deleting the session itself.
trainlog_database_replace_session_exercises(...) replaces the
session_exercises and performed_sets children inside one explicit
transaction.
The parent sessions row is never deleted. Therefore these remain stable:
session_id;- start/end timestamps;
session_type;- session notes;
- any
body_observations.session_row_idlink.
On any lookup, constraint or insertion error, the whole replacement rolls back.
trainlog_database_load_session_editable(...) exposes the exact persisted
exercise/set values in bounded caller-owned buffers. It refuses insufficient
capacity instead of silently truncating editable data.
No schema migration and no JSON v1 change are required.
TUI integration
The persistence foundation is now used by the ncurses editor.
A persisted workout can be reopened from history or session detail, corrected,
and saved without deleting/recreating the parent sessions row.
Draft editing and persisted editing share the same bounded exercise/set model. Cancelling with Escape leaves the stored workout unchanged.