Fix three timer-pause gaps from code review #75

Merged
chrisp merged 1 commit from fix/review-timer-pause-gaps into main 2026-06-06 15:57:16 +00:00
Owner

Summary

  • pauseDraftOnError now snapshots timers: The error-path pause (triggered when auto-pick fails) was emitting draft-paused without timer data, while the manual-pause route included it. Now calls onDraftPaused() first so both paths emit consistent timers snapshots and the client display syncs correctly on error pauses too.
  • Parallel DB updates in onDraftPaused: Replaced sequential await per timer with Promise.all, removing O(n) DB round-trips.
  • Shared clientExpiresAt() helper: Extracted the repeated Date.now() + timeRemaining * 1000 expression into a named function in app/lib/draft-timer.ts and replaced all three call sites (handleTimerPickStarted, handleDraftStateSync, initial loader state).

Test plan

  • Simulate an auto-pick failure (empty queue with autodraft on) — confirm the timer display syncs to the server's floor value on error pause, same as manual pause
  • Pause manually mid-countdown — confirm display still matches post-refresh (existing behaviour preserved)
  • npm run typecheck passes
## Summary - **pauseDraftOnError now snapshots timers**: The error-path pause (triggered when auto-pick fails) was emitting draft-paused without timer data, while the manual-pause route included it. Now calls onDraftPaused() first so both paths emit consistent timers snapshots and the client display syncs correctly on error pauses too. - **Parallel DB updates in onDraftPaused**: Replaced sequential await per timer with Promise.all, removing O(n) DB round-trips. - **Shared clientExpiresAt() helper**: Extracted the repeated Date.now() + timeRemaining * 1000 expression into a named function in app/lib/draft-timer.ts and replaced all three call sites (handleTimerPickStarted, handleDraftStateSync, initial loader state). ## Test plan - Simulate an auto-pick failure (empty queue with autodraft on) — confirm the timer display syncs to the server's floor value on error pause, same as manual pause - Pause manually mid-countdown — confirm display still matches post-refresh (existing behaviour preserved) - npm run typecheck passes
chrisp added 1 commit 2026-06-06 15:52:28 +00:00
Fix three timer-pause gaps found in code review
All checks were successful
🚀 Deploy / 🧪 Test (pull_request) Successful in 2m34s
🚀 Deploy / ʦ🔍 Typecheck & Lint (pull_request) Successful in 1m19s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped
677b8ce816
- pauseDraftOnError now calls onDraftPaused() before emitting so the
  error-path pause carries the same snapshotted timer data as the
  manual-pause route (fixes inconsistency between the two paths)
- Parallelize DB updates in onDraftPaused with Promise.all instead of
  sequential awaits
- Extract clientExpiresAt() helper to draft-timer.ts and use it in all
  three places that re-anchor timeRemaining to the client clock, replacing
  duplicated Date.now() + timeRemaining * 1000 expressions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
chrisp merged commit f4bf7ff723 into main 2026-06-06 15:57:16 +00:00
chrisp deleted branch fix/review-timer-pause-gaps 2026-06-06 15:57:16 +00:00
Sign in to join this conversation.
No description provided.