From 8a0953c35d16199d1ee4e35d65d8d10a2c5b28d6 Mon Sep 17 00:00:00 2001 From: Kevin Rajan <7121943+kvnloo@users.noreply.github.com> Date: Mon, 16 Nov 2026 09:03:26 -0600 Subject: [PATCH] fix(stories): retain the last shot when replaying near the end (#1724) Focused follow-up to manjunath22466's Stories contribution. A paused share link in the final 250 ms is not a completed scene. Add node:test coverage for near-end Play and true-end replay; update current-state documentation and the #1724 changelog fragment. --- changelog.d/1724-stories-near-end-play.md | 3 +++ docs/CURRENT-STATE.md | 6 ++++- src/stories/gevPlayer.js | 4 +++- src/stories/gevPlayer.test.mjs | 27 ++++++++++++++++++++++- 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 changelog.d/1724-stories-near-end-play.md diff --git a/changelog.d/1724-stories-near-end-play.md b/changelog.d/1724-stories-near-end-play.md new file mode 100644 index 000000000..a8f2963db --- /dev/null +++ b/changelog.d/1724-stories-near-end-play.md @@ -0,0 +1,3 @@ +- Keep a Stories link paused in the last quarter-second on its final shot + when Play is pressed, rather than restarting the scene; completed stories + still replay from the beginning (manjunath22466, kvnloo, #1724). diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index bb04daea9..3c6343d5d 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -716,7 +716,11 @@ facts and sources (Vantor imagery and the GeoPera reconstruction, CC BY-NC 4.0), and its key moments are the chapters that show them. Topic chips and region choices are the ones the listed stories carry. Closing Stories after a story played puts AUTHORING's own selection back (usually none); -Open in GEV leaves the story's scene selected there. +Open in GEV leaves the story's scene selected there. A paused link in the +final quarter-second retains its final shot on Play instead of restarting +at the first shot. A scene that has actually ended still replays from the +beginning; SceneDirector resumes from the shot boundary, not a fractional +position inside a shot. Opening Stories claims the camera through the shared navigation policy, so orbit, a tracked contact or a flight end, and Cockpit refuses with the diff --git a/src/stories/gevPlayer.js b/src/stories/gevPlayer.js index 35210ea65..5fb25a2b2 100644 --- a/src/stories/gevPlayer.js +++ b/src/stories/gevPlayer.js @@ -87,7 +87,9 @@ export function createGevPlayer(director, story, hooks = {}) { const mine = ++request; await idle(); if (destroyed || mine !== request || director.running) return; - if (wallMs >= durationMs - 250) { + // Natural completion is rounded up by the clock subscriber; a + // paused shared time inside the last 250 ms is not completion. + if (wallMs >= durationMs) { wallMs = 0; shotIndex = 0; } diff --git a/src/stories/gevPlayer.test.mjs b/src/stories/gevPlayer.test.mjs index e94093d19..bcbb5ad91 100644 --- a/src/stories/gevPlayer.test.mjs +++ b/src/stories/gevPlayer.test.mjs @@ -28,7 +28,8 @@ function deferredDirector({ running = false } = {}) { }, seekScene: (id, f) => calls.push(`seek ${f}`), - startScene: () => { + startScene: (_id, options) => { + director.startAfterShotId = options.afterShotId; calls.push('start'); director.running = true; return new Promise((resolve) => { @@ -107,6 +108,30 @@ test('a paused seek keeps its exact position near the end of a story', () => { assert.equal(player.state.playing, false); }); +test('Play from a paused link in the final quarter-second stays in the final shot', async () => { + const director = deferredDirector(); + const player = createGevPlayer(director, story); + player.seek(59800); // 200 ms before the end of a two-shot scene + const playing = player.play(); + await turns(); + assert.equal(player.state.wallMs, 59800, 'the link is not treated as complete'); + assert.equal(director.startAfterShotId, 'a', 'resume in the final shot'); + director.finishRun(); + await playing; +}); + +test('Play after the actual end still starts the scene from shot one', async () => { + const director = deferredDirector(); + const player = createGevPlayer(director, story); + player.seek(60000); + const playing = player.play(); + await turns(); + assert.equal(player.state.wallMs, 0); + assert.equal(director.startAfterShotId, null); + director.finishRun(); + await playing; +}); + test('Destroy cancels a waiting Play', async () => { const director = deferredDirector({ running: true }); const player = createGevPlayer(director, story);