Lightweight coding agent that runs in your terminal
Rust
Support exiting from the login menu (#6419)
Eric Trautb46012e48382
diff --git a/codex-rs/tui/src/lib.rs b/codex-rs/tui/src/lib.rsindex 99312ec198..9efa5eac5b 100644--- a/codex-rs/tui/src/lib.rs+++ b/codex-rs/tui/src/lib.rs@@ -353,6 +353,16 @@ async fn run_ratatui_app(&mut tui,).await?;+ if onboarding_result.should_exit {+ restore();+ session_log::log_session_end();+ let _ = tui.terminal.clear();+ return Ok(AppExitInfo {+ token_usage: codex_core::protocol::TokenUsage::default(),+ conversation_id: None,+ update_action: None,+ });+ }if onboarding_result.windows_install_selected {restore();session_log::log_session_end();diff --git a/codex-rs/tui/src/onboarding/onboarding_screen.rs b/codex-rs/tui/src/onboarding/onboarding_screen.rsindex 6a1a9ff5d9..02c7be7ad2 100644--- a/codex-rs/tui/src/onboarding/onboarding_screen.rs+++ b/codex-rs/tui/src/onboarding/onboarding_screen.rs@@ -57,6 +57,7 @@ pub(crate) struct OnboardingScreen {steps: Vec<Step>,is_done: bool,windows_install_selected: bool,+ should_exit: bool,}pub(crate) struct OnboardingScreenArgs {@@ -71,6 +72,7 @@ pub(crate) struct OnboardingScreenArgs {pub(crate) struct OnboardingResult {pub directory_trust_decision: Option<TrustDirectorySelection>,pub windows_install_selected: bool,+ pub should_exit: bool,}impl OnboardingScreen {@@ -137,6 +139,7 @@ impl OnboardingScreen {steps,is_done: false,windows_install_selected: false,+ should_exit: false,}}@@ -200,6 +203,10 @@ impl OnboardingScreen {pub fn windows_install_selected(&self) -> bool {self.windows_install_selected}++ pub fn should_exit(&self) -> bool {+ self.should_exit+ }}impl KeyboardHandler for OnboardingScreen {@@ -222,9 +229,12 @@ impl KeyboardHandler for OnboardingScreen {kind: KeyEventKind::Press,..} => {- if !self.is_auth_in_progress() {- self.is_done = true;+ if self.is_auth_in_progress() {+ // If the user cancels the auth menu, exit the app rather than+ // leave the user at a prompt in an unauthed state.+ self.should_exit = true;}+ self.is_done = true;}_ => {if let Some(Step::Welcome(widget)) = self@@ -442,5 +452,6 @@ pub(crate) async fn run_onboarding_app(Ok(OnboardingResult {directory_trust_decision: onboarding_screen.directory_trust_decision(),windows_install_selected: onboarding_screen.windows_install_selected(),+ should_exit: onboarding_screen.should_exit(),})}