Skip to content

fix(job-worker): preserveOrTrackInfiniteTimings doesn't do the same thing generateCurrentInfinitePieceObjects does for enable.start values#1666

Merged
jstarpl merged 2 commits intoSofie-Automation:mainfrom
nrkno:contribute/fix/sofie-4336/endRelativeToPart
Mar 23, 2026
Merged

fix(job-worker): preserveOrTrackInfiniteTimings doesn't do the same thing generateCurrentInfinitePieceObjects does for enable.start values#1666
jstarpl merged 2 commits intoSofie-Automation:mainfrom
nrkno:contribute/fix/sofie-4336/endRelativeToPart

Conversation

@jstarpl
Copy link
Copy Markdown
Contributor

@jstarpl jstarpl commented Feb 27, 2026

About the Contributor

This pull request is posted on behalf of the NRK.

Type of Contribution

This is a:

Bug fix

Current Behavior

Infinite objects in multi-gateway mode can shift around start time-wise on takes or end up with unusual stopped timestamps. Automated tests for multi-gateway mode have invalid timestamp values.

New Behavior

Infinite Piece continuation objects have enable properties that match what's created when an Infinite object starts playing. Timeline objects don't shift on takes and timeline regenerations.

Testing

  • 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 PR affects the playout logic in general, specifically the Infinite Pieces logic.

Time Frame

This Bug Fix is critical for us, please review and merge it as soon as possible.

Other Information

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.

Overview

This PR fixes incorrect timing behavior for Infinite Pieces in multi-gateway mode. Previously, infinite objects could shift their start times on takes or acquire unusual stopped timestamps. The fix ensures that infinite Piece continuation objects have enable properties that match those created when an Infinite object starts playing, preventing timeline objects from shifting on takes or timeline regenerations.

Changes

Core Logic (packages/job-worker/src/playout/timeline/multi-gateway.ts)

  • Added import of getPieceControlObjectId from corelib
  • Updated setPlannedTimingsOnPieceInstance: when computing userDurationEnd, endRelativeToPart is now correctly added to partPlannedStart instead of being used as-is
  • Updated preserveOrTrackInfiniteTimings:
    • Computes the piece's control object ID and retrieves its enable configuration
    • Extracts the pieceEnableStartOffset from the control object's enable.start property
    • Adjusts the infinite part group start time by subtracting pieceEnableStartOffset from the started playback time, ensuring consistency with how infinite pieces are initialized

Documentation (packages/job-worker/src/playout/timeline/rundown.ts)

  • Added explanatory comments describing how Infinite Part Groups handle start times in relation to piece enables, clarifying the treatment of absolute and relative starts and their interaction with the currentPartGroup context

Tests (packages/job-worker/src/playout/__tests__/timeline.test.ts)

  • Updated timing expectations in "In transitions with existing infinites" test: adjusted the expected start offset for the infinite piece's partGroup to account for the control object's enable.start offset
  • Updated "Infinite Pieces" test expectations: modified the timeline expectations to reflect the corrected offset relationship between planned playback start and the pieceGroup control start

…rateCurrentInfinitePieceObjects` does for `enable.start` values
@jstarpl jstarpl added the Contribution from NRK Contributions sponsored by NRK (nrk.no) label Feb 27, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb5dd9f and 1992048.

📒 Files selected for processing (3)
  • packages/job-worker/src/playout/__tests__/timeline.test.ts
  • packages/job-worker/src/playout/timeline/multi-gateway.ts
  • packages/job-worker/src/playout/timeline/rundown.ts

Walkthrough

Changes adjust how infinite piece start times are calculated in the playout timeline system by introducing piece control object offset computations. Test expectations are updated to reflect the new offset calculations, with supporting documentation added to explain the offset handling logic.

Changes

Cohort / File(s) Summary
Test Updates
packages/job-worker/src/playout/__tests__/timeline.test.ts
Updated test expectations for infinite piece offset calculations, adjusting start times by subtracting piece control object start offset (500ms).
Timeline Logic
packages/job-worker/src/playout/timeline/multi-gateway.ts
Added computation of pieceControlObjectId and pieceEnableStartOffset to adjust infinite part group start times relative to piece control enable values when playback has started.
Timeline Documentation
packages/job-worker/src/playout/timeline/rundown.ts
Added explanatory comments describing infinite part group start time handling relative to piece control enables and absolute/relative start interactions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • fix: Infinites timetravel #1611: Modifies infinite-piece start timing calculations by adjusting part-group starts relative to piece control enable/start values, directly related to the offset computation introduced here.

Suggested labels

Contribution

Suggested reviewers

  • Julusian

Poem

🐰 Offsets dance in timeline's grace,
Control objects find their place,
Infinite pieces start anew,
With five-hundred milliseconds' clue,
The gateway's path runs true!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main bug fix: aligning preserveOrTrackInfiniteTimings behavior with generateCurrentInfinitePieceObjects for handling enable.start values, which is the core issue addressed in this PR.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 96.87500% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...s/job-worker/src/playout/timeline/multi-gateway.ts 93.75% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jstarpl
Copy link
Copy Markdown
Contributor Author

jstarpl commented Mar 17, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 17, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jstarpl
Copy link
Copy Markdown
Contributor Author

jstarpl commented Mar 23, 2026

Having received no feedback in 3 weeks, I'm merging this.

@jstarpl jstarpl merged commit 0f06f6a into Sofie-Automation:main Mar 23, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Contribution from NRK Contributions sponsored by NRK (nrk.no)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant