From 3cf230b8b3307adb629bdc7ab921bee9e782c45c Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:29:35 -0800 Subject: [PATCH] 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 --- src/layers/launches/failedEntry.test.mjs | 38 ++++++++++++++++++++++++ src/layers/launches/ingestion.js | 12 ++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/layers/launches/failedEntry.test.mjs b/src/layers/launches/failedEntry.test.mjs index 1458da4670..19d6c7aaa2 100644 --- a/src/layers/launches/failedEntry.test.mjs +++ b/src/layers/launches/failedEntry.test.mjs @@ -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; diff --git a/src/layers/launches/ingestion.js b/src/layers/launches/ingestion.js index 58135ad991..9b7de0e633 100644 --- a/src/layers/launches/ingestion.js +++ b/src/layers/launches/ingestion.js @@ -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(