Make Space Missions an ordinary layer with its own panel

Space Missions no longer runs as a Context mode. The launches layer owns
its Satellites dependency, including the rule that a Satellites off
asked for after Space Missions was switched on ends it (request order
decides), and a small controller connects the layer to its own panel and
store. Context no longer isolates, snapshots or restores Space Missions
or Satellites, so Contacts and Space Missions run together in either
order, and scene playback no longer exits an isolating mode. Settled by
the owner: Contacts leaves Satellites as it is, and only a person's or
voice Satellites off ends Space Missions; a scene, story, preset or
other programmatic off does not.

Turning the layer on by hand or by voice, choosing it at first run, or
picking a mission on the globe opens the Space Missions panel, and on a
phone its Missions sheet. Asking voice to open the panel while the layer
is off is refused with a reason, and voice never opens it while the
Cockpit owns the screen. With no Context mode on, a voice Context off
switches Space Missions off. A failed Satellites restore no longer cuts
the layer's teardown short. Mission labels on the globe select their
mission. The layer names a failed first index load itself, so the
Context toast no longer imports Space Missions code.

Also carries the satellites request ordering and
DataLayerManager.waitForLayerIdle, the share token for the panel, voice
panel ids, Cockpit folding the panel away and the phone tab ellipsis.
The panel shares the rail gutters and hover border of the other side
panels.

On top of the Omnibar: "open space missions panel" reaches the new
panel, and Open Context no longer answers to "missions".

Co-authored-by: Sameh Khamis <[email protected]>
This commit is contained in:
Manjunath PaparajuandSameh Khamis authored and Sameh Khamis committed 2026-11-18 16:03:51 -08:00
1 parent 8b2ca602e5
commit 0a6fd5f43f
101 files changed
+2885 -1673

No files matched your search

+6 -66
View File
@@ -36,7 +36,7 @@ import {
displayShotTitle,
getSceneAppendRecipeById,
} from './recipes.js';
import { sceneLayerPlan, sceneRequiresContextModeExit } from './scenePolicy.js';
import { sceneLayerPlan } from './scenePolicy.js';
import { t, tn, msg, onLocaleChange } from '../i18n/index.js';
import { createSceneDataPacks } from './dataPacks/controller.js';
import { createSceneInteractions } from './interactions.js';
@@ -1819,7 +1819,7 @@ export class SceneDirector {
const layerResult = await this._applyLayerStates(
staleStates,
this._loadToken(generation, controller.signal, seekGeneration),
{ stopOnRefusal: true, exitContextMode: false },
{ stopOnRefusal: true },
);
if (this._loadAbort === controller) this._loadAbort = null;
if (this._seekAbort === controller) this._seekAbort = null;
@@ -2632,13 +2632,9 @@ export class SceneDirector {
* Only layers the shot declares are touched — see src/scenes/scenePolicy.js
* for why undeclared layers are left alone.
*
* Two things this pass owes the operator:
* - An isolating Context mode is left FIRST. Space Missions refuses every
* unrelated enable, so a shot applied inside it composes a scene nobody
* authored (see _exitIsolatingContextMode).
* - A refused layer is reported. setEnabled() answers false when a guard
* vetoes the transition; swallowing that answer is how playback came to
* claim success over a scene it never assembled.
* A refused layer is reported. setEnabled() answers false when a guard
* vetoes the transition; swallowing that answer is how playback came to
* claim success over a scene it never assembled.
*
* The token's signal is handed to every transition, so a stop or a newer
* request cancels the layer that is CURRENTLY moving rather than only the
@@ -2659,22 +2655,13 @@ export class SceneDirector {
async _applyLayerStates(
targetStates,
token = null,
{ stopOnRefusal = false, exitContextMode = true } = {},
{ stopOnRefusal = false } = {},
) {
const applied = [];
const refused = [];
const abort = () => ({ applied, refused, cancelled: true });
if (token?.cancelled) return abort();
// Deliberately NOT aborted: leaving an isolating mode IS the restore to
// the operator's pre-mode state, which is exactly where a stopped scene
// should come to rest. Tearing that transaction in half would strand
// Context, so it completes and cancellation is honoured immediately after.
if (exitContextMode) {
await this._exitIsolatingContextMode();
if (token?.cancelled) return abort();
}
const signal = token?.signal;
const registered = new Set(
this.dataManager.getAll().map((layer) => layer.id),
@@ -2802,53 +2789,6 @@ export class SceneDirector {
return this._releaseAbort.signal;
}
/**
* Leave a Context mode that isolates the globe, before a shot's layers land.
*
* Space Missions is the shipped case. It is a destructive-exclusive mode: a
* guard refuses every enable outside its own replay bundle, so a recipe that
* declares flights/satellites/earthquakes/traffic gets all four refused —
* and Orbital Watch, whose satellites the guard does permit, would still
* play over the mode's rocket-launches replay it never declared. Either way
* the shot is not the composition it describes.
*
* The old full-registry reconcile dismantled the mode by accident, as part
* of forcing every undeclared layer off. Declaring the exit is the honest
* version of that: the decision is read off the policy guard itself, so a
* future isolating mode is covered without being named here.
*
* @returns {Promise<boolean>} Whether a mode was exited.
*/
async _exitIsolatingContextMode() {
// Older/headless style managers may predate the Context facade.
if (typeof this.styleManager?.getContextModeState !== 'function')
return false;
if (typeof this.styleManager?.setContextMode !== 'function') return false;
const state = this.styleManager.getContextModeState() || {};
// A mode still being entered already owns the guard, so it counts.
const mode = state.entering || state.mode || null;
if (!sceneRequiresContextModeExit(mode)) return false;
const result = await this.styleManager.setContextMode('off');
if (result && result.ok === false) {
console.warn(
`[Scenes] Could not exit ${mode}:`,
result.error || 'unknown reason',
);
this._updateStatus(() =>
t('Could not exit {mode} — scene layers may be refused', { mode }),
);
this._logEvent('context_mode_exit_failed', {
mode,
error: result.error || null,
});
return false;
}
this._logEvent('context_mode_exited', { mode });
return true;
}
/**
* Use the authored sampler only for explicit moves; ordinary shots keep their
* existing flights. A resumed shot (`fromProgress` > 0) continues along the
+4 -56
View File
@@ -332,7 +332,7 @@ test('same-shot seeking rolls back earlier layers and preserves Context, clock a
await dataManager.setEnabled('flights', false);
await dataManager.setEnabled('traffic', false);
await dataManager.setEnabled('satellites', false);
styleManager.contextMode = 'space-missions';
styleManager.contextMode = 'flights';
styleManager.contextExits.length = 0;
refuse = (id) => id === 'traffic';
dataManager.setEnabledCalls.length = 0;
@@ -349,7 +349,7 @@ test('same-shot seeking rolls back earlier layers and preserves Context, clock a
assert.equal(enabled.get('flights'), false, 'first stale layer stays disabled');
assert.equal(enabled.get('traffic'), false, 'refused second layer stays disabled');
assert.equal(enabled.get('satellites'), false, 'later stale layer is never written');
assert.equal(styleManager.contextMode, 'space-missions');
assert.equal(styleManager.contextMode, 'flights');
assert.deepEqual(styleManager.contextExits, []);
assert.equal(viewer.views.length, viewsBefore, 'camera stays at the pre-seek pose');
assert.equal(styleManager.visualCalls.length, visualCalls, 'do not rebuild the shot');
@@ -966,8 +966,6 @@ const REGISTERED = [
'telegeography-submarine-cables', 'local-firms',
];
/** Layers Space Missions permits while it isolates the globe (contextModePolicy). */
const SPACE_MISSIONS_ALLOWED = new Set(['rocket-launches', 'satellites', 'radio']);
const PROJECT_FIXTURE = {
version: 3,
@@ -1089,7 +1087,7 @@ function fakeDataManager({ registered = REGISTERED, refuse = () => false } = {})
}
/** Style manager double covering the camera, visual, and Context facades. */
function fakeStyleManager({ contextMode = null, exitFails = false } = {}) {
function fakeStyleManager({ contextMode = null } = {}) {
const manager = {
contextMode,
contextExits: [],
@@ -1107,7 +1105,6 @@ function fakeStyleManager({ contextMode = null, exitFails = false } = {}) {
getContextModeState: () => ({ mode: manager.contextMode, entering: null }),
async setContextMode(mode) {
manager.contextExits.push(mode);
if (exitFails) return { ok: false, error: 'transition did not complete' };
manager.contextMode = null;
return { ok: true };
},
@@ -1429,56 +1426,7 @@ test('a shot captured while tracking never re-establishes tracking on playback',
}
});
test('a dirty Space Missions state is exited before a recipe applies its layers', async () => {
// Space Missions refuses every enable outside its own replay bundle. The old
// full-registry walk dismantled it by accident; the sparse policy never does,
// so all four Flights Radar enables were refused and reported as success.
const style = { contextMode: 'space-missions' };
const holder = {};
const data = {
refuse: (id, on) => on
&& holder.styleManager?.contextMode === 'space-missions'
&& !SPACE_MISSIONS_ALLOWED.has(id),
};
const { director, styleManager, dataManager, restore } = makeDirector({ style, data });
holder.styleManager = styleManager;
try {
const result = await director._applyLayerStates(recipeLayers('flights-radar'));
assert.deepEqual(styleManager.contextExits, ['off']);
assert.equal(styleManager.contextMode, null);
assert.deepEqual(result.refused, []);
assert.ok(result.applied.includes('flights'));
assert.deepEqual(
dataManager.setEnabledCalls.filter((call) => call.enabled).map((call) => call.id),
['flights'],
);
} finally {
restore();
}
});
test('Orbital Watch does not compose over a Space Missions replay', async () => {
// Orbital Watch declares satellites, which the guard permits — so nothing is
// refused and a refusal-only check would pass while rocket-launches stayed
// on screen. Playback leaves an isolating mode whether or not it refuses.
const { director, styleManager, dataManager, restore } = makeDirector({
style: { contextMode: 'space-missions' },
});
try {
await director._applyLayerStates(recipeLayers('orbital-watch'));
assert.deepEqual(styleManager.contextExits, ['off']);
assert.equal(
dataManager.setEnabledCalls.some((call) => call.id === 'rocket-launches'),
false,
'the recipe never declares rocket-launches; exiting the mode is what clears it',
);
} finally {
restore();
}
});
test('a non-isolating context mode is left alone', async () => {
test('playback leaves every Context mode alone', async () => {
for (const contextMode of [null, 'flights']) {
const { director, styleManager, restore } = makeDirector({ style: { contextMode } });
try {
-42
View File
@@ -18,8 +18,6 @@
// registry (director._captureLayerStates), so those shots declare all sixteen
// keys and still reconcile in full.
import { contextLayerEnableBlockReason } from '../contextModePolicy.js';
/**
* Layer params that re-establish a tracked contact — and with it a SECOND
* writer on the camera.
@@ -91,46 +89,6 @@ export function stripSceneTrackingParams(params) {
return Object.keys(kept).length ? kept : undefined;
}
/**
* Reserved layer id used ONLY to interrogate a Context mode's enable guard.
*
* The probe asks "would this mode refuse a layer it has no opinion about?" —
* so it must name a layer that can never exist. The double-underscore form is
* outside the kebab-case convention every real layer id follows, and
* scenePolicy.test.mjs asserts no registered layer claims it, so the reservation
* is enforced rather than assumed.
* @constant {string}
*/
export const SCENE_EXCLUSIVITY_PROBE_LAYER_ID = '__scene-exclusivity-probe__';
/**
* Whether an active Context mode must be exited before a shot's layers can be
* applied.
*
* Space Missions is the shipped case: it isolates replay data, so its guard
* (contextLayerEnableBlockReason) refuses every enable outside its own bundle.
* A recipe declaring only flights/satellites/earthquakes/traffic would have
* those enables refused outright — and Orbital Watch, whose satellites the
* guard does permit, would still play over the mode's rocket-launches replay
* it never declared. Either way the shot is not the composition it describes.
*
* The verdict is read off the guard itself rather than a mode name: a mode
* that refuses an arbitrary unrelated layer is by definition isolating, so a
* future isolating mode is covered the day its branch is added to the policy.
*
* @param {string|null} contextMode Active (or entering) Context mode.
* @returns {boolean} Whether playback must leave the mode first.
*/
export function sceneRequiresContextModeExit(contextMode) {
if (!contextMode) return false;
return (
contextLayerEnableBlockReason({
contextMode,
change: { layerId: SCENE_EXCLUSIVITY_PROBE_LAYER_ID, enabled: true },
}) !== null
);
}
/**
* Build the ordered layer reconcile plan for one shot.
*
-28
View File
@@ -4,12 +4,10 @@ import fs from 'node:fs';
import test from 'node:test';
import {
SCENE_EXCLUSIVITY_PROBE_LAYER_ID,
SCENE_KEPT_SELECTION_PARAM_KEYS,
SCENE_SELECTION_PARAM_PATTERN,
SCENE_TRACKING_PARAM_KEYS,
sceneLayerPlan,
sceneRequiresContextModeExit,
stripSceneTrackingParams,
} from './scenePolicy.js';
import { SCENE_RECIPES } from './recipes.js';
@@ -177,32 +175,6 @@ test('the family pattern catches selection names the old sweep would have missed
}
});
test('the exclusivity probe id is reserved — no real layer may claim it', () => {
// The probe asks a mode "would you refuse a layer you have no opinion
// about?". If a real layer ever took this id, the probe would be asking
// about a layer the mode DOES have an opinion on, and an isolating mode
// could read as non-isolating.
for (const entry of LAYER_STATE_REGISTRY) {
assert.notEqual(entry.id, SCENE_EXCLUSIVITY_PROBE_LAYER_ID);
}
assert.equal(REGISTERED.has(SCENE_EXCLUSIVITY_PROBE_LAYER_ID), false);
// Every real id is kebab-case; the sentinel deliberately is not.
for (const entry of LAYER_STATE_REGISTRY) {
assert.match(entry.id, /^[a-z][a-z0-9-]*$/, `${entry.id} breaks the layer-id convention`);
}
assert.doesNotMatch(SCENE_EXCLUSIVITY_PROBE_LAYER_ID, /^[a-z][a-z0-9-]*$/);
});
test('an isolating context mode must be exited before a shot applies', () => {
// Read off the shared guard, not a mode name: Space Missions refuses every
// enable outside its replay bundle, so a shot applied inside it is not the
// composition it describes.
assert.equal(sceneRequiresContextModeExit('space-missions'), true);
assert.equal(sceneRequiresContextModeExit('flights'), false);
assert.equal(sceneRequiresContextModeExit(null), false);
assert.equal(sceneRequiresContextModeExit(undefined), false);
});
test('shipped recipes touch only their four declared layers', () => {
for (const recipe of SCENE_RECIPES) {
const declared = Object.entries(recipe.layers || {})