fix(auth): isolate chatgptAuthTokens concept to auth manager and app-server (#10423)

So that the rest of the codebase (like TUI) don't need to be concerned
whether ChatGPT auth was handled by Codex itself or passed in via
app-server's external auth mode.
This commit is contained in:
Owen Lin
2026-02-05 10:46:06 -08:00
committed by GitHub
parent 5c0fd62ff1
commit 3582b74d01
20 changed files with 92 additions and 71 deletions

View File

@@ -3,7 +3,7 @@ use crate::text_formatting;
use chrono::DateTime;
use chrono::Local;
use codex_core::AuthManager;
use codex_core::CodexAuth;
use codex_core::auth::AuthMode as CoreAuthMode;
use codex_core::config::Config;
use codex_core::project_doc::discover_project_doc_paths;
use codex_protocol::account::PlanType;
@@ -90,15 +90,15 @@ pub(crate) fn compose_account_display(
) -> Option<StatusAccountDisplay> {
let auth = auth_manager.auth_cached()?;
match auth {
CodexAuth::Chatgpt(_) | CodexAuth::ChatgptAuthTokens(_) => {
match auth.auth_mode() {
CoreAuthMode::ApiKey => Some(StatusAccountDisplay::ApiKey),
CoreAuthMode::Chatgpt => {
let email = auth.get_account_email();
let plan = plan
.map(|plan_type| title_case(format!("{plan_type:?}").as_str()))
.or_else(|| Some("Unknown".to_string()));
Some(StatusAccountDisplay::ChatGpt { email, plan })
}
CodexAuth::ApiKey(_) => Some(StatusAccountDisplay::ApiKey),
}
}