Shared Task: Есть такое issue [ENHANCEMENT] OpenAI (ChatGPT Plus/Pro OAuth): support multiple accounts / account switching #11094
Problem (one or two sentences)
When using the OpenAI provider via "Sign in with ChatGPT" (Plus/Pro OAuth, no API key), Roo Code effectively supports only a single logged-in account. Switching between personal/work accounts requires manual logout/clearing sessions outside the extension, which is slow and error-prone.
Context (who is affected and when)
Affects users who have multiple OpenAI/ChatGPT accounts (e.g., personal + work / different orgs) and need to switch between them during normal development. This comes up whenever you need different billing, org/workspace access, or you test behavior across accounts.
Desired behavior (conceptual, not technical)
Allow using multiple OpenAI/ChatGPT accounts in Roo Code and switching between them without manual browser/session cleanup.
Two acceptable options:
Support multiple saved accounts for the OpenAI (ChatGPT OAuth) provider and let the user quickly switch the active account.
OR
Allow creating multiple OpenAI provider configurations (profiles) where each configuration can be authorized with a different OpenAI account, so different projects/workspaces can use different accounts.
На который ответили так
I've analyzed this issue and here's my proposed implementation plan:
Approach: Profile-Scoped OAuth Credentials
The current implementation uses a singleton OpenAiCodexOAuthManager with a single storage key for OAuth credentials. All OpenAI Codex profiles share the same OAuth session, making it impossible to use multiple accounts.
Proposed Solution
Associate OAuth credentials with individual provider profiles, allowing each "OpenAI - ChatGPT Plus/Pro" profile to be authorized with a different OpenAI account:
Changes Required
1. Modify OAuth credential storage (src/integrations/openai-codex/oauth.ts):
Change from a single global key (openai-codex-oauth-credentials) to profile-scoped keys (e.g., openai-codex-oauth-credentials-{profileId})
Update OpenAiCodexOAuthManager to accept a profile ID parameter for credential operations
Add methods to manage credentials for specific profiles
2. Update API handler (src/api/providers/openai-codex.ts):
Pass the active profile ID to the OAuth manager when getting/refreshing tokens
Ensure each profile uses its own OAuth session
3. Update webview message handler (src/core/webview/webviewMessageHandler.ts):
Include profile context when handling sign-in/sign-out messages
Ensure sign-out only clears credentials for the current profile
4. Update UI components (webview-ui/src/components/settings/providers/OpenAICodex.tsx):
Show which account is linked to the current profile (display email from credentials)
Allow re-authenticating a profile with a different account
User Workflow
User creates a new provider profile and selects "OpenAI - ChatGPT Plus/Pro"
User clicks "Sign in with ChatGPT" - this authorizes THAT specific profile
User can create additional profiles and sign in with different ChatGPT accounts
Switching profiles automatically uses the correct OAuth credentials
Each profile shows its linked account email for clarity
Benefits
Leverages existing profile infrastructure
Each project/mode can have a different ChatGPT account
Clear UX showing which account is linked to which profile
No need for a separate "account switcher" UI
Давай реализуем то что предложили. Что для этого нужно?