Give back the Satellites a person chose between two missions

A saved Satellites state kept by a busy restore could still carry the mark
of a Satellites switch the person made after it, which tells the restore to
leave Satellites as it is. Space Missions turned on again kept that mark,
so turning it off left Satellites on when it had been off. The next mission
now saves Satellites as it is when it starts in that case.

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-18 17:29:35 -08:00
1 parent c53a6d1c51
commit 3cf230b8b3
2 files changed
+48 -2

No files matched your search

+38
View File
@@ -670,6 +670,44 @@ test('Space Missions turned on again after a busy restore switches Satellites on
assert.equal(f.manager.isEnabled('satellites'), false);
});
test('a Satellites switch made between missions is what the next mission gives back', 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();
// The person switches Satellites on, then something else switches it off.
await f.manager.setEnabled('satellites', true, { origin: 'user' });
await f.settle();
await f.manager.setEnabled('satellites', false);
await f.settle();
assert.equal(
await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }),
true,
);
await f.settle();
assert.equal(f.manager.isEnabled('satellites'), true);
await f.manager.setEnabled('rocket-launches', false, { origin: 'user' });
await f.settle();
assert.equal(f.manager.isEnabled('satellites'), false);
});
test('a failed Satellites restore still clears the selected mission panel', async (t) => {
const f = await fixture(t);
f.upstream.status = 200;
+10 -2
View File
@@ -129,8 +129,16 @@ export function createIngestion({
return;
// A saved state kept by a restore that could not finish (Satellites was
// busy) is still the one from before the mission: keep it, and switch
// Satellites on for the mission again.
if (!layerState._satelliteStateBeforeMission)
// Satellites on for the mission again. A Satellites switch the person
// made since (restoreVisibility false) settled its visibility, so it
// is taken as it is now; its params are still the saved ones.
const kept = layerState._satelliteStateBeforeMission;
if (kept?.restoreVisibility === false)
layerState._satelliteStateBeforeMission = {
enabled: manager.isEnabled('satellites'),
params: kept.params,
};
else if (!kept)
layerState._satelliteStateBeforeMission = {
enabled: manager.isEnabled('satellites'),
params: parts.policyHelpers.satelliteParamsAfterSpaceMissions(