Add Codex device-code sign-in#1045
Conversation
Adds a device-code Codex login path alongside the existing browser OAuth flow while reusing the current Codex credential storage, profile, and runtime routing.
There was a problem hiding this comment.
Pull request overview
Adds a new Codex “device code” sign-in path alongside the existing Codex OAuth flow, reusing the same secure credential storage and Codex runtime activation behavior.
Changes:
- Introduce a Codex device-code API flow (device-code request + token polling) and a React hook to drive the UI flow and persistence.
- Add “Codex Device Code” as a selectable option in both ProviderManager and
/providerwizard flows. - Update provider validation hints and preset ordering expectations.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/providerValidation.ts | Updates Codex auth validation hints to mention device-code sign-in. |
| src/services/api/codexDeviceFlow.ts | Adds device-code request/polling implementation for Codex auth. |
| src/components/useCodexDeviceCodeFlow.ts | Adds React hook orchestrating device-code sign-in, browser open, polling, and secure persistence. |
| src/components/ProviderManager.tsx | Adds a new “Codex Device Code” setup screen and preset option. |
| src/components/ProviderManager.test.tsx | Updates preset ordering expectations to include “Codex Device Code”. |
| src/commands/provider/provider.tsx | Adds a new /provider wizard step for Codex device-code sign-in. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (canUseCodexOAuth) { | ||
| options.splice(7, 0, { | ||
| value: 'codex-device-code', | ||
| label: 'Codex Device Code', | ||
| description: | ||
| 'Sign in with a device code and store Codex credentials securely', | ||
| }) | ||
| options.splice(6, 0, { | ||
| value: 'codex-oauth', |
| export function useCodexDeviceCodeFlow(options: { | ||
| onAuthenticated: ( | ||
| tokens: CodexOAuthTokens, | ||
| persistCredentials: PersistCodexCredentials, | ||
| ) => void | Promise<void> | ||
| deps?: CodexDeviceCodeFlowDependencies | ||
| }): CodexDeviceCodeFlowStatus { |
| const response = await fetchFn(CODEX_DEVICE_CODE_URL, { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/x-www-form-urlencoded', | ||
| }, | ||
| body, | ||
| }) |
| const response = await options.fetchImpl(CODEX_REFRESH_URL, { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/x-www-form-urlencoded', | ||
| }, | ||
| body, | ||
| signal: options.signal, |
|
please address copilot's comments |
Additional Review Response for PR #10451. Missing
|
Summary
Test plan
bun run buildbun test src/commands/provider/provider.test.tsx src/components/ProviderManager.test.tsx src/utils/providerValidation.tsbun test src/services/api/providerConfig.codexSecureStorage.test.ts src/services/api/providerConfig.runtimeCodexCredentials.test.ts src/utils/codexCredentials.test.tsNotes
bun testhas unrelated environment-sensitive failures inStartupScreen.test.tsandsdk-context-isolation.test.tswhen Codex/OpenAI env vars are set locally; those tests pass when the Codex env is unset.bun run typecheckcurrently fails with unrelated baseline errors outside these changed files.