From 195aeb69be28a3938a569e6771be234051c25c0a Mon Sep 17 00:00:00 2001 From: Hare Date: Fri, 18 Sep 2026 05:27:21 +0900 Subject: [PATCH] fix: format notification batching changes --- crates/worker/src/controller.rs | 10 +++------- crates/worker/src/worker.rs | 20 ++++++++++++-------- crates/worker/tests/controller_test.rs | 11 +++++++---- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/crates/worker/src/controller.rs b/crates/worker/src/controller.rs index 30898f179..7fe3b02f4 100644 --- a/crates/worker/src/controller.rs +++ b/crates/worker/src/controller.rs @@ -368,11 +368,7 @@ fn stage_pending_notifications( } let count = notifications.len(); for (notification, extension) in notifications { - notify_buffer.push_durable_notify( - notification.message, - notification.provenance, - extension, - ); + notify_buffer.push_durable_notify(notification.message, notification.provenance, extension); } count } @@ -409,7 +405,8 @@ fn prepare_pending_run( } None if allow_notification_run && (stage_pending_notifications(pending_submissions, notify_buffer) > 0 - || notify_buffer.has_notification_pending()) => { + || notify_buffer.has_notification_pending()) => + { Some(PendingRun::RunForNotification { invoke_kind: protocol::InvokeKind::Notify, }) @@ -3149,7 +3146,6 @@ mod tests { Some(PendingRun::Submit(_)) )); assert_eq!(notify_buffer.len(), 1); - } #[test] diff --git a/crates/worker/src/worker.rs b/crates/worker/src/worker.rs index 04dc8db7b..af46ab494 100644 --- a/crates/worker/src/worker.rs +++ b/crates/worker/src/worker.rs @@ -156,11 +156,13 @@ where Many(VecDeque), } - Ok(match as serde::Deserialize>::deserialize(deserializer)? { - Some(OneOrMany::One(notification)) => VecDeque::from([notification]), - Some(OneOrMany::Many(notifications)) => notifications, - None => VecDeque::new(), - }) + Ok( + match as serde::Deserialize>::deserialize(deserializer)? { + Some(OneOrMany::One(notification)) => VecDeque::from([notification]), + Some(OneOrMany::Many(notifications)) => notifications, + None => VecDeque::new(), + }, + ) } impl PendingActivationState { @@ -10239,9 +10241,11 @@ mod build_summary_prompt_tests { handle.accept_notification("notification-1".into(), "different".into()), Err(PendingSubmissionError::IdempotencyConflict) )); - assert!(handle - .accept_notification("notification-2".into(), "second notice".into()) - .unwrap()); + assert!( + handle + .accept_notification("notification-2".into(), "second notice".into()) + .unwrap() + ); handle .accept("request-1".into(), vec![Segment::text("submit")], false) .unwrap(); diff --git a/crates/worker/tests/controller_test.rs b/crates/worker/tests/controller_test.rs index f31b9565c..2193945fa 100644 --- a/crates/worker/tests/controller_test.rs +++ b/crates/worker/tests/controller_test.rs @@ -1930,7 +1930,11 @@ async fn repeated_notify_while_idle_coalesces_and_auto_starts_one_turn() { .filter_map(|item| item.as_text()) .filter(|text| text.contains("[Notification]")) .collect::>(); - assert_eq!(notifications.len(), 2, "duplicate receipt must not duplicate content"); + assert_eq!( + notifications.len(), + 2, + "duplicate receipt must not duplicate content" + ); assert!(notifications[0].contains("progress snapshot")); assert!(notifications[1].contains("second coalesced notification")); } @@ -2684,9 +2688,8 @@ async fn pause_then_resume_preserves_notifications_and_history_consistency() { let requests = client_for_assert.captured_requests(); assert_eq!(requests.len(), 2); assert!(requests[1].items.iter().any(|item| { - item.as_text().is_some_and(|text| { - text.contains("[Notification]") && text.contains("resume context") - }) + item.as_text() + .is_some_and(|text| text.contains("[Notification]") && text.contains("resume context")) })); // History consistency: the interrupted partial response is absent, while