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

+285 -47
View File
@@ -4,12 +4,12 @@ import test from 'node:test';
import assert from 'node:assert/strict';
import { DataLayerManager } from '../../data/manager.js';
import { ContextControls } from '../../ui/contextControls.js';
import { spaceMissionsIndexFailure } from '../../ui/contextActions.js';
import { createLaunchSource } from './source.js';
import { createState } from './state.js';
import { createModel } from './model.js';
import { createPolicyHelpers } from './policyHelpers.js';
import { createIngestion } from './ingestion.js';
import { createSatelliteIntents } from './satelliteIntents.js';
import { createPanel } from './panel.js';
import { createControls } from './controls.js';
import { createLifecycle } from './lifecycle.js';
@@ -98,7 +98,7 @@ function fakeCamera() {
return camera;
}
async function fixture(t) {
async function fixture(t, { beforeConnect } = {}) {
const upstream = { status: 429, results: [launchRecord] };
const source = createLaunchSource({
async fetchImpl(url) {
@@ -191,6 +191,7 @@ async function fixture(t) {
parts.panel = createPanel(context);
parts.replay = createReplay(context);
parts.ingestion = createIngestion(context);
parts.satelliteIntents = createSatelliteIntents(context);
parts.controls = createControls(context);
parts.lifecycle = createLifecycle(context);
const missions = Object.assign(
@@ -206,6 +207,7 @@ async function fixture(t) {
manager.register(plainLayer('earthquakes', 'Earthquakes (24h)'));
manager.register(plainLayer('satellites', 'Satellites'));
manager.register(plainLayer('wind', 'Wind'));
manager.register(plainLayer('military-awareness', 'Global Context'));
manager.register(missions);
missions.attachDataManager(manager);
@@ -224,12 +226,19 @@ async function fixture(t) {
setPanelCollapsed: noop,
},
});
beforeConnect?.(manager);
controls.connect(manager);
t.after(async () => {
controls.stop();
controls.disconnect();
for (const id of ['rocket-launches', 'satellites', 'earthquakes', 'wind'])
for (const id of [
'rocket-launches',
'satellites',
'earthquakes',
'wind',
'military-awareness',
])
await manager.setEnabled(id, false);
await missions.destroy(viewer);
});
@@ -257,46 +266,37 @@ async function fixture(t) {
state,
camera,
rosters,
panel: parts.panel,
enabledIds,
view,
settle,
};
}
const entries = {
direct: (f) =>
f.manager.setEnabled('rocket-launches', true, { origin: 'user' }),
'Context-panel': async (f) =>
(
await f.controls.setContextMode('space-missions', {
claimVisualAuthority: false,
})
).ok,
};
test('a Space Missions start that gets HTTP 429 rolls back and leaves other layers alone', async (t) => {
const f = await fixture(t);
await f.manager.setEnabled('earthquakes', true, { origin: 'user' });
const before = f.view();
for (const [path, enter] of Object.entries(entries))
test(`a ${path} Space Missions entry that gets HTTP 429 rolls back instead of isolating`, async (t) => {
const f = await fixture(t);
await f.manager.setEnabled('earthquakes', true, { origin: 'user' });
const before = f.view();
const entered = await enter(f);
await f.settle();
assert.equal(entered, false, 'a failed mission index fails the enable');
assert.deepEqual(f.enabledIds(), ['earthquakes']);
assert.equal(f.controls.getContextModeState().mode, null);
assert.equal(f.controls.getContextModeState().active, false);
assert.equal(f.missions.getStats().error, 'HTTP 429');
assert.deepEqual(f.view(), before, 'the pre-entry view comes back');
assert.ok(f.camera.cancelled > 0, 'the full-globe flight is cancelled');
assert.equal(
await f.manager.setEnabled('wind', true, { origin: 'user' }),
true,
'an unrelated layer is not blocked after the failed entry',
);
const entered = await f.manager.setEnabled('rocket-launches', true, {
origin: 'user',
});
await f.settle();
assert.equal(entered, false, 'a failed mission index fails the enable');
assert.deepEqual(f.enabledIds(), ['earthquakes']);
assert.equal(f.controls.getContextModeState().mode, null);
assert.equal(f.controls.getContextModeState().active, false);
assert.equal(f.missions.getStats().error, 'HTTP 429');
assert.deepEqual(f.view(), before, 'the pre-entry view comes back');
assert.ok(f.camera.cancelled > 0, 'the full-globe flight is cancelled');
assert.equal(
await f.manager.setEnabled('wind', true, { origin: 'user' }),
true,
'an unrelated layer is not blocked after the failed entry',
);
});
// Holds the /api/launches reply until the returned release is called.
function holdReply(f) {
@@ -410,7 +410,12 @@ test('the roster reports a failed mission index instead of loading forever', asy
await f.settle();
assert.equal(f.rosters.slice(loadingFrom).includes(null), true);
assert.equal(f.rosters.at(-1).entries.length, 1);
assert.equal(f.controls.getContextModeState().mode, 'space-missions');
assert.equal(f.manager.isEnabled('rocket-launches'), true);
assert.equal(
f.controls.getContextModeState().mode,
null,
'not a Context mode',
);
});
test('a valid empty mission index is a successful entry', async (t) => {
@@ -422,7 +427,7 @@ test('a valid empty mission index is a successful entry', async (t) => {
true,
);
await f.settle();
assert.equal(f.controls.getContextModeState().mode, 'space-missions');
assert.equal(f.manager.isEnabled('rocket-launches'), true);
assert.equal(
f.rosters.at(-1).empty,
'NO MISSIONS AVAILABLE IN THE CURRENT 30-DAY WINDOW',
@@ -430,7 +435,236 @@ test('a valid empty mission index is a successful entry', async (t) => {
assert.ok(f.camera.flights > 0, 'a successful entry frames the globe');
});
test('a refresh failure after a loaded index keeps the mode and its records', async (t) => {
for (const phase of ['while starting', 'after start']) {
test(`Space Missions runs beside Contacts and a later Satellites OFF ends it (${phase})`, async (t) => {
const gate = Promise.withResolvers();
const guardReached = Promise.withResolvers();
const f = await fixture(t, {
beforeConnect(manager) {
if (phase !== 'while starting') return;
manager.addVisibilityGuard(async ({ layerId, enabled }) => {
if (layerId !== 'rocket-launches' || !enabled) return;
guardReached.resolve();
await gate.promise;
});
},
});
f.upstream.status = 200;
await f.manager.setEnabled('satellites', true, { origin: 'user' });
assert.equal(await f.controls._selectContextMode('flights'), true);
await f.settle();
assert.deepEqual(
f.enabledIds(),
['military-awareness', 'satellites'],
'Contacts leaves Satellites alone',
);
const launch = f.manager.setEnabled('rocket-launches', true, {
origin: 'user',
});
try {
if (phase === 'while starting') {
await guardReached.promise;
} else {
assert.equal(await launch, true);
assert.deepEqual(f.enabledIds(), [
'military-awareness',
'rocket-launches',
'satellites',
]);
}
assert.equal(
f.controls.getContextModeState().mode,
'flights',
'starting Space Missions leaves Contacts on',
);
assert.equal(
await f.manager.setEnabled('satellites', false, { origin: 'voice' }),
true,
);
} finally {
gate.resolve();
}
assert.equal(await launch, phase === 'after start');
await f.missions.waitForSatelliteIntents?.();
await f.settle();
assert.deepEqual(f.enabledIds(), ['military-awareness']);
assert.equal(f.controls.getContextModeState().mode, 'flights');
});
}
test('Contacts started and ended while Space Missions runs leaves it and Satellites alone', async (t) => {
const f = await fixture(t);
f.upstream.status = 200;
assert.equal(
await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }),
true,
);
await f.settle();
const missionParams = f.manager.getLayerParams('satellites');
assert.equal(missionParams.showPoints, false, 'the mission display applied');
assert.equal(await f.controls._selectContextMode('flights'), true);
await f.settle();
assert.deepEqual(f.enabledIds(), [
'military-awareness',
'rocket-launches',
'satellites',
]);
assert.equal(await f.controls._selectContextMode(null), true);
await f.settle();
assert.deepEqual(f.enabledIds(), ['rocket-launches', 'satellites']);
assert.deepEqual(f.manager.getLayerParams('satellites'), missionParams);
await f.manager.setEnabled('rocket-launches', false, { origin: 'user' });
await f.settle();
assert.deepEqual(f.enabledIds(), []);
const after = f.manager.getLayerParams('satellites');
assert.notEqual(after.showPoints, false, 'Satellites shows its points again');
assert.notEqual(after.showOrbits, false, 'and its orbits');
});
test('a Satellites OFF requested before Space Missions entry does not cancel it', async (t) => {
const f = await fixture(t);
f.upstream.status = 200;
await f.manager.setEnabled('satellites', true, { origin: 'user' });
const satellites = f.manager.layers.get('satellites').module;
const disable = satellites.disable;
const gate = Promise.withResolvers();
const disabling = Promise.withResolvers();
satellites.disable = async () => {
disabling.resolve();
await gate.promise;
};
let entry;
try {
const off = f.manager.setEnabled('satellites', false, { origin: 'user' });
await disabling.promise;
// The entry is requested while the earlier OFF is still settling.
entry = f.manager.setEnabled('rocket-launches', true, { origin: 'user' });
gate.resolve();
assert.equal(await off, true);
} finally {
gate.resolve();
satellites.disable = disable;
}
assert.equal(await entry, true, 'the later entry is not cancelled');
await f.settle();
assert.equal(f.manager.isEnabled('rocket-launches'), true);
// Leaving keeps the earlier Satellites OFF.
await f.manager.setEnabled('rocket-launches', false, { origin: 'user' });
await f.settle();
assert.equal(f.manager.isEnabled('satellites'), false);
assert.equal(f.manager.isEnabled('rocket-launches'), false);
});
test('Space Missions is an ordinary layer: it neither isolates nor opens a Context session', async (t) => {
const f = await fixture(t);
f.upstream.status = 200;
await f.manager.setEnabled('earthquakes', true, { origin: 'user' });
assert.equal(
await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }),
true,
);
await f.settle();
assert.deepEqual(f.enabledIds(), [
'earthquakes',
'rocket-launches',
'satellites',
]);
assert.equal(f.controls._contextSessionSnapshot, null);
assert.equal(
await f.manager.setEnabled('wind', true, { origin: 'user' }),
true,
'other layers are not refused while Space Missions is on',
);
await f.manager.setEnabled('rocket-launches', false, { origin: 'user' });
await f.settle();
assert.deepEqual(
f.enabledIds(),
['earthquakes', 'wind'],
'Space Missions gives back only the Satellites it turned on',
);
});
test('a Satellites enable that never settles still lets mission disable complete', async (t) => {
const f = await fixture(t);
f.upstream.status = 200;
assert.equal(
await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }),
true,
);
await f.settle();
f.state.satelliteSettleTimeoutMs = 50;
const satellites = f.manager.layers.get('satellites').module;
const enable = satellites.enable;
const stuck = Promise.withResolvers();
satellites.enable = () => stuck.promise;
try {
// A programmatic Satellites restart whose enable hangs.
await f.manager.setEnabled('satellites', false);
void f.manager.setEnabled('satellites', true);
const exit = f.manager.setEnabled('rocket-launches', false, {
origin: 'user',
});
const outcome = await Promise.race([
exit.then(() => 'settled'),
new Promise((resolve) => setTimeout(() => resolve('hung'), 2000)),
]);
assert.equal(
outcome,
'settled',
'the mission disable does not wait forever',
);
assert.equal(f.missions.getAnalystRecords().length, 0);
} finally {
satellites.enable = enable;
stuck.resolve();
}
await f.settle();
});
test('a failed Satellites restore still clears the selected mission panel', async (t) => {
const f = await fixture(t);
f.upstream.status = 200;
assert.equal(
await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }),
true,
);
await f.settle();
assert.equal(f.manager.isEnabled('satellites'), true);
let panelView;
const unsubscribe = f.panel.subscribePanel((view) => {
panelView = view;
});
const satellites = f.manager.layers.get('satellites').module;
const disable = satellites.disable;
try {
f.state._selectedLaunchId = f.state._launches[0].id;
f.panel.renderMissionPanel();
assert.ok(panelView.mission);
satellites.disable = () => {
throw new Error('injected Satellites restore failure');
};
assert.equal(
await f.manager.setEnabled('rocket-launches', false, { origin: 'user' }),
false,
);
const { enabled, uncertain } =
f.manager.getLayerLifecycleState('rocket-launches');
assert.equal(enabled, true);
assert.equal(uncertain, true);
assert.equal(panelView.mission, null);
} finally {
satellites.disable = disable;
unsubscribe();
}
});
test('a refresh failure after a loaded index keeps the layer and its records', async (t) => {
const f = await fixture(t);
f.upstream.status = 200;
await f.manager.setEnabled('rocket-launches', true, { origin: 'user' });
@@ -442,12 +676,11 @@ test('a refresh failure after a loaded index keeps the mode and its records', as
await f.settle();
assert.equal(f.manager.isEnabled('rocket-launches'), true);
assert.equal(f.controls.getContextModeState().mode, 'space-missions');
assert.equal(f.missions.getStats().count, 1);
assert.equal(f.missions.getStats().error, 'HTTP 429');
assert.equal(f.rosters.at(-1).entries.length, 1);
// Leaving a loaded mode does not restore the pre-entry view.
// Leaving after a loaded index does not restore the pre-entry view.
await f.manager.setEnabled('rocket-launches', false, { origin: 'user' });
await f.settle();
assert.deepEqual(f.view(), framed);
@@ -475,11 +708,9 @@ test('a failed first load tells the user the mission index is unavailable', asyn
const f = await fixture(t);
await f.manager.setEnabled('earthquakes', true, { origin: 'user' });
await f.controls.setContextMode('space-missions', {
claimVisualAuthority: false,
});
await f.manager.setEnabled('rocket-launches', true, { origin: 'user' });
await f.settle();
assert.equal(f.controls.getContextModeState().mode, null, 'rolled back');
assert.equal(f.manager.isEnabled('rocket-launches'), false, 'rolled back');
assert.ok(
f.toasts.some((message) => /mission index/i.test(message)),
`visible feedback names the failure, got ${JSON.stringify(f.toasts)}`,
@@ -504,10 +735,17 @@ test('navigation taking the camera keeps a mission flight it asked to preserve',
assert.equal(f.camera.flight, other);
});
test("an earlier attempt's index error is not blamed for a later failure", async (t) => {
test('a refresh error after a loaded index is not blamed on the index', async (t) => {
const f = await fixture(t);
await f.manager.setEnabled('rocket-launches', true, { origin: 'user' });
await f.settle();
assert.match(spaceMissionsIndexFailure(f.manager), /mission index/);
assert.equal(spaceMissionsIndexFailure(f.manager, Date.now() + 1), null);
assert.match(f.missions.enableFailureMessage(), /mission index/);
f.upstream.status = 200;
await f.manager.setEnabled('rocket-launches', true, { origin: 'user' });
await f.settle();
f.upstream.status = 429;
await f.missions.update();
assert.equal(f.missions.getStats().error, 'HTTP 429');
assert.equal(f.missions.enableFailureMessage(), null);
});