From 71f75f89d609f1774ab0efc7ad6d2c26b6a4ea91 Mon Sep 17 00:00:00 2001 From: Seto Elkahfi Date: Thu, 5 Nov 2026 17:40:18 +0100 Subject: [PATCH] Capitalize sign-in error reasons before reporting them Clients such as Zed prepend their own lead-in ("Sign-in did not complete:"), so embedding the reason in a second sentence read awkwardly. Report the reason as a standalone, capitalized sentence instead. Co-Authored-By: OndeCode v1.1.1-acp --- crates/agent/src/auth.rs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/crates/agent/src/auth.rs b/crates/agent/src/auth.rs index a2b89ca..cc93def 100644 --- a/crates/agent/src/auth.rs +++ b/crates/agent/src/auth.rs @@ -57,7 +57,8 @@ impl AuthProvider for OndeAuth { let flow = browser_auth::begin().map_err(|reason| { error(format!( - "{reason}. Run `{} --setup` in a terminal to paste a key instead.", + "{}. Run `{} --setup` in a terminal to paste a key instead.", + capitalize(&reason), INFO.name )) })?; @@ -78,9 +79,10 @@ impl AuthProvider for OndeAuth { tracing::info!("authenticate: connected {}", describe(&grant)); Ok(()) } + // Clients such as Zed add their own "Sign-in did not complete:" lead-in. Err(reason) => Err(error(format!( - "Sign-in did not complete ({reason}). Try again, or run `{} --setup` in a \ - terminal to paste a key.", + "{}. Try again, or run `{} --setup` in a terminal to paste a key.", + capitalize(&reason), INFO.name ))), } @@ -137,6 +139,15 @@ fn error(message: impl Into) -> agent_client_protocol::Error { agent_client_protocol::Error::new(ErrorCode::InternalError.into(), message.into()) } +/// `text` with its first character uppercased. +fn capitalize(text: &str) -> String { + let mut chars = text.chars(); + match chars.next() { + Some(first) => first.to_uppercase().chain(chars).collect(), + None => String::new(), + } +} + /// Whether the endpoint accepts the key. `GET /models` checks the key without running a model, /// so a model whose upstream is down doesn't make a good key look bad. async fn key_is_valid(config: &LlmConfig) -> bool { @@ -325,6 +336,17 @@ mod tests { assert!(matches!(method, AuthMethod::Agent(_))); } + #[test] + fn capitalize_uppercases_only_the_first_character() { + assert_eq!( + capitalize("the page was not opened"), + "The page was not opened" + ); + assert_eq!(capitalize("Already"), "Already"); + assert_eq!(capitalize("élan"), "Élan"); + assert_eq!(capitalize(""), ""); + } + #[test] fn the_default_model_is_kept_when_the_app_allows_it_else_the_first_allowed() { let default = INFO.env.default_model;