This PR allows Copilot to be used without connecting the Captain assistant to an inbox. Currently, if Captain is enabled on an account, it takes over conversations and responds directly to users. This PR enables the use of Captain as a Copilot without allowing it to respond to users. Additionally, it allows using a different assistant for Copilot instead of the default Captain assistant.
The selection logic for the Copilot assistant follows this order of preference:
- If the user has selected a specific assistant, it takes first preference for Copilot.
- If the above is not available, the assistant connected to the inbox takes preference.
- If neither of the above is available, the first assistant in the account takes preference.
When the chat is viewed, a function `fetchAllAttachments` is run to get all attachments for a particular conversation. This function, before updating the record creates the `attachments` property on the `chat` object in the store.
If in any case this function fails, the `attachments` property is not created, and when the code reaches the `dashboard/store/modules/conversations/index.js` the error occurs
This PR fixes it by ensuring that `SET_ALL_ATTACHMENTS` is always run. And it handles the default case as well
---
Sentry Issue:
[CHATWOOT-FRONTEND-APP-5Y](https://chatwoot-p3.sentry.io/issues/5459056982/)
```
TypeError: Cannot read properties of undefined (reading 'some')
at forEach(./app/javascript/dashboard/store/modules/conversations/index.js:160:31)
at Array.forEach(<anonymous>)
at mutations(./app/javascript/dashboard/store/modules/conversations/index.js:159:27)
at handler(./node_modules/vuex/dist/vuex.js:771:7)
at forEach(./node_modules/vuex/dist/vuex.js:470:9)
at Array.forEach(<anonymous>)
at fn(./node_modules/vuex/dist/vuex.js:469:13)
at Store.prototype._withCommit(./node_modules/vuex/dist/vuex.js:574:5)
at Store.prototype.commit(./node_modules/vuex/dist/vuex.js:468:10)
at this.commit(./node_modules/vuex/dist/vuex.js:420:21)
at call(./app/javascript/dashboard/store/modules/conversations/actions.js:273:7)
at tryCatch(./node_modules/videojs-record/dist/videojs.record.js:2868:27)
at _invoke(./node_modules/videojs-record/dist/videojs.record.js:3088:32)
at prototype[method](./node_modules/videojs-record/dist/videojs.record.js:2921:31)
at as(/packs/js/application-cf716bca3c984faeb095.js:4:76)
at as(/packs/js/application-cf716bca3c984faeb095.js:4:76)
at nrWrapper(/app/accounts/81898/conversations/95:6:17817)
```
---------
Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
Co-authored-by: Sojan Jose <sojan@pepalo.com>
Co-authored-by: Pranav <pranav@chatwoot.com>
Due to the pattern `**/specs/*.spec.js` defined in CircleCI, none of the
frontend spec in the folders such as
`specs/<domain-name>/getters.spec.js` were not executed in Circle CI.
This PR fixes the issue, along with the following changes:
- Use vitest instead of jest
- Remove jest dependancies
- Update tests to work with vitest
---------
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
# Replace the deprecated `eventBus` with mitt.js
## Description
Since eventBus and it's respective methods are deprecated and removed
from all future releases of vue, this was blocking us from migrating.
This PR replaces eventBus with
[mitt](https://github.com/developit/mitt). I have created a wrapper
mitt.js to simulate the same old event names so it's backwards
compatible, without making a lot of changes.
Fixes # (issue)
## Type of change
Please delete options that are not relevant.
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality not to work as expected)
- [ ] This change requires a documentation update
## How Has This Been Tested?
1. Made sure all the places we're listening to bus events are working as
expected.
2. Respective specsf or the events from mitt.
## 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
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] 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
- [x] Any dependent changes have been merged and published in downstream
modules
* feat: Attachments view with key shortcuts and dynamically updates when user delete or sent new attachments
---------
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
* fix: Update unread_count from backend instead of computing on the frontend
* Fix spec
* Remove status indicator on private notifications
* CodeClimate fix
* CodeClimate