Skip to content

Practice timer: beeps on iPhone, Apple Watch info and controls, ahead/behind (PR7c, PR7d) - #45

Merged
mattbat merged 14 commits into
mainfrom
claude/loving-keller-3kj4a0
Dec 1, 2026
Merged

mattbat merged 14 commits into
mainfrom
claude/loving-keller-3kj4a0

Conversation

@mattbat

@mattbat mattbat commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Why the beeps weren't playing

  • Silent switch: the beeps used Web Audio, and iPhone mutes Web Audio when the ring/silent switch is on. This is the most likely cause.
  • No real tap: sound was readied on pointerdown (touch-down). iOS only allows audio after a full tap (touchend/click), so the sound often never got readied.
  • After locking or switching apps: iOS puts the audio context in an interrupted state, and nothing resumed it.
  • Locked phone: no app code runs while the phone is locked, so a timer can't start a beep.

What changed

  • Sound plays through a single shared <audio> element, as media. It uses the media volume and ignores the silent switch. Where supported, it also sets navigator.audioSession.type = 'playback'.
  • Sound is readied on a full tap on the run screen and on Start practice.
  • Beep when the phone is locked (on by default): the run screen renders the rest of the block as one WAV track (8 kHz, 8-bit) that is silent until each beep. iPhone keeps playing media while locked, so the beeps arrive on time. The track is rebuilt whenever the clock or the block changes, restarted if the phone stopped it, and stopped when you leave the screen. While it plays, the live beeps stay quiet so nothing doubles.
  • Lock screen and Apple Watch: while the track plays, Now Playing shows the drill as the title and "Ends 4:40 PM · Next: " (or "Paused · 3:12 left · …") as the artist. It uses a time of day because no code runs while the phone is locked, so a countdown would go stale. The progress ring spans the whole block. The album art (src/nowPlayingArt.ts) is sized to read on a watch: "Block n of m" with a small next5 icon, ENDS and the time in large type, one line per station (coach, then drill), and the rotation times or what's next. ⏯ pauses and resumes the practice clock, and ⏭ is Next; both can be undone.
  • Watch tap at 1 minute left and time up (src/timerNotice.ts, off by default): a watch only vibrates for notifications, and there's no server to schedule one. iOS wakes the app when the timer track ends, just after the time-up beeps, so the app posts "Time's up: " then. "1 minute left: " goes out from the track's timeupdate events as they pass the 1-minute beep. iPhone forwards both to the watch while the phone is locked. It's skipped if more than 20 s late. The Diagnostics switch asks permission, and the locked test sends one too.
  • Ahead or behind (PR7d): practicePace is the target length minus the projected finish from blockEnds, the same projection as the late warning. It goes by the time of day: startedAt is kept when Start is tapped (optional field, no migration), the end time is the planned start (or the tap) plus the length, and pauses and a late start count. The box shows the target end time. The run screen shows Drill and Practice boxes side by side (green ahead, red behind, ✓ on time, no + or −). The watch art has a big coloured box beside the end time ("5m BEHIND").
  • Settings → Practice timer: the sound (Beep, Whistle, Chime, Buzzer; how loud is the phone's volume), the "Beep when the phone is locked" switch, the Apple Watch switch, a short hint, and Test beep and Test locked so any coach can check alerts work on their phone. Diagnostics keeps the last play and notification results.
  • New pure module src/domain/beeps.ts (beepPlan, renderBeeps, encodeWav) with example and property tests. Help, REQUIREMENTS (PR7c), STATUS and a changelog note are updated.

To try on the beta preview

  1. Settings → Practice timer: Test beep with the silent switch on.
  2. Tap Test locked, lock the phone, and listen for 1 beep after 10 s, then 3 beeps.
  3. Run a short practice with the phone locked.

Trade-off: while the locked track plays, it pauses music from other apps and shows as "Practice timer" on the lock screen. Turning the switch off keeps your music playing but stops beeps while the phone is locked.

Checks

Lint, type check, 518 unit tests and the build pass. The e2e suite passed on Chromium; WebKit isn't installed in this container, so CI runs it.


Generated by Claude Code

… locked (PR7c)

The beeps used Web Audio, which iPhone mutes with the silent switch; the
sound was readied on pointerdown, which iOS doesn't count as a tap for
audio; an interrupted audio context was never resumed; and no code runs
while the phone is locked.

Sound now plays through one shared <audio> element (media playback),
readied on click/touchend and on Start practice. With "Beep when the phone
is locked" on, the run screen renders the rest of the block as one WAV
track, silent until each beep, so the beeps come on time when locked.
Diagnostics gets sound (Beep, Whistle, Chime, Buzzer), volume, the locked
switch, test beeps and a 10-second locked test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vMVHghGSC1psGfSfnQnmv
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Deploying next5 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 80c032d
Status: ✅  Deploy successful!
Preview URL: https://886eec7f.next5-4gi.pages.dev
Branch Preview URL: https://claude-loving-keller-3kj4a0.next5-4gi.pages.dev

View logs

…watch (PR7c)

While the timer track plays, its Media Session title is the current drill,
the artist line is "Next: <drill> · n min", the album is "Block n of m",
and the position state spans the block, so the progress bar counts down
the time left on the lock screen and Apple Watch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vMVHghGSC1psGfSfnQnmv
…(PR7c)

- Line 2 on the lock screen and watch is "Ends 4:40 PM · Next: <drill>"
  (or "Paused · 3:12 left · …"). A time of day stays right while the phone
  is locked and runs no code; a countdown would go stale.
- Album art (512 px canvas): next5 icon, block, each station with its
  coach, when it ends, and the rotation times or what's next.
- Media Session buttons: ⏯ pauses and resumes the practice clock, ⏭ is
  Next. Both undoable. Cleared when leaving the run screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vMVHghGSC1psGfSfnQnmv
…ne (PR7c)

Option C: "Block n of m" with a small icon in the corner, ENDS and the time
in large type (PAUSED · TIME LEFT while paused), one line per station with
the coach (without "Coach") in bold and then the drill, and the rotation
times or what's next. Long lines shrink to fit; one station gets a line
each for coach and drill; past four stations, three and "+ n more".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vMVHghGSC1psGfSfnQnmv
A watch only vibrates for notifications, and with no server nothing can
schedule one. iOS does wake the app when its timer track ends, just after
the time-up beeps, so the app posts "Time's up: <drill>" (with what's
next) through the service worker then; with the phone locked it goes to
the watch. Skipped if more than 20 s late. Off by default: a Diagnostics
switch asks permission, and the locked test sends one too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vMVHghGSC1psGfSfnQnmv
The test read setTrackControls' first call as soon as the Pause button
showed, but the screen registers the buttons in an effect after that
render, so on a slower CI runner there was no call yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vMVHghGSC1psGfSfnQnmv
"1 minute left: <drill>" goes out from the timer track's timeupdate
events once they pass the 1-minute beep, since the track is still playing
then (time's up still uses its ended event). Each kind has its own tag so
one doesn't replace the other. The locked test sends both, and
Diagnostics says which was sent last.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vMVHghGSC1psGfSfnQnmv
When the time-up beeps finished, the track ended, nothing was playing,
and iOS suspended the app, so the watch's ⏭ (Next) reached nothing. Now a
5-second silent loop plays on, shown as "Time's up · Next: ...", until
Next, Pause or leaving the run screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vMVHghGSC1psGfSfnQnmv
practicePace: the target length minus the projected finish from
blockEnds (the late warning's projection), in whole minutes; on time
within half a minute. The run screen shows the drill's countdown beside a
Practice box (green ahead, red behind, ✓ on time, no + or −). The watch
album art has the same in a big coloured box beside the end time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vMVHghGSC1psGfSfnQnmv
@mattbat mattbat changed the title Practice beeps play on iPhone, silent switch on or phone locked (PR7c) Practice timer: beeps on iPhone, Apple Watch info and controls, ahead/behind (PR7c, PR7d) Dec 1, 2026
…ics (PR7c)

Settings → Practice timer now has the sound, volume, "Beep when the phone
is locked" and the Apple Watch switch, with a one-line hint and a "Test
the beep" link. Diagnostics keeps only the test beeps, the locked test
and the readings. The help tip is shorter too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vMVHghGSC1psGfSfnQnmv
…PR7d)

Practice now keeps startedAt (optional, no migration) when Start is
tapped. The end time is the planned start time plus the length (or the
tap plus the length if no time is set or it was over an hour off). While
live, blockEnds ends the current block at now plus what's left of it, so
paused time and a late start count, in the Practice box and the late
warning alike. The box shows the target end time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vMVHghGSC1psGfSfnQnmv
The box rounded to the nearest minute and the late warning rounded up,
so 2⅓ minutes over showed as 2 and 3. Pace now rounds the cautious way,
for a gym booked to a set time: behind up, like the late warning, and
ahead down. A property test checks they always agree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vMVHghGSC1psGfSfnQnmv
Beeps render at full scale, so the phone's volume buttons set how loud.
Settings → Practice timer now has Test beep and Test locked, so any coach
can check the alerts work on their phone; Diagnostics keeps only the last
sound and notification results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vMVHghGSC1psGfSfnQnmv
"18m" and "40m" at full size were wider than the box, so they were cut
to "18…". The number now shrinks to fit instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014vMVHghGSC1psGfSfnQnmv
@mattbat
mattbat marked this pull request as ready for review December 1, 2026 05:10
@mattbat
mattbat merged commit c47e5ec into main Dec 1, 2026
13 checks passed
@mattbat mattbat mentioned this pull request Dec 1, 2026
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