Skip to content

Add bar type selection to workouts - #14

Merged
benmosher merged 2 commits into
mainfrom
claude/add-bar-type-movement-gfEoX
Feb 27, 2026
Merged

Add bar type selection to workouts#14
benmosher merged 2 commits into
mainfrom
claude/add-bar-type-movement-gfEoX

Conversation

@benmosher

Copy link
Copy Markdown
Owner

Summary

This PR adds support for selecting and tracking bar types (barbell, dumbbell, etc.) in workout movements. Users can now specify which bar is used for each exercise, and this information is preserved during workout export/import and shared via URLs.

Key Changes

  • Movement bar selection: Added optional bar field to Movement type that can store either a bar type filter ({ type: string }) or a specific bar by ID ({ id: number })

  • Workout export/import:

    • exportWorkout() now accepts a bars parameter and resolves bar selections to bar types in the exported data
    • WorkoutImporter component now handles bar type mapping with UI for linking imported bar types to local bars
    • Bar type information is preserved in the packed/compressed export format
  • UI updates:

    • WorkoutEditor now displays a bar selection dropdown alongside the max selection, organized by bar type with options for specific bars or generic type selection
    • WorkoutViewer includes bar information when building set hash links for external tools
    • ShareDialog passes bars to the export function
  • Test coverage: Added comprehensive test suite for bar type round-tripping with various scenarios (specific bar ID, generic type, mixed movements, unknown bars)

Implementation Details

  • Bar type resolution uses a helper function resolveBarType() that handles both direct type specifications and ID-based lookups
  • The packed movement format is backward compatible: movements without bars use the 3-element format [name, maxName, sets], while those with bars use the 4-element format [name, maxName, sets, barType]
  • Bar selection UI uses prefixes (bar: for ID, type: for type) to distinguish between selection modes in dropdown values

https://claude.ai/code/session_01B33nPQF397D5gEJu9e2bJb

Movements can now have an optional barType (e.g. "barbell", "dumbbell")
and barId (specific bar index). This flows through the full system:

- Editor: select bar type or specific bar per movement via grouped dropdown
- Viewer: set buttons include bar/barWeight in URL hash for the calculator
- Export: barType is included in the packed format (backward-compatible)
- Import: bar type mapping UI with auto-match to existing bar types

Both fields are optional, so existing workouts are unaffected.

https://claude.ai/code/session_01B33nPQF397D5gEJu9e2bJb
Replace `barType?: string` + `barId?: number` with a single
`bar?: { type: string } | { id: number }` field on Movement.

Export now takes a bars array and resolves `{ id }` to the bar's type
string, so the portable format always contains the bar type regardless
of how the user selected the bar. Added test coverage for id resolution
and unknown bar id fallback.

https://claude.ai/code/session_01B33nPQF397D5gEJu9e2bJb
@benmosher
benmosher merged commit 82f2d47 into main Feb 27, 2026
1 check passed
@benmosher
benmosher deleted the claude/add-bar-type-movement-gfEoX branch February 27, 2026 22:40
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.

2 participants