Skip to content

Bug: program session suggested set programExerciseId mirrors session-exercise id (copy/paste) #228

Description

@evan188199-tech

Bug

In src/features/programs/actions/get-session-by-slug.action.ts, each suggested set's programExerciseId is filled with the session-exercise id instead of a program-exercise reference — a copy/paste that assigns the same value to two fields:

suggestedSets: ex.suggestedSets.map((set) => ({
  id: set.id,
  programSessionExerciseId: set.programSessionExerciseId,
  programExerciseId: set.programSessionExerciseId,   // ← same as above
  ...

set.programSessionExerciseId is the parent ProgramSessionExercise.id (ex.id). The ProgramSuggestedSet model has no programExerciseId column at all, so the field is synthesized — and it's synthesized to the wrong value: it always equals programSessionExerciseId, which already carries the session-exercise id. The real program-exercise identity available in this scope is ex.exerciseId (the underlying Exercise.id).

Impact

Latent: the current ProgramSessionClient doesn't read programExerciseId (it consumes types/valuesInt/valuesSec/units), so today's UI is unaffected. But the SuggestedSet type declares the field and any future consumer / test that relies on it gets a silently wrong value (it can never distinguish the program exercise and will always mirror the session-exercise id).

Fix

Carry the parent's real exercise id into the mapped set:

suggestedSets: ex.suggestedSets.map((set) => ({
  id: set.id,
  programSessionExerciseId: set.programSessionExerciseId,
  programExerciseId: ex.exerciseId,
  setIndex: set.setIndex,
  ...

I have a PR ready.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions