Appearance
UC-026.4: Edge Cases & Error Handling โ
๐ 1. Context & Problem Statement โ
- Distance Recalculation Integrity: Manual distance overrides or retroactively reassigning bikes for Strava activities must dynamically modify the affected frames'
totalKmto avoid cumulative discrepancies. - Ghost Bikes & Onboarding: Missing gear/bike references in Strava activities block synchronization. We need a wizard to map untracked frames immediately.
- Indoor/Trainer GPS Lack: Activities recorded indoors do not possess GPS polyline geometry, requiring disabled map controls and helpful tooltips to prevent drawing errors.
- Token Revocation Security: If a user revokes Strava access, subsequent syncs fail with
401 Unauthorized. The app must gracefully purge credentials and guide the user to relink.
โ๏ธ 2. Backend Logic & API (apps/api) โ
PATCH /api/strava/activities/:id/reassign:- Accepts payload
{ newLocalBikeId: string }forCONFIRMEDactivities. - Transactional: subtracts activity distance from old bike's
totalKmand adds it to new bike'stotalKm.
- Accepts payload
PATCH /api/strava/activities/:id/distance:- Accepts payload
{ newDistance: number }(meters) forCONFIRMEDactivities. - Transactional: calculates distance delta and updates the assigned bike's
totalKmsafely.
- Accepts payload
- 401 Purge Interceptor:
- Catches expired/revoked
401 Unauthorizedtoken responses, clears the user's Strava tokens, and resets credential records in the database.
- Catches expired/revoked
๐จ 3. User Interface (apps/web) โ
- Indoor Workouts: Displays "No GPS Data Available" banners and disables "Map Route" buttons with customized hover-tooltips for virtual rides lacking geometry.
- Ghost Bike Resolver: Clicking "[ โ Import New Bike ]" inside the frame selection dropdown opens the
SmartMappingWizardModalto import missing bikes from Strava on the fly.
๐งช 4. Testing Requirements โ
- Integration Tests: Verify reassignment and distance math transaction locks. Test token purge workflows.