Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions apps/web/src/components/sidebar/updateEverything.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ function machine(
};
}

// A desktop-mode server the desktop app cannot control, such as a WSL backend or an older app.
function withoutDesktopControl(base: UpdateEverythingMachine): UpdateEverythingMachine {
return {
...base,
serverConfig: {
...base.serverConfig!,
environment: {
...base.serverConfig!.environment,
capabilities: { repositoryIdentity: true, serverSelfUpdate: "desktop-managed" },
},
},
};
}

describe("collectServerUpdateTargets", () => {
it("updates remote servers that can move to the target and names every skipped one", () => {
const { targets, skipped } = collectServerUpdateTargets(
Expand All @@ -67,6 +81,7 @@ describe("collectServerUpdateTargets", () => {
machine("current", "0.0.50", "boot-service"),
machine("current-offline", "0.0.50", "boot-service", { connected: false }),
machine("manual", "0.0.40", undefined),
withoutDesktopControl(machine("wsl-backend", "0.0.40", "desktop-managed")),
],
"0.0.50",
);
Expand All @@ -82,6 +97,7 @@ describe("collectServerUpdateTargets", () => {
["no-scope", "no permission"],
["busy", "already updating"],
["manual", "needs a manual update"],
["wsl-backend", "update T3 Code on that machine"],
]);
});

Expand Down Expand Up @@ -215,15 +231,9 @@ describe("collectChannelSwitchTargets", () => {
host(machine("service", "0.1.2", "boot-service"), 70),
// A Stable tag built a migration the latest Nightly does not have yet.
host(machine("ahead", "0.1.3", "boot-service"), 73),
machine("old-desktop", "0.1.2", "desktop-managed", {
serverConfig: {
...machine("old-desktop", "0.1.2", "desktop-managed").serverConfig!,
environment: {
...machine("old-desktop", "0.1.2", "desktop-managed").serverConfig!.environment,
capabilities: { repositoryIdentity: true, serverSelfUpdate: "desktop-managed" },
},
},
}),
withoutDesktopControl(machine("old-desktop", "0.1.2", "desktop-managed")),
// Already on Nightly, so it needs an update rather than a channel switch.
withoutDesktopControl(machine("behind-desktop", OLD_NIGHTLY, "desktop-managed")),
machine("current", NIGHTLY, "boot-service"),
// The server refuses a track its policy rules out, so the dialog skips it up front.
managedHost(host(machine("no-nightly", "0.1.2", "boot-service"), 70)),
Expand All @@ -239,7 +249,8 @@ describe("collectChannelSwitchTargets", () => {
"ahead",
`its database has changes ${NIGHTLY} does not support yet; stay on Stable until Nightly has them`,
],
["old-desktop", "needs a newer desktop app"],
["old-desktop", "change the update track on that machine"],
["behind-desktop", "update T3 Code on that machine"],
[
"no-nightly",
"Example Corp manages T3 Code updates. Only stable releases can be installed.",
Expand Down
8 changes: 6 additions & 2 deletions apps/web/src/components/sidebar/updateEverything.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export interface SkippedMachine {
readonly reason: string;
}

// Desktop servers without the desktop control fd (older apps, WSL backends: wsl.exe cannot pass
// fds) cannot be updated from here, and their desktop app is not necessarily the stale part.
const UPDATE_ON_THAT_MACHINE = "update T3 Code on that machine";

/** Skip current and app-hosted servers; the latter update with the app and would relaunch mid-run.
* Desktop-managed servers use their own feed. Each server's updater checks that it can install the
* release before it restarts, so no registry precheck runs here. */
Expand Down Expand Up @@ -109,7 +113,7 @@ export function collectServerUpdateTargets(
continue;
}
if (selfUpdate === "desktop-managed" && !desktopAppUpdate) {
skip("needs a newer desktop app");
skip(UPDATE_ON_THAT_MACHINE);
continue;
}
const serverVersion = config.environment.serverVersion;
Expand Down Expand Up @@ -336,7 +340,7 @@ function trackSwitchMove(
if (selfUpdate === null) return { skip: "needs a manual update" };
if (selfUpdate !== "desktop-managed") return { selfUpdate };
if (config.environment.capabilities.desktopAppChannelSwitch !== true) {
return { skip: "needs a newer desktop app" };
return { skip: sameTrack ? UPDATE_ON_THAT_MACHINE : "change the update track on that machine" };
}
// Squirrel.Mac renames the bundle for the new track and then cannot relaunch it.
if (!sameTrack && config.environment.platform.os === "darwin") {
Expand Down
Loading