iachat/app/javascript/dashboard
Sivin Varghese c24a6dc74c
fix: Prevent CC/BCC field reset on chat activity actions (#11342)
# Pull Request Template

## Description

This PR fixes the CC/BCC field reset issue on activity action.
Fixes
[CW-4256](https://linear.app/chatwoot/issue/CW-4256/emails-added-in-cc-and-bcc-disappears-when-you-click-on-assign-to-me),
#5234

### Cause of the Issue
Previously, the CC and BCC fields in the reply box were being reset
whenever a conversation activity occurred (such as assignment, status
change, etc.). This happened because watchers on the current chat
messages array and current chat object would trigger
`setCCAndToEmailsFromLastChat` even when the last message was an
activity or system message, not a real email.

### Solution

- The updated logic ensures that the CC and BCC fields are only set
under the following conditions:
   **1**. Switching to a new conversation.
**2**. In the same conversation, only if the last message is not an
activity (i.e., only for actual emails).

- It uses the `lastEmail` computed property, which filters out private
and activity messages, ensuring only real email context changes update
the fields.
- This prevents user-entered `CC/BCC` values from being cleared after
system events (e.g., assignments or status changes), while still
updating the fields correctly when relevant messages are received.

## Type of change

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

## How Has This Been Tested?

### Loom video
**Before**

https://www.loom.com/share/2ec50dd1c0ed4eaf9170465274bea41e?sid=cc8b88cb-fd39-473a-8df3-78a242c8407b

**After**

https://www.loom.com/share/17fd2d96d5d84a049dcbf20d401d2ada?sid=8949ad48-7769-49d2-92c5-267da8c60d6e



## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules
2025-04-21 13:48:56 +05:30
..
api feat: Implement UI for Agent Bots in settings and remove CSML support (#11276) 2025-04-16 18:02:49 +05:30
assets chore: Update date range picker with new theme colors (#11267) 2025-04-09 16:03:53 +05:30
components fix: Prevent CC/BCC field reset on chat activity actions (#11342) 2025-04-21 13:48:56 +05:30
components-next chore: deprecate report_v4 feature flag and remove gating logic (#11320) 2025-04-17 08:52:56 +05:30
composables chore: Improve translation service with HTML and plain text support (#11305) 2025-04-16 17:59:06 +05:30
constants feat: Add visibility checks for installation types (#10773) 2025-02-21 14:48:31 -08:00
helper feat: allow role based filtering on the frontend (#11246) 2025-04-09 11:46:20 -07:00
i18n feat: Implement UI for Agent Bots in settings and remove CSML support (#11276) 2025-04-16 18:02:49 +05:30
mixins chore: fix circleci on vite build (#10214) 2024-10-07 15:27:41 +05:30
modules chore: Update buttons in dashboard (#11145) 2025-03-31 17:21:32 -07:00
routes fix: Handle Instagram text and attachments as separate messages (#11315) 2025-04-16 20:46:47 +05:30
store feat: Implement UI for Agent Bots in settings and remove CSML support (#11276) 2025-04-16 18:02:49 +05:30
App.vue feat: Upgrade page instead of banner (#11202) 2025-03-28 02:28:17 -07:00
featureFlags.js feat: Instagram Inbox using Instagram Business Login (#11054) 2025-04-08 10:47:41 +05:30