Skip to content

Commit 2a33ddc

Browse files
authored
Merge pull request #10149 from uinstinct/non-whitespace
fix: prevent non whitespace characters from being sent from input
2 parents f14a2ff + 2a717dd commit 2a33ddc

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,22 @@ export function hasValidEditorContent(json: JSONContent): boolean {
5656
(c) => c.type === PromptBlock.name || c.type === CodeBlock.name,
5757
);
5858

59-
// Check for text content
60-
const hasTextContent = json.content?.some((c) => c.content);
59+
// Check for non-whitespace text content
60+
const hasNonWhitespaceText = json.content?.some((c) =>
61+
c.content?.some((child) => {
62+
if (child.type === "text" && child.text) {
63+
return child.text.trim().length > 0;
64+
}
65+
// Mentions and other non-text nodes are valid content
66+
if (child.type === "mention") {
67+
return true;
68+
}
69+
return false;
70+
}),
71+
);
6172

62-
// Content is valid if it has either text or special blocks
63-
return hasTextContent || hasPromptOrCodeBlock || false;
73+
// Content is valid if it has either non-whitespace text or special blocks
74+
return hasNonWhitespaceText || hasPromptOrCodeBlock || false;
6475
}
6576

6677
/**

0 commit comments

Comments
 (0)