From ee86b962c7dd55b40dd39c48438e487dc2200e12 Mon Sep 17 00:00:00 2001 From: pallyoung Date: Thu, 27 Aug 2026 13:08:41 +0800 Subject: [PATCH] fix(release): identify active desktop runtime --- .../verify-desktop-installed-update.test.ts | 6 +++++ scripts/verify-desktop-installed-update.ts | 27 ++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/scripts/verify-desktop-installed-update.test.ts b/scripts/verify-desktop-installed-update.test.ts index c59f16de..cd64a4c5 100644 --- a/scripts/verify-desktop-installed-update.test.ts +++ b/scripts/verify-desktop-installed-update.test.ts @@ -5,6 +5,7 @@ import { describe, expect, it, vi } from "vitest"; import { buildSidecarCommandPageScript, type InstalledDesktopScenario, + resolveActualRuntimeVersion, toSidecarWebSocketUrl, type VerifyInstalledDesktopDeps, verifyInstalledDesktopScenario, @@ -73,6 +74,11 @@ function createDeps( } describe("verify-desktop-installed-update", () => { + it("uses the coordinator Runtime when active.json retains an older rollback candidate", () => { + expect(resolveActualRuntimeVersion("0.5.13", "0.5.8", null, "0.5.13")).toBe("0.5.13"); + expect(resolveActualRuntimeVersion(null, "0.5.8", null, "0.5.7")).toBe("0.5.8"); + }); + it("preserves installed logs beside the report before deleting acceptance-owned paths", async () => { const runner = await readFile( resolve(import.meta.dirname, "verify-desktop-installed-update.ps1"), diff --git a/scripts/verify-desktop-installed-update.ts b/scripts/verify-desktop-installed-update.ts index 80b669b0..50716eb8 100644 --- a/scripts/verify-desktop-installed-update.ts +++ b/scripts/verify-desktop-installed-update.ts @@ -107,6 +107,15 @@ export interface InstalledDesktopScenarioReport extends InstalledEvidence { logPaths: string[]; } +export function resolveActualRuntimeVersion( + coordinatorVersion: string | null | undefined, + activePointerVersion: string | null, + externalVersion: string | null | undefined, + factoryVersion: string | null +): string { + return coordinatorVersion || activePointerVersion || externalVersion || factoryVersion || ""; +} + interface SidecarCommandPayload { wsUrl: string; operation: string; @@ -431,7 +440,9 @@ export async function verifyInstalledDesktopScenario( evidence.actualShellVersion !== scenario.targetShellVersion || evidence.actualRuntimeVersion !== expectedRuntime ) { - throw new Error("Installed component versions do not match the accepted candidate"); + throw new Error( + `Installed component versions do not match the accepted candidate: shell ${evidence.actualShellVersion} (expected ${scenario.targetShellVersion}); Runtime ${evidence.actualRuntimeVersion} (expected ${expectedRuntime})` + ); } if (isWslScenario(scenario.name)) { if (evidence.wslRuntimeVersion !== scenario.targetRuntimeVersion) { @@ -796,11 +807,15 @@ async function createDefaultDeps(options: InstalledDriverOptions): Promise<{ const observedWslRuntimeVersion = await readWslActiveRuntimeVersion(options.wslDistro); const external = await readEvidenceFile(options.evidencePath); const observedWslMarker = await wslMarkerExists(options.wslDistro, options.wslMarkerPath); - const actualRuntimeVersion = - observedRuntimeVersion ?? - external.actualRuntimeVersion ?? - observedFactoryRuntimeVersion ?? - state.productVersion; + // active.json can intentionally retain the previous Runtime as a rollback + // candidate when a newer Factory Runtime is running. The coordinator state + // reflects the Runtime selected for the current process. + const actualRuntimeVersion = resolveActualRuntimeVersion( + state.productVersion, + observedRuntimeVersion, + external.actualRuntimeVersion, + observedFactoryRuntimeVersion + ); if ( isWslScenario(options.scenario.name) && typeof external.wslNpmMarkerExists !== "boolean" &&