Lightweight coding agent that runs in your terminal
Rust
tui_app_server: open ChatGPT login in the local browser (#15672)
Eric Traut1b86377635ab
diff --git a/codex-rs/tui_app_server/src/onboarding/auth.rs b/codex-rs/tui_app_server/src/onboarding/auth.rsindex 612fdbe2ac..948e0cd9b7 100644--- a/codex-rs/tui_app_server/src/onboarding/auth.rs+++ b/codex-rs/tui_app_server/src/onboarding/auth.rs@@ -771,6 +771,7 @@ impl AuthModeWidget {.await{Ok(LoginAccountResponse::Chatgpt { login_id, auth_url }) => {+ maybe_open_auth_url_in_browser(&request_handle, &auth_url);*error.write().unwrap() = None;*sign_in_state.write().unwrap() =SignInState::ChatGptContinueInBrowser(ContinueInBrowserState {@@ -880,6 +881,16 @@ impl WidgetRef for AuthModeWidget {}}+pub(super) fn maybe_open_auth_url_in_browser(request_handle: &AppServerRequestHandle, url: &str) {+ if !matches!(request_handle, AppServerRequestHandle::InProcess(_)) {+ return;+ }++ if let Err(err) = webbrowser::open(url) {+ tracing::warn!("failed to open browser for login URL: {err}");+ }+}+#[cfg(test)]mod tests {use super::*;diff --git a/codex-rs/tui_app_server/src/onboarding/auth/headless_chatgpt_login.rs b/codex-rs/tui_app_server/src/onboarding/auth/headless_chatgpt_login.rsindex 33afe740b8..d0834fe166 100644--- a/codex-rs/tui_app_server/src/onboarding/auth/headless_chatgpt_login.rs+++ b/codex-rs/tui_app_server/src/onboarding/auth/headless_chatgpt_login.rs@@ -29,6 +29,7 @@ use super::ContinueInBrowserState;use super::ContinueWithDeviceCodeState;use super::SignInState;use super::mark_url_hyperlink;+use super::maybe_open_auth_url_in_browser;use super::onboarding_request_id;pub(super) fn start_headless_chatgpt_login(widget: &mut AuthModeWidget) {@@ -289,6 +290,7 @@ async fn fallback_to_browser_login(.await{Ok(LoginAccountResponse::Chatgpt { login_id, auth_url }) => {+ maybe_open_auth_url_in_browser(&request_handle, &auth_url);*error.write().unwrap() = None;let _updated = set_device_code_state_for_active_attempt(&sign_in_state,