From e5027d326ee8216a50c7e0c9262a8ba8dd1a3941 Mon Sep 17 00:00:00 2001 From: Chadi Shwada Date: Sat, 16 May 2026 22:48:36 +0200 Subject: [PATCH] chore: improve Windows OAuth and test ergonomics --- .gitignore | 1 + crates/sinew-app/src/bash.rs | 7 ++++++- src-tauri/src/providers.rs | 17 ++++++++++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 31efcc62..47632749 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /dist /node_modules /src-tauri/binaries/rg-* +/src-tauri/gen/schemas/windows-schema.json /.history /.sinew/ .DS_Store diff --git a/crates/sinew-app/src/bash.rs b/crates/sinew-app/src/bash.rs index 8cf24e13..eb9b7ce4 100644 --- a/crates/sinew-app/src/bash.rs +++ b/crates/sinew-app/src/bash.rs @@ -819,9 +819,14 @@ mod tests { let root = temp_workspace("interactive_session_accepts_input"); let tool = BashTool::new(&root); + #[cfg(windows)] + let command = "[Console]::Write('Name: '); $name = [Console]::In.ReadLine(); [Console]::WriteLine(\"Hello $name\")"; + #[cfg(not(windows))] + let command = "printf 'Name: '; read name; printf 'Hello %s\\n' \"$name\""; + let started = tool .run(json!({ - "command": "printf 'Name: '; read name; printf 'Hello %s\\n' \"$name\"", + "command": command, "yield_time_ms": 500 })) .await; diff --git a/src-tauri/src/providers.rs b/src-tauri/src/providers.rs index 5dc6893b..2a33464f 100644 --- a/src-tauri/src/providers.rs +++ b/src-tauri/src/providers.rs @@ -410,9 +410,20 @@ pub(super) async fn handle_openai_oauth_request( pub(super) async fn bind_anthropic_oauth_listener() -> Result { const CALLBACK_PORT: u16 = 53692; - tokio::net::TcpListener::bind(("127.0.0.1", CALLBACK_PORT)) - .await - .context("unable to bind Anthropic OAuth callback port 53692") + match tokio::net::TcpListener::bind(("127.0.0.1", CALLBACK_PORT)).await { + Ok(listener) => Ok(listener), + Err(err) => { + let mut message = + format!("unable to bind Anthropic OAuth callback port {CALLBACK_PORT}"); + #[cfg(target_os = "windows")] + if err.raw_os_error() == Some(10013) { + message.push_str( + "; Windows may have reserved this port. Check excluded TCP port ranges or restart WinNAT/HNS before trying again", + ); + } + Err(err).with_context(|| message) + } + } } pub(super) async fn run_anthropic_oauth_server(