Skip to content

Add Codex launch arguments setting#2892

Open
jamesx0416 wants to merge 4 commits into
pingdotgg:mainfrom
jamesx0416:t3code/codex-launch-args
Open

Add Codex launch arguments setting#2892
jamesx0416 wants to merge 4 commits into
pingdotgg:mainfrom
jamesx0416:t3code/codex-launch-args

Conversation

@jamesx0416
Copy link
Copy Markdown
Contributor

@jamesx0416 jamesx0416 commented Jun 1, 2026

What Changed

  • Added a Codex provider launchArgs setting to the shared settings schema and provider settings form.
  • Pass configured launch args to codex app-server for provider probes and live session startup.
  • Added focused coverage for schema trimming, settings form visibility, argv construction, and runtime/probe propagation.

Why

Codex instances need the same kind of configurable launch arguments Claude already exposes, so users can pass app-server CLI flags like -c model_provider="codex-lb" without changing the binary path. The field is split into argv tokens directly and never shell-executed.

UI Changes

Adds a small Launch arguments text field to Codex provider settings.

Screenshots will be added separately.

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

Validation:

  • bun fmt
  • bun lint
  • bun typecheck

Open in Devin Review

Note

Medium Risk
Changes how the Codex child process is spawned from user-supplied strings; mistakes in launch args could break sessions or probes, though args are tokenized without a shell.

Overview
Adds a Codex launchArgs provider setting (schema, settings patch, and Launch arguments field in provider settings), mirroring Claude’s pattern.

Configured values are passed through codex app-server startup: a shared codexAppServerArgs helper prepends app-server and splits the string on whitespace into argv (no shell). CodexSessionRuntime, CodexAdapter, and provider status probes all use it; spawn error messages reflect the full command.

Tests cover argv building, schema trim/default, form field visibility, adapter/runtime/probe propagation, and fixture updates for the new default field.

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

Note

Add launchArgs setting to configure Codex app-server CLI arguments

  • Adds an optional launchArgs string field to CodexSettings and CodexSettingsPatch in settings.ts; the value is trimmed and defaults to empty.
  • Passes launchArgs through the provider status check, session runtime, and process spawn in CodexSessionRuntime.ts and CodexProvider.ts.
  • A codexAppServerArgs helper splits the string into argv, returning ['app-server'] for empty/whitespace input and ['app-server', ...args] otherwise.
  • Spawn error messages now include the full argv for easier debugging.

Macroscope summarized eba666f.

Summary by CodeRabbit

  • New Features
    • Added a "Launch arguments" field to Codex provider settings so users can pass custom arguments to the Codex app-server when starting sessions.
    • Input is trimmed and normalized (defaults to empty), and configured arguments are applied when launching the Codex service.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 60b5cf37-2ab9-4316-9943-e0c3de807492

📥 Commits

Reviewing files that changed from the base of the PR and between 0d0a277 and eba666f.

📒 Files selected for processing (4)
  • apps/server/src/provider/Layers/CodexAdapter.test.ts
  • apps/server/src/provider/Layers/CodexProvider.ts
  • apps/server/src/provider/Layers/CodexSessionRuntime.ts
  • packages/contracts/src/settings.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/server/src/provider/Layers/CodexSessionRuntime.ts
  • apps/server/src/provider/Layers/CodexAdapter.test.ts
  • packages/contracts/src/settings.ts
  • apps/server/src/provider/Layers/CodexProvider.ts

📝 Walkthrough

Walkthrough

Adds a trimmed launchArgs string to Codex provider settings, a codexAppServerArgs helper to build the app-server argv, threads launchArgs into provider probes and session runtime, uses it when spawning the app-server child process, and updates tests/fixtures to cover the new field.

Changes

Codex Launch Arguments

Layer / File(s) Summary
CodexSettings schema with launchArgs field
packages/contracts/src/settings.ts, packages/contracts/src/settings.test.ts
CodexSettings gains a launchArgs string field (default "", trimmed) and ServerSettingsPatch accepts optional providers.codex.launchArgs; tests verify trimming/normalization.
Launch arguments parsing helper
apps/server/src/provider/Layers/CodexProvider.ts, apps/server/src/provider/Layers/codexLaunchArgs.test.ts
Adds exported codexAppServerArgs(launchArgs?: string) that returns ["app-server", ...tokens]; tests cover empty and whitespace-split inputs.
Provider probing with launch arguments
apps/server/src/provider/Layers/CodexProvider.ts, apps/server/src/provider/Layers/ProviderRegistry.test.ts
Probe input types accept optional launchArgs; CodexClient.layerCommand uses codexAppServerArgs(input.launchArgs) and checkCodexProviderStatus forwards configured launchArgs into probe invocation; test asserts probe receives expected launchArgs.
Session runtime with launch arguments
apps/server/src/provider/Layers/CodexSessionRuntime.ts, apps/server/src/provider/Layers/CodexAdapter.ts, apps/server/src/provider/Layers/CodexAdapter.test.ts
CodexSessionRuntimeOptions adds optional launchArgs; runtime imports helper and computes appServerArgs from options.launchArgs for ChildProcess.make(...); adapter passes codexConfig.launchArgs to runtime; tests verify flow into created runtime.
Test fixture and assertion updates
apps/server/src/provider/Layers/ProviderInstanceRegistryLive.test.ts, apps/server/src/serverSettings.test.ts, apps/web/src/components/KeybindingsToast.browser.tsx, apps/web/src/components/settings/ProviderSettingsForm.test.ts, apps/server/src/provider/Layers/ProviderRegistry.test.ts, apps/server/src/provider/Layers/CodexAdapter.test.ts
Test helpers and fixtures updated to include launchArgs: "" in Codex provider configs; new/updated tests assert trimming and propagation of non-empty launchArgs values.

🎯 3 (Moderate) | ⏱️ ~20 minutes

"🐰
I nudge the args from settings deep,
Split by spaces, their secrets keep,
Through probes and runtimes, steady pace,
App-server starts with proper grace. 🥕"

🚥 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 launch arguments setting to the provider configuration.
Description check ✅ Passed The description covers all required sections: What Changed, Why, UI Changes, and Checklist. It clearly explains the feature, its purpose, and testing validation, though UI screenshots are noted as pending.
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.

✏️ 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 size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Jun 1, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Jun 1, 2026

Approvability

Verdict: Needs human review

This PR introduces a new user-configurable feature that affects how processes are spawned at runtime. New capabilities that change process execution behavior warrant human review regardless of implementation simplicity.

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 Jun 1, 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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/contracts/src/settings.ts (1)

209-213: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add "launchArgs" to the order array for consistency.

The order array should include "launchArgs" to ensure the field appears in the intended position in the settings form. ClaudeSettings (line 255) includes launchArgs in its order array, and the test expectation in ProviderSettingsForm.test.ts (line 21) assumes launchArgs appears after shadowHomePath.

♻️ Proposed fix
   },
   {
-    order: ["binaryPath", "homePath", "shadowHomePath"],
+    order: ["binaryPath", "homePath", "shadowHomePath", "launchArgs"],
   },
 );
🤖 Prompt for 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.

In `@packages/contracts/src/settings.ts` around lines 209 - 213, The settings
schema object currently sets order: ["binaryPath", "homePath", "shadowHomePath"]
but omits "launchArgs", causing form ordering and tests to fail; update that
object's order array to include "launchArgs" after "shadowHomePath" so it
matches ClaudeSettings and the expectation in ProviderSettingsForm.test.ts,
ensuring the "order" array change is applied to the same settings object in
packages/contracts/src/settings.ts.
🤖 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/CodexSessionRuntime.ts`:
- Around line 721-724: The CodexAppServerSpawnError message currently logs a
hardcoded "${options.binaryPath} app-server" which can mismatch the actual
command; update the error construction where CodexAppServerSpawnError is thrown
(after the spawner.spawn call) to include the computed appServerArgs (from
codexAppServerArgs(options.launchArgs)) along with options.binaryPath so the
logged command reflects ChildProcess.make(options.binaryPath, appServerArgs,
...) and any flags from options.launchArgs; ensure you reference appServerArgs
and options.binaryPath in the error message so spawn failures show the real
command invoked.

---

Outside diff comments:
In `@packages/contracts/src/settings.ts`:
- Around line 209-213: The settings schema object currently sets order:
["binaryPath", "homePath", "shadowHomePath"] but omits "launchArgs", causing
form ordering and tests to fail; update that object's order array to include
"launchArgs" after "shadowHomePath" so it matches ClaudeSettings and the
expectation in ProviderSettingsForm.test.ts, ensuring the "order" array change
is applied to the same settings object in packages/contracts/src/settings.ts.
🪄 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: b83f8476-9f14-45be-9c09-5bab8a90c3d4

📥 Commits

Reviewing files that changed from the base of the PR and between b3e8c03 and 0d0a277.

📒 Files selected for processing (12)
  • 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.ts
  • apps/server/src/provider/Layers/ProviderInstanceRegistryLive.test.ts
  • apps/server/src/provider/Layers/ProviderRegistry.test.ts
  • apps/server/src/provider/Layers/codexLaunchArgs.test.ts
  • apps/server/src/serverSettings.test.ts
  • apps/web/src/components/KeybindingsToast.browser.tsx
  • apps/web/src/components/settings/ProviderSettingsForm.test.ts
  • packages/contracts/src/settings.test.ts
  • packages/contracts/src/settings.ts

Comment thread apps/server/src/provider/Layers/CodexSessionRuntime.ts
@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Jun 1, 2026
@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Jun 1, 2026
@jamesx0416
Copy link
Copy Markdown
Contributor Author

jamesx0416 commented Jun 1, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 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.

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

Labels

size:S 10-29 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