Skip to content

Add Codex App LLM setup support - #5810

Merged
JAORMX merged 2 commits into
mainfrom
feat/codex-app-llm-setup
Jul 15, 2026
Merged

JAORMX merged 2 commits into
mainfrom
feat/codex-app-llm-setup

Conversation

@JAORMX

@JAORMX JAORMX commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Codex desktop users could not run thv llm setup unless the separate Codex CLI was installed and had already created ~/.codex. The desktop app uses the same Codex user configuration, so requiring CLI installation prevented ToolHive from configuring otherwise valid app-only installations.

  • Detect the Codex desktop app independently on macOS and Windows while retaining the existing CLI detection path.
  • Keep one canonical codex setup and teardown target because the CLI and desktop app share the same user configuration.
  • Validate the macOS bundle identifier and the exact Store-signed Windows package family before treating the app as installed.
  • Document the shared configuration and supported desktop platforms.
  • Add unit coverage and a Darwin app-only CLI E2E scenario.

Fixes #5785

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Additional verification:

  • task build
  • task docs

The full E2E suite was attempted but could not complete because its API test server reported that no usable container runtime was available. The new Darwin app-only E2E scenario is included for CI/macOS execution.

API Compatibility

  • This PR does not break the v1beta1 API, OR the api-break-allowed label is applied and the migration guidance is described above.

Changes

File Change
pkg/client/codex_desktop.go Detect and validate Codex desktop installations on macOS and Windows.
pkg/client/llm_gateway.go Treat CLI or desktop evidence as one canonical Codex installation.
pkg/client/discovery.go Wire the native detector into the production client manager.
pkg/client/*_test.go Cover platform identities and CLI/app detection combinations.
test/e2e/cli_llm_all_clients_test.go Exercise app-only setup and teardown through the real CLI on macOS.
cmd/thv/app/llm.go, docs/cli/thv_llm_setup.md Explain shared configuration, platforms, and the canonical codex target.

Does this introduce a user-facing change?

Yes. thv llm setup --client codex now detects Codex desktop installations on macOS and Windows even when the Codex CLI is absent. CLI and desktop installations continue to share one codex configuration and teardown target.

Implementation plan

Approved implementation plan
  1. Keep the existing canonical codex client identity and reuse its ~/.codex/config.toml writer and teardown logic.
  2. Extend Codex installation detection with OR semantics: existing CLI evidence or native desktop evidence, returning one result when both exist.
  3. Detect legacy and current macOS bundles and validate CFBundleIdentifier = com.openai.codex.
  4. Detect the exact Store-signed Windows package family without scanning protected, versioned WindowsApps paths.
  5. Preserve Linux as CLI-only and leave all other clients' detection behavior unchanged.
  6. Add deterministic unit coverage for CLI-only, app-only, combined, stale-directory, platform identity, and detector-failure cases.
  7. Add app-only setup/teardown coverage through the existing CLI E2E harness on macOS.
  8. Regenerate CLI documentation and run build, unit tests, lint, and E2E verification where supported.

Runtime model discoverability is not applicable because this is host application detection and local configuration.

Special notes for reviewers

The current unified macOS application is named ChatGPT.app but retains the Codex bundle identifier com.openai.codex; the detector also supports the legacy Codex.app path. Windows detection verifies the exact package family OpenAI.Codex_2p2nqsd0c76g0 and requires a Microsoft Store signature.

@github-actions github-actions Bot added the size/M Medium PR: 300-599 lines changed label Jul 15, 2026
@codecov

codecov Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.41096% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.89%. Comparing base (30ecff0) to head (9ef7064).

Files with missing lines Patch % Lines
pkg/client/llm_gateway.go 84.61% 2 Missing and 2 partials ⚠️
pkg/client/codex_desktop.go 92.30% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5810      +/-   ##
==========================================
- Coverage   70.90%   70.89%   -0.02%     
==========================================
  Files         685      686       +1     
  Lines       69696    69758      +62     
==========================================
+ Hits        49421    49457      +36     
- Misses      16650    16687      +37     
+ Partials     3625     3614      -11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

rdimitrov
rdimitrov previously approved these changes Jul 15, 2026

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Automated review focused on the new Codex desktop detection path. The change is solid and well-tested — the config-write case when ~/.codex is absent is correctly handled by configureCodexAuth's os.MkdirAll, and it's covered by the new E2E scenario. The comments below are robustness/quality issues rather than correctness-breaking bugs. Findings 1–2 (silent non-detection with no log) are the ones worth acting on before merge.

Generated with Claude Code

Comment thread pkg/client/llm_gateway.go Outdated
Comment thread pkg/client/codex_desktop.go
Comment thread pkg/client/llm_gateway.go Outdated
Comment thread pkg/client/llm_gateway.go Outdated
Comment thread pkg/client/llm_gateway.go Outdated
Comment thread pkg/client/codex_desktop.go Outdated

@github-actions github-actions 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.

Large PR Detected

This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.

How to unblock this PR:

Add a section to your PR description with the following format:

## Large PR Justification

[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformation

Alternative:

Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.

See our Contributing Guidelines for more details.


This review will be automatically dismissed once you add the justification section.

@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/M Medium PR: 300-599 lines changed size/XL Extra large PR: 1000+ lines changed labels Jul 15, 2026
JAORMX added 2 commits July 15, 2026 15:48
Detect Codex desktop installations on macOS and Windows so app-only users can configure the shared Codex model provider through thv llm setup. Keep one canonical Codex configuration and teardown path for both the CLI and desktop app.

Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
- Log detector errors at WARN instead of silently swallowing them
- Invoke plutil by absolute path (/usr/bin/plutil) to avoid PATH
  resolution failures in stripped environments
- Refactor to a per-client LLMInstalledDetector hook, removing the
  hardcoded Codex branch and duplicated CLI detection logic
- Guard lookPath consistently in the shared detection path
- Tighten the #nosec G204 justification
@jhrozek
jhrozek force-pushed the feat/codex-app-llm-setup branch from b590b16 to 9ef7064 Compare July 15, 2026 14:51
@github-actions
github-actions Bot dismissed their stale review July 15, 2026 14:51

PR size has been reduced below the XL threshold. Thank you for splitting this up!

@github-actions

Copy link
Copy Markdown
Contributor

✅ PR size has been reduced below the XL threshold. The size review has been dismissed and this PR can now proceed with normal review. Thank you for splitting this up!

@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jul 15, 2026

@jhrozek jhrozek 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.

restoring previous approval

@JAORMX
JAORMX merged commit b80f1c3 into main Jul 15, 2026
59 of 60 checks passed
@JAORMX
JAORMX deleted the feat/codex-app-llm-setup branch July 15, 2026 15:26
@github-actions github-actions Bot mentioned this pull request Jul 15, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Codex Desktop App support to thv llm setup

4 participants