From c5a0f042daace12993d59189127f3fc85e3f481e Mon Sep 17 00:00:00 2001 From: JoshuaRileyDev <59296334+JoshuaRileyDev@users.noreply.github.com> Date: Fri, 23 Jan 2026 17:43:53 +0000 Subject: [PATCH] fix: use API profile environment variables for task title generation (#1471) Task title generation was failing when an API profile was active because it only used Claude OAuth profile environment variables (CLAUDE_CODE_OAUTH_TOKEN), not the API profile vars (ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, etc.). This fixes it by: 1. Adding getAPIProfileEnv() to fetch API profile env vars 2. Adding getOAuthModeClearVars() to clear stale ANTHROPIC_* vars when in OAuth mode 3. Including all three env sources in the spawn() call This matches the pattern used in agent-queue.ts for spawning agent processes. Fixes error: "Your account does not have access to Claude Code. Please run /login." when using API profiles. Signed-off-by: Joshua Riley Co-authored-by: Claude --- apps/frontend/src/main/title-generator.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/frontend/src/main/title-generator.ts b/apps/frontend/src/main/title-generator.ts index ae809ba3..5b27cbab 100644 --- a/apps/frontend/src/main/title-generator.ts +++ b/apps/frontend/src/main/title-generator.ts @@ -11,6 +11,8 @@ import { EventEmitter } from 'events'; import { detectRateLimit, createSDKRateLimitInfo, getProfileEnv } from './rate-limit-detector'; import { parsePythonCommand, getValidatedPythonPath } from './python-detector'; import { getConfiguredPythonPath } from './python-env-manager'; +import { getAPIProfileEnv } from './services/profile'; +import { getOAuthModeClearVars } from './agent/env-utils'; /** * Debug logging - only logs when DEBUG=true or in development mode @@ -142,8 +144,15 @@ export class TitleGenerator extends EventEmitter { hasOAuthToken: !!autoBuildEnv.CLAUDE_CODE_OAUTH_TOKEN }); - // Get active Claude profile environment (CLAUDE_CONFIG_DIR if not default) - const profileEnv = getProfileEnv(); + // Get active API profile environment variables (ANTHROPIC_* vars) + const apiProfileEnv = await getAPIProfileEnv(); + const isApiProfileActive = Object.keys(apiProfileEnv).length > 0; + + // Only get OAuth profile env if no API profile is active to avoid conflicts + const profileEnv = isApiProfileActive ? {} : getProfileEnv(); + + // Get OAuth mode clearing vars (clears stale ANTHROPIC_* vars when in OAuth mode) + const oauthModeClearVars = getOAuthModeClearVars(apiProfileEnv); return new Promise((resolve) => { // Parse Python command to handle space-separated commands like "py -3" @@ -153,7 +162,9 @@ export class TitleGenerator extends EventEmitter { env: { ...process.env, ...autoBuildEnv, - ...profileEnv, // Include active Claude profile config + ...profileEnv, // Claude OAuth profile (only when no API profile active) + ...apiProfileEnv, // API profile (ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, etc.) + ...oauthModeClearVars, // Clear stale ANTHROPIC_* vars when in OAuth mode PYTHONUNBUFFERED: '1', PYTHONIOENCODING: 'utf-8', PYTHONUTF8: '1'