Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
Seanaye/fix/remove noise notifications (#6289)
Sean Aye83d3a28072bb
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.mdindex 361b23aaa5..5aba981f61 100644--- a/docs/AGENT_GUIDE/surfaces.md+++ b/docs/AGENT_GUIDE/surfaces.md@@ -182,3 +182,8 @@ but unconnected app gets a tool result saying so, and the agent's reply rendersToast regions are labeled `Notifications (alt+T)`; five empty live regions always exist inthe a11y tree (ignore them when parsing snapshots).++Staff Noise emails still create in-app notification rows, but do not send a new-notification+event over GraphQL or the legacy WebSocket gateway, so they do not trigger browser popups.+Those rows are available on the next fetch/refetch. Signal delivery and the existing+staff/customer eligibility rules are unchanged; no browser eligibility request is needed.diff --git a/services/email_service/src/pubsub/inbox_sync/operations/upsert_message.rs b/services/email_service/src/pubsub/inbox_sync/operations/upsert_message.rsindex ce1cbc64ca..cf84afcb8f 100644--- a/services/email_service/src/pubsub/inbox_sync/operations/upsert_message.rs+++ b/services/email_service/src/pubsub/inbox_sync/operations/upsert_message.rs@@ -738,15 +738,13 @@ async fn send_notifications(EntityType::EmailThread.with_entity_string(message.thread_db_id.to_string());if !staff_recipients.is_empty() {- let request = SendNotificationRequestBuilder {+ let request = tier.notification_request(SendNotificationRequestBuilder {notification_entity: notification_entity.clone(),secondary_notification_entity: None,notification: notification.clone(),sender_id: sender_id.clone(),recipient_ids: staff_recipients,- }- .into_request()- .with_conn_gateway();+ });match tier {NewEmailTier::Signal => publish_new_email_notification(ctx, request.with_apns()).await,NewEmailTier::StaffInbox => publish_new_email_notification(ctx, request).await,@@ -754,15 +752,13 @@ async fn send_notifications(}if !customer_recipients.is_empty() {- let request = SendNotificationRequestBuilder {+ let request = tier.notification_request(SendNotificationRequestBuilder {notification_entity,secondary_notification_entity: None,notification,sender_id,recipient_ids: customer_recipients,- }- .into_request()- .with_conn_gateway();+ });publish_new_email_notification(ctx, request).await;}@@ -802,6 +798,21 @@ enum NewEmailTier {StaffInbox,}+impl NewEmailTier {+ fn notification_request<'a>(+ self,+ builder: SendNotificationRequestBuilder<'a, NewEmailMetadata>,+ ) -> SendNotificationRequest<'a, NewEmailMetadata, ()> {+ let request = builder.into_request();+ match self {+ Self::Signal => request.with_conn_gateway(),+ // Persist the same row, but do not deliver a new-notification event+ // over either GraphQL or the legacy gateway (both produce popups).+ Self::StaffInbox => request,+ }+ }+}+fn signal_filter(thread_id: Uuid) -> Expr<EmailLiteral> {Expr::and(Expr::Literal(EmailLiteral::ThreadId(thread_id)),diff --git a/services/email_service/src/pubsub/inbox_sync/operations/upsert_message/test.rs b/services/email_service/src/pubsub/inbox_sync/operations/upsert_message/test.rsindex bc3a22dd37..7370120a4b 100644--- a/services/email_service/src/pubsub/inbox_sync/operations/upsert_message/test.rs+++ b/services/email_service/src/pubsub/inbox_sync/operations/upsert_message/test.rs@@ -218,6 +218,78 @@ fn customer_only_recipients_do_not_take_the_apns_path() {assert_eq!(customers, HashSet::from([id("macro|[email protected]")]));}+fn email_notification_builder(+ recipient: &str,+) -> SendNotificationRequestBuilder<'static, NewEmailMetadata> {+ SendNotificationRequestBuilder {+ notification_entity: EntityType::EmailThread.with_entity_string(Uuid::nil().to_string()),+ secondary_notification_entity: None,+ notification: NewEmailMetadata {+ sender: Some("Sender".to_string()),+ to_email: "[email protected]".to_string(),+ thread_id: Uuid::nil().to_string(),+ subject: "Subject".to_string(),+ snippet: "Snippet".to_string(),+ },+ sender_id: Some(id("macro|[email protected]")),+ recipient_ids: HashSet::from([id(recipient)]),+ }+}++#[test]+fn noise_requests_preserve_rows_without_realtime_delivery() {+ // A staff inbox may also notify a non-staff delegate. Neither recipient+ // partition should receive GraphQL/gateway events for the Noise tier.+ for recipient in ["macro|[email protected]", "macro|[email protected]"] {+ let builder = email_notification_builder(recipient);+ let original = serde_json::to_value(&builder).unwrap();+ let request = NewEmailTier::StaffInbox.notification_request(builder);+ let request = serde_json::to_value(request).unwrap();++ assert_eq!(request["send_conn_gateway"], false);+ assert!(request["build_apns"].is_null());+ assert!(request["build_email"].is_null());+ assert!(request["uuid_to_write"].is_string());+ for field in [+ "notification_entity",+ "secondary_notification_entity",+ "sender_id",+ "recipient_ids",+ ] {+ assert_eq!(request["req"][field], original[field]);+ }+ assert_eq!(request["req"]["notification"]["tag"], "new_email");+ assert_eq!(+ request["req"]["notification"]["content"],+ original["notification"]+ );+ }+}++#[test]+fn signal_requests_keep_realtime_delivery_for_both_recipient_partitions() {+ for recipient in ["macro|[email protected]", "macro|[email protected]"] {+ let request =+ NewEmailTier::Signal.notification_request(email_notification_builder(recipient));+ let request = serde_json::to_value(request).unwrap();++ assert_eq!(request["send_conn_gateway"], true);+ // The staff branch adds APNS separately; customer requests stay realtime-only.+ assert!(request["build_apns"].is_null());+ }+}++#[test]+fn signal_staff_requests_keep_apns_and_realtime_delivery() {+ let request = NewEmailTier::Signal+ .notification_request(email_notification_builder("macro|[email protected]"))+ .with_apns();+ let request = serde_json::to_value(request).unwrap();++ assert_eq!(request["send_conn_gateway"], true);+ assert!(request["build_apns"].is_object());+}+#[test]fn signal_filter_requires_importance_and_unshared() {let thread_id = Uuid::nil();