Skip to content

feat(tui): add Codex API format picker (fix meta revert bug)#254

Open
heliar-k wants to merge 1 commit into
SaladDay:mainfrom
heliar-k:feat/api_format_sellection_for_codex
Open

feat(tui): add Codex API format picker (fix meta revert bug)#254
heliar-k wants to merge 1 commit into
SaladDay:mainfrom
heliar-k:feat/api_format_sellection_for_codex

Conversation

@heliar-k

@heliar-k heliar-k commented Jun 8, 2026

Copy link
Copy Markdown

Summary

Add an API format picker to the Codex provider form and unify the Claude/Codex/Gemini API format representation under a single ApiFormat enum. Also fixes a bug where changing a provider's apiFormat in the TUI would appear to save but revert to the old value after restart.

Changes

1. Codex API Format Picker

  • Add picker overlay to Codex provider form for non-official providers
  • Two options: OpenAI Responses (default) and OpenAI Chat (local routing)
  • Reuses existing picker overlay infrastructure from Claude/Gemini

2. ApiFormat Enum Unification (TUI layer only)

  • Rename ClaudeApiFormatApiFormat (describes generic wire protocols, not Claude-specific)
  • Rename ProviderAddField::ClaudeApiFormat::ApiFormat
  • Rename Overlay::ClaudeApiFormatPicker::ApiFormatPicker
  • Single api_format field on the form state replaces previous claude_api_format / codex_api_format fields

3. Bug Fix: Meta Revert After Edit

Symptom: changing a provider's apiFormat (e.g. openai_chat → Anthropic) in the TUI appeared to save, but reverted to the old value after restart.

Root cause: provider_json.rs removed the entire meta key when the meta object became empty. Deserialization then produced meta: None, and the merge logic in ProviderService::update() preserved the old meta (including the old apiFormat).

Fix: keep "meta": {} in the JSON output even when empty, so deserialization produces Some(ProviderMeta::default()) and the merge logic correctly treats the form output as authoritative.

Test plan

  • cargo test --lib -- api_format — 29 tests pass (including new test_exact_tui_form_api_format_roundtrip regression test)
  • cargo test --lib -- codex_local_routing — passes
  • cargo test --lib -- provider_add_form_codex — passes
  • cargo check — no errors (only pre-existing warnings from main)
  • Manual TUI verification: add/edit Codex provider with API format picker

Adds a TUI form picker for Codex providers to select between
openai_responses and openai_chat wire API formats. Unifies the
previously separate ClaudeApiFormat and CodexApiFormat enums into a
single shared ApiFormat enum used by both Claude and Codex provider
forms. Also fixes a bug where api_format would revert after editing
an existing provider (preserves empty meta objects in JSON output
so ProviderService::update() treats the form as authoritative).

Includes end-to-end tests for the api_format roundtrip through the
TUI form, JSON serialization, and DB persistence.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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.

1 participant