Skip to content
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
10c7ddb
feat: move RundownTimingCalculator into meteor-lib
Julusian Aug 10, 2026
adf5c61
feat: add TimerState-based playlist timing calculator
Julusian Aug 10, 2026
68a9318
refactor: single implementation for playlist timing states
Julusian Aug 10, 2026
7d35644
feat: add playlistTimingState publication
Julusian Aug 10, 2026
a404f74
feat: rundown header consumes the playlistTimingState publication
Julusian Aug 10, 2026
ada909b
fix: make the timing state union safe to narrow
Julusian Aug 11, 2026
797034d
feat: add resumesAt to TimerState, tighten the paused variant
Julusian Aug 11, 2026
4fb94d4
refactor: usePlaylistTimingValue returns evaluated numbers
Julusian Aug 11, 2026
baa7d44
test: cover the timing publication end to end
Julusian Aug 11, 2026
77ba256
feat: allow subscribing to a custom publication in-process
Julusian Aug 11, 2026
650ae18
fix: compute playlist timing from the UI Parts, not the raw collections
Julusian Aug 11, 2026
eb4c6a9
test: cover the in-process publication observer against a real one
Julusian Aug 11, 2026
ce28fa2
fix: keep the projected end fixed across a take, and don't publish a …
Julusian Aug 11, 2026
d5eadb8
feat: publish the on-air part and segment timers
Julusian Aug 11, 2026
fd0e3e6
feat: publish per-segment timing documents
Julusian Aug 12, 2026
5d2cfad
refactor: move the remaining playlist-level displays onto the publica…
Julusian Aug 12, 2026
a831fe2
refactor: extract the part duration cascade into PartDurationResolver
Julusian Aug 12, 2026
491c67c
refactor: derive every part countdown from one live timer state
Julusian Aug 12, 2026
f5b06ef
feat: add the per-part timing state document and its assembly
Julusian Aug 12, 2026
df1bf38
feat: publish a timing document per part
Julusian Aug 12, 2026
e100263
feat: read the per-part timers from the publication
Julusian Aug 12, 2026
60ae05e
feat: read more per-part values from the publication
Julusian Aug 12, 2026
824b1a8
feat: order parts and read part durations from the publication
Julusian Aug 12, 2026
b6a6f4e
refactor: read the planned playlist times from the publication
Julusian Aug 12, 2026
dce7b03
feat: move the last non-geometry readers onto the publication
Julusian Aug 12, 2026
30f61cf
feat: read segment geometry from the publication
Julusian Aug 17, 2026
951231f
feat: read all remaining geometry from the publication
Julusian Aug 18, 2026
60d7570
refactor: the timing calculator now runs only on the server
Julusian Aug 18, 2026
c1ac573
refactor: replace the timing context with a playlist id context
Julusian Aug 18, 2026
fbc14ba
chore: delete the webui rundownTiming compat shim
Julusian Aug 18, 2026
c52d810
refactor: move the timing calculator into the meteor server
Julusian Aug 18, 2026
2a3d2c0
refactor: put the timing calculator inside its publication
Julusian Aug 18, 2026
e3a9358
docs: describe the rundown timing publication
Julusian Aug 18, 2026
062e54f
feat(live-status-gateway): subscribe to the timing publication
Julusian Aug 19, 2026
ffcf7be
feat(live-status-gateway-api): add the computed timing values to the …
Julusian Aug 19, 2026
f002543
feat(live-status-gateway): take part and segment timing from the publ…
Julusian Aug 19, 2026
0d55bfd
feat(live-status-gateway): expose per-part rundown timing
Julusian Aug 19, 2026
7bdf0d1
feat(corelib): timing state for part countdowns as offsets, and a fix…
jesperstarkar Oct 28, 2026
3fcfa03
fix(sofie-core): timing publication fixes, and a take changes only a …
jesperstarkar Oct 28, 2026
89b1172
fix(live-status-gateway): take all timing from the publication
jesperstarkar Oct 28, 2026
f1e0e76
fix(webui): the screens read the publication correctly, and redraw less
jesperstarkar Oct 28, 2026
f4e7a95
fix(webui): each countdown shows the time that is left
jesperstarkar Oct 28, 2026
2c87ea2
test(sofie-core): reference rundown, playout driver and comparison wi…
jesperstarkar Oct 28, 2026
8aae3f8
docs: rundown timing for developers and gateway consumers
jesperstarkar Oct 28, 2026
5bf3806
refactor: publish the segment content length, and fixed lengths as pl…
Julusian Nov 4, 2026
9581082
fix(webui): take the untimed playlist's fallback length from the publ…
Julusian Nov 4, 2026
8b18a11
fix(sofie-core): an undefined field no longer reads as changed in an …
Julusian Nov 4, 2026
c24781a
refactor(sofie-core): the timing publication builds its documents as …
Julusian Nov 4, 2026
96c2ac2
docs(sofie-core): say why there is one part timing state per Part
Julusian Nov 4, 2026
8bdca01
test: share the reference rundown from corelib
Julusian Nov 4, 2026
81617bf
test(webui): load components with their stylesheets in Jest
Julusian Nov 4, 2026
27dce28
fix(live-status-gateway): the current part's end is never the part be…
Julusian Nov 4, 2026
cadbcd0
feat(live-status-gateway): each part's timing in a partTimings topic …
Julusian Nov 4, 2026
3fb5fe9
Revert "feat(live-status-gateway): each part's timing in a partTiming…
Julusian Nov 4, 2026
97e7498
docs: the gateway's current part end right after a take
Julusian Nov 4, 2026
aba9604
fix(webui): the camera screen draws each part's timing at its own second
Julusian Nov 4, 2026
a7ebbc8
test: drive the timing tests with the job worker's real playout jobs
Julusian Nov 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions packages/blueprints-integration/src/context/tTimersContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,28 @@ export interface RundownTTimerModeTimeOfDay {
* Timing state for a timer, optimized for efficient client rendering.
* When running, the client calculates current time from zeroTime.
* When paused, the duration is frozen and sent directly.
* pauseTime indicates when the timer should automatically pause (when current part ends and overrun begins).
*
* Each variant carries the timestamp of its transition into the *other* state, so that a transition
* whose time is known in advance does not depend on a new state being published at that moment
* (which would cost accuracy - the value would be stale until the message lands, then jump):
* - `pauseTime` on a running timer: when it freezes (e.g. when the current part ends and overrun begins)
* - `resumesAt` on a paused timer: when it starts running (e.g. a scheduled start)
*
* The other one is always null/absent, and a state therefore has at most one transition. Anything
* with further transitions relies on an updated state being published in between; there is a
* multi-second window to do so in practice, so that is safe.
*
* Client rendering logic:
* ```typescript
* if (state.paused === true) {
* // Manually paused by user or already pushing/overrun
* duration = state.duration
* } else if (state.pauseTime && now >= state.pauseTime) {
* if (state.resumesAt != null && now >= state.resumesAt) {
* // Scheduled start has passed, running since then
* duration = state.duration - (now - state.resumesAt)
* } else {
* // Manually paused by user, already pushing/overrun, or waiting for a scheduled start
* duration = state.duration
* }
* } else if (state.pauseTime != null && now >= state.pauseTime) {
* // Auto-pause at overrun (current part ended)
* duration = state.zeroTime - state.pauseTime
* } else {
Expand All @@ -60,14 +74,18 @@ export type TimerState =
zeroTime: number
/** Optional timestamp when the timer should pause (when current part ends) */
pauseTime?: number | null
/** Not applicable while running - a running timer has no scheduled start */
resumesAt?: null
}
| {
/** Whether the timer is paused */
paused: true
/** The frozen duration value in milliseconds */
duration: number
/** Optional timestamp when the timer should pause (null when already paused/pushing) */
pauseTime?: number | null
/** Not applicable while paused - a paused timer has already stopped */
pauseTime?: null
/** Optional timestamp when the timer should start running, if that is known in advance */
resumesAt?: number | null
}

export interface ITTimersContext {
Expand Down
1 change: 1 addition & 0 deletions packages/corelib/src/dataModel/Collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ export enum CustomCollectionName {
UIParts = 'uiParts',
UIPartInstances = 'uiPartInstances',
UIPieceInstances = 'uiPieceInstances',
PlaylistTimingState = 'playlistTimingState',
}
85 changes: 3 additions & 82 deletions packages/corelib/src/dataModel/RundownPlaylist/TTimers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { PartId } from '../Ids.js'
import type { TimerState } from '../TimerState.js'

export { timerStateToDuration, timerStateToZeroTime, type TimerState } from '../TimerState.js'

export type RundownTTimerMode = RundownTTimerModeFreeRun | RundownTTimerModeCountdown | RundownTTimerModeTimeOfDay

Expand Down Expand Up @@ -32,88 +35,6 @@ export interface RundownTTimerModeTimeOfDay {
readonly stopAtZero: boolean
}

/**
* Timing state for a timer, optimized for efficient client rendering.
* When running, the client calculates current time from zeroTime.
* When paused, the duration is frozen and sent directly.
* pauseTime indicates when the timer should automatically pause (when current part ends and overrun begins).
*
* Client rendering logic:
* ```typescript
* if (state.paused === true) {
* // Manually paused by user or already pushing/overrun
* duration = state.duration
* } else if (state.pauseTime && now >= state.pauseTime) {
* // Auto-pause at overrun (current part ended)
* duration = state.zeroTime - state.pauseTime
* } else {
* // Running normally
* duration = state.zeroTime - now
* }
* ```
*/
export type TimerState =
| {
/** Whether the timer is paused */
paused: false
/** The absolute timestamp (ms) when the timer reaches/reached zero */
zeroTime: number
/** Optional timestamp when the timer should pause (when current part ends) */
pauseTime?: number | null
}
| {
/** Whether the timer is paused */
paused: true
/** The frozen duration value in milliseconds */
duration: number
/** Optional timestamp when the timer should pause (null when already paused/pushing) */
pauseTime?: number | null
}

/**
* Calculate the current duration for a timer state.
* Handles paused, auto-pause (pauseTime), and running states.
*
* @param state The timer state
* @param now Current timestamp in milliseconds
* @returns The current duration in milliseconds
*/
export function timerStateToDuration(state: TimerState, now: number): number {
if (state.paused) {
// Manually paused by user or already pushing/overrun
return state.duration
} else if (state.pauseTime != null && now >= state.pauseTime) {
// Auto-pause at overrun (current part ended)
return state.zeroTime - state.pauseTime
} else {
// Running normally
return state.zeroTime - now
}
}

/**
* Get the zero time (reference timestamp) for a timer state.
* - For countdown/timeOfDay timers: when the timer reaches zero
* - For freeRun timers: when the timer started (what it counts from)
* For paused timers, calculates when zero would be if resumed now.
*
* @param state The timer state
* @param now Current timestamp in milliseconds
* @returns The zero time timestamp in milliseconds
*/
export function timerStateToZeroTime(state: TimerState, now: number): number {
if (state.paused) {
// Calculate when zero would be if we resumed now
return now + state.duration
} else if (state.pauseTime && now >= state.pauseTime) {
// Auto-pause at overrun (current part ended)
return state.zeroTime - state.pauseTime + now
} else {
// Already have the zero time
return state.zeroTime
}
}

export type RundownTTimerIndex = 1 | 2 | 3

export function isRundownTTimerIndex(index: unknown): index is RundownTTimerIndex {
Expand Down
133 changes: 133 additions & 0 deletions packages/corelib/src/dataModel/TimerState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/**
* Timing state for a timer, optimized for efficient client rendering.
* When running, the client calculates current time from zeroTime.
* When paused, the duration is frozen and sent directly.
*
* Each variant carries the timestamp of its transition into the *other* state, so that a transition
* whose time is known in advance does not depend on a new state being published at that moment
* (which would cost accuracy - the value would be stale until the message lands, then jump):
* - `pauseTime` on a running timer: when it freezes (e.g. when the current part ends and overrun begins)
* - `resumesAt` on a paused timer: when it starts running (e.g. a scheduled start)
*
* The other one is always null/absent, and a state therefore has at most one transition. Anything
* with further transitions relies on an updated state being published in between; there is a
* multi-second window to do so in practice, so that is safe.
*
* Client rendering logic:
* ```typescript
* if (state.paused === true) {
* if (state.resumesAt != null && now >= state.resumesAt) {
* // Scheduled start has passed, running since then
* duration = state.duration - (now - state.resumesAt)
* } else {
* // Manually paused by user, already pushing/overrun, or waiting for a scheduled start
* duration = state.duration
* }
* } else if (state.pauseTime != null && now >= state.pauseTime) {
* // Auto-pause at overrun (current part ended)
* duration = state.zeroTime - state.pauseTime
* } else {
* // Running normally
* duration = state.zeroTime - now
* }
* ```
*/
export type TimerState =
| {
/** Whether the timer is paused */
paused: false
/** The absolute timestamp (ms) when the timer reaches/reached zero */
zeroTime: number
/** Optional timestamp when the timer should pause (when current part ends) */
pauseTime?: number | null
/** Not applicable while running - a running timer has no scheduled start */
resumesAt?: null
}
| {
/** Whether the timer is paused */
paused: true
/** The frozen duration value in milliseconds */
duration: number
/** Not applicable while paused - a paused timer has already stopped */
pauseTime?: null
/** Optional timestamp when the timer should start running, if that is known in advance */
resumesAt?: number | null
}

/**
* Calculate the current duration for a timer state.
* Handles paused, auto-pause (pauseTime), and running states.
*
* @param state The timer state
* @param now Current timestamp in milliseconds
* @returns The current duration in milliseconds
*/
export function timerStateToDuration(state: TimerState, now: number): number {
if (state.paused) {
if (state.resumesAt != null && now >= state.resumesAt) {
// Scheduled start has passed, so it has been running since then
return state.duration - (now - state.resumesAt)
}
// Manually paused by user, already pushing/overrun, or waiting for a scheduled start
return state.duration
} else if (state.pauseTime != null && now >= state.pauseTime) {
// Auto-pause at overrun (current part ended)
return state.zeroTime - state.pauseTime
} else {
// Running normally
return state.zeroTime - now
}
}

/**
* Shift a timer state by a constant amount, giving a state whose duration read is always `offset`
* greater than the original's, and whose zero time is always `offset` later.
*
* This is how a whole family of timers that differ only by a fixed head start is expressed as
* offsets from a single running one - e.g. the countdown to each upcoming Part, which is that Part's
* static wait plus the one countdown that is actually ticking. Only the one live state has to be
* derived; the rest are shifts of it, so they cannot drift apart from it or from each other.
*
* The breakpoint (`pauseTime`/`resumesAt`) is deliberately not shifted: it is the moment the timer
* changes slope, which is the same moment for every member of the family.
*
* @param state The timer state to shift
* @param offset Milliseconds to add to the state's duration
*/
export function offsetTimerState(state: TimerState, offset: number): TimerState {
if (state.paused) {
return { ...state, duration: state.duration + offset }
} else {
return { ...state, zeroTime: state.zeroTime + offset }
}
}

/**
* Get the zero time (reference timestamp) for a timer state.
* - For countdown/timeOfDay timers: when the timer reaches zero
* - For freeRun timers: when the timer started (what it counts from)
* For paused timers, calculates when zero would be if resumed now - unless a scheduled start
* (`resumesAt`) has already passed, in which case zero is a fixed point measured from it.
*
* @param state The timer state
* @param now Current timestamp in milliseconds
* @returns The zero time timestamp in milliseconds
*/
export function timerStateToZeroTime(state: TimerState, now: number): number {
if (state.paused) {
if (state.resumesAt != null && now >= state.resumesAt) {
// Scheduled start has passed, so zero is a fixed point measured from it
return state.resumesAt + state.duration
}
// Calculate when zero would be if we resumed now
return now + state.duration
} else if (state.pauseTime != null && now >= state.pauseTime) {
// Auto-pause at overrun (current part ended)
// (note: `!= null` rather than a truthiness check, so that this agrees with
// timerStateToDuration for the degenerate pauseTime of 0)
return state.zeroTime - state.pauseTime + now
} else {
// Already have the zero time
return state.zeroTime
}
}
Loading
Loading