Skip to content

fix(timeline): roll playhead seconds into the next minute#671

Open
soufian3hm wants to merge 1 commit into
webadderallorg:mainfrom
soufian3hm:fix/playhead-time-minute-rollover
Open

fix(timeline): roll playhead seconds into the next minute#671
soufian3hm wants to merge 1 commit into
webadderallorg:mainfrom
soufian3hm:fix/playhead-time-minute-rollover

Conversation

@soufian3hm

@soufian3hm soufian3hm commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

formatPlayheadTime rounds the seconds component independently of the minutes/hours, so a time that rounds up to 60.0 does not carry into the next minute. During playback/scrubbing the editor's playhead clock then renders invalid labels.

Root cause

const s = ms / 1000;
const min = Math.floor(s / 60);
const sec = s % 60;          // e.g. 59.97
// sec.toFixed(1) -> "60.0", but `min` was already computed

(59.97).toFixed(1) becomes "60.0", which is appended to the already-computed minute.

Observed (before)

input (ms) output expected
59950 60.0s 1:00.0
59970 60.0s 1:00.0
119970 1:60.0 2:00.0

Fix

Round to the displayed precision (tenths of a second) first, then split into minutes/seconds so any carry rolls into the minute correctly. Existing outputs (1234 -> 1.2s, 61400 -> 1:01.4) are unchanged.

Tests

Added a regression test covering the rollover boundary. Full time.test.ts suite passes (7/7).

Risk

Minimal — pure display formatting, no behavioural change outside the rounding boundary; existing assertions preserved.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Corrected video editor timeline playhead time formatting to properly round values near minute transitions, preventing display inconsistencies when time approaches 60 seconds.
  • Tests

    • Added unit test to validate playhead time rounding behavior at minute boundaries.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a69f1c28-d657-4fa9-a854-4aa2fe034b19

📥 Commits

Reviewing files that changed from the base of the PR and between 52dd842 and 4ac4b7d.

📒 Files selected for processing (2)
  • src/components/video-editor/timeline/core/time.test.ts
  • src/components/video-editor/timeline/core/time.ts

📝 Walkthrough

Walkthrough

The PR fixes a rounding inconsistency in playhead time formatting. formatPlayheadTime now pre-rounds milliseconds to tenths of a second before computing minutes and seconds, ensuring that values near the 60-second threshold carry over into the next minute cleanly. A test validates this behavior.

Changes

Playhead Time Rounding

Layer / File(s) Summary
Playhead time rounding and test
src/components/video-editor/timeline/core/time.ts, src/components/video-editor/timeline/core/time.test.ts
formatPlayheadTime now rounds milliseconds to tenths of a second before deriving minutes and remaining seconds, preventing edge cases where values just under 60 seconds render with carry inconsistencies. A test case validates that near-60-second values (e.g., 59.950, 59.970 ms) round correctly into the next minute (1:00.0) format.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A playhead near sixty did stumble and sway,
But rounding first fixes what formatting couldn't convey!
Now fifty-nine point-nine-seven rolls to one:zero,
No more six-zero nonsense—this fix is a hero! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description covers the problem, root cause with code example, observed vs expected behavior, the fix approach, tests added, and risk assessment. However, it does not follow the repository's template structure with required sections like Type of Change checkbox, Related Issue(s), Screenshots/Video, and Testing Guide. Restructure the description to match the template: add Type of Change (Bug Fix), Related Issue(s) section, optional Screenshots/Video sections, and a Testing Guide with step-by-step reproduction instructions.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(timeline): roll playhead seconds into the next minute' clearly summarizes the main fix: ensuring rounded seconds carry into the next minute.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant