From 81c23ecfefba72adb0a7a39ad396effdf051ed7c Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 3 Feb 2026 18:00:39 +0530 Subject: [PATCH] prevent non whitespace characters from being sent from input --- .../TipTapEditor/utils/editorConfig.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts index b05109c9bca..7076fa60a6a 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts @@ -56,11 +56,22 @@ export function hasValidEditorContent(json: JSONContent): boolean { (c) => c.type === PromptBlock.name || c.type === CodeBlock.name, ); - // Check for text content - const hasTextContent = json.content?.some((c) => c.content); + // Check for non-whitespace text content + const hasNonWhitespaceText = json.content?.some((c) => + c.content?.some((child) => { + if (child.type === "text" && child.text) { + return child.text.trim().length > 0; + } + // Mentions and other non-text nodes are valid content + if (child.type === "mention") { + return true; + } + return false; + }), + ); - // Content is valid if it has either text or special blocks - return hasTextContent || hasPromptOrCodeBlock || false; + // Content is valid if it has either non-whitespace text or special blocks + return hasNonWhitespaceText || hasPromptOrCodeBlock || false; } /**