Skip to content

Commit eeef8a3

Browse files
MikeeBuildsgemini-code-assist[bot]AndyMik90
authored
fix: check .claude.json for OAuth auth in profile scorer (AndyMik90#652)
* fix: check .claude.json for OAuth auth in profile scorer The isProfileAuthenticated() function only checked legacy credential files (credentials, credentials.json, .credentials, settings.json) when determining if a profile is eligible for auto-switch. Claude Code CLI (v1.0+) stores OAuth authentication in .claude.json with an oauthAccount field containing accountUuid and emailAddress. This meant profiles authenticated via OAuth were silently rejected by the profile scorer, causing auto-switch to fail even when 'Reactive Recovery' was enabled. This fix adds a check for .claude.json containing oauthAccount info before falling through to legacy credential file checks. Fixes incomplete resolution of AndyMik90#365 and AndyMik90#43 * fix: add type validation and error logging per review feedback - Add typeof check before accessing oauthAccount properties - Log parse errors with console.warn for debugging malformed .claude.json Co-authored-by: gemini-code-assist[bot] <176abortvfax+gemini-code-assist[bot]@Fusers.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176abortvfax+gemini-code-assist[bot]@Fusers.noreply.github.com> Co-authored-by: Andy <119136210+AndyMik90@users.noreply.github.com>
1 parent e1e8943 commit eeef8a3

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

apps/frontend/src/main/claude-profile/profile-utils.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,32 @@ export async function createProfileDirectory(profileName: string): Promise<strin
5656

5757
/**
5858
* Check if a profile has valid authentication
59-
* (checks if the config directory has credential files)
59+
* (checks if the config directory has credential files or OAuth account info)
6060
*/
6161
export function isProfileAuthenticated(profile: ClaudeProfile): boolean {
6262
const configDir = profile.configDir;
6363
if (!configDir || !existsSync(configDir)) {
6464
return false;
6565
}
6666

67-
// Claude stores auth in .claude/credentials or similar files
67+
// Check for .claude.json with OAuth account info (modern Claude Code CLI)
68+
// This is how Claude Code CLI stores OAuth authentication since v1.0
69+
const claudeJsonPath = join(configDir, '.claude.json');
70+
if (existsSync(claudeJsonPath)) {
71+
try {
72+
const content = readFileSync(claudeJsonPath, 'utf-8');
73+
const data = JSON.parse(content);
74+
// Check for oauthAccount which indicates successful OAuth authentication
75+
if (data && typeof data === 'object' && (data.oauthAccount?.accountUuid || data.oauthAccount?.emailAddress)) {
76+
return true;
77+
}
78+
} catch (error) {
79+
// Log parse errors for debugging, but fall through to legacy checks
80+
console.warn(`[profile-utils] Failed to read or parse ${claudeJsonPath}:`, error);
81+
}
82+
}
83+
84+
// Legacy: Claude stores auth in .claude/credentials or similar files
6885
// Check for common auth indicators
6986
const possibleAuthFiles = [
7087
join(configDir, 'credentials'),

0 commit comments

Comments
 (0)