chatwoot/app
Tanmay Deep Sharma 3cd8cf43ce
fix: atomically claim conversation to prevent duplicate assignment (#14495)
## Description

Fixes a bug under Assignment V2 where a single conversation could be
reassigned dozens of times in a row by the system, producing long stacks
of "Assigned to X by Automation System via <policy>" activity messages
alternating between agents. After this change each unassigned
conversation is assigned exactly once, even on busy inboxes.

## Fixes # (issue)


## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)

## How Has This Been Tested?

## How to reproduce
1. Enable `assignment_v2` on an account with at least 2 online agents in
an inbox.
2. Generate sustained resolve/snooze activity in the inbox (each one
enqueues `AutoAssignment::AssignmentJob` for the whole inbox).
3. Watch any one unassigned conversation while the jobs drain — pre-fix
it picks up multiple back-to-back "Assigned to …" activity rows
alternating between agents.


## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules
2026-05-21 16:14:28 +05:30
..
actions fix: Skip redundant contact saves in ContactIdentifyAction (#13778) 2026-03-11 21:40:38 -07:00
assets feat: Hide installation identifier (#11722) 2025-06-17 15:45:40 -07:00
builders fix: prevent bot metrics double-counting when handoff and resolution coexist [CW-6210] (#14032) 2026-05-13 18:43:23 +05:30
channels fix: Move contact events to account stream rather than individual user stream (#11082) 2025-03-13 17:46:48 -07:00
controllers feat: Unread Count: added api, store refresher, invalidation and events (2/3)[CW-6851] (#14369) 2026-05-20 17:36:09 +05:30
dashboards feat: Add platform-wide status banners for outage notifications (#13943) 2026-04-29 17:18:38 +04:00
dispatchers feat: Unread Count: added api, store refresher, invalidation and events (2/3)[CW-6851] (#14369) 2026-05-20 17:36:09 +05:30
drops fix: render agent variables in automation messages (#14338) 2026-05-04 13:25:40 +05:30
fields fix(super-admin): prefill confirmed_at in new user form (#13662) 2026-03-10 12:14:58 +05:30
finders feat(voice): Wire Twilio voice flow through unified call model (#14091) 2026-04-30 11:25:39 +04:00
helpers fix: captain-v2 cannot see image attachments shared via email (#14449) 2026-05-19 10:11:32 +05:30
javascript feat: Unread Count: Frontend changes for showing unread count badges (3/3)[CW-6851] (#14372) 2026-05-20 19:21:25 +05:30
jobs fix: atomically claim conversation to prevent duplicate assignment (#14495) 2026-05-21 16:14:28 +05:30
listeners feat: Unread Count: added api, store refresher, invalidation and events (2/3)[CW-6851] (#14369) 2026-05-20 17:36:09 +05:30
mailboxes fix: captain-v2 cannot see image attachments shared via email (#14449) 2026-05-19 10:11:32 +05:30
mailers fix: validate OpenAI hook credentials (#14068) 2026-05-18 14:08:57 +05:30
models fix: atomically claim conversation to prevent duplicate assignment (#14495) 2026-05-21 16:14:28 +05:30
policies fix(security): Enforce admin authorization on custom attribute definitions API (#14392) 2026-05-08 11:42:23 +04:00
presenters fix: index email subject from conversation for outbound messages (#14122) 2026-04-22 20:36:35 +05:30
services fix: atomically claim conversation to prevent duplicate assignment (#14495) 2026-05-21 16:14:28 +05:30
views feat: Add an option on the dashboard to allow switching help center layout (#14491) 2026-05-19 06:42:48 -07:00