From 5f70fd44543b66e821262ee40ad1ff3b9e17fcc0 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Sun, 28 Jun 2026 20:46:51 -0700 Subject: [PATCH] fix: preserve explicit assignee for bot inbox conversations --- app/models/conversation.rb | 2 ++ spec/models/conversation_spec.rb | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/app/models/conversation.rb b/app/models/conversation.rb index fb5701765..e21410451 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -296,6 +296,8 @@ class Conversation < ApplicationRecord end def assign_connected_agent_bot + return if assignee_id.present? + self.assignee = nil self.assignee_agent_bot = inbox.agent_bot end diff --git a/spec/models/conversation_spec.rb b/spec/models/conversation_spec.rb index 0e15920eb..153649de2 100644 --- a/spec/models/conversation_spec.rb +++ b/spec/models/conversation_spec.rb @@ -663,6 +663,14 @@ RSpec.describe Conversation do expect(conversation.assignee).to be_nil end + it 'preserves explicit human assignee' do + agent = create(:user, account: bot_inbox.inbox.account) + conversation = create(:conversation, inbox: bot_inbox.inbox, assignee: agent) + + expect(conversation.assignee).to eq(agent) + expect(conversation.assignee_agent_bot).to be_nil + end + context 'with campaigns' do let(:user) { create(:user, account: bot_inbox.inbox.account) }