Revert "fix(dashboard): self-clear mobile send/stop dedupe ref so subsequent taps work"
This reverts commit 27d6511af3.
This commit is contained in:
@@ -1998,21 +1998,22 @@ export function ChatView({ projectId, addToast }: ChatViewProps) {
|
||||
if (typeof window === "undefined" || window.innerWidth > 768) return;
|
||||
event.preventDefault();
|
||||
if (event.pointerType && event.pointerType !== "mouse") {
|
||||
// Dedupe across the pointerdown/touchstart/click burst
|
||||
// from a single tap. preventDefault() on pointer/touch
|
||||
// can suppress the synthesized click that previously
|
||||
// cleared this ref, so we self-clear it via a short
|
||||
// timeout — otherwise once set the next tap silently
|
||||
// bails (long press stops working too).
|
||||
// On mobile, both onPointerDown and onTouchStart fire
|
||||
// for a quick tap. Without this guard handleSend runs
|
||||
// twice — the second call closes the first's stream
|
||||
// (useChat.ts: streamRef.current.close()) and the
|
||||
// server-side beginGeneration aborts the in-flight
|
||||
// generation, leaving the chat with no output. A
|
||||
// long-press doesn't fire both events the same way,
|
||||
// which is why holding the button "fixes" sending.
|
||||
if (handledMobileSendRef.current) return;
|
||||
handledMobileSendRef.current = true;
|
||||
markPreserveComposerFocus();
|
||||
focusComposerInput();
|
||||
void handleSend();
|
||||
window.setTimeout(() => {
|
||||
handledMobileSendRef.current = false;
|
||||
preserveComposerFocusRef.current = false;
|
||||
}, 500);
|
||||
}, 1500);
|
||||
}
|
||||
}}
|
||||
onTouchStart={(event) => {
|
||||
@@ -2024,9 +2025,8 @@ export function ChatView({ projectId, addToast }: ChatViewProps) {
|
||||
focusComposerInput();
|
||||
void handleSend();
|
||||
window.setTimeout(() => {
|
||||
handledMobileSendRef.current = false;
|
||||
preserveComposerFocusRef.current = false;
|
||||
}, 500);
|
||||
}, 1500);
|
||||
}}
|
||||
onMouseDown={(event) => {
|
||||
if (typeof window === "undefined" || window.innerWidth > 768) return;
|
||||
|
||||
@@ -2474,9 +2474,6 @@ export function QuickChatFAB({
|
||||
if (handledMobileActionRef.current) return;
|
||||
handledMobileActionRef.current = true;
|
||||
stopStreaming();
|
||||
window.setTimeout(() => {
|
||||
handledMobileActionRef.current = false;
|
||||
}, 500);
|
||||
}
|
||||
}}
|
||||
onTouchStart={(event) => {
|
||||
@@ -2485,9 +2482,6 @@ export function QuickChatFAB({
|
||||
if (handledMobileActionRef.current) return;
|
||||
handledMobileActionRef.current = true;
|
||||
stopStreaming();
|
||||
window.setTimeout(() => {
|
||||
handledMobileActionRef.current = false;
|
||||
}, 500);
|
||||
}}
|
||||
onMouseDown={(event) => {
|
||||
if (typeof window === "undefined" || window.innerWidth > QUICK_CHAT_DESKTOP_BREAKPOINT) return;
|
||||
@@ -2513,18 +2507,17 @@ export function QuickChatFAB({
|
||||
if (typeof window === "undefined" || window.innerWidth > QUICK_CHAT_DESKTOP_BREAKPOINT) return;
|
||||
event.preventDefault();
|
||||
if (event.pointerType && event.pointerType !== "mouse") {
|
||||
// Dedupe across pointerdown/touchstart/click for one
|
||||
// tap; self-clear via setTimeout because preventDefault
|
||||
// can suppress the synthesized click that previously
|
||||
// cleared this ref. (See ChatView send button.)
|
||||
// Guard against the same touch firing both
|
||||
// onPointerDown and onTouchStart, which would call
|
||||
// handleSendMessage twice — the second call closes
|
||||
// the first's stream and the server-side
|
||||
// beginGeneration aborts the in-flight generation,
|
||||
// producing no output. (See ChatView send button.)
|
||||
if (handledMobileActionRef.current) return;
|
||||
handledMobileActionRef.current = true;
|
||||
markPreserveComposerFocus();
|
||||
focusComposerInput();
|
||||
void handleSendMessage();
|
||||
window.setTimeout(() => {
|
||||
handledMobileActionRef.current = false;
|
||||
}, 500);
|
||||
}
|
||||
}}
|
||||
onTouchStart={(event) => {
|
||||
@@ -2535,9 +2528,6 @@ export function QuickChatFAB({
|
||||
markPreserveComposerFocus();
|
||||
focusComposerInput();
|
||||
void handleSendMessage();
|
||||
window.setTimeout(() => {
|
||||
handledMobileActionRef.current = false;
|
||||
}, 500);
|
||||
}}
|
||||
onMouseDown={(event) => {
|
||||
if (typeof window === "undefined" || window.innerWidth > QUICK_CHAT_DESKTOP_BREAKPOINT) return;
|
||||
|
||||
Reference in New Issue
Block a user