The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): native helpers build byte-identical, so the prepared native input stays comparable
kshitijk4poor1d41d9f610c1
diff --git a/apps/desktop/scripts/build-command-screenshot-monitor.mjs b/apps/desktop/scripts/build-command-screenshot-monitor.mjsindex e584556717e..e6c45d36331 100644--- a/apps/desktop/scripts/build-command-screenshot-monitor.mjs+++ b/apps/desktop/scripts/build-command-screenshot-monitor.mjs@@ -2,7 +2,7 @@// Build-time only: the shipped app never needs clang or Xcode tools.import { execFileSync } from 'node:child_process'import { chmodSync, mkdirSync, renameSync, rmSync } from 'node:fs'-import { dirname, resolve } from 'node:path'+import { basename, dirname, join, resolve } from 'node:path'import { fileURLToPath } from 'node:url'import { macosSysroot, xcrunClangArgv } from './macos-sysroot.mjs'@@ -19,8 +19,12 @@ export function buildCommandScreenshotMonitor({} = {}) {if (platform !== 'darwin') return nullconst output = resolve(distDir, 'native/command-screenshot-monitor')- const staging = `${output}.${process.pid}.tmp`- mkdirSync(dirname(output), { recursive: true })+ // ld64 signs the Mach-O ad hoc with its output FILE NAME as the identifier, so a pid-suffixed+ // staging name made every build's bytes differ and the native-deps input never compared+ // equal. Stage under the final name inside a private directory instead.+ const stagingDir = `${output}.${process.pid}.tmp`+ const staging = join(stagingDir, basename(output))+ mkdirSync(stagingDir, { recursive: true })const sdk = sysroot === undefined ? macosSysroot() : sysroottry {execFileSync('xcrun', [@@ -36,7 +40,7 @@ export function buildCommandScreenshotMonitor({console.log(`built ${output} (arm64 + x86_64)`)return output} finally {- rmSync(staging, { force: true })+ rmSync(stagingDir, { recursive: true, force: true })}}diff --git a/apps/desktop/scripts/build-command-screenshot-monitor.test.mjs b/apps/desktop/scripts/build-command-screenshot-monitor.test.mjsindex b362dff575f..b663caa1161 100644--- a/apps/desktop/scripts/build-command-screenshot-monitor.test.mjs+++ b/apps/desktop/scripts/build-command-screenshot-monitor.test.mjs@@ -20,7 +20,7 @@ describe('buildCommandScreenshotMonitor argv', () => {it('uses the paired sysroot or delegates SDK selection to xcrun', () => {for (const sysroot of ['/Developer/SDKs/MacOSX.sdk', null]) {const distDir = fs.mkdtempSync(path.join(os.tmpdir(), 'csm-argv-'))- const staging = path.resolve(distDir, `native/command-screenshot-monitor.${process.pid}.tmp`)+ const staging = path.resolve(distDir, `native/command-screenshot-monitor.${process.pid}.tmp/command-screenshot-monitor`)fs.mkdirSync(path.dirname(staging), { recursive: true })fs.writeFileSync(staging, 'staged')diff --git a/apps/desktop/scripts/build-hud-modifier-monitor.mjs b/apps/desktop/scripts/build-hud-modifier-monitor.mjsindex f9e684268a1..db316ea2055 100644--- a/apps/desktop/scripts/build-hud-modifier-monitor.mjs+++ b/apps/desktop/scripts/build-hud-modifier-monitor.mjs@@ -2,7 +2,7 @@// 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, rmdirSync, rmSync } from 'node:fs'-import { dirname, resolve } from 'node:path'+import { basename, dirname, join, resolve } from 'node:path'import { fileURLToPath } from 'node:url'import { retryHeld } from '../../../scripts/build/frontend-common.mjs'import { macosSysroot, xcrunClangArgv } from './macos-sysroot.mjs'@@ -39,9 +39,12 @@ export function buildHudModifierMonitor({}if (!['darwin', 'linux', 'win32'].includes(platform)) return nullconst output = resolve(distDir, hudModifierBinaryRelativePath(platform, arch))- const staging = `${output}.${process.pid}.tmp${platform === 'win32' ? '.exe' : ''}`+ // The macOS linker signs ad hoc with the output file name as identifier: stage under the final+ // name in a private directory so rebuilding the same source yields the same bytes.+ const stagingDir = `${output}.${process.pid}.tmp`+ const staging = join(stagingDir, basename(output))const nativeSource = name => resolve(source, 'apps/desktop/electron/native', name)- mkdirSync(dirname(output), { recursive: true })+ mkdirSync(stagingDir, { recursive: true })try {if (platform === 'darwin') {execFileSync(@@ -97,6 +100,7 @@ export function buildHudModifierMonitor({return output} catch (error) {rmSync(output, { force: true }) // Never keep a stale helper after a failed rebuild.+ rmSync(stagingDir, { recursive: true, force: true }) // before the empty-ancestor sweep below// 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@@ -113,7 +117,7 @@ export function buildHudModifierMonitor({console.warn(String(error.stderr || error.message))return null} finally {- rmSync(staging, { force: true })+ rmSync(stagingDir, { recursive: true, force: true })}}