Skip to content

The agent that grows with you

fix(desktop): route App Installer sideloads to the app-installer updater

ethernet380d0c5a8d4b
diff --git a/apps/desktop/electron/install-stamp.ts b/apps/desktop/electron/install-stamp.ts
index 40d5df7f123..5745c46fc18 100644
--- a/apps/desktop/electron/install-stamp.ts
+++ b/apps/desktop/electron/install-stamp.ts
@@ -38,6 +38,8 @@ export interface InstallStamp {
displayVersion: string | null
distance: number | null
payload: ArtifactKind
+ /** True for the Store-submission build (HERMES_DESKTOP_VARIANT=store). */
+ store?: boolean
/** The pinned release tag. Always set for 'bundled' and 'light', never for 'bootstrap'. */
tag: string | null
}
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 7117a496144..e70e82bf4f8 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -724,9 +724,11 @@ function loadInstallStamp() {
path: p,
// Bundled/light artifacts carry these; mirror them so the union
// with the baked stamp stays typed (tag/payload drive the App
- // Installer channel + variant).
+ // Installer channel + variant; store separates Microsoft Store
+ // deployments from App Installer sideloads).
tag: typeof parsed.tag === 'string' ? parsed.tag : null,
- payload: parsed.payload === 'light' || parsed.payload === 'bundled' ? parsed.payload : 'bootstrap'
+ payload: parsed.payload === 'light' || parsed.payload === 'bundled' ? parsed.payload : 'bootstrap',
+ store: typeof parsed.store === 'boolean' ? parsed.store : undefined
})
}
} catch (e) {
@@ -3168,6 +3170,16 @@ function resolveBundledUpdateStrategy(bundledPayload) {
/** True when this process is a Microsoft Store deployment. */
function isWindowsStore(): boolean {
+ // process.windowsStore is true for ANY MSIX package — App Installer
+ // sideloads included — not just Microsoft Store deployments (electron.d.ts:
+ // "If the app is running as an MSIX package ... this property is true").
+ // The store-vs-sideload distinction is a BUILD-TIME fact baked into the
+ // stamp (HERMES_DESKTOP_VARIANT=store vs bundled); trust it when present
+ // and fall back to the Electron flag only for dev runs / legacy stamps.
+ if (INSTALL_STAMP && typeof INSTALL_STAMP.store === 'boolean') {
+ return INSTALL_STAMP.store
+ }
+
return Boolean((process as any).windowsStore)
}
diff --git a/apps/desktop/scripts/write-build-stamp.mjs b/apps/desktop/scripts/write-build-stamp.mjs
index 076d5a893e2..ecd7db35bfa 100644
--- a/apps/desktop/scripts/write-build-stamp.mjs
+++ b/apps/desktop/scripts/write-build-stamp.mjs
@@ -6,12 +6,18 @@
*
* Schema (subject to bump via STAMP_SCHEMA_VERSION):
* {
- * "schemaVersion": 1,
- * "commit": "<40-char SHA>",
- * "branch": "<branch name>",
- * "builtAt": "<ISO 8601 UTC timestamp>",
- * "dirty": true|false,
- * "source": "ci" | "local" | "fallback"
+ * "schemaVersion": 1,
+ * "commit": "<40-char SHA>",
+ * "branch": "<branch name>",
+ * "builtAt": "<ISO 8601 UTC timestamp>",
+ * "dirty": true|false,
+ * "source": "ci" | "local" | "fallback",
+ * // Staged desktop builds only (HERMES_DESKTOP_VARIANT set):
+ * "payload": "bundled" | "light" | "bootstrap",
+ * "store": true|false,
+ * "distribution": "desktop-app",
+ * "updateMechanism": "external",
+ * "tag": "<release tag>"
* }
*
* Source preference order:
@@ -149,17 +155,8 @@ function main() {
)
}
- const payload = {
- schemaVersion: STAMP_SCHEMA_VERSION,
- commit: stamp.commit,
- branch: stamp.branch,
- builtAt: new Date().toISOString(),
- dirty: stamp.dirty,
- source: stamp.source
- }
-
mkdirSync(OUT_DIR, { recursive: true })
- writeFileSync(OUT_FILE, JSON.stringify(payload, null, 2) + "\n", "utf8")
+ writeFileSync(OUT_FILE, JSON.stringify(buildStampPayload(stamp, process.env), null, 2) + "\n", "utf8")
console.log(
"[write-build-stamp] wrote " +
relative(REPO_ROOT, OUT_FILE) +
@@ -171,6 +168,47 @@ function main() {
)
}
+/**
+ * Build the install-stamp.json payload. The legacy 5-field shape (schemaVersion
+ * 1: commit/branch/builtAt/dirty/source) is always present; when the desktop
+ * build is staged (HERMES_DESKTOP_VARIANT set), the full-schema fields the
+ * updater mechanism resolution reads are added: payload, distribution,
+ * updateMechanism, tag, and the store-submission flag. The variant is a
+ * BUILD-TIME fact — process.windowsStore cannot tell a Microsoft Store
+ * deployment from an App Installer sideload (Electron sets it true for any
+ * MSIX package), so the resolver must read it from the baked stamp.
+ *
+ * Mirrors scripts/write_install_stamp.py::build_stamp's variant handling:
+ * store -> payload 'bundled' (steward-owned, no in-app updater)
+ * bundled -> payload 'bundled'
+ * light -> payload 'light'
+ * '' / bootstrap -> payload 'bootstrap'
+ * Dev/local builds (no variant) keep the old shape; installShape() then treats
+ * them as checkout, which is correct for a dev run.
+ */
+export function buildStampPayload(stamp, env = process.env) {
+ const variant = (env.HERMES_DESKTOP_VARIANT || "").trim()
+ const base = {
+ schemaVersion: STAMP_SCHEMA_VERSION,
+ commit: stamp.commit,
+ branch: stamp.branch,
+ builtAt: new Date().toISOString(),
+ dirty: stamp.dirty,
+ source: stamp.source
+ }
+ if (!variant) return base
+
+ return {
+ ...base,
+ payload: variant === "store" ? "bundled" : variant || "bootstrap",
+ store: variant === "store",
+ distribution: "desktop-app",
+ updateMechanism: "external", // sealed artifact — the OS/steward owns updates
+ tag: env.HERMES_PAYLOAD_TAG || null
+ }
+}
+
if (isMain(import.meta.url)) {
main()
}
+
diff --git a/apps/desktop/scripts/write-build-stamp.test.mjs b/apps/desktop/scripts/write-build-stamp.test.mjs
index 53c88e23704..f24dffd8a61 100644
--- a/apps/desktop/scripts/write-build-stamp.test.mjs
+++ b/apps/desktop/scripts/write-build-stamp.test.mjs
@@ -84,3 +84,72 @@ test('resolveStamp falls back when neither CI nor git is available', () => {
source: 'fallback'
})
})
+
+// ── buildStampPayload — the staged-desktop full schema ─────────────────────
+
+import { buildStampPayload } from './write-build-stamp.mjs'
+
+const baseStamp = {
+ commit: 'c'.repeat(40),
+ branch: 'main',
+ builtAt: '2026-08-14T00:00:00Z',
+ dirty: false,
+ source: 'ci'
+}
+
+test('buildStampPayload without a variant keeps the legacy 5-field shape', () => {
+ const payload = buildStampPayload(baseStamp, {})
+ assert.deepEqual(payload, {
+ schemaVersion: 1,
+ commit: baseStamp.commit,
+ branch: 'main',
+ builtAt: payload.builtAt, // stamped at write time, not the fixture's
+ dirty: false,
+ source: 'ci'
+ })
+ assert.equal(typeof payload.builtAt, 'string')
+ assert.ok(!('payload' in payload))
+ assert.ok(!('store' in payload))
+ assert.ok(!('tag' in payload))
+})
+
+test('buildStampPayload with bundled variant stamps payload bundled, store false', () => {
+ const payload = buildStampPayload(baseStamp, {
+ HERMES_DESKTOP_VARIANT: 'bundled',
+ HERMES_PAYLOAD_TAG: 'v0.27.1-nightly.20260901072553'
+ })
+ assert.equal(payload.payload, 'bundled')
+ assert.equal(payload.store, false)
+ assert.equal(payload.distribution, 'desktop-app')
+ assert.equal(payload.updateMechanism, 'external')
+ assert.equal(payload.tag, 'v0.27.1-nightly.20260901072553')
+})
+
+test('buildStampPayload with store variant stamps payload bundled, store true', () => {
+ const payload = buildStampPayload(baseStamp, {
+ HERMES_DESKTOP_VARIANT: 'store',
+ HERMES_PAYLOAD_TAG: 'v0.27.1'
+ })
+ assert.equal(payload.payload, 'bundled')
+ assert.equal(payload.store, true)
+})
+
+test('buildStampPayload with light variant stamps payload light', () => {
+ const payload = buildStampPayload(baseStamp, {
+ HERMES_DESKTOP_VARIANT: 'light',
+ HERMES_PAYLOAD_TAG: 'v0.27.1'
+ })
+ assert.equal(payload.payload, 'light')
+ assert.equal(payload.store, false)
+})
+
+test('buildStampPayload keeps schemaVersion + provenance in the staged shape', () => {
+ const payload = buildStampPayload(baseStamp, {
+ HERMES_DESKTOP_VARIANT: 'bundled'
+ })
+ assert.equal(payload.schemaVersion, 1)
+ assert.equal(payload.commit, baseStamp.commit)
+ assert.equal(payload.source, 'ci')
+ assert.equal(payload.tag, null)
+})
+