@@ -12,10 +12,8 @@ use codex_core::RolloutRecorder;
12
12
use codex_core:: config:: Config ;
13
13
use codex_core:: config:: ConfigOverrides ;
14
14
use codex_core:: config:: ConfigToml ;
15
- use codex_core:: config:: GPT_5_CODEX_MEDIUM_MODEL ;
16
15
use codex_core:: config:: find_codex_home;
17
16
use codex_core:: config:: load_config_as_toml_with_cli_overrides;
18
- use codex_core:: config:: persist_model_selection;
19
17
use codex_core:: find_conversation_path_by_id_str;
20
18
use codex_core:: protocol:: AskForApproval ;
21
19
use codex_core:: protocol:: SandboxPolicy ;
@@ -54,7 +52,6 @@ pub mod live_wrap;
54
52
mod markdown;
55
53
mod markdown_render;
56
54
mod markdown_stream;
57
- mod new_model_popup;
58
55
pub mod onboarding;
59
56
mod pager_overlay;
60
57
mod render;
@@ -79,14 +76,11 @@ pub mod test_backend;
79
76
#[ cfg( not( debug_assertions) ) ]
80
77
mod updates;
81
78
82
- use crate :: new_model_popup:: ModelUpgradeDecision ;
83
- use crate :: new_model_popup:: run_model_upgrade_popup;
84
79
use crate :: onboarding:: TrustDirectorySelection ;
85
80
use crate :: onboarding:: onboarding_screen:: OnboardingScreenArgs ;
86
81
use crate :: onboarding:: onboarding_screen:: run_onboarding_app;
87
82
use crate :: tui:: Tui ;
88
83
pub use cli:: Cli ;
89
- use codex_core:: internal_storage:: InternalStorage ;
90
84
91
85
// (tests access modules directly within the crate)
92
86
@@ -204,8 +198,6 @@ pub async fn run_main(
204
198
cli_profile_override,
205
199
) ?;
206
200
207
- let internal_storage = InternalStorage :: load ( & config. codex_home ) ;
208
-
209
201
let log_dir = codex_core:: config:: log_dir ( & config) ?;
210
202
std:: fs:: create_dir_all ( & log_dir) ?;
211
203
// Open (or create) your log file, appending to it.
@@ -249,21 +241,14 @@ pub async fn run_main(
249
241
250
242
let _ = tracing_subscriber:: registry ( ) . with ( file_layer) . try_init ( ) ;
251
243
252
- run_ratatui_app (
253
- cli,
254
- config,
255
- internal_storage,
256
- active_profile,
257
- should_show_trust_screen,
258
- )
259
- . await
260
- . map_err ( |err| std:: io:: Error :: other ( err. to_string ( ) ) )
244
+ run_ratatui_app ( cli, config, active_profile, should_show_trust_screen)
245
+ . await
246
+ . map_err ( |err| std:: io:: Error :: other ( err. to_string ( ) ) )
261
247
}
262
248
263
249
async fn run_ratatui_app (
264
250
cli : Cli ,
265
251
config : Config ,
266
- mut internal_storage : InternalStorage ,
267
252
active_profile : Option < String > ,
268
253
should_show_trust_screen : bool ,
269
254
) -> color_eyre:: Result < AppExitInfo > {
@@ -389,36 +374,6 @@ async fn run_ratatui_app(
389
374
resume_picker:: ResumeSelection :: StartFresh
390
375
} ;
391
376
392
- if should_show_model_rollout_prompt (
393
- & cli,
394
- & config,
395
- active_profile. as_deref ( ) ,
396
- internal_storage. gpt_5_codex_model_prompt_seen ,
397
- ) {
398
- internal_storage. gpt_5_codex_model_prompt_seen = true ;
399
- if let Err ( e) = internal_storage. persist ( ) . await {
400
- error ! ( "Failed to persist internal storage: {e:?}" ) ;
401
- }
402
-
403
- let upgrade_decision = run_model_upgrade_popup ( & mut tui) . await ?;
404
- let switch_to_new_model = upgrade_decision == ModelUpgradeDecision :: Switch ;
405
-
406
- if switch_to_new_model {
407
- config. model = GPT_5_CODEX_MEDIUM_MODEL . to_owned ( ) ;
408
- config. model_reasoning_effort = None ;
409
- if let Err ( e) = persist_model_selection (
410
- & config. codex_home ,
411
- active_profile. as_deref ( ) ,
412
- & config. model ,
413
- config. model_reasoning_effort ,
414
- )
415
- . await
416
- {
417
- error ! ( "Failed to persist model selection: {e:?}" ) ;
418
- }
419
- }
420
- }
421
-
422
377
let Cli { prompt, images, .. } = cli;
423
378
424
379
let app_result = App :: run (
@@ -532,140 +487,3 @@ fn should_show_login_screen(login_status: LoginStatus, config: &Config) -> bool
532
487
533
488
login_status == LoginStatus :: NotAuthenticated
534
489
}
535
-
536
- fn should_show_model_rollout_prompt (
537
- cli : & Cli ,
538
- config : & Config ,
539
- active_profile : Option < & str > ,
540
- gpt_5_codex_model_prompt_seen : bool ,
541
- ) -> bool {
542
- let login_status = get_login_status ( config) ;
543
-
544
- active_profile. is_none ( )
545
- && cli. model . is_none ( )
546
- && !gpt_5_codex_model_prompt_seen
547
- && config. model_provider . requires_openai_auth
548
- && matches ! ( login_status, LoginStatus :: AuthMode ( AuthMode :: ChatGPT ) )
549
- && !cli. oss
550
- }
551
-
552
- #[ cfg( test) ]
553
- mod tests {
554
- use super :: * ;
555
- use clap:: Parser ;
556
- use codex_core:: auth:: AuthDotJson ;
557
- use codex_core:: auth:: get_auth_file;
558
- use codex_core:: auth:: login_with_api_key;
559
- use codex_core:: auth:: write_auth_json;
560
- use codex_core:: token_data:: IdTokenInfo ;
561
- use codex_core:: token_data:: TokenData ;
562
- use std:: sync:: atomic:: AtomicUsize ;
563
- use std:: sync:: atomic:: Ordering ;
564
-
565
- fn get_next_codex_home ( ) -> PathBuf {
566
- static NEXT_CODEX_HOME_ID : AtomicUsize = AtomicUsize :: new ( 0 ) ;
567
- let mut codex_home = std:: env:: temp_dir ( ) ;
568
- let unique_suffix = format ! (
569
- "codex_tui_test_{}_{}" ,
570
- std:: process:: id( ) ,
571
- NEXT_CODEX_HOME_ID . fetch_add( 1 , Ordering :: Relaxed )
572
- ) ;
573
- codex_home. push ( unique_suffix) ;
574
- codex_home
575
- }
576
-
577
- fn make_config ( ) -> Config {
578
- // Create a unique CODEX_HOME per test to isolate auth.json writes.
579
- let codex_home = get_next_codex_home ( ) ;
580
- std:: fs:: create_dir_all ( & codex_home) . expect ( "create unique CODEX_HOME" ) ;
581
- Config :: load_from_base_config_with_overrides (
582
- ConfigToml :: default ( ) ,
583
- ConfigOverrides :: default ( ) ,
584
- codex_home,
585
- )
586
- . expect ( "load default config" )
587
- }
588
-
589
- /// Test helper to write an `auth.json` with the requested auth mode into the
590
- /// provided CODEX_HOME directory. This ensures `get_login_status()` reads the
591
- /// intended mode deterministically.
592
- fn set_auth_method ( codex_home : & std:: path:: Path , mode : AuthMode ) {
593
- match mode {
594
- AuthMode :: ApiKey => {
595
- login_with_api_key ( codex_home, "sk-test-key" ) . expect ( "write api key auth.json" ) ;
596
- }
597
- AuthMode :: ChatGPT => {
598
- // Minimal valid JWT payload: header.payload.signature (all base64url, no padding)
599
- const FAKE_JWT : & str = "eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.e30.c2ln" ; // {"alg":"none","typ":"JWT"}.{}."sig"
600
- let mut id_info = IdTokenInfo :: default ( ) ;
601
- id_info. raw_jwt = FAKE_JWT . to_string ( ) ;
602
- let auth = AuthDotJson {
603
- openai_api_key : None ,
604
- tokens : Some ( TokenData {
605
- id_token : id_info,
606
- access_token : "access-token" . to_string ( ) ,
607
- refresh_token : "refresh-token" . to_string ( ) ,
608
- account_id : None ,
609
- } ) ,
610
- last_refresh : None ,
611
- } ;
612
- let file = get_auth_file ( codex_home) ;
613
- write_auth_json ( & file, & auth) . expect ( "write chatgpt auth.json" ) ;
614
- }
615
- }
616
- }
617
-
618
- #[ test]
619
- fn shows_login_when_not_authenticated ( ) {
620
- let cfg = make_config ( ) ;
621
- assert ! ( should_show_login_screen(
622
- LoginStatus :: NotAuthenticated ,
623
- & cfg
624
- ) ) ;
625
- }
626
-
627
- #[ test]
628
- fn shows_model_rollout_prompt_for_default_model ( ) {
629
- let cli = Cli :: parse_from ( [ "codex" ] ) ;
630
- let cfg = make_config ( ) ;
631
- set_auth_method ( & cfg. codex_home , AuthMode :: ChatGPT ) ;
632
- assert ! ( should_show_model_rollout_prompt( & cli, & cfg, None , false , ) ) ;
633
- }
634
-
635
- #[ test]
636
- fn hides_model_rollout_prompt_when_api_auth_mode ( ) {
637
- let cli = Cli :: parse_from ( [ "codex" ] ) ;
638
- let cfg = make_config ( ) ;
639
- set_auth_method ( & cfg. codex_home , AuthMode :: ApiKey ) ;
640
- assert ! ( !should_show_model_rollout_prompt( & cli, & cfg, None , false , ) ) ;
641
- }
642
-
643
- #[ test]
644
- fn hides_model_rollout_prompt_when_marked_seen ( ) {
645
- let cli = Cli :: parse_from ( [ "codex" ] ) ;
646
- let cfg = make_config ( ) ;
647
- set_auth_method ( & cfg. codex_home , AuthMode :: ChatGPT ) ;
648
- assert ! ( !should_show_model_rollout_prompt( & cli, & cfg, None , true , ) ) ;
649
- }
650
-
651
- #[ test]
652
- fn hides_model_rollout_prompt_when_cli_overrides_model ( ) {
653
- let cli = Cli :: parse_from ( [ "codex" , "--model" , "gpt-4.1" ] ) ;
654
- let cfg = make_config ( ) ;
655
- set_auth_method ( & cfg. codex_home , AuthMode :: ChatGPT ) ;
656
- assert ! ( !should_show_model_rollout_prompt( & cli, & cfg, None , false , ) ) ;
657
- }
658
-
659
- #[ test]
660
- fn hides_model_rollout_prompt_when_profile_active ( ) {
661
- let cli = Cli :: parse_from ( [ "codex" ] ) ;
662
- let cfg = make_config ( ) ;
663
- set_auth_method ( & cfg. codex_home , AuthMode :: ChatGPT ) ;
664
- assert ! ( !should_show_model_rollout_prompt(
665
- & cli,
666
- & cfg,
667
- Some ( "gpt5" ) ,
668
- false ,
669
- ) ) ;
670
- }
671
- }
0 commit comments