Skip to content

fix: Infinites timetravel#1611

Open
jstarpl wants to merge 2 commits intoSofie-Automation:mainfrom
nrkno:upstream/fix/infinites-timetravel
Open

fix: Infinites timetravel#1611
jstarpl wants to merge 2 commits intoSofie-Automation:mainfrom
nrkno:upstream/fix/infinites-timetravel

Conversation

@jstarpl
Copy link
Contributor

@jstarpl jstarpl commented Jan 22, 2026

About the Contributor

This pull request is posted on behalf of the NRK.

Type of Contribution

This is a:

Bug fix

Current Behavior

When using Multi-Gateway mode, a piece of code that is supposed to keep infinites enable objects while in "Single Gateway Mode" stable across takes, makes them shift around in time.

New Behavior

The code is only enabled when Multi-Gateway mode is not enabled. Tests to ensure this stable behavior are added.

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, timeline generation logic specifically.

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.

@jstarpl jstarpl requested a review from a team as a code owner January 22, 2026 16:20
@jstarpl jstarpl added Contribution External contribution Contribution from NRK Contributions sponsored by NRK (nrk.no) labels Jan 22, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

Walkthrough

This change introduces multi-gateway mode support to the playout timeline generation system. A multiGatewayMode boolean flag is added to the RundownTimelineTimingContext interface and propagated through the timeline generation pipeline, influencing timing calculations for infinite pieces. Test coverage expands to validate both single-gateway and multi-gateway scenarios with updated test structures and timing behaviors.

Changes

Cohort / File(s) Summary
Mock Setup
packages/job-worker/src/__mocks__/context.ts
Extends setupDefaultJobEnvironment to accept optional studioSettings parameter; merges provided settings into studio.settingsWithOverrides.defaults at runtime.
Timeline Tests
packages/job-worker/src/playout/__tests__/timeline.test.ts
Major refactoring separating single-gateway and multi-gateway test modes; adds timing helpers (getCurrentTime, explicit adjustFakeTime calls); expands assertions for timeline validation (activation IDs, rehearsal flags, part states, latency handling); introduces multi-gateway latency and safety margin workflows. (+1400/-1006 lines)
Rundown Tests
packages/job-worker/src/playout/timeline/__tests__/rundown.test.ts
Updates all buildTimelineObjsForRundown call sites to pass an additional boolean parameter as fourth argument.
Timeline Generation Logic
packages/job-worker/src/playout/timeline/generate.ts
Passes isMultiGatewayMode flag to buildTimelineObjsForRundown function invocation.
Rundown Timeline Core
packages/job-worker/src/playout/timeline/rundown.ts
Adds multiGatewayMode: boolean field to RundownTimelineTimingContext interface; extends buildTimelineObjsForRundown signature with multiGatewayMode parameter; adjusts infinite piece enable calculations to branch on multiGatewayMode, using pieceInstance.reportedStartedPlayback in non-multi-gateway mode instead of plannedStartedPlayback.

Sequence Diagram

sequenceDiagram
    actor Caller
    participant Generate as Timeline<br/>Generate
    participant Rundown as Rundown<br/>Builder
    participant Context as Timeline<br/>Timing Context
    participant Calc as Timing<br/>Calculator

    Caller->>Generate: generatePlayoutTimeline(isMultiGatewayMode)
    Generate->>Rundown: buildTimelineObjsForRundown(..., multiGatewayMode)
    Rundown->>Context: Create RundownTimelineTimingContext<br/>(multiGatewayMode)
    Context-->>Rundown: timingContext with flag
    Rundown->>Calc: calculateInfinitePieceEnable<br/>(context with multiGatewayMode)
    alt multiGatewayMode
        Calc->>Calc: Use planned timing path
    else Single Gateway
        Calc->>Calc: Use reportedStartedPlayback<br/>as absolute start
    end
    Calc-->>Rundown: timing result
    Rundown-->>Generate: timeline objects
    Generate-->>Caller: timeline result
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~60 minutes

The review requires careful examination of timing logic changes across multiple files, understanding how multiGatewayMode affects infinite piece calculations, validating test restructuring across both gateway modes, and verifying consistency of the new parameter threading through the call stack.

Poem

🐰 A gateway split in two, we see,
With timing logic revised with care,
Through contexts threaded, true and free,
Multi-mode timelines everywhere!
Infinite pieces now align,
In both the single and double-line design!

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "fix: Infinites timetravel" is vague and does not clearly convey the main change. "Infinites timetravel" is unclear terminology that does not meaningfully describe the bug fix to prevent timeline instability in Multi-Gateway mode. Revise the title to be more descriptive, such as "fix: Prevent timeline shifts in Multi-Gateway mode for infinite pieces" or "fix: Restrict infinite piece stability code to Single Gateway Mode only" to better communicate the actual change.
✅ Passed checks (1 passed)
Check name Status Explanation
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.

✨ Finishing touches
  • 📝 Generate docstrings

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

codecov bot commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@jstarpl
Copy link
Contributor Author

jstarpl commented Jan 22, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 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.

@PeterC89 PeterC89 changed the base branch from release53 to main February 4, 2026 12:38
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) Contribution External contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant