Skip to content

Add Codex config profile setting#2756

Open
jamesx0416 wants to merge 1 commit into
pingdotgg:mainfrom
jamesx0416:codex-config-profile
Open

Add Codex config profile setting#2756
jamesx0416 wants to merge 1 commit into
pingdotgg:mainfrom
jamesx0416:codex-config-profile

Conversation

@jamesx0416
Copy link
Copy Markdown
Contributor

@jamesx0416 jamesx0416 commented May 19, 2026

What Changed

Adds a minimal Codex Config profile provider setting and threads it through Codex launch paths:

  • Passes -p <profile> to Codex app-server status probes, app-server sessions, and codex exec text generation.
  • Reads the selected profile's model_provider from Codex config and passes it into app-server thread/start / thread/resume startup.
  • Avoids showing the OpenAI auth error as blocking when the profiled app-server returns models.
  • Adds focused schema/runtime tests for the new setting and launch behavior.

Why

This lets T3 Code use Codex config profiles backed by non-default providers, such as a custom provider profile.

The explicit config lookup exists because of an upstream Codex app-server bug/limitation: codex -p <profile> app-server does not apply the profile's model_provider to thread/start by default, even though codex -p <profile> exec ... does. Without passing modelProvider explicitly, app-server starts threads with modelProvider: "openai" and can hit OpenAI 401s for custom-provider profiles.

Upstream issue: openai/codex#23417

UI Changes

Adds a small Config profile text field to the existing Codex provider settings form.
Before:
Screenshot 2026-05-19 at 3 27 38 pm

After:
Screenshot 2026-05-19 at 3 26 15 pm

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Verification:

  • bun fmt
  • bun lint (passes with existing warnings)
  • bun typecheck
  • cd apps/server && bun run test src/provider/Layers/CodexProvider.test.ts src/provider/Layers/CodexSessionRuntime.test.ts src/textGeneration/CodexTextGeneration.test.ts src/serverSettings.test.ts

Note

Medium Risk
Changes Codex provider launch/probe behavior and thread-start parameters (including auth-status determination), which can affect whether Codex sessions start and how they authenticate, but scope is limited to the Codex integration and is covered by new tests.

Overview
Adds a new Codex provider setting, profileName, surfaced in the settings schema/UI and supported in settings patches.

When set, Codex commands now run with -p <profileName> for app-server probes, app-server session spawn, and codex exec text generation; session startup also reads Codex config (config/read) to extract model_provider (profile-specific first) and forwards it via modelProvider in thread/start/thread/resume.

Provider status probing is adjusted so profiled providers don’t treat requiresOpenaiAuth as blocking when non-custom models are present; tests are updated/added to validate profile propagation, modelProvider forwarding, and the auth/model readiness behavior.

Reviewed by Cursor Bugbot for commit 03a7261. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add profileName config profile setting to Codex provider

  • Adds profileName to CodexSettings in settings.ts, wiring it through the provider status check, session runtime, and text generation layers.
  • When set, prepends -p {profileName} to app-server and codex exec command args, and reads profile-specific model config for thread start/resume requests.
  • Providers with a configured profile treat requiresOpenaiAuth as non-blocking when models are available, allowing the provider to report ready without OpenAI auth.
  • Behavioral Change: unauthenticated Codex accounts with a profile set no longer block provider readiness on OpenAI auth.

Macroscope summarized 03a7261.

Summary by CodeRabbit

  • New Features

    • Added optional "Config profile" setting for the Codex provider, enabling profile-scoped configuration and model-provider selection; the Codex helper now forwards a selected profile to the Codex server process.
  • Tests

    • Added and updated tests to validate profile handling, model-provider propagation, probe behavior, and settings patch/encoding for Codex profile.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

📝 Walkthrough

Walkthrough

This PR adds optional Codex profile name configuration to the provider. The new profileName setting flows through the provider status probe, session runtime initialization, adapter integration, and CLI execution. When set, it spawns the app-server with -p <profileName> and enables profile-scoped model provider derivation.

Changes

Codex profile configuration support

Layer / File(s) Summary
Schema definition
packages/contracts/src/settings.ts
CodexSettings and CodexSettingsPatch gain optional profileName field with empty-string default and "Config profile" UI annotation.
Provider probe and status checking
apps/server/src/provider/Layers/CodexProvider.ts, apps/server/src/provider/Layers/ProviderRegistry.test.ts
Probe accepts profileName and passes -p <profileName> to app-server. Early unauthenticated-return is suppressed when a profile is provided. Status computation forwards profileName to the probe and only clears requiresOpenaiAuth when non-custom models exist.
Session runtime initialization and modelProvider
apps/server/src/provider/Layers/CodexSessionRuntime.ts, apps/server/src/provider/Layers/CodexSessionRuntime.test.ts
Runtime options add profileName. App-server spawn uses -p <profileName> when present. buildThreadStartParams and openCodexThread accept/propagate modelProvider. start reads config, derives profile-scoped modelProvider, and passes it into thread startup.
Adapter integration
apps/server/src/provider/Layers/CodexAdapter.ts, apps/server/src/provider/Layers/CodexAdapter.test.ts
Adapter forwards codexConfig.profileName into CodexSessionRuntimeOptions; tests validate the runtime factory receives the profileName.
CLI execution with profile
apps/server/src/textGeneration/CodexTextGeneration.ts, apps/server/src/textGeneration/CodexTextGeneration.test.ts
CLI invocation conditionally adds -p <profileName> argument. Fake CLI helper parses -p, records the profile name, and can assert expected requireProfileName.
Settings and test fixtures
apps/server/src/serverSettings.test.ts, apps/server/src/provider/Layers/ProviderInstanceRegistryLive.test.ts, apps/web/src/components/KeybindingsToast.browser.tsx, apps/web/src/components/settings/ProviderSettingsForm.test.ts
Settings tests cover providers.codex.profileName decoding, merge, and trimming. Test fixtures and UI tests updated to include default empty profileName and expect it in provider field derivation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A profile for Codex takes shape,
With -p flags and models to reap,
The runtime now knows
Where config flow goes,
And sessions are ready to leap! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a Codex config profile setting, which aligns with the comprehensive changeset across multiple files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description comprehensively covers all required sections: clear explanation of what changed, detailed reasoning including an upstream issue reference, before/after UI screenshots, and a completed checklist confirming scope and focus.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels May 19, 2026
Comment thread apps/server/src/provider/Layers/CodexProvider.ts Outdated
Comment thread apps/server/src/provider/Layers/CodexProvider.ts
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 19, 2026

Approvability

Verdict: Needs human review

This PR introduces a new Codex profile configuration feature that modifies authentication flow behavior - when a profile is set, OpenAI auth requirements are bypassed. These runtime behavior changes around authentication warrant human review.

You can customize Macroscope's approvability policy. Learn more.

@jamesx0416
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/server/src/provider/Layers/CodexProvider.ts`:
- Around line 495-499: The code incorrectly forces account.requiresOpenaiAuth to
false whenever snapshot.models.length > 0, which can flip auth-required for
custom models that were added via the unauthenticated early-return/settings
path; instead only clear requiresOpenaiAuth when those models were discovered
during an authenticated probe. Update the logic around account construction (the
account variable and its use by accountProbeStatus) to only set
requiresOpenaiAuth = false when snapshot.models.length > 0 AND the snapshot
indicates an authenticated probe (e.g., check snapshot.authenticated or another
flag that distinguishes provider-discovered models from settings-provided
models); otherwise preserve snapshot.account.requiresOpenaiAuth. Ensure you
reference and update the same symbols: snapshot.models,
snapshot.account.requiresOpenaiAuth, and accountProbeStatus(account).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e7130f37-a535-4ca9-ba1e-e8c4f8470f2a

📥 Commits

Reviewing files that changed from the base of the PR and between d1e85c4 and d8beb90.

📒 Files selected for processing (13)
  • apps/server/src/provider/Layers/CodexAdapter.test.ts
  • apps/server/src/provider/Layers/CodexAdapter.ts
  • apps/server/src/provider/Layers/CodexProvider.ts
  • apps/server/src/provider/Layers/CodexSessionRuntime.test.ts
  • apps/server/src/provider/Layers/CodexSessionRuntime.ts
  • apps/server/src/provider/Layers/ProviderInstanceRegistryLive.test.ts
  • apps/server/src/provider/Layers/ProviderRegistry.test.ts
  • apps/server/src/serverSettings.test.ts
  • apps/server/src/textGeneration/CodexTextGeneration.test.ts
  • apps/server/src/textGeneration/CodexTextGeneration.ts
  • apps/web/src/components/KeybindingsToast.browser.tsx
  • apps/web/src/components/settings/ProviderSettingsForm.test.ts
  • packages/contracts/src/settings.ts

Comment thread apps/server/src/provider/Layers/CodexProvider.ts Outdated
@jamesx0416 jamesx0416 force-pushed the codex-config-profile branch from d8beb90 to e2275ac Compare May 19, 2026 05:25
@jamesx0416
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Comment thread apps/server/src/provider/Layers/ProviderRegistry.test.ts
@jamesx0416 jamesx0416 force-pushed the codex-config-profile branch from e2275ac to 03a7261 Compare May 19, 2026 05:40
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 03a7261. Configure here.

profileName: TrimmedString.pipe(
Schema.withDecodingDefault(Effect.succeed("")),
Schema.annotateKey({ title: "Config profile" }),
),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

profileName missing from form field order array

Low Severity

The profileName field is not included in the order array for CodexSettings, which only lists ["binaryPath", "homePath", "shadowHomePath"]. Every other provider settings schema (Claude, Cursor, OpenCode) explicitly lists all visible fields in its order array. The profileName field's position in the settings form relies on the implicit ordering behavior of deriveProviderSettingsFields for unordered fields, making it fragile if that function's behavior changes.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 03a7261. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant