Skip to content

fix: Prevent invalid part instance from autonexting - #1794

Draft
PeterC89 wants to merge 6 commits into
Sofie-Automation:mainfrom
bbc:fix/prevent-invalid-part-instance-autonext
Draft

fix: Prevent invalid part instance from autonexting#1794
PeterC89 wants to merge 6 commits into
Sofie-Automation:mainfrom
bbc:fix/prevent-invalid-part-instance-autonext

Conversation

@PeterC89

Copy link
Copy Markdown
Contributor

About the Contributor

This pull request is posted on behalf of the BBC.

Type of Contribution

This is a: Bug fix

Current Behavior

Manual takes are blocked by invalid part instances but auto-takes are not.

New Behavior

Auto-takes are blocked for invalid part instances.

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.

Time Frame

Not urgent, but we would like to get this merged into the in-development release.

Other Information

Written with the assistance of GitHub Copilot

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

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3010ef73-01cf-4dd7-8d12-1f4b83262fa8

📥 Commits

Reviewing files that changed from the base of the PR and between c01be32 and 2e37a57.

📒 Files selected for processing (4)
  • packages/job-worker/src/playout/timings/partPlayback.ts
  • packages/webui/src/client/lib/__tests__/rundownTiming.test.ts
  • packages/webui/src/client/ui/SegmentTimeline/Parts/SegmentTimelinePart.tsx
  • packages/webui/src/client/ui/SegmentTimeline/SegmentTimelineContainer.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/webui/src/client/ui/SegmentTimeline/SegmentTimelineContainer.tsx
  • packages/webui/src/client/ui/SegmentTimeline/Parts/SegmentTimelinePart.tsx

Walkthrough

Invalid next PartInstances now block auto-next playout, are omitted from generated next-part timeline objects, propagate as user errors, and expose a blocked state through WebUI timing and timeline components.

Changes

Invalid next-part playout handling

Layer / File(s) Summary
Playout guards and auto-next timing
packages/job-worker/src/playout/timeline/rundown.ts, packages/job-worker/src/playout/timings/partPlayback.ts
Invalid next parts are excluded from timeline objects and rejected before playback state advances; auto-next stop timing uses the previous planned start plus expected duration.
Error propagation and regression coverage
packages/job-worker/src/playout/timings/index.ts, packages/job-worker/src/playout/__tests__/playout.test.ts
UserError instances are rethrown from playback-change handling, and tests verify invalid auto-next rejection with unchanged selections.
Timing state and timeline presentation
packages/webui/src/client/lib/rundownTiming.ts, packages/webui/src/client/ui/RundownView/RundownTiming/*, packages/webui/src/client/ui/SegmentTimeline/*, packages/webui/src/client/ui/SegmentTimeline/SmallParts/*, packages/webui/src/client/lib/__tests__/rundownTiming.test.ts
invalidReason flows into timing calculations, produces a one-time critical notification, changes live-duration handling, and is threaded through timeline components with updated expectations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PlayoutPlayback
  participant handleOnPlayoutPlaybackChanged
  participant onPartPlaybackStarted
  participant RundownTiming
  participant NotificationCenter
  PlayoutPlayback->>handleOnPlayoutPlaybackChanged: report next PartInstance playback
  handleOnPlayoutPlaybackChanged->>onPartPlaybackStarted: process playback start
  onPartPlaybackStarted->>onPartPlaybackStarted: check invalidReason
  onPartPlaybackStarted-->>handleOnPlayoutPlaybackChanged: throw TakePartInstanceInvalid
  RundownTiming->>RundownTiming: compute blocked auto-next state
  RundownTiming->>NotificationCenter: push critical notification once
Loading

Possibly related PRs

Suggested reviewers: julusian

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: blocking auto-next for invalid part instances.
Description check ✅ Passed The description matches the bug fix and the updated test coverage for invalid part instances blocking auto-takes.
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.
✨ 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.

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@PeterC89

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

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 added 🐛🔨 bugfix This is a fix for an issue Contribution from BBC Contributions sponsored by BBC (bbc.co.uk) labels Jul 14, 2026
@PeterC89

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

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 marked this pull request as ready for review July 14, 2026 11:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/webui/src/client/ui/SegmentTimeline/SegmentTimelineContainer.tsx`:
- Line 728: Update the currentPartAutoNextBlockedByInvalidReason prop assignment
in SegmentTimelineContainer to read from this.context?.durations, preserving the
existing false fallback and matching the access path used by other timing reads.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 54aaa405-c76c-4cc6-b577-f04a671ca33c

📥 Commits

Reviewing files that changed from the base of the PR and between 5b5e9ae and af88cfe.

📒 Files selected for processing (6)
  • packages/webui/src/client/lib/rundownTiming.ts
  • packages/webui/src/client/ui/RundownView/RundownTiming/AutoNextStatus.tsx
  • packages/webui/src/client/ui/RundownView/RundownTiming/RundownTimingProvider.tsx
  • packages/webui/src/client/ui/SegmentTimeline/Parts/SegmentTimelinePart.tsx
  • packages/webui/src/client/ui/SegmentTimeline/SegmentTimeline.tsx
  • packages/webui/src/client/ui/SegmentTimeline/SegmentTimelineContainer.tsx

Comment thread packages/webui/src/client/ui/SegmentTimeline/SegmentTimelineContainer.tsx Outdated
@PeterC89
PeterC89 marked this pull request as draft July 15, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛🔨 bugfix This is a fix for an issue Contribution from BBC Contributions sponsored by BBC (bbc.co.uk)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant