From 2aad3a13b832f6ffe6a841ac340812f1f9da5035 Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Mon, 18 Aug 2025 18:15:50 -0700 Subject: [PATCH] fix: remove shutdown_flag param to run_login_server() (#2399) In practice, this was always passed in as `None`, so eliminated the param and updated all the call sites. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2399). * __->__ #2399 * #2398 * #2396 * #2395 * #2394 * #2393 * #2389 --- codex-rs/cli/src/login.rs | 2 +- codex-rs/login/src/server.rs | 7 ++----- codex-rs/login/tests/login_server_e2e.rs | 4 ++-- codex-rs/mcp-server/src/codex_message_processor.rs | 2 +- codex-rs/tui/src/onboarding/auth.rs | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/codex-rs/cli/src/login.rs b/codex-rs/cli/src/login.rs index fc40a027..36bbf220 100644 --- a/codex-rs/cli/src/login.rs +++ b/codex-rs/cli/src/login.rs @@ -14,7 +14,7 @@ use std::path::PathBuf; pub async fn login_with_chatgpt(codex_home: PathBuf) -> std::io::Result<()> { let opts = ServerOptions::new(codex_home, CLIENT_ID.to_string()); - let server = run_login_server(opts, None)?; + let server = run_login_server(opts)?; eprintln!( "Starting local login server on http://localhost:{}.\nIf your browser did not open, navigate to this URL to authenticate:\n\n{}", diff --git a/codex-rs/login/src/server.rs b/codex-rs/login/src/server.rs index e8af09fb..32229484 100644 --- a/codex-rs/login/src/server.rs +++ b/codex-rs/login/src/server.rs @@ -77,10 +77,7 @@ impl ShutdownHandle { } } -pub fn run_login_server( - opts: ServerOptions, - shutdown_flag: Option>, -) -> io::Result { +pub fn run_login_server(opts: ServerOptions) -> io::Result { let pkce = generate_pkce(); let state = opts.force_state.clone().unwrap_or_else(generate_state); @@ -118,7 +115,7 @@ pub fn run_login_server( }) }; - let shutdown_notify = shutdown_flag.unwrap_or_else(|| Arc::new(tokio::sync::Notify::new())); + let shutdown_notify = Arc::new(tokio::sync::Notify::new()); let server_handle = { let shutdown_notify = shutdown_notify.clone(); let server = server.clone(); diff --git a/codex-rs/login/tests/login_server_e2e.rs b/codex-rs/login/tests/login_server_e2e.rs index ef387f57..ceb0a947 100644 --- a/codex-rs/login/tests/login_server_e2e.rs +++ b/codex-rs/login/tests/login_server_e2e.rs @@ -101,7 +101,7 @@ async fn end_to_end_login_flow_persists_auth_json() { open_browser: false, force_state: Some(state), }; - let server = run_login_server(opts, None).unwrap(); + let server = run_login_server(opts).unwrap(); let login_port = server.actual_port; // Simulate browser callback, and follow redirect to /success @@ -159,7 +159,7 @@ async fn creates_missing_codex_home_dir() { open_browser: false, force_state: Some(state), }; - let server = run_login_server(opts, None).unwrap(); + let server = run_login_server(opts).unwrap(); let login_port = server.actual_port; let client = reqwest::Client::new(); diff --git a/codex-rs/mcp-server/src/codex_message_processor.rs b/codex-rs/mcp-server/src/codex_message_processor.rs index 4f2b3bb6..1decf11d 100644 --- a/codex-rs/mcp-server/src/codex_message_processor.rs +++ b/codex-rs/mcp-server/src/codex_message_processor.rs @@ -154,7 +154,7 @@ impl CodexMessageProcessor { Error(JSONRPCErrorError), } - let reply = match run_login_server(opts, None) { + let reply = match run_login_server(opts) { Ok(server) => { let login_id = Uuid::new_v4(); let shutdown_handle = server.cancel_handle(); diff --git a/codex-rs/tui/src/onboarding/auth.rs b/codex-rs/tui/src/onboarding/auth.rs index 490f85bf..facd06c6 100644 --- a/codex-rs/tui/src/onboarding/auth.rs +++ b/codex-rs/tui/src/onboarding/auth.rs @@ -281,7 +281,7 @@ impl AuthModeWidget { fn start_chatgpt_login(&mut self) { self.error = None; let opts = ServerOptions::new(self.codex_home.clone(), CLIENT_ID.to_string()); - let server = run_login_server(opts, None); + let server = run_login_server(opts); match server { Ok(child) => { let auth_url = child.auth_url.clone();