Skip to content

Fix rundown view crash when tTimers or studio settings are missing - #5

Merged
kubo6472 merged 2 commits into
mainfrom
cursor/fix-rundown-header-timers-crash-1ea5
Jun 17, 2026
Merged

Fix rundown view crash when tTimers or studio settings are missing#5
kubo6472 merged 2 commits into
mainfrom
cursor/fix-rundown-header-timers-crash-1ea5

Conversation

@kubo6472

@kubo6472 kubo6472 commented Jun 17, 2026

Copy link
Copy Markdown
Member

Playlists created before the T-timers feature may not have a tTimers field in MongoDB, causing RundownHeaderTimers to crash when calling .filter() on undefined.

Similarly, studios that have not run recent migrations may be missing packageContainerSettingsWithOverrides and other ObjectWithOverrides fields, causing server publications to throw when reading .defaults.

  • Add getRundownTTimers() helper with DEFAULT_RUNDOWN_T_TIMERS fallback
  • Guard RundownHeaderTimers and getDefaultTTimer against undefined input
  • Make applyAndValidateOverrides tolerate undefined/null/invalid objects

About the Contributor

Type of Contribution

This is a:

Bug fix / Feature / Code improvement / Documentation improvement / Other (please specify)

Current Behavior

New Behavior

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

Time Frame

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.

Summary by CodeRabbit

  • Bug Fixes
    • Improved timer handling by safely accepting missing/undefined timer data and applying sensible defaults.
    • Updated rundown header timer rendering and default timer selection to use the same fallback logic.
    • Strengthened settings override validation to handle undefined/null inputs by returning empty validation results.
  • Tests
    • Added coverage for override application when the input is undefined.
  • Refactor
    • Centralized default rundown timer logic to ensure consistent behavior across the UI and client utilities.

Playlists created before the T-timers feature may not have a tTimers
field in MongoDB, causing RundownHeaderTimers to crash when calling
.filter() on undefined.

Similarly, studios that have not run recent migrations may be missing
packageContainerSettingsWithOverrides and other ObjectWithOverrides
fields, causing server publications to throw when reading .defaults.

- Add getRundownTTimers() helper with DEFAULT_RUNDOWN_T_TIMERS fallback
- Guard RundownHeaderTimers and getDefaultTTimer against undefined input
- Make applyAndValidateOverrides tolerate undefined/null/invalid objects
@coderabbitai

coderabbitai Bot commented Jun 17, 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: 9b2e08d1-eafe-41f7-aff2-0714ab2b3276

📥 Commits

Reviewing files that changed from the base of the PR and between d97d9db and 7cfcb62.

📒 Files selected for processing (1)
  • packages/webui/src/client/ui/RundownView/RundownHeader/RundownHeaderTimers.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/webui/src/client/ui/RundownView/RundownHeader/RundownHeaderTimers.tsx

📝 Walkthrough

Walkthrough

The PR adds a DEFAULT_RUNDOWN_T_TIMERS constant and a getRundownTTimers normalizer to the corelib timer model. It propagates null/undefined acceptance to getDefaultTTimer and RundownHeaderTimers, which now route through the normalizer. Separately, isObjectWithOverrides and applyAndValidateOverrides are updated to handle null/undefined inputs, returning empty result structures instead of failing.

Changes

TTimer Null-Safety

Layer / File(s) Summary
DEFAULT_RUNDOWN_T_TIMERS constant and getRundownTTimers helper
packages/corelib/src/dataModel/RundownPlaylist/TTimers.ts
Adds a typed 3-element default tuple and a normalizer function that returns it when the input is null or undefined.
UI utilities and header component updated to accept null/undefined tTimers
packages/webui/src/client/lib/tTimerUtils.ts, packages/webui/src/client/ui/RundownView/RundownHeader/RundownHeaderTimers.tsx
getDefaultTTimer and RundownHeaderTimers now call getRundownTTimers(tTimers) before filtering, accepting null/undefined in their signatures.

ObjectWithOverrides Null-Safety

Layer / File(s) Summary
isObjectWithOverrides and applyAndValidateOverrides null handling + test
packages/corelib/src/settings/objectWithOverrides.ts, packages/corelib/src/settings/__tests__/objectWithOverrides.spec.ts
Both functions widen their accepted types to include null/undefined; applyAndValidateOverrides returns an empty result structure for invalid/missing input and initializes result.obj via clone(obj.defaults). A new test verifies the undefined input path returns {} with empty arrays.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🕰️ Three timers sat, all null and cold,
Until a default tuple was told.
"Pass me undefined? No fear!"
Said the helper, crystal clear.
Overrides and timers now play nice —
Null-safe coding, oh so precise! ✨


ELI5: Any Issues with the Code?

The Good News: There are no critical issues here. This is defensive programming at its best! 🛡️

What's happening (in simple terms):

The code is like giving functions a safety net. Before, these functions expected you to always pass them a proper value—like handing them a timer tuple or configuration object. If you accidentally passed null or undefined, they would break.

Now? The functions say "Okay, I see you've got null or undefined. No problem—I've got a backup plan!" For timers, there's now a default set of three empty timers. For the settings system, empty objects with empty arrays are the safety landing pad.

Why it matters: Real-world code can be messy. Data comes from APIs, databases, or complex logic, and sometimes things are null when you don't expect it. By adding these guardrails early, the PR prevents silent bugs or crashes downstream. The code is now more forgiving and predictable. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: fixing crashes caused by missing tTimers and studio settings data.
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
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch cursor/fix-rundown-header-timers-crash-1ea5

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.

@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: 2

🤖 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/RundownView/RundownHeader/RundownHeaderTimers.tsx`:
- Line 20: The activeTimers variable assignment has a method chain that Prettier
wants formatted on multiple lines for better readability. In the line where
activeTimers is defined with the getRundownTTimers(tTimers).filter((t) =>
t.mode).slice(0, 2) chain, break the method calls onto separate lines with
proper indentation so that each method call in the chain starts on its own line.
- Around line 1-4: The import statement for RundownTTimer and getRundownTTimers
from the TTimers module is split across multiple lines, which Prettier requires
to be on a single line. Consolidate the import statement so that the opening
brace, all imported items (type RundownTTimer and getRundownTTimers), closing
brace, and the from clause with the full module path are all on a single line
without line breaks.
🪄 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: d577df38-712b-4d91-a771-1b3a688d9b93

📥 Commits

Reviewing files that changed from the base of the PR and between 05d3915 and d97d9db.

📒 Files selected for processing (5)
  • packages/corelib/src/dataModel/RundownPlaylist/TTimers.ts
  • packages/corelib/src/settings/__tests__/objectWithOverrides.spec.ts
  • packages/corelib/src/settings/objectWithOverrides.ts
  • packages/webui/src/client/lib/tTimerUtils.ts
  • packages/webui/src/client/ui/RundownView/RundownHeader/RundownHeaderTimers.tsx

Comment thread packages/webui/src/client/ui/RundownView/RundownHeader/RundownHeaderTimers.tsx Outdated
Comment thread packages/webui/src/client/ui/RundownView/RundownHeader/RundownHeaderTimers.tsx Outdated
@kubo6472
kubo6472 merged commit 9100611 into main Jun 17, 2026
43 checks passed
@kubo6472
kubo6472 deleted the cursor/fix-rundown-header-timers-crash-1ea5 branch June 17, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants