Skip to content

refactor: add named RundownUtils timecode-diff helpers, replace 22 call sites#1742

Draft
rjmunro wants to merge 5 commits into
Sofie-Automation:mainfrom
rjmunro:rjmunro/simplify-format-diff-timecode
Draft

refactor: add named RundownUtils timecode-diff helpers, replace 22 call sites#1742
rjmunro wants to merge 5 commits into
Sofie-Automation:mainfrom
rjmunro:rjmunro/simplify-format-diff-timecode

Conversation

@rjmunro
Copy link
Copy Markdown
Contributor

@rjmunro rjmunro commented May 7, 2026

About the Contributor

This pull request is posted on behalf of SuperflyTV.

Type of Contribution

This is a: Code improvement

Current Behavior

Timecode difference formatting logic was duplicated across ~22 call sites in the webui. Each call site directly called low-level RundownUtils helpers (formatDiffToTimecode, formatDiffToTimecodeSign, etc.) with varying combinations of arguments, making the intent of each call unclear and changes risky.

New Behavior

Four named helper functions are added to RundownUtils:

  • formatDiffToTimecodeHours — formats a diff as HH:MM:SS (for durations where hours matter)
  • formatDiffToTimecodeCountdown — formats a diff as a countdown (MM:SS with sign)
  • formatDiffToTimecodeWithSign — formats a diff with an explicit +/- sign prefix
  • formatDiffToTimecodeOverUnder — formats a diff as over/under with optional floor-to-zero behaviour

All 22 call sites across 15 files are updated to use the appropriate helper, reducing duplication and making each call site's intent self-documenting.

Testing Instructions

  • I have added one or more unit tests for this PR
  • I have updated the relevant unit tests
  • No unit test changes are needed for this PR

Affected areas

This is a pure refactor — no behaviour changes. Affected areas are timing displays throughout the Rundown view, Clock view, Segment list, and Shelf.

Time Frame

Not urgent. This is a clean-up refactor with no functional impact.

Other Information

No breaking changes. The new helpers are thin wrappers over the existing RundownUtils functions, which remain unchanged.

Status

  • PR is ready to be reviewed.
  • The functionality has been tested by the author.
  • Relevant unit tests has been added / updated.
  • Relevant documentation (code comments, system documentation) has been added / updated.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: da333936-81ef-4f65-8e0f-0e35b287665d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ 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.

@rjmunro rjmunro force-pushed the rjmunro/simplify-format-diff-timecode branch from 1918f11 to c8cbca2 Compare May 7, 2026 11:13
@Saftret Saftret added the Contribution from SuperFly.tv Contributions sponsored by SuperFly.tv label May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Contribution from SuperFly.tv Contributions sponsored by SuperFly.tv

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants