From 43bd25382d7fb547b1f1411236bd1b6c292035aa Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Mon, 23 Nov 2026 10:57:55 -0800 Subject: [PATCH] Play does nothing at live (#1915) * Play does nothing at live At live the clock is already at now, running with the world, so Play on the timeline leaves it there instead of jumping to the start of the track and playing it from there. Paused in the past, Play runs from that time; paused at the end of the track, it starts again from the top, as before. * Format worldTime.js; changelog fragment for #1915 --- changelog.d/1915-play-at-live.md | 3 +++ src/ui/stores/worldTime.js | 13 +++++++------ src/ui/views/panels/WorldTimeline.test.mjs | 20 ++++++++++++++++++-- 3 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 changelog.d/1915-play-at-live.md diff --git a/changelog.d/1915-play-at-live.md b/changelog.d/1915-play-at-live.md new file mode 100644 index 0000000000..e3042e7301 --- /dev/null +++ b/changelog.d/1915-play-at-live.md @@ -0,0 +1,3 @@ +- Leave the clock at live when Play is pressed at live. Play used to jump to + the start of the track and play the whole range from there; paused in the + past it still plays from that time (samehkhamis, #1915). diff --git a/src/ui/stores/worldTime.js b/src/ui/stores/worldTime.js index 57d7da55a9..2780b8f061 100644 --- a/src/ui/stores/worldTime.js +++ b/src/ui/stores/worldTime.js @@ -141,17 +141,18 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => { time, /** * Play runs the track at the world clock's rate (the speed chosen, which - * sets it), from the start when it is at - * its end (at live, say), as a video plays again from the top. It runs - * the clock itself: weather follows the time frame by frame like every - * other layer the track covers. + * sets it), from where the clock is, or from the start when it is paused + * at the track's end, as a video plays again from the top. At live it + * does nothing: the clock is already at now, running with the world. It + * runs the clock itself: weather follows the time frame by frame like + * every other layer the track covers. */ togglePlay() { const { playing, live, timeMs, span } = time.value; if (playing) return worldClock.pause(); + if (live) return; const covered = reach(); - if (span && covered && (live || timeMs >= covered.end)) - worldClock.seek(span.start); + if (span && covered && timeMs >= covered.end) worldClock.seek(span.start); // At the clock's rate: the speed chosen, or a host's own. worldClock.play({ continuous: true }); }, diff --git a/src/ui/views/panels/WorldTimeline.test.mjs b/src/ui/views/panels/WorldTimeline.test.mjs index f496d6d860..5faf0a1801 100644 --- a/src/ui/views/panels/WorldTimeline.test.mjs +++ b/src/ui/views/panels/WorldTimeline.test.mjs @@ -186,7 +186,7 @@ test('on a track that runs over years, only the last minutes are near now', asyn assert.equal(worldClock.isLive(), true, 'a minute back goes live'); }); -test('play runs in real time, from the start of the track when at live', async (t) => { +test('play does nothing at live, and runs in real time from a time in the past', async (t) => { const bar = mount(t); const now = Date.now(); const start = now - 10 * 86_400_000; @@ -207,12 +207,23 @@ test('play runs in real time, from the start of the track when at live', async ( pause: () => stepped.push('pause'), }); t.after(() => driver.detach()); + assert.equal(worldClock.isLive(), true); + bar().querySelector('.world-timeline-play').click(); + await nextTick(); + assert.equal(worldClock.isLive(), true, 'play at live stays live'); + assert.equal(worldClock.isPlaying(), false, 'and plays nothing'); + assert.ok(Math.abs(worldClock.now() - Date.now()) < 60_000, 'still at now'); + + // Paused in the past, play runs from there. + const from = start + 86_400_000; + worldClock.seek(from); + await nextTick(); bar().querySelector('.world-timeline-play').click(); worldClock.pause(); await nextTick(); assert.deepEqual(stepped, []); const rate = worldClock.getRate(); - assert.ok(worldClock.now() - start < rate * 1_000, 'from the start of the track'); + assert.ok(Math.abs(worldClock.now() - from) < rate * 1_000, 'from where it was'); assert.equal(rate, 1, 'real time to start with'); worldClock.play({ continuous: true }); @@ -275,6 +286,8 @@ test('the speed chosen sets how fast play runs, at once while playing', async (t ); select.value = 'week'; select.dispatchEvent(new Event('change')); + // Play runs from a time in the past (at live it does nothing). + worldClock.seek(now - 5 * 86_400_000); await nextTick(); bar().querySelector('.world-timeline-play').click(); assert.equal(worldClock.getRate(), 604_800, 'a week a second'); @@ -763,6 +776,9 @@ test('the speed shown follows the world clock, and Play runs at its rate', async worldClock.setRate(5_000); await nextTick(); assert.equal(select().value, 'hour'); + // Play runs from a time in the past (at live it does nothing). + worldClock.seek(now - 5 * 86_400_000); + await nextTick(); bar().querySelector('.world-timeline-play').click(); assert.equal(worldClock.isPlaying(), true); assert.equal(worldClock.getRate(), 5_000, 'Play runs at the clock\'s own rate');