Add copilot to every page

This commit is contained in:
Pranav
2025-05-09 13:16:27 -07:00
parent a06964c0f1
commit 66fcaa5e01
5 changed files with 92 additions and 1 deletions
@@ -23,6 +23,9 @@ const assistants = useMapGetter('captainAssistants/getRecords');
const inboxAssistant = useMapGetter('getCopilotAssistant');
const { uiSettings, updateUISettings } = useUISettings();
const getUIState = useMapGetter('uiState/getUIState');
const isSidebarOpen = computed(() => getUIState.value('isCopilotSidebarOpen'));
const messages = ref([]);
const isCaptainTyping = ref(false);
const selectedAssistantId = ref(null);
@@ -99,6 +102,10 @@ onMounted(() => {
store.dispatch('captainAssistants/get');
});
const handleClose = () => {
store.dispatch('uiState/set', 'isCopilotSidebarOpen', false);
};
watchEffect(() => {
if (props.conversationId) {
store.dispatch('getInboxCaptainAssistantById', props.conversationId);
@@ -108,7 +115,7 @@ watchEffect(() => {
</script>
<template>
<div class="border-l border-n-weak min-w-[17.5rem]">
<div v-if="isSidebarOpen" class="border-l border-n-weak min-w-[17.5rem]">
<Copilot
:messages="messages"
:support-agent="currentUser"
@@ -119,6 +126,8 @@ watchEffect(() => {
@set-assistant="setAssistant"
@send-message="sendMessage"
@reset="handleReset"
@close="handleClose"
/>
</div>
<div v-else class="hidden" />
</template>
@@ -0,0 +1,43 @@
<script setup>
import { computed } from 'vue';
import { useStore } from 'vuex';
import { useRoute } from 'vue-router';
import Button from 'dashboard/components-next/button/Button.vue';
import { useMapGetter } from 'dashboard/composables/store';
const store = useStore();
const route = useRoute();
const getUIState = useMapGetter('uiState/getUIState');
const isSidebarOpen = computed(() => getUIState.value('isCopilotSidebarOpen'));
const isConversationRoute = computed(() => {
const CONVERSATION_ROUTES = [
'inbox_conversation',
'conversation_through_inbox',
'conversations_through_label',
'team_conversations_through_label',
'conversations_through_folders',
'conversation_through_mentions',
'conversation_through_unattended',
'conversation_through_participating',
];
return CONVERSATION_ROUTES.includes(route.name);
});
const toggleSidebar = () => {
store.dispatch('uiState/toggle', 'isCopilotSidebarOpen');
};
</script>
<template>
<div class="fixed bottom-4 right-4 z-50">
<Button
v-if="!isSidebarOpen && !isConversationRoute"
icon="i-woot-captain"
class="!rounded-full bg-n-iris-9 text-xl"
lg
@click="toggleSidebar"
/>
</div>
</template>