Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #11094
Description
This PR implements profile-scoped OAuth credentials for the OpenAI Codex (ChatGPT Plus/Pro) provider. Previously, Roo Code used a single global session for all OpenAI Codex profiles, making it impossible to use multiple ChatGPT accounts (e.g., personal and work) without manual logout.
Key Implementation Details:
Stable, Profile-Scoped Storage: Modified OpenAiCodexOAuthManager to use storage keys based on internal profile IDs (openai-codex-oauth-credentials-{id}). This ensures that renaming a profile does not invalidate the authorized session.
Profile-Aware API Handling: Updated OpenAiCodexHandler and the buildApiHandler factory to propagate the active profile name, ensuring each request uses the correct account's tokens.
Dynamic UI Updates: Added openAiCodexEmail to the extension state. The settings UI now dynamically displays the authorized email for the currently active profile, providing clear feedback on which account is being used.
Isolated Sign-out: Updated webview message handlers so that signing out of one profile only clears credentials for that specific profile.
Test Procedure
Unit Tests:
Added src/integrations/openai-codex/tests/oauth.spec.ts to verify:
Different profiles use unique storage keys.
Renaming/switching profiles correctly loads associated credentials.
Sign-out is isolated to the target profile.
Manual Verification:
Open Roo Code settings and create two provider profiles (e.g., "Personal" and "Work").
Set both to use the "OpenAI - ChatGPT Plus/Pro" provider.
Select "Personal", click "Sign in to OpenAI Codex", and authorize with Account A. Verify the UI shows "Authenticated as [Account A]".
Switch to "Work". Verify it shows as not authenticated.
Click "Sign in" and authorize with Account B. Verify the UI shows "Authenticated as [Account B]".
Switch back to "Personal". Verify the UI immediately updates to show Account A.
Perform a task in each profile and verify (via logs or behavior) that the correct account is used.
Pre-Submission Checklist
Issue Linked: This PR is linked to an approved GitHub Issue #11094.
Scope: My changes are focused on the linked issue.
Self-Review: I have performed a thorough self-review of my code.
Testing: New unit tests have been added.
Documentation Impact: No user-facing documentation updates required.
Contribution Guidelines: I have read and agree to the Contributor Guidelines.
Screenshots / Videos
The OpenAI Codex settings now include an "Authenticated as [email]" status indicator and a profile-specific Sign Out button.
Documentation Updates
No documentation updates are required.