Skip to content

Allow completed workout sessions to be deleted or reopened (#5) - #80

Merged
NeoLorenzo merged 1 commit into
mainfrom
claude/fix-5-session-delete-reopen-3f731e
Oct 17, 2026
Merged

NeoLorenzo merged 1 commit into
mainfrom
claude/fix-5-session-delete-reopen-3f731e

Conversation

@NeoLorenzo

Copy link
Copy Markdown
Owner

Closes #5.

What changes

  • Delete a completed session. Session History has a Delete action with an explicit confirmation step. It calls the owner-scoped RPC delete_completed_workout_session.
  • Reopen a completed session. reopen_workout_session puts the session back in the live-workout editor. It is refused while another workout is in progress, which keeps the one-active-session rule.
    • Before reopening, it stores an exact snapshot of the session, its exercises and its sets in workout_session_reopen_snapshots: owner-scoped with RLS, and deleted along with the session.
  • Cancelling a reopened correction restores the original. cancel_workout_session restores the snapshot, including canonical_equipment_id and the legacy equipment fields, instead of deleting the session. Completing the correction discards the snapshot.
  • Built on Normalize canonical equipment identity across gyms and separate equipment from exercise identity #22.
    • Reopen refuses a session that references a retired exercise.
    • Discard refuses (and leaves the correction open) if an exercise was retired since the reopen.
    • Equipment that only the snapshot still references keeps its name, and its link is cleared.

Migration

supabase/migrations/20261018110000_add_completed_session_delete_and_reopen.sql. It sorts after #22's migrations and only adds things: a new table, new functions, and a replaced cancel_workout_session. It does not change existing rows.

Validation

npm run agent:check passes locally against a fresh disposable DB: syntax, node tests, and all pgTAP suites, including the new workout_session_lifecycle (54 checks) and #22's canonical_equipment_identity. Not yet clicked through in a browser.

Deploying

Merging deploys the frontend through GitHub Pages straight away, so apply the migration to production at the same time, as with #22.

Session History can delete a completed session after confirmation, or reopen
it in the live-workout editor while no other workout is active. Reopening
snapshots the completed session; cancelling a reopened correction restores
that snapshot, including canonical equipment, instead of destroying history.

Closes #5.
@NeoLorenzo
NeoLorenzo merged commit 567e2cf into main Oct 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow completed workout sessions to be deleted or reopened for full editing

1 participant