( options: ScheduleSimulatorDefaultsRefreshOptions, )
| 42 | } |
| 43 | |
| 44 | async function refreshSimulatorDefaults( |
| 45 | options: ScheduleSimulatorDefaultsRefreshOptions, |
| 46 | ): Promise<void> { |
| 47 | let simulatorId = options.simulatorId; |
| 48 | let simulatorName = options.simulatorName; |
| 49 | const patch: Partial<SessionDefaults> = {}; |
| 50 | const executor = options.executor ?? getDefaultCommandExecutor(); |
| 51 | |
| 52 | try { |
| 53 | if (simulatorName) { |
| 54 | const resolution = await resolveSimulatorNameToId(executor, simulatorName); |
| 55 | if (resolution.success && resolution.simulatorId !== simulatorId) { |
| 56 | simulatorId = resolution.simulatorId; |
| 57 | patch.simulatorId = resolution.simulatorId; |
| 58 | } |
| 59 | } else if (simulatorId) { |
| 60 | const resolution = await resolveSimulatorIdToName(executor, simulatorId); |
| 61 | if (resolution.success) { |
| 62 | simulatorName = resolution.simulatorName; |
| 63 | patch.simulatorName = resolution.simulatorName; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | const shouldRecomputePlatform = options.recomputePlatform ?? true; |
| 68 | if (shouldRecomputePlatform && (simulatorId || simulatorName)) { |
| 69 | const inferred = await inferPlatform( |
| 70 | { |
| 71 | simulatorId, |
| 72 | simulatorName, |
| 73 | sessionDefaults: { |
| 74 | ...sessionStore.getAllForProfile(options.profile), |
| 75 | ...patch, |
| 76 | simulatorId, |
| 77 | simulatorName, |
| 78 | simulatorPlatform: undefined, |
| 79 | }, |
| 80 | }, |
| 81 | executor, |
| 82 | ); |
| 83 | |
| 84 | if (inferred.source !== 'default') { |
| 85 | patch.simulatorPlatform = inferred.platform; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | if (Object.keys(patch).length === 0) { |
| 90 | return; |
| 91 | } |
| 92 | |
| 93 | const applied = sessionStore.setDefaultsIfRevisionForProfile( |
| 94 | options.profile, |
| 95 | patch, |
| 96 | options.expectedRevision, |
| 97 | ); |
| 98 | if (!applied) { |
| 99 | log( |
| 100 | 'info', |
| 101 | `[Session] Skipped background simulator defaults refresh (${options.reason}) because defaults changed during refresh.`, |
no test coverage detected