From 6a53a91ff3aa8c74ff15bb6bb1f358ad59062f78 Mon Sep 17 00:00:00 2001 From: Ion Mudreac Date: Fri, 20 Feb 2026 18:09:27 +0800 Subject: [PATCH] fix(auth): align profile-id in config with writeOAuthCredentials writeOAuthCredentials writes profile as `provider:email` when email is present, but applyAuthProfileConfig was always called with `provider:default`. This caused config to reference a non-existent profile when OAuth returned an email. Compute the same profile-id (email or 'default' fallback) in both auth-choice.apply.oauth.ts (chutes) and auth-choice.apply.openai.ts (openai-codex) so config references the actually-written profile. Fixes failing tests: - stores openai-codex OAuth with email profile id - writes Chutes OAuth credentials when selecting chutes (remote/manual) --- src/commands/auth-choice.apply.oauth.ts | 4 +++- src/commands/auth-choice.apply.openai.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/commands/auth-choice.apply.oauth.ts b/src/commands/auth-choice.apply.oauth.ts index 5550fe0c8a4..c5170d45533 100644 --- a/src/commands/auth-choice.apply.oauth.ts +++ b/src/commands/auth-choice.apply.oauth.ts @@ -69,8 +69,10 @@ export async function applyAuthChoiceOAuth( spin.stop("Chutes OAuth complete"); await writeOAuthCredentials("chutes", creds, params.agentDir); + const chutesEmail = + typeof creds.email === "string" && creds.email.trim() ? creds.email.trim() : "default"; nextConfig = applyAuthProfileConfig(nextConfig, { - profileId: "chutes:default", + profileId: `chutes:${chutesEmail}`, provider: "chutes", mode: "oauth", }); diff --git a/src/commands/auth-choice.apply.openai.ts b/src/commands/auth-choice.apply.openai.ts index e1e1b244220..0f62c8ed14b 100644 --- a/src/commands/auth-choice.apply.openai.ts +++ b/src/commands/auth-choice.apply.openai.ts @@ -120,8 +120,10 @@ export async function applyAuthChoiceOpenAI( await writeOAuthCredentials("openai-codex", creds, params.agentDir, { syncSiblingAgents: true, }); + const codexEmail = + typeof creds.email === "string" && creds.email.trim() ? creds.email.trim() : "default"; nextConfig = applyAuthProfileConfig(nextConfig, { - profileId: "openai-codex:default", + profileId: `openai-codex:${codexEmail}`, provider: "openai-codex", mode: "oauth", });