From a037672befe394ad66420e58dbe3f98603f791df Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Tue, 17 Nov 2026 01:07:31 +0700 Subject: [PATCH 1/4] fix(player): suspend queue schedule clock when guide is inactive --- components/player/Queue.vue | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/components/player/Queue.vue b/components/player/Queue.vue index 5333f7692..aeffd4086 100644 --- a/components/player/Queue.vue +++ b/components/player/Queue.vue @@ -492,19 +492,29 @@ watch( ); let scheduleClockTimer: ReturnType | null = null; +const needsScheduleClock = computed(() => + activeTab.value === 'schedule' && props.visible && props.scheduleIsReference && props.program.length > 0, +); +const stopScheduleClock = () => { + if (scheduleClockTimer === null) return; + clearInterval(scheduleClockTimer); + scheduleClockTimer = null; +}; onMounted(() => { scheduleNow.value = Math.floor(Date.now() / 1000); - scheduleClockTimer = setInterval(() => { - // Clock and the timeline fill move once per second. Only update the - // visible reference guide; real-time provider EPG is unaffected. - if (activeTab.value === 'schedule' && props.visible && props.scheduleIsReference) { + watch(needsScheduleClock, (active) => { + stopScheduleClock(); + if (!active) return; + scheduleNow.value = Math.floor(Date.now() / 1000); + scheduleClockTimer = setInterval(() => { + // Do not wake the queue when hidden, showing stations or without a guide. scheduleNow.value = Math.floor(Date.now() / 1000); - } - }, 1_000); + }, 1_000); + }, { immediate: true }); if (activeTab.value === 'schedule' && props.visible) void jumpToSchedulePosition(); }); onBeforeUnmount(() => { - if (scheduleClockTimer !== null) clearInterval(scheduleClockTimer); + stopScheduleClock(); scrollGeneration += 1; }); From 179d63151afe9c4ebcc1f651d6c8daf4e1c00ad3 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Tue, 17 Nov 2026 01:07:43 +0700 Subject: [PATCH 2/4] test(player): guard reference guide clock idle lifecycle --- tests/station-schedule.test.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/station-schedule.test.mjs b/tests/station-schedule.test.mjs index 145cfa662..9471b8bc6 100644 --- a/tests/station-schedule.test.mjs +++ b/tests/station-schedule.test.mjs @@ -157,9 +157,14 @@ test('live time bar is wired to a one-second clock only for visible reference gu const q = await readFile(new URL('../components/player/Queue.vue', import.meta.url), 'utf8'); const gap = await readFile(new URL('../components/player/ScheduleGap.vue', import.meta.url), 'utf8'); assert.match(q, /scheduleTimelineProgress\(item\.startTime, item\.endTime, scheduleNow\.value\)/); + assert.match(q, /watch\(needsScheduleClock, \(active\) => \{/); assert.match(q, /scheduleClockTimer = setInterval\(/); assert.match(q, /\}, 1_000\)/); - assert.match(q, /props\.visible && props\.scheduleIsReference/); + assert.match(q, /activeTab\.value === 'schedule' && props\.visible && props\.scheduleIsReference && props\.program\.length > 0/); + assert.match(q, /if \(!active\) return/); + assert.match(q, /stopScheduleClock\(\)/); + assert.match(q, /onBeforeUnmount\(\(\) => \{\s*stopScheduleClock\(\)/); + assert.doesNotMatch(q, /scheduleClockTimer = setInterval\([\s\S]*?if \(activeTab\.value === 'schedule'/); assert.match(q, /data-schedule-clock role="timer"/); assert.match(q, /data-schedule-time-progress/); assert.match(q, /:start-time="gapStartTime\(scheduleGap\.insertIndex\)"/); From 70ef1f0e8ff5c298449445c43847e20c259f9be4 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Tue, 17 Nov 2026 01:07:55 +0700 Subject: [PATCH 3/4] test(player): scope idle clock regression assertion --- tests/station-schedule.test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/station-schedule.test.mjs b/tests/station-schedule.test.mjs index 9471b8bc6..7479db1e5 100644 --- a/tests/station-schedule.test.mjs +++ b/tests/station-schedule.test.mjs @@ -164,7 +164,7 @@ test('live time bar is wired to a one-second clock only for visible reference gu assert.match(q, /if \(!active\) return/); assert.match(q, /stopScheduleClock\(\)/); assert.match(q, /onBeforeUnmount\(\(\) => \{\s*stopScheduleClock\(\)/); - assert.doesNotMatch(q, /scheduleClockTimer = setInterval\([\s\S]*?if \(activeTab\.value === 'schedule'/); + assert.doesNotMatch(q, /scheduleClockTimer = setInterval\(\(\) => \{[\s\S]*?if \(activeTab\.value === 'schedule' && props\.visible/); assert.match(q, /data-schedule-clock role="timer"/); assert.match(q, /data-schedule-time-progress/); assert.match(q, /:start-time="gapStartTime\(scheduleGap\.insertIndex\)"/); From 649db285ac7e0b696d520ba920a4cf81f458d604 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Tue, 17 Nov 2026 01:08:37 +0700 Subject: [PATCH 4/4] test(player): inspect only interval callback for idle guard --- tests/station-schedule.test.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/station-schedule.test.mjs b/tests/station-schedule.test.mjs index 7479db1e5..b770b2633 100644 --- a/tests/station-schedule.test.mjs +++ b/tests/station-schedule.test.mjs @@ -164,7 +164,9 @@ test('live time bar is wired to a one-second clock only for visible reference gu assert.match(q, /if \(!active\) return/); assert.match(q, /stopScheduleClock\(\)/); assert.match(q, /onBeforeUnmount\(\(\) => \{\s*stopScheduleClock\(\)/); - assert.doesNotMatch(q, /scheduleClockTimer = setInterval\(\(\) => \{[\s\S]*?if \(activeTab\.value === 'schedule' && props\.visible/); + const intervalBody = q.match(/scheduleClockTimer = setInterval\(\(\) => \{([\s\S]*?)\}, 1_000\)/)?.[1]; + assert.ok(intervalBody, 'one-second callback exists only behind the eligibility watcher'); + assert.doesNotMatch(intervalBody, /if \(activeTab\.value === 'schedule'/); assert.match(q, /data-schedule-clock role="timer"/); assert.match(q, /data-schedule-time-progress/); assert.match(q, /:start-time="gapStartTime\(scheduleGap\.insertIndex\)"/);