From 6bbb763d4ad0d150952c9172d313597ce8b5063c Mon Sep 17 00:00:00 2001 From: Pranav Date: Tue, 14 Jul 2026 16:34:14 -0700 Subject: [PATCH] refactor(captain): inline engagement check in Enterprise::Conversation Drop the diff comments and the one-use captain_should_engage? helper; determine_conversation_status now checks the assistant inline. --- enterprise/app/models/enterprise/conversation.rb | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/enterprise/app/models/enterprise/conversation.rb b/enterprise/app/models/enterprise/conversation.rb index 2addc1a89..e83e98f11 100644 --- a/enterprise/app/models/enterprise/conversation.rb +++ b/enterprise/app/models/enterprise/conversation.rb @@ -33,23 +33,12 @@ module Enterprise::Conversation private - # When a Captain inbox parks new conversations as pending, demote to open (human queue) when the - # assistant won't engage (contact outside audience, or off-schedule) so they aren't stuck waiting - # on a bot that stays silent. def determine_conversation_status super return unless pending? - self.status = :open unless captain_should_engage? - end - - # True for non-Captain inboxes (don't interfere) and for Captain inboxes that should engage this - # conversation (audience matches AND on-schedule). False only when a Captain assistant opts out. - def captain_should_engage? assistant = inbox.captain_assistant - return true if assistant.blank? - - assistant.engages?(contact, self) + self.status = :open if assistant.present? && !assistant.engages?(contact, self) end def dispatch_captain_inference_event(event_name)