fix: Codex model catalog WYSIWYG and config consolidation

- Remove mergeCodexDefaultCatalogModelForSave implicit injection (P1)
  The model mapping table is now the single source of truth; no hidden
  entries are prepended on save.

- Sync first catalog row model into config.toml on save
  Ensures Codex default request model matches the table's first entry
  instead of retaining a stale template value.

- Remove API Format selector from CodexFormFields (P3)
  wire_api is always 'responses'; the selector confused users into
  thinking they were changing the upstream protocol. Only the 'Needs
  Local Routing' toggle remains.

- Add restart hint to model mapping i18n text (P2)
  model_catalog_json is loaded at Codex startup; users are now informed
  that a restart is needed after changes.

- Unify write_codex_live_with_catalog helper (P4)
  Replaces three scattered prepare+write call sites in config.rs,
  provider/live.rs, and proxy.rs with a single entry point.

- Clean up useCodexConfigState dead state (P3 follow-up)
  Remove codexModelName, codexContextWindow, codexAutoCompactLimit and
  their handlers/effects since no component consumes them after the UI
  consolidation.
This commit is contained in:
Jason
2026-05-20 10:24:06 +08:00
parent 90b7f25111
commit 791ced0034
13 changed files with 959 additions and 207 deletions
+20 -2
View File
@@ -1080,12 +1080,30 @@
"saveFailed": "Save failed: {{error}}",
"modelNameHint": "Specify the model to use, will be auto-updated in config.toml",
"modelName": "Model Name",
"localRoutingToggle": "Needs Local Routing",
"localRoutingOffHint": "Use this when the provider natively supports OpenAI Responses and the model can be used directly by Codex; Codex can connect to the provider without local routing.",
"localRoutingOnHint": "Use this for custom models such as DeepSeek or Kimi, or providers that only support Chat Completions; keep local routing running while in use.",
"upstreamModelName": "Upstream Model Name",
"upstreamModelNameHint": "For Chat format, enter the real upstream model here; takeover writes a Codex-compatible local model and routing maps it back to this model.",
"upstreamModelNameHint": "For Chat format, enter the real upstream model here; routing converts Codex Responses requests to Chat Completions while keeping this model.",
"modelNamePlaceholder": "e.g., gpt-5-codex",
"contextWindow1M": "1M Context Window",
"contextWindow": "Context Window",
"contextWindowPlaceholder": "e.g., 128000",
"autoCompactLimit": "Auto Compact Limit",
"autoCompactLimitHint": "Auto-compacts history when context reaches this token limit"
"autoCompactLimitPlaceholder": "e.g., 90000",
"autoCompactLimitHint": "Auto-compacts history when context reaches this token limit",
"modelMetadataAdvanced": "Model Metadata Advanced Options",
"modelMetadataAdvancedHint": "Overrides Codex metadata for unknown models; clearing a field removes the matching config.toml entry.",
"modelMappingTitle": "Model Mapping",
"modelMappingHint": "Generates Codex model_catalog_json so /model can show these third-party model names; entries are saved exactly as listed. Codex must be restarted to refresh the model list after changes.",
"addCatalogModel": "Add Model",
"catalogDisplayName": "Display Name",
"catalogDisplayNamePlaceholder": "e.g., DeepSeek V4 Flash",
"catalogModelId": "Model ID",
"catalogModelPlaceholder": "e.g., deepseek-v4-flash",
"catalogColumnDisplay": "Menu Display Name",
"catalogColumnModel": "Actual Request Model",
"catalogColumnContext": "Context Window"
},
"geminiConfig": {
"envFile": "Environment Variables (.env)",
+20 -2
View File
@@ -1080,12 +1080,30 @@
"saveFailed": "保存に失敗しました: {{error}}",
"modelNameHint": "使用するモデルを指定します。config.toml に自動更新されます",
"modelName": "モデル名",
"localRoutingToggle": "ローカルルーティングが必要",
"localRoutingOffHint": "プロバイダーが OpenAI Responses API をネイティブにサポートし、Codex がモデルを直接使用できる場合に適しています。Codex はローカルルーティングなしで接続できます。",
"localRoutingOnHint": "DeepSeek、Kimi などのカスタムモデル、または Chat Completions のみをサポートするプロバイダー向けです。利用中はローカルルーティングを起動したままにしてください。",
"upstreamModelName": "上流モデル名",
"upstreamModelNameHint": "Chat 形式ではここに実際の上流モデルを入力します。接管時は Codex 互換のローカルモデルを書き込み、ルーティングでこのモデルに戻します。",
"upstreamModelNameHint": "Chat 形式ではここに実際の上流モデルを入力します。ルーティングで Codex の Responses リクエストを Chat Completions に変換し、このモデルを維持します。",
"modelNamePlaceholder": "例: gpt-5-codex",
"contextWindow1M": "1M コンテキストウィンドウ",
"contextWindow": "コンテキストウィンドウ",
"contextWindowPlaceholder": "例: 128000",
"autoCompactLimit": "自動圧縮しきい値",
"autoCompactLimitHint": "コンテキストトークン数がこのしきい値に達すると履歴を自動圧縮"
"autoCompactLimitPlaceholder": "例: 90000",
"autoCompactLimitHint": "コンテキストトークン数がこのしきい値に達すると履歴を自動圧縮",
"modelMetadataAdvanced": "モデルメタデータ詳細オプション",
"modelMetadataAdvancedHint": "未知のモデル向けに Codex メタデータを上書きします。空にすると対応する config.toml 設定を削除します。",
"modelMappingTitle": "モデルマッピング",
"modelMappingHint": "Codex model_catalog_json を生成し、/model コマンドでこれらの第三者モデル名を表示できるようにします。リストの内容はそのまま保存されます。変更後、モデルリストを更新するには Codex の再起動が必要です。",
"addCatalogModel": "モデルを追加",
"catalogDisplayName": "表示名",
"catalogDisplayNamePlaceholder": "例: DeepSeek V4 Flash",
"catalogModelId": "モデル ID",
"catalogModelPlaceholder": "例: deepseek-v4-flash",
"catalogColumnDisplay": "メニュー表示名",
"catalogColumnModel": "実際のリクエストモデル",
"catalogColumnContext": "コンテキストウィンドウ"
},
"geminiConfig": {
"envFile": "環境変数 (.env)",
+20 -2
View File
@@ -1080,12 +1080,30 @@
"saveFailed": "保存失败: {{error}}",
"modelNameHint": "指定使用的模型,将自动更新到 config.toml 中",
"modelName": "模型名称",
"localRoutingToggle": "需要本地路由映射",
"localRoutingOffHint": "适合供应商原生支持 OpenAI Responses API 且模型在 Codex 中可直接使用的场景,请求可由 Codex 直连供应商。",
"localRoutingOnHint": "适合 DeepSeek、Kimi 等自定义模型或仅支持 Chat Completions 的供应商;使用时请保持本地路由开启。",
"upstreamModelName": "上游模型名称",
"upstreamModelNameHint": "Chat 格式下这里填写真实上游模型;接管时 Codex 本地会使用兼容模型,并由路由映射回该模型。",
"upstreamModelNameHint": "Chat 格式下这里填写真实上游模型;路由会把 Codex 的 Responses 请求转换为 Chat Completions 并保持该模型。",
"modelNamePlaceholder": "例如: gpt-5-codex",
"contextWindow1M": "1M 上下文窗口",
"contextWindow": "上下文窗口",
"contextWindowPlaceholder": "例如: 128000",
"autoCompactLimit": "压缩阈值",
"autoCompactLimitHint": "上下文 token 数达到此阈值时自动压缩历史"
"autoCompactLimitPlaceholder": "例如: 90000",
"autoCompactLimitHint": "上下文 token 数达到此阈值时自动压缩历史",
"modelMetadataAdvanced": "模型元数据高级选项",
"modelMetadataAdvancedHint": "用于未知模型的 Codex 元数据覆盖;清空字段会从 config.toml 删除对应配置。",
"modelMappingTitle": "模型映射",
"modelMappingHint": "生成 Codex model_catalog_json,让 /model 命令显示这些第三方模型名;表中条目按填写内容原样保存。修改后需要重启 Codex 才能刷新模型列表。",
"addCatalogModel": "添加模型",
"catalogDisplayName": "显示名称",
"catalogDisplayNamePlaceholder": "例如: DeepSeek V4 Flash",
"catalogModelId": "模型 ID",
"catalogModelPlaceholder": "例如: deepseek-v4-flash",
"catalogColumnDisplay": "菜单显示名",
"catalogColumnModel": "实际请求模型",
"catalogColumnContext": "上下文窗口"
},
"geminiConfig": {
"envFile": "环境变量 (.env)",