Skip to content
Closed
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
40 changes: 31 additions & 9 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,30 @@ function machine(
};
}

/** A desktop-managed server that cannot drive its desktop app's update. */
function desktopWithoutAppUpdate(
id: string,
serverVersion: string,
machineKind?: "linux" | "desktop",
): UpdateEverythingMachine {
const base = machine(id, serverVersion, "desktop-managed");
const environment = base.serverConfig!.environment;
return {
...base,
serverConfig: {
...base.serverConfig!,
environment: {
...environment,
platform: {
...environment.platform,
...(machineKind === undefined ? {} : { machine: machineKind }),
},
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 +91,8 @@ 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),
desktopWithoutAppUpdate("old-desktop", "0.0.40", "desktop"),
desktopWithoutAppUpdate("wsl-desktop", "0.0.40", "linux"),
],
"0.0.50",
);
Expand All @@ -82,6 +108,8 @@ describe("collectServerUpdateTargets", () => {
["no-scope", "no permission"],
["busy", "already updating"],
["manual", "needs a manual update"],
["old-desktop", "needs a newer desktop app"],
["wsl-desktop", "runs in WSL, so update the T3 Code desktop app on that machine"],
]);
});

Expand Down Expand Up @@ -215,15 +243,8 @@ 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" },
},
},
}),
desktopWithoutAppUpdate("old-desktop", "0.1.2"),
desktopWithoutAppUpdate("wsl-desktop", "0.1.2", "linux"),
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 @@ -240,6 +261,7 @@ describe("collectChannelSwitchTargets", () => {
`its database has changes ${NIGHTLY} does not support yet; stay on Stable until Nightly has them`,
],
["old-desktop", "needs a newer desktop app"],
["wsl-desktop", "runs in WSL, so switch the T3 Code desktop app on that machine"],
[
"no-nightly",
"Example Corp manages T3 Code updates. Only stable releases can be installed.",
Expand Down
20 changes: 18 additions & 2 deletions apps/web/src/components/sidebar/updateEverything.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ export function collectServerUpdateTargets(
continue;
}
if (selfUpdate === "desktop-managed" && !desktopAppUpdate) {
skip("needs a newer desktop app");
skip(
runsInWsl(config)
? "runs in WSL, so update the T3 Code desktop app on that machine"
: "needs a newer desktop app",
);
continue;
}
const serverVersion = config.environment.serverVersion;
Expand Down Expand Up @@ -324,6 +328,14 @@ function isOnTrack(version: string, channel: DesktopUpdateChannel): boolean {
return cliReleaseChannelOf(version) !== "preview" && desktopUpdateChannelOf(version) === channel;
}

// A WSL backend can't receive the desktop app's update channel: wsl.exe drops the extra fds.
// The server reports WSL as a Linux "linux" machine; DMI detection never yields that kind.
function runsInWsl(config: NonNullable<UpdateEverythingMachine["serverConfig"]>): boolean {
return (
config.environment.platform.os === "linux" && config.environment.platform.machine === "linux"
);
}

/** How a switch moves a host, or why it never can from here, whatever the release. */
function trackSwitchMove(
config: NonNullable<UpdateEverythingMachine["serverConfig"]>,
Expand All @@ -336,7 +348,11 @@ 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: runsInWsl(config)
? "runs in WSL, so switch the T3 Code desktop app on that machine"
: "needs a newer desktop app",
};
}
// Squirrel.Mac renames the bundle for the new track and then cannot relaunch it.
if (!sameTrack && config.environment.platform.os === "darwin") {
Expand Down
Loading