Skip to content

feat(codex): discover native session models from the runtime - #13183

Closed
rp0927 wants to merge 2 commits into
stablyai:mainfrom
rp0927:feat/codex-runtime-model-discovery
Closed

rp0927 wants to merge 2 commits into
stablyai:mainfrom
rp0927:feat/codex-runtime-model-discovery

Conversation

@rp0927

@rp0927 rp0927 commented Aug 8, 2026 •

Copy link
Copy Markdown

Suggested title

feat(codex): discover native session models from the runtime

Summary

Native Codex session controls now discover the models exposed by the effective runtime instead of relying only on the static seed catalog. The discovery path reuses the existing bounded codex debug models parser and converts each model's supported reasoning levels into model-specific native-chat options.

The static catalog remains available immediately while discovery runs and remains the fallback when the CLI is unavailable, returns no models, or emits malformed output.

This is intentionally the first, narrow step toward account-scoped model discovery. It does not add an account picker or change account selection. A follow-up can bind discovery to a PTY-pinned managed account without expanding this PR's wire surface.

Screenshots

No visual layout change. Existing native Codex model and reasoning controls receive runtime-discovered choices after the asynchronous probe completes.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions

Focused validation:

  • pnpm exec vitest run --config config/vitest.config.ts src/shared/codex-model-list-probe.test.ts src/shared/agent-session-option-catalog.test.ts src/shared/commit-message-agent-spec.test.ts src/renderer/src/components/native-chat/native-chat-session-option-enrichment.test.ts — 70 tests passed after rebasing onto the current main.
  • pnpm run check:max-lines-ratchet — passed with no new bypasses.
  • git diff --check — passed.
  • Node 24 full test run — 47,059 tests passed, 6 failed, and 85 were skipped.
  • Node 24 pnpm run build:desktop — passed as part of the full build attempt.
  • Node 24 env -u npm_execpath node config/scripts/build-native-for-platform.mjs — passed.

Local environment notes:

  • The workstation default is Node 25.8.1, so the full validation was rerun with an isolated Node 24.19.0 runtime.
  • The full pnpm test run reported six remaining failures in config/scripts/check-root-directory-entries.test.mjs and src/main/ssh/ssh-posix-command-wrapper.test.ts. The same failures reproduced from a clean detached origin/main worktree. Another 23 failures caused by inherited Orca CODEX_HOME and Git environment variables passed after those variables were removed.
  • The full pnpm build reached the native stage after desktop compilation succeeded. The native wrapper then attempted to execute this workstation's standalone Mach-O npm_execpath with Node. Running the same native build script without that injected variable passed. No build script is changed in this PR.

AI Review Report

The review checked the shared parser extraction, fallback behavior, asynchronous enrichment, model-specific reasoning defaults, duplicate input handling, and preservation of existing Claude and Cursor behavior.

It flagged two missing regression assertions:

  1. a successful Codex probe must replace the static seed rather than mix unavailable seed models into the discovered account catalog;
  2. duplicate model rows and duplicate reasoning levels must be removed deterministically.

Both assertions were added. Automated review also identified the missing total-output bound; the parser now rejects input over 4,194,304 characters before structural scanning or JSON.parse. All cases pass in the focused 70-test suite.

Cross-platform review:

  • No platform-specific path, keyboard, label, shell quoting, or Electron API behavior was added.
  • Probe execution continues through the existing runtime model-discovery path, preserving local, WSL, SSH, and remote execution ownership.
  • No Git command or provider-specific source-control behavior changed.
  • The renderer probe remains asynchronous and once-per-agent/host, so it does not block rendering or launch.

Security Audit

  • Codex JSON is rejected above 4,194,304 characters and still passes through structural-token and nesting-depth limits before JSON.parse.
  • The parser accepts only non-empty model IDs, labels, and reasoning-level strings; malformed rows are ignored and duplicate IDs are removed.
  • No token, auth file, managed-home path, account identifier, or credential content is added to renderer state, logs, IPC, or cache keys.
  • No new command is constructed from user-controlled values. The existing fixed codex debug models invocation and runtime command-override handling are reused.
  • Probe failures fail safely to the static catalog; they do not switch credentials or retry under another account.
  • Dependencies and remote wire contracts are unchanged.

Notes

  • This PR does not make the cache PTY-account-aware. That follow-up requires an optional PTY identity and resolution through the existing managed-account registry.

@nwparker
nwparker requested a review from brennanb2025 August 8, 2026 10:20
@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 412facb7-b379-4e10-ae3d-9ff196ed7314

📥 Commits

Reviewing files that changed from the base of the PR and between 400321e and df302d3de82b1d23a361fcf0cc33a9f8c99ddecc.

📒 Files selected for processing (9)
  • src/renderer/src/components/native-chat/native-chat-session-option-discovery.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-enrichment.test.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-enrichment.ts
  • src/shared/agent-session-option-catalog-claude-codex.ts
  • src/shared/agent-session-option-catalog.test.ts
  • src/shared/agent-session-option-catalog.ts
  • src/shared/codex-model-list-probe.test.ts
  • src/shared/codex-model-list-probe.ts
  • src/shared/commit-message-agent-spec.ts
🚧 Files skipped from review as they are similar to previous changes (9)
  • src/shared/codex-model-list-probe.test.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-enrichment.test.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-discovery.ts
  • src/shared/commit-message-agent-spec.ts
  • src/shared/agent-session-option-catalog.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-enrichment.ts
  • src/shared/codex-model-list-probe.ts
  • src/shared/agent-session-option-catalog.test.ts
  • src/shared/agent-session-option-catalog-claude-codex.ts

📝 Walkthrough

Walkthrough

Codex model discovery now uses a shared bounded JSON probe that normalizes models, effort levels, defaults, and duplicates. Shared catalog helpers generate Codex effort options and expose model-list discovery. Commit-message discovery uses the shared parser and command arguments. Native chat accepts probe-origin Codex results, creates per-model thinking options, and uses discovered Codex models directly. Tests cover parsing, defaults, malformed output, deduplication, enrichment, and fallback behavior.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed and relevant, but it omits required template sections, including ELI5, What Changed, Why, Linked Issue, Visual Proof, Review, Checklist, and Author. Populate the required sections and add a valid issue reference; mark Visual Proof as N/A with a reason and complete the testing and checklist items.
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 (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states that the PR discovers native Codex session models from the runtime, which matches the primary change.
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.

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.

@rp0927
rp0927 force-pushed the feat/codex-runtime-model-discovery branch from 16ca22f to e705db5 Compare August 8, 2026 10:21
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 06910a60-2a42-47a1-aa62-6c872ffff9e3

📥 Commits

Reviewing files that changed from the base of the PR and between 4349599 and e705db52372a902df7ed3e713c0d68ea593598e3.

📒 Files selected for processing (8)
  • src/renderer/src/components/native-chat/native-chat-session-option-discovery.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-enrichment.test.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-enrichment.ts
  • src/shared/agent-session-option-catalog-claude-codex.ts
  • src/shared/agent-session-option-catalog.test.ts
  • src/shared/agent-session-option-catalog.ts
  • src/shared/codex-model-list-probe.ts
  • src/shared/commit-message-agent-spec.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/renderer/src/components/native-chat/native-chat-session-option-enrichment.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-discovery.ts
  • src/shared/agent-session-option-catalog.test.ts
  • src/shared/commit-message-agent-spec.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-enrichment.test.ts
  • src/shared/agent-session-option-catalog-claude-codex.ts
  • src/shared/agent-session-option-catalog.ts

Comment thread src/shared/codex-model-list-probe.ts Resolved
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@rp0927

rp0927 commented Aug 13, 2026

Copy link
Copy Markdown
Author

Rebased onto current origin/main (392 commits). Conflict resolutions kept main’s usage-provider IPC/lifecycle and PTY cwd prevalidation, and ported account-filter / managed-home behavior onto those paths. Localization keys were merged rather than dropped. Stack branches were force-pushed with --force-with-lease. GitHub will not accept another fork branch as the base, so these PRs still target main and still contain the full stack below them — review bottom-up starting at #13183.

@rp0927
rp0927 force-pushed the feat/codex-runtime-model-discovery branch from 35575ea to df302d3 Compare August 14, 2026 03:32
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@rp0927
rp0927 force-pushed the feat/codex-runtime-model-discovery branch 9 times, most recently from fd5bf00 to 939abf4 Compare August 15, 2026 13:23
@rp0927

rp0927 commented Aug 15, 2026

Copy link
Copy Markdown
Author

Restacked onto current origin/main (c0a775454); force-pushed with --force-with-lease. New head: 939abf46b.

The stack was also restructured so each PR is green on its own head — previously every follow-up fix landed on the tip (#13276), which meant ancestor heads failed typecheck/oxlint standalone and reviewers (including CodeRabbit) were reading a snapshot without the fixes. Details in #13276 (comment).

This head was verified standalone: typecheck:node, typecheck:web, typecheck:cli, oxlint all pass.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants