Skip to content

Conversation

@ganievs
Copy link

@ganievs ganievs commented Oct 16, 2025

Issue

Closes #469

Reason for this change

Users could send empty messages or messages containing only whitespace in the AI chat interface, causing model validation errors:

  • Error: The model returned the following errors: messages: text content blocks must contain non-whitespace text
  • Error: Invalid message content: empty string. 'human' must contain non-empty content.

This occurred when users clicked Send or pressed Enter without typing actual content, resulting in confusing error messages and poor UX.

Description of changes

Added client-side validation in ChatInputComponent to prevent submission of empty or whitespace-only messages:

  1. Send button validation: Modified the Send button's disabled prop to check if the message contains non-whitespace content using !message.trim()
  2. Enter key validation: Updated the checkKeyPress handler to validate message content (message.trim()) before processing Enter key submission

The fix ensures that:

  • The Send button is disabled when the input is empty or contains only whitespace
  • Pressing Enter without non-whitespace content does not trigger submission
  • Shift+Enter continues to work normally for multi-line input

Description of how you validated changes

Manual testing performed:

  • Verified Send button is disabled with empty input
  • Verified Send button is disabled with whitespace-only input (spaces, tabs, newlines)
  • Verified Send button enables with actual text content
  • Confirmed Enter key does not submit empty messages
  • Confirmed Enter key does not submit whitespace-only messages
  • Confirmed Shift+Enter still creates new lines
  • Verified no model validation errors occur after fix
  • Tested message submission still works correctly with valid content

No unit tests added as this is a UI interaction fix in an existing component without test coverage.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@ganievs ganievs requested a review from a team as a code owner October 16, 2025 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: Prevent empty/whitespace-only messages in AI chat

1 participant