fix(chat): prevent accidental abort on mobile touch send (#440)

Mobile touch send was firing on pointerdown and then same gesture click landed on stop button after UI switched to abort state. Removed pointerdown-based send/queue handlers and dedupe ref. Mobile send/queue now trigger from click path, avoiding retargeted click to stop.
This commit is contained in:
shekohex
2026-02-18 11:51:25 +02:00
committed by GitHub
parent 09173df37f
commit 7eba5141fa
@@ -127,7 +127,6 @@ export const ChatInput: React.FC<ChatInputProps> = ({ onOpenSettings, scrollToBo
const [showAbortStatus, setShowAbortStatus] = React.useState(false);
const abortTimeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);
const prevWasAbortedRef = React.useRef(false);
const sendTriggeredByPointerDownRef = React.useRef(false);
// Message queue
const queueModeEnabled = useMessageQueueStore((state) => state.queueModeEnabled);
@@ -1660,30 +1659,11 @@ export const ChatInput: React.FC<ChatInputProps> = ({ onOpenSettings, scrollToBo
<button
type={isMobile ? 'button' : 'submit'}
disabled={!canSend || (!currentSessionId && !newSessionDraftOpen)}
onPointerDownCapture={(event) => {
if (!isMobile || event.pointerType !== 'touch') {
return;
}
if (!canSend || (!currentSessionId && !newSessionDraftOpen)) {
return;
}
sendTriggeredByPointerDownRef.current = true;
event.preventDefault();
event.stopPropagation();
handlePrimaryAction();
}}
onClick={(event) => {
if (!isMobile) {
return;
}
if (sendTriggeredByPointerDownRef.current) {
sendTriggeredByPointerDownRef.current = false;
return;
}
event.preventDefault();
handlePrimaryAction();
}}
@@ -1704,26 +1684,8 @@ export const ChatInput: React.FC<ChatInputProps> = ({ onOpenSettings, scrollToBo
<button
type="button"
disabled={!hasContent || !currentSessionId}
onPointerDownCapture={(event) => {
if (!isMobile || event.pointerType !== 'touch') {
return;
}
if (!hasContent || !currentSessionId) {
return;
}
sendTriggeredByPointerDownRef.current = true;
event.preventDefault();
event.stopPropagation();
handleQueueMessage();
}}
onClick={(event) => {
if (isMobile) {
if (sendTriggeredByPointerDownRef.current) {
sendTriggeredByPointerDownRef.current = false;
return;
}
event.preventDefault();
}
handleQueueMessage();