From de0be208da0f23ebfaeb5b56617e7d56d81ce88c Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Mon, 16 Nov 2026 13:37:51 -0800 Subject: [PATCH] Scenes: an import counts appended packs as built in, as drafts do --- src/scenes/director.js | 13 +++++++------ src/scenes/director.test.mjs | 25 ++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/scenes/director.js b/src/scenes/director.js index 77eeb84e7..ee87f7d9b 100644 --- a/src/scenes/director.js +++ b/src/scenes/director.js @@ -80,6 +80,11 @@ import { sceneSaveFailureReason } from './sceneSaveError.js'; import { STORY_TAG_LIMIT, STORY_TAGS } from './storyTags.js'; import { captureStoryThumb } from './storyThumb.js'; +/** Scenes GEV ships (recipes and appended packs), as opposed to a person's own. */ +const BUILT_IN_SCENE_IDS = new Set( + [...SCENE_RECIPES, ...SCENE_APPEND_RECIPES].map(({ id }) => id), +); + /** @constant {string} localStorage key for the serialized project */ const STORAGE_KEY = 'godsEyeView.sceneProject.v2'; const STORAGE_CHECKPOINT_KEY = 'godsEyeView.sceneProject.checkpoint.v1'; @@ -2078,15 +2083,12 @@ export class SceneDirector { * @returns {Array<{id: string, title: string, camera: object, shotCount: number, thumb: string, tags: string[]}>} */ draftScenes() { - const builtIn = new Set( - [...SCENE_RECIPES, ...SCENE_APPEND_RECIPES].map(({ id }) => id), - ); return this._project.scenes .filter( (scene) => scene.stories !== true && scene.shots.length > 0 && - !builtIn.has(scene.id), + !BUILT_IN_SCENE_IDS.has(scene.id), ) .map((scene) => ({ id: scene.id, @@ -2535,11 +2537,10 @@ export class SceneDirector { this._storageReadError = null; // Keep authoring on the named or current scene, else the first scene // that is not a built-in one, else the first scene. - const builtIn = new Set(SCENE_RECIPES.map(({ id }) => id)); const selected = project.scenes.find(({ id }) => id === selection?.sceneId) || project.scenes.find(({ id }) => id === this._selectedSceneId) || - project.scenes.find(({ id }) => !builtIn.has(id)) || + project.scenes.find(({ id }) => !BUILT_IN_SCENE_IDS.has(id)) || project.scenes[0] || null; this._selectedSceneId = selected?.id ?? null; diff --git a/src/scenes/director.test.mjs b/src/scenes/director.test.mjs index 9ea30b4b7..5dd7400f3 100644 --- a/src/scenes/director.test.mjs +++ b/src/scenes/director.test.mjs @@ -22,7 +22,11 @@ import { LayerLifecycle } from '../data/lifecycle.js'; import { SceneDirector } from './director.js'; import { stringifySceneDocument } from '../director/document.js'; import { SCENE_TRACKING_PARAM_KEYS } from './scenePolicy.js'; -import { SCENE_RECIPES, getSceneAppendRecipeById } from './recipes.js'; +import { + SCENE_APPEND_RECIPES, + SCENE_RECIPES, + getSceneAppendRecipeById, +} from './recipes.js'; import { STORY_TAGS } from './storyTags.js'; const NEPAL_ORIGINAL_SHOT_TITLES = [ @@ -2534,6 +2538,25 @@ test('an import keeps the current scene, else picks a non-built-in scene, else t SCENE_RECIPES[0].id, 'a built-in scene only when there is nothing else', ); + // An appended pack's scene is built in too, as Stories' drafts count it. + const [pack] = SCENE_APPEND_RECIPES; + const withPack = JSON.stringify({ + version: 6, + scenes: [ + { ...structuredClone(PROJECT_FIXTURE.scenes[0]), id: pack.id }, + { ...structuredClone(PROJECT_FIXTURE.scenes[0]), id: 'mine' }, + ], + }); + director._selectedSceneId = null; + assert.equal( + await director.importProjectFile({ + name: 'c.json', + text: async () => withPack, + }), + true, + ); + assert.equal(director._selectedSceneId, 'mine'); + assert.deepEqual(director.draftScenes().map(({ id }) => id), ['mine']); } finally { restore(); }