Keep a Satellites setting the person changes while Space Missions holds its saved state

A setting such as "show orbits" changed by the person or by voice while
Space Missions keeps the Satellites state from before it (while it runs, or
after a restore that found Satellites busy) was overwritten when the mission
ended. It is now kept in that saved state, as their visibility choice is.

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-18 17:36:15 -08:00
1 parent 3cf230b8b3
commit ab01345c7d
3 files changed
+56 -1

No files matched your search

+35
View File
@@ -708,6 +708,41 @@ test('a Satellites switch made between missions is what the next mission gives b
assert.equal(f.manager.isEnabled('satellites'), false);
});
test('a Satellites setting changed between missions survives the next one', 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 {
await f.manager.setEnabled('satellites', false);
void f.manager.setEnabled('satellites', true);
await f.manager.setEnabled('rocket-launches', false, { origin: 'user' });
} finally {
satellites.enable = enable;
stuck.resolve();
}
await f.settle();
f.manager.setLayerParams(
'satellites',
{ showOrbits: false },
{ origin: 'user' },
);
await f.settle();
await f.manager.setEnabled('rocket-launches', true, { origin: 'user' });
await f.settle();
await f.manager.setEnabled('rocket-launches', false, { origin: 'user' });
await f.settle();
assert.equal(f.manager.getLayerParams('satellites').showOrbits, false);
});
test('a failed Satellites restore still clears the selected mission panel', async (t) => {
const f = await fixture(t);
f.upstream.status = 200;
+20
View File
@@ -93,6 +93,24 @@ export function createSatelliteIntents({ state: layerState }) {
return stop;
}
/**
* Keep a Satellites setting the person changed while Space Missions holds
* its saved state ("show orbits" off): it survives the mission teardown,
* as their visibility choice does.
*/
function handleParams(change) {
if (
change?.type !== 'params' ||
change.layerId !== 'satellites' ||
!isExplicitOrigin(change.origin)
)
return;
const previous = layerState._satelliteStateBeforeMission;
const requested = change.requestedParams;
if (!previous || !requested || typeof requested !== 'object') return;
previous.params = { ...previous.params, ...requested };
}
/** Settle once a Satellites OFF has finished stopping Space Missions. */
function settled() {
return pendingStop ?? Promise.resolve(false);
@@ -108,6 +126,7 @@ export function createSatelliteIntents({ state: layerState }) {
manager.subscribeVisibilityRequests?.(recordRequest) ?? null;
const unsubscribeChanges =
manager.subscribe?.((change) => {
handleParams(change);
void handleVisibility(change);
}) ?? null;
unsubscribe = () => {
@@ -120,6 +139,7 @@ export function createSatelliteIntents({ state: layerState }) {
connect,
settled,
handleVisibility,
handleParams,
recordRequest,
offFollowsMissionsEntry,
};