From ea3eed3e1eca3ea8e792c13915178d97222008b5 Mon Sep 17 00:00:00 2001 From: Val Alexander <68980965+BunsDev@users.noreply.github.com> Date: Sat, 27 Jun 2026 19:01:36 -0500 Subject: [PATCH 1/2] fix: stabilize idle timeout sender tests --- app/src/ai/agent_sdk/driver_tests.rs | 29 +++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/app/src/ai/agent_sdk/driver_tests.rs b/app/src/ai/agent_sdk/driver_tests.rs index ae36cf4a..aa136d93 100644 --- a/app/src/ai/agent_sdk/driver_tests.rs +++ b/app/src/ai/agent_sdk/driver_tests.rs @@ -1,4 +1,9 @@ -use std::{collections::HashMap, ffi::OsString, sync::Arc, time::Duration}; +use std::{ + collections::HashMap, + ffi::OsString, + sync::Arc, + time::{Duration, Instant}, +}; use futures::channel::oneshot; use warp_cli::agent::Harness; @@ -118,6 +123,22 @@ fn test_normalize_sse_server_with_headers() { // ── IdleTimeoutSender tests ────────────────────────────────────────────────────── +fn recv_within(rx: &mut oneshot::Receiver, timeout: Duration) -> Option { + let started_at = Instant::now(); + + loop { + if let Some(value) = rx.try_recv().unwrap() { + return Some(value); + } + + if started_at.elapsed() >= timeout { + return None; + } + + std::thread::sleep(Duration::from_millis(10)); + } +} + #[test] fn idle_timeout_sender_send_now_delivers_value() { let (tx, mut rx) = oneshot::channel::(); @@ -144,8 +165,7 @@ fn idle_timeout_sender_send_after_delivers_after_timeout() { // Not yet delivered. assert_eq!(rx.try_recv().unwrap(), None); - std::thread::sleep(Duration::from_millis(100)); - assert_eq!(rx.try_recv().unwrap(), Some(99)); + assert_eq!(recv_within(&mut rx, Duration::from_secs(1)), Some(99)); } #[test] @@ -180,8 +200,7 @@ fn idle_timeout_sender_later_send_after_supersedes_earlier() { // Second timer: short timeout. The first is implicitly cancelled. idle_timeout.end_run_after(Duration::from_millis(50), 2); - std::thread::sleep(Duration::from_millis(100)); - assert_eq!(rx.try_recv().unwrap(), Some(2)); + assert_eq!(recv_within(&mut rx, Duration::from_secs(1)), Some(2)); } #[test] From 3925c9c0e966a1677ed645448d36ea6ca94703d2 Mon Sep 17 00:00:00 2001 From: Val Alexander <68980965+BunsDev@users.noreply.github.com> Date: Sun, 28 Jun 2026 04:56:16 -0500 Subject: [PATCH 2/2] fix(test): use instant::Instant in idle timeout tests for clippy CI's `clippy::disallowed_types` lint forbids `std::time::Instant` (it isn't implemented for wasm targets) and requires `instant::Instant`, which the rest of the crate already uses. Swap the import; `Duration` stays from std (it is allowed). Co-Authored-By: Claude Opus 4.8 (1M context) --- app/src/ai/agent_sdk/driver_tests.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/src/ai/agent_sdk/driver_tests.rs b/app/src/ai/agent_sdk/driver_tests.rs index aa136d93..965ff590 100644 --- a/app/src/ai/agent_sdk/driver_tests.rs +++ b/app/src/ai/agent_sdk/driver_tests.rs @@ -1,11 +1,7 @@ -use std::{ - collections::HashMap, - ffi::OsString, - sync::Arc, - time::{Duration, Instant}, -}; +use std::{collections::HashMap, ffi::OsString, sync::Arc, time::Duration}; use futures::channel::oneshot; +use instant::Instant; use warp_cli::agent::Harness; use warp_cli::{ OZ_CLI_ENV, OZ_HARNESS_ENV, OZ_PARENT_RUN_ID_ENV, OZ_RUN_ID_ENV, SERVER_ROOT_URL_OVERRIDE_ENV,