diff --git a/apps/frontend/src/main/ipc-handlers/github/oauth-handlers.ts b/apps/frontend/src/main/ipc-handlers/github/oauth-handlers.ts index 5f34cf34..dfe3a1a8 100644 --- a/apps/frontend/src/main/ipc-handlers/github/oauth-handlers.ts +++ b/apps/frontend/src/main/ipc-handlers/github/oauth-handlers.ts @@ -242,7 +242,8 @@ export function registerStartGhAuth(): void { debugLog('Spawning: gh', args); const ghProcess = spawn('gh', args, { - stdio: ['pipe', 'pipe', 'pipe'] + stdio: ['pipe', 'pipe', 'pipe'], + env: getAugmentedEnv() }); let output = ''; @@ -399,7 +400,8 @@ export function registerGetGhToken(): void { debugLog('Running: gh auth token'); const token = execSync('gh auth token', { encoding: 'utf-8', - stdio: 'pipe' + stdio: 'pipe', + env: getAugmentedEnv() }).trim(); if (!token) { @@ -438,7 +440,8 @@ export function registerGetGhUser(): void { debugLog('Running: gh api user'); const userJson = execSync('gh api user', { encoding: 'utf-8', - stdio: 'pipe' + stdio: 'pipe', + env: getAugmentedEnv() }); debugLog('User API response received'); @@ -479,7 +482,8 @@ export function registerListUserRepos(): void { 'gh repo list --limit 100 --json nameWithOwner,description,isPrivate', { encoding: 'utf-8', - stdio: 'pipe' + stdio: 'pipe', + env: getAugmentedEnv() } ); @@ -585,7 +589,8 @@ export function registerGetGitHubBranches(): void { ['api', apiEndpoint, '--paginate', '--jq', '.[].name'], { encoding: 'utf-8', - stdio: 'pipe' + stdio: 'pipe', + env: getAugmentedEnv() } ); @@ -632,7 +637,8 @@ export function registerCreateGitHubRepo(): void { // Get the authenticated username const username = execSync('gh api user --jq .login', { encoding: 'utf-8', - stdio: 'pipe' + stdio: 'pipe', + env: getAugmentedEnv() }).trim(); // Determine the owner (personal account or organization) @@ -662,7 +668,8 @@ export function registerCreateGitHubRepo(): void { const output = execFileSync('gh', args, { encoding: 'utf-8', cwd: options.projectPath, - stdio: 'pipe' + stdio: 'pipe', + env: getAugmentedEnv() }); debugLog('gh repo create output:', output); @@ -768,7 +775,8 @@ export function registerListGitHubOrgs(): void { // Get user's organizations const output = execSync('gh api user/orgs --jq \'.[] | {login: .login, avatarUrl: .avatar_url}\'', { encoding: 'utf-8', - stdio: 'pipe' + stdio: 'pipe', + env: getAugmentedEnv() }); // Parse the JSON lines output diff --git a/apps/frontend/src/main/ipc-handlers/github/pr-handlers.ts b/apps/frontend/src/main/ipc-handlers/github/pr-handlers.ts index 835fb2e4..7a0b06f3 100644 --- a/apps/frontend/src/main/ipc-handlers/github/pr-handlers.ts +++ b/apps/frontend/src/main/ipc-handlers/github/pr-handlers.ts @@ -15,6 +15,7 @@ import fs from 'fs'; import { IPC_CHANNELS, MODEL_ID_MAP, DEFAULT_FEATURE_MODELS, DEFAULT_FEATURE_THINKING } from '../../../shared/constants'; import { getGitHubConfig, githubFetch } from './utils'; import { readSettingsFile } from '../../settings-utils'; +import { getAugmentedEnv } from '../../env-utils'; import type { Project, AppSettings } from '../../../shared/types'; import { createContextLogger } from './utils/logger'; import { withProjectOrNull } from './utils/project-middleware'; @@ -477,6 +478,7 @@ export function registerPRHandlers( const diff = execFileSync('gh', ['pr', 'diff', String(prNumber)], { cwd: project.path, encoding: 'utf-8', + env: getAugmentedEnv(), }); return diff; } catch { @@ -748,6 +750,7 @@ export function registerPRHandlers( // Use execFileSync with arguments array to prevent command injection execFileSync('gh', ['pr', 'comment', String(prNumber), '--body-file', tmpFile], { cwd: project.path, + env: getAugmentedEnv(), }); unlinkSync(tmpFile); } catch (error) { @@ -848,6 +851,7 @@ export function registerPRHandlers( // Use execFileSync with arguments array to prevent command injection execFileSync('gh', ['pr', 'merge', String(prNumber), `--${mergeMethod}`], { cwd: project.path, + env: getAugmentedEnv(), }); debugLog('PR merged successfully', { prNumber }); return true; diff --git a/apps/frontend/src/main/ipc-handlers/github/triage-handlers.ts b/apps/frontend/src/main/ipc-handlers/github/triage-handlers.ts index 8714fb35..7e0f960b 100644 --- a/apps/frontend/src/main/ipc-handlers/github/triage-handlers.ts +++ b/apps/frontend/src/main/ipc-handlers/github/triage-handlers.ts @@ -14,6 +14,7 @@ import fs from 'fs'; import { IPC_CHANNELS, MODEL_ID_MAP, DEFAULT_FEATURE_MODELS, DEFAULT_FEATURE_THINKING } from '../../../shared/constants'; import { getGitHubConfig } from './utils'; import { readSettingsFile } from '../../settings-utils'; +import { getAugmentedEnv } from '../../env-utils'; import type { Project, AppSettings } from '../../../shared/types'; import { createContextLogger } from './utils/logger'; import { withProjectOrNull } from './utils/project-middleware'; @@ -435,6 +436,7 @@ export function registerTriageHandlers( // Use execFileSync with arguments array to prevent command injection execFileSync('gh', ['issue', 'edit', String(issueNumber), '--add-label', safeLabels.join(',')], { cwd: project.path, + env: getAugmentedEnv(), }); } }