fix: clear bot owner on handoff

This commit is contained in:
Sojan Jose
2026-07-07 19:21:19 -07:00
parent 4f237add73
commit d96415c814
2 changed files with 9 additions and 0 deletions
+1
View File
@@ -165,6 +165,7 @@ class Conversation < ApplicationRecord
def bot_handoff!
update(waiting_since: Time.current) if waiting_since.blank?
self.assignee_agent_bot = nil
open!
dispatcher_dispatch(CONVERSATION_BOT_HANDOFF)
end
+8
View File
@@ -347,6 +347,14 @@ RSpec.describe Conversation do
expect(conversation.reload.status).to eq('open')
end
it 'clears agent bot ownership' do
conversation.update!(assignee_agent_bot: create(:agent_bot, account: conversation.account))
conversation.bot_handoff!
expect(conversation.reload.assignee_agent_bot).to be_nil
end
it 'dispatches CONVERSATION_BOT_HANDOFF event' do
expect(Rails.configuration.dispatcher).to receive(:dispatch)
.with(described_class::CONVERSATION_BOT_HANDOFF, anything, hash_including(conversation: conversation))