From 58e2e9a2bb797025a6aa1cc4d484e8fbf8d22c4a Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Wed, 18 Mar 2026 16:44:17 -0600 Subject: [PATCH] codex: fix follow-up PR blockers (#15106) --- codex-rs/app-server-client/src/lib.rs | 30 ++++++++++++++----- codex-rs/exec/src/lib.rs | 1 - .../src/app/app_server_adapter.rs | 5 +++- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/codex-rs/app-server-client/src/lib.rs b/codex-rs/app-server-client/src/lib.rs index 7ea9552c41..e3724d5c0a 100644 --- a/codex-rs/app-server-client/src/lib.rs +++ b/codex-rs/app-server-client/src/lib.rs @@ -335,14 +335,6 @@ impl ChatgptAuthRefreshContext { "local ChatGPT auth must use workspace {expected_workspace}, but found {chatgpt_account_id:?}" )); } - if let Some(previous_account_id) = params.previous_account_id.as_deref() - && previous_account_id != chatgpt_account_id - { - return Err(format!( - "local ChatGPT auth refresh account mismatch: expected `{previous_account_id}`, got `{chatgpt_account_id}`" - )); - } - Ok(ChatgptAuthTokensRefreshResponse { access_token, chatgpt_account_id, @@ -1702,6 +1694,28 @@ mod tests { assert!(!response.access_token.is_empty()); } + #[test] + fn chatgpt_auth_refresh_context_ignores_previous_workspace_mismatch() { + let codex_home = TestCodexHome::new(); + write_local_chatgpt_auth(&codex_home.path); + let context = ChatgptAuthRefreshContext { + codex_home: codex_home.path.clone(), + auth_credentials_store_mode: AuthCredentialsStoreMode::File, + forced_chatgpt_workspace_id: Some("workspace-1".to_string()), + }; + + let response = context + .resolve_refresh_response(&ChatgptAuthTokensRefreshParams { + reason: ChatgptAuthTokensRefreshReason::Unauthorized, + previous_account_id: Some("workspace-2".to_string()), + }) + .expect("stale previous workspace should not fail local auth refresh"); + + assert_eq!(response.chatgpt_account_id, "workspace-1"); + assert_eq!(response.chatgpt_plan_type.as_deref(), Some("business")); + assert!(!response.access_token.is_empty()); + } + #[test] fn chatgpt_auth_refresh_context_rejects_workspace_mismatch() { let codex_home = TestCodexHome::new(); diff --git a/codex-rs/exec/src/lib.rs b/codex-rs/exec/src/lib.rs index 09466f5ad2..92a6e5e858 100644 --- a/codex-rs/exec/src/lib.rs +++ b/codex-rs/exec/src/lib.rs @@ -1012,7 +1012,6 @@ fn all_thread_source_kinds() -> Vec { ThreadSourceKind::VsCode, ThreadSourceKind::Exec, ThreadSourceKind::AppServer, - ThreadSourceKind::Custom, ThreadSourceKind::SubAgent, ThreadSourceKind::SubAgentReview, ThreadSourceKind::SubAgentCompact, diff --git a/codex-rs/tui_app_server/src/app/app_server_adapter.rs b/codex-rs/tui_app_server/src/app/app_server_adapter.rs index 952a9bf7b8..701a77b7be 100644 --- a/codex-rs/tui_app_server/src/app/app_server_adapter.rs +++ b/codex-rs/tui_app_server/src/app/app_server_adapter.rs @@ -975,7 +975,6 @@ fn split_command_string(command: &str) -> Vec { } } -#[cfg(test)] fn app_server_web_search_action_to_core( action: codex_app_server_protocol::WebSearchAction, ) -> Option { @@ -1025,6 +1024,10 @@ mod tests { use codex_app_server_protocol::TurnCompletedNotification; use codex_app_server_protocol::TurnError; use codex_app_server_protocol::TurnStatus; + use codex_core::auth::AuthCredentialsStoreMode; + use codex_core::auth::AuthDotJson; + use codex_core::auth::save_auth; + use codex_core::token_data::TokenData; use codex_protocol::ThreadId; use codex_protocol::items::AgentMessageContent; use codex_protocol::items::AgentMessageItem;