From 918133a4be38ea51da2ab158640c79b971866bde Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Thu, 16 Jul 2026 01:29:32 +0530 Subject: [PATCH] feat(chat): add CanSubmitChat interface and logic to determine chat submission eligibility --- surfsense_web/lib/chat/can-submit-chat.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 surfsense_web/lib/chat/can-submit-chat.ts diff --git a/surfsense_web/lib/chat/can-submit-chat.ts b/surfsense_web/lib/chat/can-submit-chat.ts new file mode 100644 index 000000000..106b298af --- /dev/null +++ b/surfsense_web/lib/chat/can-submit-chat.ts @@ -0,0 +1,23 @@ +export interface CanSubmitChatInput { + isLoadingMessages: boolean; + isThreadRunning: boolean; + isBlockedByOtherUser: boolean; + isComposerEmpty: boolean; + isWorkspaceChatReady: boolean; +} + +export function canSubmitChat({ + isLoadingMessages, + isThreadRunning, + isBlockedByOtherUser, + isComposerEmpty, + isWorkspaceChatReady, +}: CanSubmitChatInput): boolean { + return ( + !isLoadingMessages && + !isThreadRunning && + !isBlockedByOtherUser && + !isComposerEmpty && + isWorkspaceChatReady + ); +}