feat: block replies during agent bot ownership

This commit is contained in:
Sojan Jose
2026-06-28 20:10:46 -07:00
parent d0b1c055e8
commit b9834c3a18
7 changed files with 94 additions and 12 deletions
@@ -171,6 +171,9 @@ export default {
return this.isATwilioWhatsAppChannel && !this.isPrivate;
},
isPrivate() {
if (this.isAgentBotOwned) {
return true;
}
if (
this.currentChat.can_reply ||
this.isAWhatsAppChannel ||
@@ -197,10 +200,14 @@ export default {
},
isReplyRestricted() {
return (
!this.currentChat?.can_reply &&
!(this.isAWhatsAppChannel || this.isAPIInbox)
this.isAgentBotOwned ||
(!this.currentChat?.can_reply &&
!(this.isAWhatsAppChannel || this.isAPIInbox))
);
},
isAgentBotOwned() {
return this.currentChat?.meta?.assignee_type === 'AgentBot';
},
inboxId() {
return this.currentChat.inbox_id;
},
@@ -462,6 +469,11 @@ export default {
return;
}
if (this.isAgentBotOwned) {
this.replyType = REPLY_EDITOR_MODES.NOTE;
return;
}
if (canReply || this.isAWhatsAppChannel || this.isAPIInbox) {
this.replyType = REPLY_EDITOR_MODES.REPLY;
} else {
@@ -501,6 +513,9 @@ export default {
mounted() {
this.getFromDraft();
if (this.isAgentBotOwned) {
this.replyType = REPLY_EDITOR_MODES.NOTE;
}
// Don't use the keyboard listener mixin here as the events here are supposed to be
// working even if the editor is focussed.
document.addEventListener('paste', this.onPaste);
@@ -921,6 +936,9 @@ export default {
this.hideContentTemplatesModal();
},
setReplyMode(mode = REPLY_EDITOR_MODES.REPLY) {
if (this.isAgentBotOwned && mode === REPLY_EDITOR_MODES.REPLY) {
return;
}
// Clear attachments when switching between private note and reply modes
// This is to prevent from breaking the upload rules
if (this.attachedFiles.length > 0) this.attachedFiles = [];
@@ -4,7 +4,6 @@ import { useStore } from 'vuex';
import { useMapGetter } from 'dashboard/composables/store';
import { useAlert } from 'dashboard/composables';
import { useI18n } from 'vue-i18n';
import wootConstants from 'dashboard/constants/globals';
import Banner from 'dashboard/components/ui/Banner.vue';
@@ -34,6 +33,7 @@ const assignedAgent = computed({
store.dispatch('setCurrentChatAssignee', {
conversationId: currentChat.value?.id,
assignee: agent,
assigneeType: agent ? 'User' : null,
});
store.dispatch('assignAgent', {
conversationId: currentChat.value?.id,
@@ -56,11 +56,11 @@ const showSelfAssignBanner = computed(() => {
);
});
const showBotHandoffBanner = computed(
() =>
isUserTyping.value &&
currentChat.value?.status === wootConstants.STATUS_TYPE.PENDING
);
const showBotHandoffBanner = computed(() => {
return (
isUserTyping.value && currentChat.value?.meta?.assignee_type === 'AgentBot'
);
});
const botHandoffActionLabel = computed(() => {
return assignedAgent.value?.id === currentUser.value?.id
@@ -89,7 +89,7 @@ const onClickSelfAssign = async () => {
const reopenConversation = async () => {
await store.dispatch('toggleStatus', {
conversationId: currentChat.value?.id,
status: wootConstants.STATUS_TYPE.OPEN,
status: 'open',
});
};
@@ -223,8 +223,11 @@ const actions = {
}
},
setCurrentChatAssignee({ commit }, { conversationId, assignee }) {
commit(types.ASSIGN_AGENT, { conversationId, assignee });
setCurrentChatAssignee(
{ commit },
{ conversationId, assignee, assigneeType }
) {
commit(types.ASSIGN_AGENT, { conversationId, assignee, assigneeType });
},
assignTeam: async ({ dispatch }, { conversationId, teamId }) => {
@@ -108,10 +108,13 @@ export const mutations = {
}
},
[types.ASSIGN_AGENT](_state, { conversationId, assignee }) {
[types.ASSIGN_AGENT](_state, { conversationId, assignee, assigneeType }) {
const chat = getConversationById(_state)(conversationId);
if (chat) {
chat.meta.assignee = assignee;
if (assigneeType !== undefined) {
chat.meta.assignee_type = assigneeType;
}
}
},
@@ -716,6 +716,21 @@ describe('#mutations', () => {
expect(state.allConversations[0].meta.assignee).toEqual(assignee);
expect(state.allConversations[1].meta.assignee).toBeUndefined();
});
it('should update assignee type when provided', () => {
const assignee = { id: 1, name: 'Agent' };
const state = {
allConversations: [{ id: 1, meta: { assignee_type: 'AgentBot' } }],
};
mutations[types.ASSIGN_AGENT](state, {
conversationId: 1,
assignee,
assigneeType: 'User',
});
expect(state.allConversations[0].meta.assignee_type).toEqual('User');
});
});
describe('#ASSIGN_PRIORITY', () => {