Skip to content
TypeScript

fix(web): update everything no longer waits on npm for service hosts (#26917)

Theo Brownee6ca17001d0f
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e9c731cf6fa..6d89b7c7abe 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -947,6 +947,7 @@ jobs:
body_path: ${{ hashFiles('release-notes.md') != '' && 'release-notes.md' || '' }}
previous_tag: ${{ needs.preflight.outputs.previous_tag }}
prerelease: ${{ needs.preflight.outputs.is_prerelease }}
+ draft: ${{ needs.preflight.outputs.is_prerelease }}
make_latest: ${{ needs.preflight.outputs.make_latest }}
files: ${{ steps.release_files.outputs.files }}
fail_on_unmatched_files: true
@@ -962,11 +963,23 @@ jobs:
generate_release_notes: ${{ needs.preflight.outputs.release_channel != 'preview' }}
body_path: ${{ needs.preflight.outputs.release_channel == 'preview' && 'release-notes.md' || '' }}
prerelease: ${{ needs.preflight.outputs.is_prerelease }}
+ draft: ${{ needs.preflight.outputs.is_prerelease }}
make_latest: ${{ needs.preflight.outputs.make_latest }}
files: ${{ steps.release_files.outputs.files }}
fail_on_unmatched_files: true
token: ${{ github.token }}
+ # The action keeps a stable release a draft until its assets finish uploading, but publishes a
+ # prerelease first. Desktop clients update connected servers from the CLI archives as soon as
+ # they see the release, so a prerelease also goes public only once every asset is attached.
+ - name: Publish prerelease
+ if: needs.preflight.outputs.is_prerelease == 'true'
+ env:
+ GH_TOKEN: ${{ github.token }}
+ GH_REPO: ${{ github.repository }}
+ RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
+ run: gh release edit "$RELEASE_TAG" --draft=false
+
# The `t3` npm package is a launcher that downloads this version's CLI
# archive from the GitHub Release, so it publishes only once that release
# exists. Preview publishes too, under the `preview` dist-tag, which
diff --git a/apps/web/src/components/sidebar/updateEverything.logic.test.ts b/apps/web/src/components/sidebar/updateEverything.logic.test.ts
index 4c09823d405..df60c036e21 100644
--- a/apps/web/src/components/sidebar/updateEverything.logic.test.ts
+++ b/apps/web/src/components/sidebar/updateEverything.logic.test.ts
@@ -69,6 +69,7 @@ describe("collectServerUpdateTargets", () => {
machine("manual", "0.0.40", undefined),
],
"0.0.50",
+ true,
);
expect(targets.map((target) => [target.serverLabel, target.targetVersion])).toEqual([
@@ -84,6 +85,22 @@ describe("collectServerUpdateTargets", () => {
["manual", "needs a manual update"],
]);
});
+
+ it("waits for npm only for hosts that install from it or when the release may lack archives", () => {
+ const hosts = [
+ machine("archive-service", "0.1.4", "boot-service"),
+ machine("npm-service", "0.0.40", "boot-service"),
+ machine("legacy-respawn", "0.1.4", "respawn"),
+ machine("desktop", "0.1.4", "desktop-managed"),
+ ];
+ const waits = (releaseArchivesPublished: boolean) =>
+ collectServerUpdateTargets(hosts, "0.1.5", releaseArchivesPublished).waitForNpm.map(
+ (target) => target.serverLabel,
+ );
+
+ expect(waits(true)).toEqual(["npm-service", "legacy-respawn"]);
+ expect(waits(false)).toEqual(["archive-service", "npm-service", "legacy-respawn"]);
+ });
});
describe("collectChannelSwitchTargets", () => {
diff --git a/apps/web/src/components/sidebar/updateEverything.logic.ts b/apps/web/src/components/sidebar/updateEverything.logic.ts
index 8d82b7b568e..de21c535f51 100644
--- a/apps/web/src/components/sidebar/updateEverything.logic.ts
+++ b/apps/web/src/components/sidebar/updateEverything.logic.ts
@@ -63,14 +63,25 @@ export interface SkippedMachine {
readonly reason: string;
}
+/** Boot services before this build installed the server from npm, not from release archives. */
+const RELEASE_ARCHIVE_SELF_UPDATE_SINCE = "0.0.41-nightly.20260914.1700";
+
/** Skip current and app-hosted servers; the latter update with the app and would relaunch mid-run.
- * Desktop-managed servers use their own feed. */
+ * Desktop-managed servers use their own feed. `waitForNpm` lists targets that need
+ * `t3@<targetVersion>` on npm first. `releaseArchivesPublished` means the version came from the
+ * desktop feed: its GitHub Release goes public with the CLI archives that boot services download. */
export function collectServerUpdateTargets(
machines: ReadonlyArray<UpdateEverythingMachine>,
targetVersion: string,
-): { readonly targets: ServerUpdateTarget[]; readonly skipped: SkippedMachine[] } {
+ releaseArchivesPublished: boolean,
+): {
+ readonly targets: ServerUpdateTarget[];
+ readonly skipped: SkippedMachine[];
+ readonly waitForNpm: ServerUpdateTarget[];
+} {
const targets: ServerUpdateTarget[] = [];
const skipped: SkippedMachine[] = [];
+ const waitForNpm: ServerUpdateTarget[] = [];
for (const machine of machines) {
const config = machine.serverConfig;
if (machine.hostedByThisApp) continue;
@@ -105,16 +116,25 @@ export function collectServerUpdateTargets(
skip(`on the ${cliReleaseChannelOf(serverVersion)} channel`);
continue;
}
- targets.push({
+ const target: ServerUpdateTarget = {
environmentId: machine.environmentId,
serverLabel: machine.label,
selfUpdate,
installation: config.environment.capabilities.serverInstallation,
desktopAppUpdate,
targetVersion,
- });
+ };
+ targets.push(target);
+ if (
+ selfUpdate !== "desktop-managed" &&
+ (!releaseArchivesPublished ||
+ selfUpdate === "respawn" ||
+ compareSemverVersions(serverVersion, RELEASE_ARCHIVE_SELF_UPDATE_SINCE) < 0)
+ ) {
+ waitForNpm.push(target);
+ }
}
- return { targets, skipped };
+ return { targets, skipped, waitForNpm };
}
function unavailableReason(machine: UpdateEverythingMachine): string | null {
diff --git a/apps/web/src/components/sidebar/useUpdateEverything.ts b/apps/web/src/components/sidebar/useUpdateEverything.ts
index 84e9697cd65..d8ab3a5bce7 100644
--- a/apps/web/src/components/sidebar/useUpdateEverything.ts
+++ b/apps/web/src/components/sidebar/useUpdateEverything.ts
@@ -68,19 +68,18 @@ export function useUpdateEverything(
canMaintain: canUpdateServer(sessionStates[index]!),
updateState: updateStates[index]!,
}));
- const { targets: behindServers, skipped: unreachable } = channelSwitch
- ? collectChannelSwitchTargets(machines, channelSwitch)
- : collectServerUpdateTargets(machines, targetVersion);
- // Desktop-managed servers use their app feed; only npm installs need to wait for publication.
// A track switch's target came from npm already.
- const needsNpm =
- channelSwitch === undefined &&
- behindServers.some((server) => server.selfUpdate !== "desktop-managed");
- const published = useNpmReleasePublished(needsNpm ? targetVersion : null);
- const servers =
- published || channelSwitch !== undefined
- ? behindServers
- : behindServers.filter((server) => server.selfUpdate === "desktop-managed");
+ const {
+ targets: behindServers,
+ skipped: unreachable,
+ waitForNpm,
+ } = channelSwitch
+ ? { ...collectChannelSwitchTargets(machines, channelSwitch), waitForNpm: [] }
+ : collectServerUpdateTargets(machines, targetVersion, localUpdateVersion !== null);
+ const published = useNpmReleasePublished(waitForNpm.length > 0 ? targetVersion : null);
+ const servers = published
+ ? behindServers
+ : behindServers.filter((server) => !waitForNpm.includes(server));
const skipped: ReadonlyArray<SkippedMachine> = [
...unreachable,
...behindServers
diff --git a/docs/operations/release.md b/docs/operations/release.md
index 89003a5e761..15fb3a4e964 100644
--- a/docs/operations/release.md
+++ b/docs/operations/release.md
@@ -431,7 +431,10 @@ release archives, and then its npm launcher, available before users can receive
The workflow enforces this ordering:
-1. `release` publishes the GitHub Release with the CLI archives and `SHA256SUMS`.
+1. `release` publishes the GitHub Release with the CLI archives and `SHA256SUMS`. Every channel
+ uploads to a draft and publishes only after all assets are attached, so a version in the
+ desktop update feed always has its archives. **Update everything** relies on this to update
+ background-service hosts before npm has the version.
2. `publish_cli` publishes the `t3@<version>` launcher, which downloads from that release, on every
channel.
3. `deploy_web` depends on both before moving the hosted channel to the new client.
diff --git a/docs/user/updating.md b/docs/user/updating.md
index 006c4985d43..afb0395d141 100644
--- a/docs/user/updating.md
+++ b/docs/user/updating.md
@@ -22,8 +22,9 @@ restart from the update button when you are ready. A server still restarting
finishes on its own, and the button keeps showing it after the desktop app
restarts.
-Server updates appear only after that version is published to npm. Remote
-desktop apps do not wait for npm. The confirmation lists each machine it skips
+Remote desktop apps never wait for npm. Background services do not wait either
+when the version comes from the desktop app's update. Other server updates
+appear only after that version is published to npm. The confirmation lists each machine it skips
and why, such as a machine that is offline or needs a manual update. Use
**Settings → Environments** for those.