Skip to content

The agent that grows with you

fix(desktop): preserve freshness without X11 headers

ethernetf56bdde75767
diff --git a/apps/desktop/scripts/build-hud-modifier-monitor.mjs b/apps/desktop/scripts/build-hud-modifier-monitor.mjs
index 9ce2e061652..054f3095e6c 100644
--- a/apps/desktop/scripts/build-hud-modifier-monitor.mjs
+++ b/apps/desktop/scripts/build-hud-modifier-monitor.mjs
@@ -1,7 +1,7 @@
#!/usr/bin/env node
// Host-built helper. Windows uses its in-box .NET Framework compiler; no SDK download.
import { execFileSync } from 'node:child_process'
-import { chmodSync, existsSync, mkdirSync, renameSync, rmSync } from 'node:fs'
+import { chmodSync, existsSync, mkdirSync, renameSync, rmdirSync, rmSync } from 'node:fs'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
@@ -95,6 +95,17 @@ export function buildHudModifierMonitor({
return output
} catch (error) {
rmSync(output, { force: true }) // Never keep a stale helper after a failed rebuild.
+ // Packaged ASAR output omits empty directories. Leaving native/linux-* behind
+ // makes the packaged renderer differ from its compiler receipt, so source
+ // installs report a healthy desktop bundle as stale when X11 headers are
+ // unavailable. Remove only empty ancestors; stop at the product root.
+ for (let directory = dirname(output); directory !== resolve(distDir); directory = dirname(directory)) {
+ try {
+ rmdirSync(directory)
+ } catch {
+ break
+ }
+ }
if (platform !== 'linux') throw error
console.warn('[hud-modifier] unavailable: native build needs a C compiler, libx11-dev and libxi-dev; desktop packaging continues')
console.warn(String(error.stderr || error.message))
diff --git a/apps/desktop/scripts/stage-native-deps.test.mjs b/apps/desktop/scripts/stage-native-deps.test.mjs
index 0c473f27539..019ee1521e3 100644
--- a/apps/desktop/scripts/stage-native-deps.test.mjs
+++ b/apps/desktop/scripts/stage-native-deps.test.mjs
@@ -5,6 +5,7 @@ import path from 'node:path'
import { pathToFileURL } from 'node:url'
import { test } from 'vitest'
+import { buildHudModifierMonitor } from '../scripts/build-hud-modifier-monitor.mjs'
import {
findHalfInstalledGetWindowsDir,
installGetWindowsNativeBinding,
@@ -61,6 +62,24 @@ function makeFakeUnixTerminal(srcRoot) {
)
}
+// ─── optional native helper tests ───────────────────────────────────
+
+test('a missing Linux HUD toolchain leaves no empty package directories', () => {
+ const tmp = fs.mkdtempSync(join(os.tmpdir(), 'hermes-hud-'))
+ const warnings = []
+ const originalWarn = console.warn
+ console.warn = message => warnings.push(String(message))
+ try {
+ const distDir = join(tmp, 'dist')
+ assert.equal(buildHudModifierMonitor({ source: join(tmp, 'missing-source'), distDir, platform: 'linux', arch: 'x64' }), null)
+ assert.equal(existsSync(join(distDir, 'native')), false)
+ assert.match(warnings.join('\n'), /desktop packaging continues/)
+ } finally {
+ console.warn = originalWarn
+ fs.rmSync(tmp, { recursive: true, force: true })
+ }
+})
+
// ─── classifyNativeBinary tests ─────────────────────────────────────
test('classifyNativeBinary detects ELF as linux', () => {