From f22edc6ed80c6469dc7590f1f250a8bdf20078a8 Mon Sep 17 00:00:00 2001 From: joelhulen Date: Thu, 1 Aug 2024 17:06:00 -0400 Subject: [PATCH] Check whether there are agents and show warning when sending message --- src/ui/UserPortal/components/ChatThread.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ui/UserPortal/components/ChatThread.vue b/src/ui/UserPortal/components/ChatThread.vue index 55dc921f6e..fd13a5192b 100644 --- a/src/ui/UserPortal/components/ChatThread.vue +++ b/src/ui/UserPortal/components/ChatThread.vue @@ -102,7 +102,20 @@ export default { this.isMessagePending = true; this.userSentMessage = true; - const agent = this.$appStore.getSessionAgent(this.currentSession).resource; + const agent = this.$appStore.getSessionAgent(this.currentSession)?.resource; + + // Display an error toast message if agent is null or undefined. + if (!agent) { + this.$toast.add({ + severity: 'info', + summary: 'Could not send message', + detail: 'Please select an agent and try again. If no agents are available, refresh the page.', + life: 8000, + }); + this.isMessagePending = false; + return; + } + if (agent.long_running) { // Handle long-running operations const operationId = await this.$appStore.startLongRunningProcess('/completions', {