Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix(agent-cli): cancel pending account sign-in

thinhlpga161c7d9b845
diff --git a/src-tauri/src/core/cli/tui.rs b/src-tauri/src/core/cli/tui.rs
index a38ca9a5e..b54f43aed 100644
--- a/src-tauri/src/core/cli/tui.rs
+++ b/src-tauri/src/core/cli/tui.rs
@@ -6981,6 +6981,12 @@ async fn handle_key(
match key.code {
KeyCode::Esc => {
+ if app.account_login_active {
+ app.account_login_active = false;
+ app.account_login_submit = None;
+ app.note("account sign-in cancelled");
+ return;
+ }
// Esc cancels a run or clears typed input; it never quits (that's
// Ctrl-D / Ctrl-C when idle), so a stray Esc can't close the app.
if app.status == Status::Running {
@@ -14846,6 +14852,19 @@ mod tests {
assert!(app.login_submit.is_none());
}
+ #[tokio::test]
+ async fn esc_cancels_a_pending_account_sign_in() {
+ let mut app = test_app();
+ super::open_account_login(&mut app, "openai");
+ assert!(app.account_login_active);
+ assert!(app.account_login_submit.is_some());
+
+ press(&mut app, KeyCode::Esc, KeyModifiers::NONE).await;
+
+ assert!(!app.account_login_active);
+ assert!(app.account_login_submit.is_none());
+ }
+
#[tokio::test]
async fn login_stays_cancellable_while_verifying() {
let mut app = test_app();