Skip to content

Fix timer countdown display and audio tick timing#67

Merged
auerbachb merged 1 commit into
mainfrom
issue-61-fix-timer-timing
Mar 31, 2026
Merged

Fix timer countdown display and audio tick timing#67
auerbachb merged 1 commit into
mainfrom
issue-61-fix-timer-timing

Conversation

@auerbachb
Copy link
Copy Markdown
Owner

@auerbachb auerbachb commented Mar 31, 2026

Summary

  • Fixes spurious first audio tick firing immediately at session start by initializing lastTickSec to 0 instead of -1
  • Fixes timer display off-by-one by using ceiling rounding (Int(ceil(remaining))) so remaining=10.0 shows "0:10" not "0:09"
  • Extracts shared displaySeconds computed property to DRY up minutes/seconds logic

Closes #61

Test plan

  • lastTickSec initialized to 0 instead of -1
  • First audio tick fires at ~1 second, not immediately at session start
  • Timer display uses ceiling rounding (Int(ceil(remaining)))
  • Display shows "0:10" when remaining=10.0 (not "0:09")
  • Display shows "0:00" at session completion (remaining=0.0)
  • Only SessionViewModel.swift was modified — no changes to AudioEngine, BlockGridView, or SessionLogic

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved countdown display to round up remaining time (prevents showing a lower second prematurely).
    • Adjusted per-second audio cue timing so the first tick aligns correctly with the displayed time, reducing mismatched or missing initial cues.

- Initialize lastTickSec to 0 instead of -1 to prevent spurious first
  tick firing immediately at session start (~50ms)
- Use ceiling rounding for timer display so remaining=10.0 shows "0:10"
  instead of "0:09", with edge case handling for remaining=0.0

Closes #61

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
still-point Ignored Ignored Mar 31, 2026 10:50pm

Request Review

@auerbachb
Copy link
Copy Markdown
Owner Author

@greptileai

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 31, 2026

📝 Walkthrough

Walkthrough

Ceiling-based rounding for displayed countdown seconds was added to SessionViewModel, and the tick-sound gating variable lastTickSec was changed from -1 to 0 to alter the first per-second tick trigger.

Changes

Cohort / File(s) Summary
SessionViewModel (timer & tick logic)
ios/StillPointApp/ViewModels/SessionViewModel.swift
Added displaySeconds computed property using ceil(remaining) clamped to 0; minutes/seconds now use displaySeconds. Changed lastTickSec initialization from -1 to 0, altering first tick-trigger condition.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 I hopped and fixed the counting beat,
Ceil gentle-stepped each numbered seat,
The ticks now line up, one by one,
No double chime, the race is run.
A quiet session, steady fun. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly matches the main changes: fixing timer display off-by-one and audio tick timing issues as described in the objectives.
Linked Issues check ✅ Passed Code changes address both issue #61 objectives: using ceiling rounding fixes block countdown off-by-one, and changing lastTickSec initialization from -1 to 0 fixes spurious first tick.
Out of Scope Changes check ✅ Passed All changes remain focused on SessionViewModel.swift addressing the timer display and tick timing issues; no unrelated modifications to other components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #61

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-61-fix-timer-timing

Comment @coderabbitai help to get the list of available commands and usage tips.

@auerbachb
Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 31, 2026

✅ Actions performed

Full review triggered.

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.

[iOS Bug] Timer countdown and audio tick timing are inconsistent

1 participant