File tree Expand file tree Collapse file tree 5 files changed +16
-9
lines changed
Expand file tree Collapse file tree 5 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -819,6 +819,7 @@ mod tests {
819819 base_url : "https://example.test" . to_string ( ) ,
820820 http : reqwest:: Client :: new ( ) ,
821821 bearer_token : None ,
822+ auth_headers : HeaderMap :: new ( ) ,
822823 user_agent : None ,
823824 chatgpt_account_id : None ,
824825 chatgpt_account_is_fedramp : false ,
@@ -833,6 +834,7 @@ mod tests {
833834 base_url : "https://chatgpt.com/backend-api" . to_string ( ) ,
834835 http : reqwest:: Client :: new ( ) ,
835836 bearer_token : None ,
837+ auth_headers : HeaderMap :: new ( ) ,
836838 user_agent : None ,
837839 chatgpt_account_id : None ,
838840 chatgpt_account_is_fedramp : false ,
Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ pub(crate) async fn chatgpt_get_request_with_timeout<T: DeserializeOwned>(
3030 auth. uses_codex_backend( ) ,
3131 "ChatGPT backend requests require Codex backend auth"
3232 ) ;
33+ let _account_id = auth. get_account_id ( ) . ok_or_else ( || {
34+ anyhow:: anyhow!( "ChatGPT account ID not available, please re-run `codex login`" )
35+ } ) ?;
3336
3437 // Make direct HTTP request to ChatGPT backend API with the token
3538 let client = create_client ( ) ;
Original file line number Diff line number Diff line change @@ -3,10 +3,7 @@ use codex_model_provider::SharedModelProvider;
33use codex_model_provider:: create_model_provider;
44
55pub ( super ) fn image_generation_tool_auth_allowed ( auth_manager : Option < & AuthManager > ) -> bool {
6- auth_manager
7- . and_then ( AuthManager :: auth_cached)
8- . as_ref ( )
9- . is_some_and ( CodexAuth :: uses_codex_backend)
6+ auth_manager. is_some_and ( AuthManager :: current_auth_uses_codex_backend)
107}
118
129#[ derive( Clone , Debug ) ]
@@ -86,9 +83,7 @@ impl TurnContext {
8683 let uses_codex_backend = self
8784 . auth_manager
8885 . as_deref ( )
89- . and_then ( AuthManager :: auth_cached)
90- . as_ref ( )
91- . is_some_and ( CodexAuth :: uses_codex_backend) ;
86+ . is_some_and ( AuthManager :: current_auth_uses_codex_backend) ;
9287 self . features . apps_enabled_for_auth ( uses_codex_backend)
9388 }
9489
Original file line number Diff line number Diff line change @@ -1723,6 +1723,13 @@ impl AuthManager {
17231723 self . auth_cached ( ) . as_ref ( ) . map ( CodexAuth :: auth_mode)
17241724 }
17251725
1726+ pub fn current_auth_uses_codex_backend ( & self ) -> bool {
1727+ matches ! (
1728+ self . auth_mode( ) ,
1729+ Some ( AuthMode :: Chatgpt | AuthMode :: ChatgptAuthTokens | AuthMode :: AgentIdentity )
1730+ )
1731+ }
1732+
17261733 fn is_stale_for_proactive_refresh ( auth : & CodexAuth ) -> bool {
17271734 let chatgpt_auth = match auth {
17281735 CodexAuth :: Chatgpt ( chatgpt_auth) => chatgpt_auth,
Original file line number Diff line number Diff line change @@ -540,8 +540,8 @@ impl ModelsManager {
540540 let uses_codex_backend = self
541541 . provider
542542 . auth_manager ( )
543- . and_then ( |auth_manager| auth_manager . auth_cached ( ) )
544- . is_some_and ( |auth| auth . uses_codex_backend ( ) ) ;
543+ . as_deref ( )
544+ . is_some_and ( AuthManager :: current_auth_uses_codex_backend ) ;
545545 presets = ModelPreset :: filter_by_auth ( presets, uses_codex_backend) ;
546546
547547 ModelPreset :: mark_default_by_picker_visibility ( & mut presets) ;
You can’t perform that action at this time.
0 commit comments