Skip to content

Conversation

@arii
Copy link
Owner

@arii arii commented Feb 10, 2026

Description

This PR addresses regressions and UX issues in useWorkoutSession:

  1. HR Zones: Re-implemented timeInZones calculation and persistence within the hook state to ensure analytics features work correctly in real-time.
  2. Auto-Pause: Added logic to automatically transition a 'running' session to 'paused' upon page load if the last activity was more than 1 minute ago, preventing incorrect duration accumulation.
  3. Throttling: Reduced the UI flush interval from 5s to 1s to provide a more responsive interface.
  4. Performance: Stabilized startWorkout callback to prevent unnecessary re-renders in consumer components (ConnectPage).
  5. Tests: Updated and fixed useWorkoutSession.test.ts to verify these changes.

Fixes #

Change Type: 🐛 Bug fix (non-breaking change fixing an issue)

PR Scope Checklist

This checklist is mandatory for all PRs.

  • PR has a clear, single purpose: The title and description of the PR clearly state the purpose of the change.
  • All changes relate to the stated objective: The code changes should be directly related to the purpose of the PR.
  • No unrelated cleanup or refactoring: The PR should not contain any changes that are not directly related to the stated objective.
  • Title and description match the actual changes: The title and description should accurately reflect the changes in the PR.
  • Tests cover the specific change scope: The tests should be focused on the changes in the PR and should not include unrelated tests.

Impact Assessment

  • Changes are backward compatible (or breaking changes are documented)
  • Tests are added/updated for new functionality
  • Documentation is updated if needed
  • ADR is created/updated for significant architectural changes
Original PR Body

This PR addresses regressions and UX issues in useWorkoutSession:

  1. HR Zones: Re-implemented timeInZones calculation and persistence within the hook state to ensure analytics features work correctly in real-time.
  2. Auto-Pause: Added logic to automatically transition a 'running' session to 'paused' upon page load if the last activity was more than 1 minute ago, preventing incorrect duration accumulation.
  3. Throttling: Reduced the UI flush interval from 5s to 1s to provide a more responsive interface.
  4. Performance: Stabilized startWorkout callback to prevent unnecessary re-renders in consumer components (ConnectPage).
  5. Tests: Updated and fixed useWorkoutSession.test.ts to verify these changes.

PR created automatically by Jules for task 8015467242927168109 started by @arii

…ptimize UX

- Implement `timeInZones` state and logic in `useWorkoutSession` to restore regression.
- Add `lastActiveTime` tracking and auto-pause logic on session hydration to prevent duration jumps.
- Reduce UI update throttling from 5000ms to 1000ms for smoother experience.
- Optimize `startWorkout` stability using `useRef` for `totalCalories`.
- Update unit tests to cover new functionality and fix mock discrepancies.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions github-actions bot changed the title Refactor useWorkoutSession for Zones, Auto-Pause, and Throttling test(medium): Refactor useWorkoutSession for Zones, Auto-Pause, and Throttling Feb 10, 2026
@arii
Copy link
Owner Author

arii commented Feb 10, 2026

📋 Quality Gate Results

Check Status
Knip ✅ success
Lint ❌ failure
Slop ✅ success
Build ✅ success
Infra Tests ❌ skipped
Unit Tests ❌ skipped
Component Tests ❌ skipped
Perf Tests ❌ skipped
Visual Tests ❌ skipped

❌ Lint Failure Details


> hrm@0.30.0 lint /home/runner/work/hrm/hrm
> eslint app/ components/ constants/ context/ hooks/ lib/ services/ tests/ types/ utils/ server.ts proxy.ts --cache


/home/runner/work/hrm/hrm/hooks/useWorkoutSession.ts
   73:13  error  'newState' is never reassigned. Use 'const' instead                                                                                                                                                prefer-const
  110:6   error  Replace `·type:·'UPDATE_ZONES';·payload:·{·zone:·HrZoneName;·delta:·number;·now:·number·}` with `⏎······type:·'UPDATE_ZONES'⏎······payload:·{·zone:·HrZoneName;·delta:·number;·now:·number·}⏎···`  prettier/prettier
  164:43  error  Insert `,`                                                                                                                                                                                         prettier/prettier
  465:48  error  Replace `(now·-·1000)` with `now·-·1000`                                                                                                                                                           prettier/prettier
  476:19  error  Replace `·type:·'UPDATE_ZONES',·payload:·{·zone:·zoneName,·delta,·now·}` with `⏎··········type:·'UPDATE_ZONES',⏎··········payload:·{·zone:·zoneName,·delta,·now·},⏎·······`                        prettier/prettier

✖ 5 problems (5 errors, 0 warnings)
  5 errors and 0 warnings potentially fixable with the `--fix` option.

 ELIFECYCLE  Command failed with exit code 1.

❌ Infrastructure Test Failure Details

Log file not found.

❌ Unit Test Failure Details

Log file not found.

❌ Component Test Failure Details

Log file not found.

❌ Visual Test Failure Details

Log file not found.

❌ Performance Test Failure Details

Log file not found.

⚠️ Some checks failed. Full logs available in workflow artifacts.


Report generated for commit: a7d0f4576a657335798e87084916dcbb85643e75

@google-labs-jules
Copy link
Contributor

📋 Quality Gate Results

Check Status
Knip ✅ success
Lint ❌ failure
Slop ✅ success
Build ✅ success
Infra Tests ❌ skipped
Unit Tests ❌ skipped
Component Tests ❌ skipped
Perf Tests ❌ skipped
Visual Tests ❌ skipped

❌ Lint Failure Details


> hrm@0.30.0 lint /home/runner/work/hrm/hrm
> eslint app/ components/ constants/ context/ hooks/ lib/ services/ tests/ types/ utils/ server.ts proxy.ts --cache


/home/runner/work/hrm/hrm/hooks/useWorkoutSession.ts
   73:13  error  'newState' is never reassigned. Use 'const' instead                                                                                                                                                prefer-const
  110:6   error  Replace `·type:·'UPDATE_ZONES';·payload:·{·zone:·HrZoneName;·delta:·number;·now:·number·}` with `⏎······type:·'UPDATE_ZONES'⏎······payload:·{·zone:·HrZoneName;·delta:·number;·now:·number·}⏎···`  prettier/prettier
  164:43  error  Insert `,`                                                                                                                                                                                         prettier/prettier
  465:48  error  Replace `(now·-·1000)` with `now·-·1000`                                                                                                                                                           prettier/prettier
  476:19  error  Replace `·type:·'UPDATE_ZONES',·payload:·{·zone:·zoneName,·delta,·now·}` with `⏎··········type:·'UPDATE_ZONES',⏎··········payload:·{·zone:·zoneName,·delta,·now·},⏎·······`                        prettier/prettier

✖ 5 problems (5 errors, 0 warnings)
  5 errors and 0 warnings potentially fixable with the `--fix` option.

 ELIFECYCLE  Command failed with exit code 1.

❌ Infrastructure Test Failure Details

Log file not found.

❌ Unit Test Failure Details

Log file not found.

❌ Component Test Failure Details

Log file not found.

❌ Visual Test Failure Details

Log file not found.

❌ Performance Test Failure Details

Log file not found.

⚠️ Some checks failed. Full logs available in workflow artifacts.


Report generated for commit: a7d0f4576a657335798e87084916dcbb85643e75

I have addressed the linting and formatting issues in hooks/useWorkoutSession.ts by running pnpm run lint --fix. The prefer-const error and Prettier formatting errors have been resolved.

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.

1 participant