Support exiting from the login menu (#6419)
I recently fixed a bug in [this PR](https://github.com/openai/codex/pull/6285) that prevented Ctrl+C from dismissing the login menu in the TUI and leaving the user unauthed. A [user pointed out](https://github.com/openai/codex/issues/6418) that this makes Ctrl+C can no longer be used to exit the app. This PR changes the behavior so we exit the app rather than ignoring the Ctrl+C.
This commit is contained in:
@@ -353,6 +353,16 @@ async fn run_ratatui_app(
|
|||||||
&mut tui,
|
&mut tui,
|
||||||
)
|
)
|
||||||
.await?;
|
.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 {
|
if onboarding_result.windows_install_selected {
|
||||||
restore();
|
restore();
|
||||||
session_log::log_session_end();
|
session_log::log_session_end();
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ pub(crate) struct OnboardingScreen {
|
|||||||
steps: Vec<Step>,
|
steps: Vec<Step>,
|
||||||
is_done: bool,
|
is_done: bool,
|
||||||
windows_install_selected: bool,
|
windows_install_selected: bool,
|
||||||
|
should_exit: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct OnboardingScreenArgs {
|
pub(crate) struct OnboardingScreenArgs {
|
||||||
@@ -71,6 +72,7 @@ pub(crate) struct OnboardingScreenArgs {
|
|||||||
pub(crate) struct OnboardingResult {
|
pub(crate) struct OnboardingResult {
|
||||||
pub directory_trust_decision: Option<TrustDirectorySelection>,
|
pub directory_trust_decision: Option<TrustDirectorySelection>,
|
||||||
pub windows_install_selected: bool,
|
pub windows_install_selected: bool,
|
||||||
|
pub should_exit: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OnboardingScreen {
|
impl OnboardingScreen {
|
||||||
@@ -137,6 +139,7 @@ impl OnboardingScreen {
|
|||||||
steps,
|
steps,
|
||||||
is_done: false,
|
is_done: false,
|
||||||
windows_install_selected: false,
|
windows_install_selected: false,
|
||||||
|
should_exit: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,6 +203,10 @@ impl OnboardingScreen {
|
|||||||
pub fn windows_install_selected(&self) -> bool {
|
pub fn windows_install_selected(&self) -> bool {
|
||||||
self.windows_install_selected
|
self.windows_install_selected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn should_exit(&self) -> bool {
|
||||||
|
self.should_exit
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KeyboardHandler for OnboardingScreen {
|
impl KeyboardHandler for OnboardingScreen {
|
||||||
@@ -222,9 +229,12 @@ impl KeyboardHandler for OnboardingScreen {
|
|||||||
kind: KeyEventKind::Press,
|
kind: KeyEventKind::Press,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if !self.is_auth_in_progress() {
|
if self.is_auth_in_progress() {
|
||||||
self.is_done = true;
|
// 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
|
if let Some(Step::Welcome(widget)) = self
|
||||||
@@ -442,5 +452,6 @@ pub(crate) async fn run_onboarding_app(
|
|||||||
Ok(OnboardingResult {
|
Ok(OnboardingResult {
|
||||||
directory_trust_decision: onboarding_screen.directory_trust_decision(),
|
directory_trust_decision: onboarding_screen.directory_trust_decision(),
|
||||||
windows_install_selected: onboarding_screen.windows_install_selected(),
|
windows_install_selected: onboarding_screen.windows_install_selected(),
|
||||||
|
should_exit: onboarding_screen.should_exit(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user