feat(codex-oauth): fetch model list from ChatGPT backend on demand

- Add `get_codex_oauth_models` Tauri command reusing the managed OAuth
  access token to hit `chatgpt.com/backend-api/codex/models`; HTTP and
  multi-shape JSON parsing live in `services::codex_oauth_models` so the
  command stays thin.
- Unify the Claude form's "fetch models" button across normal / Copilot /
  Codex OAuth presets, drop the auto-load effect for Copilot in favor of
  explicit clicks, and guard against stale responses with a requestId ref.
- Add Vitest coverage for both Copilot and Codex OAuth paths asserting no
  request on mount and the correct account id on click; add Rust unit
  tests for the four model-list payload shapes.
This commit is contained in:
Jason
2026-05-14 15:03:31 +08:00
parent f93b935d5f
commit 73bc4eb65d
7 changed files with 557 additions and 47 deletions
+13
View File
@@ -27,6 +27,19 @@ export async function fetchModelsForConfig(
});
}
/**
* 获取 Codex OAuth (ChatGPT Plus/Pro 反代) 可用模型列表
*
* Codex OAuth 使用 ChatGPT 的 backend-api/codex 端点,不兼容普通 /v1/models。
*/
export async function fetchCodexOauthModels(
accountId?: string | null,
): Promise<FetchedModel[]> {
return invoke("get_codex_oauth_models", {
accountId: accountId || null,
});
}
/**
* 根据错误类型显示对应的 toast 提示
*/