Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

updateEverything.logic.ts

680 lines23.6 KB

1import type { ServerUpdateState } from "@t3tools/client-runtime/state/server";
2import {
3 type DesktopUpdateChannel,
4 type EnvironmentId,
5 managedNightlyDeniedMessage,
6 managedUpdatesDenial,
7 type ServerConfig,
8 type ServerSelfUpdateCapability,
9} from "@t3tools/contracts";
10import { cliReleaseChannelOf, desktopUpdateChannelOf } from "@t3tools/shared/cliRelease";
11import { compareSemverVersions } from "@t3tools/shared/semver";
12​
13import {
14 resolveServerSelfUpdateCapability,
15 resolveVersionMismatch,
16 supportsDesktopAppUpdate,
17} from "~/versionSkew";
18import type { ServerUpdateOutcome, ServerUpdateTarget } from "../ServerUpdateAction";
19​
20export interface UpdateEverythingMachine {
21 readonly environmentId: EnvironmentId;
22 readonly label: string;
23 readonly serverConfig: {
24 readonly environment: ServerConfig["environment"];
25 readonly settings: Pick<ServerConfig["settings"], "continueThreadsAfterServerUpdate">;
26 readonly managedPolicy?: ServerConfig["managedPolicy"];
27 } | null;
28 readonly connected: boolean;
29 readonly hostedByThisApp: boolean;
30 readonly canMaintain: boolean;
31 readonly updateState: ServerUpdateState;
33​
34export interface RestartingMachine {
35 readonly environmentId: EnvironmentId;
36 readonly continuesThreads: boolean;
38​
39export function collectRestartingMachines(
40 machines: ReadonlyArray<UpdateEverythingMachine>,
41 servers: ReadonlyArray<Pick<ServerUpdateTarget, "environmentId">>,
42 installsLocal: boolean,
43): RestartingMachine[] {
44 const updated = new Set(servers.map((server) => server.environmentId));
45 return machines.flatMap((machine) => {
46 const config = machine.serverConfig;
47 if (
48 config === null ||
49 !machine.connected ||
50 !(updated.has(machine.environmentId) || (installsLocal && machine.hostedByThisApp))
51 ) {
52 return [];
53 }
54 return [
55 {
56 environmentId: machine.environmentId,
57 continuesThreads: config.settings.continueThreadsAfterServerUpdate === true,
58 },
59 ];
60 });
62​
63export interface SkippedMachine {
64 readonly environmentId: EnvironmentId;
65 readonly label: string;
66 readonly reason: string;
68​
69/** Skip current and app-hosted servers; the latter update with the app and would relaunch mid-run.
70 * Desktop-managed servers use their own feed. Each server's updater checks that it can install the
71 * release before it restarts, so no registry precheck runs here. */
72export function collectServerUpdateTargets(
73 machines: ReadonlyArray<UpdateEverythingMachine>,
74 targetVersion: string,
75): {
76 readonly targets: ServerUpdateTarget[];
77 readonly skipped: SkippedMachine[];
78} {
79 const targets: ServerUpdateTarget[] = [];
80 const skipped: SkippedMachine[] = [];
81 for (const machine of machines) {
82 const config = machine.serverConfig;
83 if (machine.hostedByThisApp) continue;
84 if (
85 config !== null &&
86 resolveVersionMismatch(config.environment.serverVersion, targetVersion) === null
87 ) {
88 continue;
89 }
90 const skip = (reason: string) =>
91 skipped.push({ environmentId: machine.environmentId, label: machine.label, reason });
92 const unavailable = unavailableReason(machine);
93 if (config === null || unavailable !== null) {
94 skip(unavailable ?? "not connected");
95 continue;
96 }
97 const selfUpdate = resolveServerSelfUpdateCapability(config);
98 const managedDenial = managedMachineUpdateDenial(
99 config,
100 selfUpdate === "desktop-managed" ? undefined : targetVersion,
101 );
102 if (managedDenial !== undefined) {
103 skip(managedDenial);
104 continue;
105 }
106 const desktopAppUpdate = supportsDesktopAppUpdate(config);
107 if (selfUpdate === null) {
108 skip("needs a manual update");
109 continue;
110 }
111 if (selfUpdate === "desktop-managed" && !desktopAppUpdate) {
112 skip("needs a newer desktop app");
113 continue;
114 }
115 const serverVersion = config.environment.serverVersion;
116 if (
117 selfUpdate !== "desktop-managed" &&
118 cliReleaseChannelOf(serverVersion) !== cliReleaseChannelOf(targetVersion)
119 ) {
120 skip(`on the ${cliReleaseChannelOf(serverVersion)} channel`);
121 continue;
122 }
123 const target: ServerUpdateTarget = {
124 environmentId: machine.environmentId,
125 serverLabel: machine.label,
126 selfUpdate,
127 installation: config.environment.capabilities.serverInstallation,
128 desktopAppUpdate,
129 targetVersion,
130 };
131 targets.push(target);
132 }
133 return { targets, skipped };
135​
136function unavailableReason(machine: UpdateEverythingMachine): string | null {
137 if (machine.serverConfig === null || !machine.connected) return "not connected";
138 if (!machine.canMaintain) return "no permission";
139 if (machine.updateState.status === "running") return "already updating";
140 return null;
142​
143/** The latest release on the track a fleet switches to, as npm reports it. */
144export interface ChannelSwitchRelease {
145 readonly channel: DesktopUpdateChannel;
146 readonly version: string;
147 readonly databaseMigration: number | undefined;
149​
150export const channelSwitchLabel = (channel: DesktopUpdateChannel) =>
151 channel === "nightly" ? "Nightly" : "Stable";
152​
153/** Stable and Nightly each build their own commits, so either can hold migrations the other lacks.
154 * Crossing tracks needs proof that the target release knows every migration the database holds. */
155const crossesTrack = (fromVersion: string, release: ChannelSwitchRelease) =>
156 desktopUpdateChannelOf(fromVersion) !== release.channel;
157​
158function channelSwitchBlockReason(
159 fromVersion: string,
160 release: ChannelSwitchRelease,
161 currentMigration: number | undefined,
162): string | null {
163 if (!crossesTrack(fromVersion, release)) return null;
164 const from = channelSwitchLabel(desktopUpdateChannelOf(fromVersion));
165 // Servers and releases from before this check report no migration number.
166 if (currentMigration === undefined) {
167 return `its server predates database checks; update it on ${from} first`;
168 }
169 if (release.databaseMigration === undefined) {
170 return `${release.version} predates database checks; wait for a newer ${channelSwitchLabel(release.channel)} release`;
171 }
172 return currentMigration > release.databaseMigration
173 ? `its database has changes ${release.version} does not support yet; stay on ${from} until ${channelSwitchLabel(release.channel)} has them`
174 : null;
176​
177/** This app's reinstall restarts every server it hosts, so each of their databases must allow the
178 * switch. `backendCount` is the desktop's own inventory: a backend still starting has no client
179 * entry yet. A cached config can outlive its connection, so only a connected server's head counts. */
180export function localSwitchBlockReason(
181 appVersion: string,
182 release: ChannelSwitchRelease,
183 hosted: ReadonlyArray<{
184 readonly connected: boolean;
185 readonly databaseMigration: number | undefined;
186 }>,
187 backendCount: number,
188): string | null {
189 if (!crossesTrack(appVersion, release)) return null;
190 if (
191 hosted.length === 0 ||
192 hosted.length < backendCount ||
193 hosted.some((server) => !server.connected)
194 ) {
195 return "its server is not connected, so its database cannot be checked";
196 }
197 return (
198 hosted
199 .map((server) => channelSwitchBlockReason(appVersion, release, server.databaseMigration))
200 .find((reason) => reason !== null) ?? null
201 );
203​
204/**
205 * The server refuses these with the same message; say so before the run instead of after.
206 * `targetVersion` is undefined when the server picks its own version, as desktop apps do.
207 */
208function managedMachineUpdateDenial(
209 config: NonNullable<UpdateEverythingMachine["serverConfig"]>,
210 targetVersion: string | undefined,
211): string | undefined {
212 const policy = config.managedPolicy;
213 return (
214 managedUpdatesDenial(policy) ??
215 (policy !== undefined &&
216 policy.limits?.updates?.allowNightly === false &&
217 targetVersion !== undefined &&
218 cliReleaseChannelOf(targetVersion) !== "stable"
219 ? managedNightlyDeniedMessage(policy.organization)
220 : undefined)
221 );
223​
224/** Servers move to the release; desktop-managed hosts reinstall their app on its track. A desktop
225 * host already current gets a track-only request, since its saved track may still differ. */
226export function collectChannelSwitchTargets(
227 machines: ReadonlyArray<UpdateEverythingMachine>,
228 release: ChannelSwitchRelease,
229): { readonly targets: ServerUpdateTarget[]; readonly skipped: SkippedMachine[] } {
230 const targets: ServerUpdateTarget[] = [];
231 const skipped: SkippedMachine[] = [];
232 for (const machine of machines) {
233 const config = machine.serverConfig;
234 if (machine.hostedByThisApp) continue;
235 const skip = (reason: string) =>
236 skipped.push({ environmentId: machine.environmentId, label: machine.label, reason });
237 const target = (
238 selfUpdate: ServerSelfUpdateCapability,
239 targetVersion: string,
240 ): ServerUpdateTarget => ({
241 environmentId: machine.environmentId,
242 serverLabel: machine.label,
243 selfUpdate,
244 installation: config?.environment.capabilities.serverInstallation,
245 desktopAppUpdate: config !== null && supportsDesktopAppUpdate(config),
246 targetVersion,
247 ...(selfUpdate === "desktop-managed" ? { channel: release.channel } : {}),
248 ...(release.databaseMigration === undefined
249 ? {}
250 : { targetDatabaseMigration: release.databaseMigration }),
251 });
252 const serverVersion = config?.environment.serverVersion;
253 const sameTrack = serverVersion !== undefined && isOnTrack(serverVersion, release.channel);
254 if (
255 config !== null &&
256 sameTrack &&
257 resolveVersionMismatch(serverVersion, release.version) === null
258 ) {
259 const move = trackSwitchMove(config, true);
260 if (
261 !("skip" in move) &&
262 move.selfUpdate === "desktop-managed" &&
263 unavailableReason(machine) === null &&
264 managedMachineUpdateDenial(config, release.version) === undefined
265 ) {
266 targets.push({ ...target(move.selfUpdate, serverVersion), trackOnly: true });
267 }
268 continue;
269 }
270 const unavailable = unavailableReason(machine);
271 if (config === null || serverVersion === undefined || unavailable !== null) {
272 skip(unavailable ?? "not connected");
273 continue;
274 }
275 const managedDenial = managedMachineUpdateDenial(config, release.version);
276 if (managedDenial !== undefined) {
277 skip(managedDenial);
278 continue;
279 }
280 const move = trackSwitchMove(config, sameTrack);
281 if ("skip" in move) {
282 skip(move.skip);
283 continue;
284 }
285 const blocked = channelSwitchBlockReason(
286 serverVersion,
287 release,
288 config.environment.databaseMigration,
289 );
290 if (blocked !== null) {
291 skip(blocked);
292 continue;
293 }
294 // Service launchers only accept newer versions, so leaving for an older release is manual.
295 if (
296 move.selfUpdate === "boot-service" &&
297 compareSemverVersions(release.version, serverVersion) <= 0
298 ) {
299 skip(
300 `run \`t3 update --channel ${release.channel === "nightly" ? "nightly" : "stable"} --allow-downgrade\` there`,
301 );
302 continue;
303 }
304 targets.push(target(move.selfUpdate, release.version));
305 }
306 return { targets, skipped };
308​
309/** A remote host on the other track that a switch can still move, for retrying a partial switch. */
310export function awaitsTrackSwitch(
311 machine: Pick<UpdateEverythingMachine, "serverConfig" | "hostedByThisApp">,
312 channel: DesktopUpdateChannel,
313): boolean {
314 const config = machine.serverConfig;
315 return (
316 !machine.hostedByThisApp &&
317 config !== null &&
318 !isOnTrack(config.environment.serverVersion, channel) &&
319 !("skip" in trackSwitchMove(config, false))
320 );
322​
323function isOnTrack(version: string, channel: DesktopUpdateChannel): boolean {
324 return cliReleaseChannelOf(version) !== "preview" && desktopUpdateChannelOf(version) === channel;
326​
327/** How a switch moves a host, or why it never can from here, whatever the release. */
328function trackSwitchMove(
329 config: NonNullable<UpdateEverythingMachine["serverConfig"]>,
330 sameTrack: boolean,
331): { readonly selfUpdate: ServerSelfUpdateCapability } | { readonly skip: string } {
332 if (cliReleaseChannelOf(config.environment.serverVersion) === "preview") {
333 return { skip: "runs a preview build" };
334 }
335 const selfUpdate = resolveServerSelfUpdateCapability(config);
336 if (selfUpdate === null) return { skip: "needs a manual update" };
337 if (selfUpdate !== "desktop-managed") return { selfUpdate };
338 if (config.environment.capabilities.desktopAppChannelSwitch !== true) {
339 return { skip: "needs a newer desktop app" };
340 }
341 // Squirrel.Mac renames the bundle for the new track and then cannot relaunch it.
342 if (!sameTrack && config.environment.platform.os === "darwin") {
343 return { skip: "switch the Mac app on that Mac" };
344 }
345 return { selfUpdate };
347​
348export interface UpdateEverythingSteps<Providers, Servers> {
349 readonly downloadLocal?: () => Promise<boolean>;
350 readonly updateProviders: () => Promise<Providers>;
351 readonly updateServers: () => Promise<Servers>;
353​
354/** Finish provider installs before server restarts. Install this app last when localReady; failed
355 * downloads skip only that install. */
356export async function runUpdateEverything<Providers, Servers>(
357 steps: UpdateEverythingSteps<Providers, Servers>,
358): Promise<{
359 readonly localReady: boolean;
360 readonly providers: Providers;
361 readonly servers: Servers;
362}> {
363 const [localReady, remote] = await Promise.all([
364 steps.downloadLocal?.() ?? Promise.resolve(true),
365 steps
366 .updateProviders()
367 .then(async (providers) => ({ providers, servers: await steps.updateServers() })),
368 ]);
369 return { localReady, ...remote };
371​
372export type UpdateRunMachineStatus =
373 | "providers"
374 | "waiting"
375 | "downloading"
376 | "restarting"
377 | "done"
378 | "failed";
379​
380export interface UpdateRunMachine {
381 readonly environmentId: EnvironmentId;
382 readonly label: string;
383 readonly updatesProviders: boolean;
384 readonly server: ServerUpdateTarget | null;
385 readonly handedOffVersion: string | null;
386 readonly startedAt: number;
387 readonly result: "done" | "failed" | null;
388 readonly failure: string | null;
389 readonly providerFailure: string | null;
391​
392export interface UpdateEverythingRun {
393 /** Track switches retry through their planner, which re-checks each database. */
394 readonly trackSwitch?: boolean;
395 readonly localVersion: string | null;
396 readonly phase: "providers" | "servers" | "countdown" | "installing";
397 readonly restartAt: number | null;
398 readonly machines: ReadonlyArray<UpdateRunMachine>;
400​
401export function resolveUpdateRunMachineStatus(
402 machine: UpdateRunMachine,
403 phase: UpdateEverythingRun["phase"],
404 serverState: ServerUpdateState,
405): UpdateRunMachineStatus {
406 if (machine.result !== null) return machine.result;
407 if (machine.handedOffVersion !== null) return "restarting";
408 if (phase === "providers" && machine.updatesProviders) return "providers";
409 if (machine.server !== null && serverState.status === "running") {
410 return serverState.stage === "resuming" ? "restarting" : "downloading";
411 }
412 return "waiting";
414​
415export function isServerUpdateHandedOff(state: ServerUpdateState): boolean {
416 return state.status === "running" && state.stage === "resuming";
418​
419export function closeFinishedUpdateRun(run: UpdateEverythingRun): UpdateEverythingRun | null {
420 return run.phase === "servers" &&
421 run.localVersion === null &&
422 run.machines.every((machine) => machine.result === "done")
423 ? null
424 : run;
426​
427const UPDATE_SLOW_AFTER_MS = 3 * 60 * 1000;
428​
429export function formatUpdateElapsed(ms: number): string {
430 const minutes = Math.floor(ms / 60_000);
431 if (minutes < 1) return "<1m";
432 if (minutes < 60) return `${minutes}m`;
433 return `${Math.floor(minutes / 60)}h ${minutes % 60}m`;
435​
436export interface UpdateRunMachineView {
437 readonly machine: UpdateRunMachine;
438 readonly status: UpdateRunMachineStatus;
440​
441export type UpdateRunLocalState =
442 | { readonly status: "downloading"; readonly percent: number | null }
443 | { readonly status: "waiting" }
444 | null;
445​
446export interface UpdateCapsuleView {
447 readonly tone: "default" | "slow" | "failed";
448 readonly label: string;
449 readonly slow?: { readonly status: string; readonly elapsed: string };
450 readonly action: "later" | "retry" | "dismiss" | null;
452​
453const isActive = (status: UpdateRunMachineStatus) => status !== "done" && status !== "failed";
454​
455export function describeUpdateCapsule(
456 run: UpdateEverythingRun,
457 machines: ReadonlyArray<UpdateRunMachineView>,
458 local: UpdateRunLocalState,
459 now: number,
460): UpdateCapsuleView {
461 if (run.phase === "countdown" && run.restartAt !== null) {
462 const seconds = Math.max(0, Math.ceil((run.restartAt - now) / 1000));
463 return { tone: "default", label: `Restart in ${seconds}s`, action: "later" };
464 }
465 if (run.phase === "installing") {
466 return { tone: "default", label: "Restarting…", action: null };
467 }
468 const active = machines.filter(({ status }) => isActive(status) && status !== "waiting");
469 const slowest = active.toSorted((a, b) => a.machine.startedAt - b.machine.startedAt)[0];
470 if (slowest && now - slowest.machine.startedAt >= UPDATE_SLOW_AFTER_MS) {
471 return {
472 tone: "slow",
473 label: slowest.machine.label,
474 slow: {
475 status: RUN_STATUS_LABELS[slowest.status],
476 elapsed: formatUpdateElapsed(now - slowest.machine.startedAt),
477 },
478 action: null,
479 };
480 }
481 const done = machines.filter(({ status }) => status === "done").length;
482 if (machines.some(({ status }) => isActive(status))) {
483 return { tone: "default", label: `${done} of ${machines.length} updated`, action: null };
484 }
485 if (local?.status === "downloading") {
486 return {
487 tone: "default",
488 label: `Downloading${local.percent === null ? "" : ` ${Math.floor(local.percent)}%`}`,
489 action: null,
490 };
491 }
492 const failed = machines.filter(({ status }) => status === "failed");
493 if (failed.length > 0) {
494 return {
495 tone: "failed",
496 label: failed.length === 1 ? `${failed[0]!.machine.label} failed` : `${failed.length} failed`,
497 action:
498 !run.trackSwitch && failed.some(({ machine }) => machine.server !== null)
499 ? "retry"
500 : "dismiss",
501 };
502 }
503 return { tone: "default", label: `${done} of ${machines.length} updated`, action: null };
505​
506export const RUN_STATUS_LABELS: Record<UpdateRunMachineStatus, string> = {
507 providers: "updating providers",
508 waiting: "waiting",
509 downloading: "downloading",
510 restarting: "restarting",
511 done: "done",
512 failed: "failed",
513};
514​
515export interface UpdateEverythingResult {
516 readonly localVersion: string | null;
517 readonly updatedServers: number;
518 readonly updatedProviders: number;
519 readonly failures: ReadonlyArray<string>;
520 readonly restarting: ReadonlyArray<string>;
522​
523export function collectUpdateEverythingResult(input: {
524 readonly localVersion: string | null;
525 readonly localFailures: ReadonlyArray<string>;
526 readonly servers: ReadonlyArray<{
527 readonly label: string;
528 readonly outcome: ServerUpdateOutcome;
529 }>;
530 readonly providers: ReadonlyArray<
531 | { readonly status: "interrupted" | "updated" }
532 | { readonly status: "failed"; readonly line: string }
533 >;
534}): UpdateEverythingResult {
535 return {
536 localVersion: input.localVersion,
537 updatedServers: input.servers.filter(({ outcome }) => outcome.status === "updated").length,
538 updatedProviders: input.providers.filter((outcome) => outcome.status === "updated").length,
539 restarting: [],
540 failures: [
541 ...input.localFailures.map((failure) => `This app: ${failure}`),
542 ...input.servers.flatMap(({ label, outcome }) =>
543 outcome.status === "failed" ? [`${label}: ${outcome.message}`] : [],
544 ),
545 ...input.providers.flatMap((outcome) => (outcome.status === "failed" ? [outcome.line] : [])),
546 ],
547 };
549​
550export function getUpdateEverythingToastView(
551 result: UpdateEverythingResult,
552 appVersion: string,
553): {
554 readonly type: "success" | "error";
555 readonly title: string;
556 readonly description?: string;
557} | null {
558 const parts = [
559 result.localVersion !== null && result.localVersion === appVersion ? "this app" : null,
560 countLabel(result.updatedServers, "server"),
561 countLabel(result.updatedProviders, "provider"),
562 ].filter((part) => part !== null);
563 const restarting =
564 result.restarting.length === 0
565 ? []
566 : [
567 `${joinList(result.restarting)} ${result.restarting.length === 1 ? "is" : "are"} still restarting.`,
568 ];
569 if (result.failures.length === 0) {
570 if (parts.length === 0) return null;
571 return {
572 type: "success",
573 title: `Updated ${joinList(parts)}`,
574 ...(restarting.length === 0 ? {} : { description: restarting.join("\n") }),
575 };
576 }
577 return {
578 type: "error",
579 title: parts.length === 0 ? "Update failed" : `Updated ${joinList(parts)}`,
580 description: [...result.failures, ...restarting].join("\n"),
581 };
583​
584export interface UpdateEverythingPlan {
585 readonly localVersion: string | null;
586 /** Machines whose servers this app hosts; this app's update restarts them. */
587 readonly localMachines: ReadonlyArray<{
588 readonly environmentId: EnvironmentId;
589 readonly label: string;
590 }>;
591 readonly servers: ReadonlyArray<
592 Pick<ServerUpdateTarget, "environmentId" | "serverLabel" | "selfUpdate" | "targetVersion">
593 >;
594 readonly providerMachines: ReadonlyArray<{
595 readonly environmentId: EnvironmentId;
596 readonly label: string;
597 readonly providers: ReadonlyArray<string>;
598 }>;
599 readonly skipped: ReadonlyArray<SkippedMachine>;
601​
602export interface UpdateEverythingRow {
603 readonly environmentId: EnvironmentId | null;
604 readonly label: string;
605 readonly app: "this-app" | "server" | "desktop-app" | null;
606 readonly skipped: string | null;
607 readonly providers: ReadonlyArray<string>;
609​
610function countLabel(count: number, noun: string): string | null {
611 return count === 0 ? null : `${count} ${noun}${count === 1 ? "" : "s"}`;
613​
614function joinList(parts: ReadonlyArray<string>): string {
615 if (parts.length <= 2) return parts.join(" and ");
616 return `${parts.slice(0, -1).join(", ")}, and ${parts.at(-1)}`;
618​
619/** One row per machine: this app's machines first, then servers, provider-only, and skipped. */
620export function describeUpdateEverything(plan: UpdateEverythingPlan): {
621 readonly summary: string;
622 readonly version: string | null;
623 readonly providerCount: number;
624 readonly rows: ReadonlyArray<UpdateEverythingRow>;
625} {
626 const providerCount = plan.providerMachines.reduce(
627 (count, machine) => count + machine.providers.length,
628 0,
629 );
630 const summary = `Update ${joinList(
631 [
632 plan.localVersion ? "this app" : null,
633 countLabel(plan.servers.length, "server"),
634 countLabel(providerCount, "provider"),
635 ].filter((part) => part !== null),
636 )}`;
637​
638 const rows = new Map<EnvironmentId | null, UpdateEverythingRow>();
639 const update = (
640 environmentId: EnvironmentId | null,
641 label: string,
642 change: Partial<UpdateEverythingRow>,
643 ) => {
644 const row = rows.get(environmentId) ?? {
645 environmentId,
646 label,
647 app: null,
648 skipped: null,
649 providers: [],
650 };
651 rows.set(environmentId, { ...row, ...change });
652 };
653 if (plan.localVersion) {
654 if (plan.localMachines.length === 0) update(null, "This app", { app: "this-app" });
655 for (const machine of plan.localMachines) {
656 update(machine.environmentId, machine.label, { app: "this-app" });
657 }
658 }
659 for (const server of plan.servers) {
660 update(server.environmentId, server.serverLabel, {
661 app: server.selfUpdate === "desktop-managed" ? "desktop-app" : "server",
662 });
663 }
664 for (const machine of plan.providerMachines) {
665 update(machine.environmentId, machine.label, { providers: machine.providers });
666 }
667 for (const machine of plan.skipped) {
668 update(machine.environmentId, machine.label, { skipped: machine.reason });
669 }
670​
671 return {
672 summary,
673 version:
674 plan.localVersion ??
675 plan.servers.find((server) => server.selfUpdate !== "desktop-managed")?.targetVersion ??
676 null,
677 providerCount,
678 rows: Array.from(rows.values()),
679 };