Switch Satellites on again when Space Missions returns after a busy restore

A restore that found Satellites still busy keeps the saved state, and the
next Space Missions start then skipped switching Satellites on, so it came
up with no satellites. It now keeps that saved state (still the one from
before the mission) and switches Satellites on for the mission again.

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-18 17:14:04 -08:00
1 parent 71229c8549
commit 74d38e6d14
2 files changed
+49 -7

No files matched your search

+38
View File
@@ -632,6 +632,44 @@ test('a Satellites enable that never settles still lets mission disable complete
assert.equal(f.manager.isEnabled('satellites'), false);
});
test('Space Missions turned on again after a busy restore switches Satellites on', 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();
// Something else switches Satellites off, then Space Missions comes back.
await f.manager.setEnabled('satellites', false);
await f.settle();
assert.equal(f.manager.isEnabled('satellites'), false);
assert.equal(
await f.manager.setEnabled('rocket-launches', true, { origin: 'user' }),
true,
);
await f.settle();
assert.equal(f.manager.isEnabled('satellites'), true);
// Its own off still gives back the Satellites from before the first start.
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;
+11 -7
View File
@@ -108,7 +108,7 @@ export function createIngestion({
async function captureSatelliteDependency() {
const manager = layerState._dataManager;
if (!manager || layerState._satelliteStateBeforeMission) return;
if (!manager) return;
const token = layerState._lifecycleToken;
// Let a pending Satellites action finish before reserving dependency ON.
// A successful explicit OFF can cancel this mission entry while we wait.
@@ -127,12 +127,16 @@ export function createIngestion({
!manager.isEffectivelyEnabled('rocket-launches'))
)
return;
layerState._satelliteStateBeforeMission = {
enabled: manager.isEnabled('satellites'),
params: parts.policyHelpers.satelliteParamsAfterSpaceMissions(
manager.getLayerParams('satellites'),
),
};
// 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)
layerState._satelliteStateBeforeMission = {
enabled: manager.isEnabled('satellites'),
params: parts.policyHelpers.satelliteParamsAfterSpaceMissions(
manager.getLayerParams('satellites'),
),
};
manager.setLayerParams(
'satellites',
parts.policyHelpers.satelliteParamsForSpaceMissions(