Fix chat send button (#5647)

Co-authored-by: Lee Jackson <130007945+Imagineer99@users.noreply.github.com>
Co-authored-by: Wasim Yousef Said <wasimysdev@gmail.com>
This commit is contained in:
Harikrishna C 2026-05-22 17:17:29 +05:30 committed by GitHub
commit 549e24e7d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -289,19 +289,31 @@ const PendingAudioChip: FC = () => {
const Composer: FC<{ disabled?: boolean }> = ({ disabled }) => {
const { inputProps, isComposing, isComposingRef } = useImeComposerInputHandlers();
const composerText = useAuiState(({ composer }) => composer.text);
const hasAttachments = useAuiState(
({ composer }) => composer.attachments.length > 0,
);
const hasPendingAttachments = useAuiState(({ composer }) =>
composer.attachments.some(
(attachment) => attachment.status.type === "running",
),
);
const hasPendingAudio = useChatRuntimeStore((s) => Boolean(s.pendingAudioName));
const hasSendableContent =
composerText.trim().length > 0 || hasAttachments || hasPendingAudio;
const handleSubmit = useCallback(
(event: FormEvent<HTMLFormElement>) => {
if (disabled || isComposingRef.current || hasPendingAttachments) {
if (
disabled ||
!hasSendableContent ||
isComposingRef.current ||
hasPendingAttachments
) {
event.preventDefault();
}
},
[disabled, hasPendingAttachments, isComposingRef],
[disabled, hasPendingAttachments, hasSendableContent, isComposingRef],
);
const composerContent = (
@ -323,8 +335,12 @@ const Composer: FC<{ disabled?: boolean }> = ({ disabled }) => {
{...inputProps}
/>
<ComposerAction
disabled={disabled || isComposing || hasPendingAttachments}
blockSend={() => isComposingRef.current || hasPendingAttachments}
disabled={
disabled || !hasSendableContent || isComposing || hasPendingAttachments
}
blockSend={() =>
!hasSendableContent || isComposingRef.current || hasPendingAttachments
}
/>
</>
);