From 8f2155d6c7cb41001d2f9fdabb59261b19a39a96 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Mon, 16 Nov 2026 13:59:09 -0800 Subject: [PATCH] Scenes: startup selects the first scene after shot-pack upgrades An upgrade of a later scene's pack selected that scene; the first scene and shot are now selected once the upgrades are done. --- src/scenes/director.js | 4 ++++ src/scenes/director.test.mjs | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/scenes/director.js b/src/scenes/director.js index cadf2c007..edc141e01 100644 --- a/src/scenes/director.js +++ b/src/scenes/director.js @@ -238,6 +238,10 @@ export class SceneDirector { } } } + // Upgrades select the scene they change; startup still opens on the + // first scene and shot. + this._selectedSceneId = this._project.scenes[0]?.id || null; + this._selectedShotId = this._project.scenes[0]?.shots[0]?.id || null; this._initUI(); // A status the director wrote itself follows the language; one it was // handed (an error message) stays as it is. diff --git a/src/scenes/director.test.mjs b/src/scenes/director.test.mjs index e84394a08..cf0770873 100644 --- a/src/scenes/director.test.mjs +++ b/src/scenes/director.test.mjs @@ -721,6 +721,33 @@ test('installed v12 Nepal pack inserts ten points without replacing renamed came }); +test('startup selects the first scene after upgrading a later scene’s shot pack', () => { + const first = makeDirector({ project: nepalProjectFixture() }); + let legacy; + const recipe = getSceneAppendRecipeById('bhote-koshi-nepal-evidence-pack'); + try { + first.director.appendShotPack('scene-1', recipe.id); + legacy = structuredClone(first.director._project); + const scene = legacy.scenes[0]; + scene.id = 'nepal'; + scene.shots = scene.shots.filter((shot) => !shot.sourcePackId + || recipe.previousRequiredSourcePackBeatIds.includes(shot.layers['bhote-koshi-2026'].params.beatId)); + scene.appliedShotPacks[0].version = 12; + const ids = new Set(scene.shots.map(({ id }) => id)); + scene.appliedShotPacks[0].shotBindings = Object.fromEntries( + Object.entries(scene.appliedShotPacks[0].shotBindings).filter(([, id]) => ids.has(id))); + // An ordinary scene comes first; the pack to upgrade is in the second. + legacy.scenes.unshift(structuredClone(PROJECT_FIXTURE.scenes[0])); + } finally { first.restore(); } + const upgraded = makeDirector({ project: legacy }); + try { + const { director } = upgraded; + assert.equal(director._project.scenes[1].appliedShotPacks[0].version, 18, 'the pack was upgraded'); + assert.equal(director._selectedSceneId, 'scene-1'); + assert.equal(director._selectedShotId, 'shot-a'); + } finally { upgraded.restore(); } +}); + test('a legacy three-shot Nepal browser project bootstraps to the current 25-shot sequence', () => { const project = legacyThreeShotNepalProjectFixture(); const originalIds = project.scenes[0].shots.map(({ id }) => id);