The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): delete main.ts runGit now that the skew probe uses execGit
kshitijk4poor3a21c2a75a87
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 6460d6613e9..d4077c3a4a1 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -368,7 +368,7 @@ import {} from './native-oauth'import { runNativeLogin } from './native-oauth-login'import { loadNativeTokenSet, type NativeTokenStoreIo, persistNativeTokenSet } from './native-token-store'-import { execGit, planNoConsoleGitSpawn, setNoConsoleGitRoots, windowsGitHost } from './no-console-git'+import { execGit, setNoConsoleGitRoots } from './no-console-git'import { registerNativeNotifications } from './notification-ipc'import { isExpectedOauthNavigationAbort } from './oauth-navigation'import { serializeJsonBody, setJsonRequestHeaders } from './oauth-net-request'@@ -496,7 +496,7 @@ import {writeSecretStoragePolicy} from './secret-storage-policy'import { selectPathsDialogProperties } from './select-paths-dialog'-import { describeGitSpawnFailure, GIT_UNUSABLE, selectRunnableBinary } from './select-runnable-binary'+import { selectRunnableBinary } from './select-runnable-binary'import {buildInstanceWindowUrl,buildSessionWindowUrl,@@ -3307,57 +3307,6 @@ function resolveUpdateRoot() {return candidates.find(isGitCheckout) || candidates[0] || ACTIVE_HERMES_ROOT}-function runGit(args, options: any = {}): Promise<{ code: number; stdout: string; stderr: string }> {- return new Promise((resolve, reject) => {- const gitBinary = resolveGitBinary()- const gitArgs = IS_WINDOWS ? ['-c', 'windows.appendAtomically=false', ...args] : args- const host = IS_WINDOWS ? windowsGitHost(true) : null-- const plan = planNoConsoleGitSpawn({- gitBin: gitBinary,- args: gitArgs,- isWindows: IS_WINDOWS,- pythonBin: host?.pythonBin ?? null,- scriptPath: host?.scriptPath ?? null,- env: { ...process.env, ...((options.env || {}) as any), GIT_TERMINAL_PROMPT: '0' }- })-- const child = spawn(- plan.command,- plan.args,- hiddenWindowsChildOptions({- cwd: options.cwd,- env: plan.env,- stdio: plan.stdio- })- )-- let stdout = ''- let stderr = ''- child.stdout.on('data', chunk => {- const text = chunk.toString()- stdout += text- options.onLine?.('stdout', text)- })- child.stderr.on('data', chunk => {- const text = chunk.toString()- stderr += text- options.onLine?.('stderr', text)- })- // A spawn-level failure means git itself never ran (missing, not- // executable, wrong CPU architecture) — a local problem, not a network one.- child.once('error', error => {- const local = describeGitSpawnFailure(error, gitBinary)-- reject(local ? Object.assign(new Error(local), { kind: GIT_UNUSABLE, cause: error }) : error)- })- // 'close', not 'exit': exit can fire before the stdio pipes drain, and a- // resolved-early `remote get-url` came back as "" often enough to route- // passive checks down the wrong remote path.- child.once('close', (code: number): void => resolve({ code, stdout, stderr }))- })-}-function emitUpdateProgress(payload) {const merged = { stage: 'idle', message: '', percent: null, error: null, ...payload, at: Date.now() }rememberLog(`[updates] ${merged.stage}: ${merged.message || merged.error || ''}`)@@ -18222,10 +18171,10 @@ const disposeTerminalSession = terminalIpc.disposeTerminalSessionipcMain.handle('hermes:updates:check',async (_event: Electron.IpcMainInvokeEvent, opts?: { force?: boolean }): Promise<UpdaterStatusWire> =>- checkUpdates({ force: Boolean(opts?.force) }).catch((error: Error & { kind?: string }): UpdaterStatusWire => ({+ checkUpdates({ force: Boolean(opts?.force) }).catch((error: Error): UpdaterStatusWire => ({supported: true,branch: readDesktopUpdateConfig().branch,- error: error?.kind === GIT_UNUSABLE ? GIT_UNUSABLE : 'check-failed',+ error: 'check-failed',message: error?.message || String(error),fetchedAt: Date.now()}))diff --git a/apps/desktop/electron/select-runnable-binary.test.ts b/apps/desktop/electron/select-runnable-binary.test.tsindex 14f27439fb7..6552cd03d9c 100644--- a/apps/desktop/electron/select-runnable-binary.test.ts+++ b/apps/desktop/electron/select-runnable-binary.test.ts@@ -2,7 +2,7 @@ import assert from 'node:assert/strict'import { test } from 'vitest'-import { describeGitSpawnFailure, selectRunnableBinary } from './select-runnable-binary'+import { selectRunnableBinary } from './select-runnable-binary'const yes = () => trueconst no = () => false@@ -56,27 +56,3 @@ test('missing candidates are never probed, and nothing existing yields null forassert.equal(selectRunnableBinary({ candidates: ['/opt/homebrew/bin/gh'], fileExists: no, binaryRuns: no }), null)assert.equal(selectRunnableBinary({ candidates: [], fileExists: yes, binaryRuns: yes }), null)})--test.each([- {- // The reported machine: Darwin errno 86 (Bad CPU type) reaches Node as a- // bare `errno: -86` with no `code` — "spawn Unknown system error -86".- name: 'EBADARCH via errno -86 names the binary and the CPU-type cause',- error: { errno: -86, syscall: 'spawn', message: 'spawn Unknown system error -86' },- expected: /\/usr\/local\/bin\/git.*Bad CPU type/- },- {- name: 'ENOENT reads as a missing binary',- error: { code: 'ENOENT', errno: -2, syscall: 'spawn /usr/local/bin/git' },- expected: /\/usr\/local\/bin\/git: not found/- }-])('$name', ({ error, expected }) => {- assert.match(describeGitSpawnFailure(error, '/usr/local/bin/git') ?? '', expected)-})--test('a git that ran and exited nonzero is not a spawn failure and keeps its own wording', () => {- // Nonzero exits never fire the child 'error' event; only spawn-level- // failures (binary missing / not executable / wrong architecture) do.- assert.equal(describeGitSpawnFailure(new Error('fatal: not a git repository'), '/usr/bin/git'), null)- assert.equal(describeGitSpawnFailure({ code: 'ETIMEDOUT' }, '/usr/bin/git'), null)-})diff --git a/apps/desktop/electron/select-runnable-binary.ts b/apps/desktop/electron/select-runnable-binary.tsindex beafb96a004..ba526d3d9f8 100644--- a/apps/desktop/electron/select-runnable-binary.ts+++ b/apps/desktop/electron/select-runnable-binary.ts@@ -32,39 +32,3 @@ export function selectRunnableBinary(opts: RunnableBinaryOptions): string | nullreturn existing.find(opts.binaryRuns) || existing[0] || null}--/** Marker on the error runGit rejects with when the git binary itself could not be spawned. */-export const GIT_UNUSABLE = 'git-unusable'--const SPAWN_FAILURE_REASONS: Record<string, string> = {- ENOENT: 'not found',- EACCES: 'permission denied',- EBADARCH: 'Bad CPU type in executable'-}--/**- * Turn a child-process 'error' (the binary never ran, as opposed to running- * and exiting nonzero) into an actionable local-executable message.- *- * Without this the caller shows the update-server/network copy plus the raw- * `spawn Unknown system error -86` — a network claim for a local Intel-only- * git that macOS refuses to launch (EBADARCH is errno 86 on Darwin, surfaced by- * Node as errno -86 with no `code`). The message names the binary that failed- * so the user can replace it; nothing in this path is a network problem.- *- * Returns null for anything that is not a spawn-level failure so those keep- * their existing wording.- */-export function describeGitSpawnFailure(error: any, binaryPath: string): string | null {- const code = error?.code || (error?.errno === -86 ? 'EBADARCH' : '')- const reason = SPAWN_FAILURE_REASONS[code]-- if (!reason) {- return null- }-- return (- `Git on this computer cannot run (${binaryPath}: ${reason}). ` +- 'Install a Git build for this machine (on macOS: `xcode-select --install`) and check again.'- )-}