diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx index 21ff4756fc..36e7d1348e 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx +++ b/apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx @@ -1,6 +1,6 @@ 'use client' -import { useCallback, useEffect, useLayoutEffect, useRef } from 'react' +import { useCallback, useLayoutEffect, useRef } from 'react' import { cn } from '@/lib/core/utils/cn' import { MessageActions } from '@/app/workspace/[workspaceId]/components' import { ChatMessageAttachments } from '@/app/workspace/[workspaceId]/home/components/chat-message-attachments' @@ -99,41 +99,16 @@ export function MothershipChat({ const hasMessages = messages.length > 0 const initialScrollDoneRef = useRef(false) - const primedQueueIdRef = useRef(null) - const primeTimerRef = useRef | null>(null) const messageQueueRef = useRef(messageQueue) messageQueueRef.current = messageQueue const onSendQueuedMessageRef = useRef(onSendQueuedMessage) onSendQueuedMessageRef.current = onSendQueuedMessage - const clearPrimed = useCallback(() => { - primedQueueIdRef.current = null - if (primeTimerRef.current) { - clearTimeout(primeTimerRef.current) - primeTimerRef.current = null - } - }, []) - const handleEnterWhileEmpty = useCallback(() => { const topMessage = messageQueueRef.current[0] if (!topMessage) return false - - if (primedQueueIdRef.current === topMessage.id) { - clearPrimed() - void onSendQueuedMessageRef.current(topMessage.id) - return true - } - - primedQueueIdRef.current = topMessage.id - if (primeTimerRef.current) clearTimeout(primeTimerRef.current) - primeTimerRef.current = setTimeout(clearPrimed, 3000) + void onSendQueuedMessageRef.current(topMessage.id) return true - }, [clearPrimed]) - - useEffect(() => { - return () => { - if (primeTimerRef.current) clearTimeout(primeTimerRef.current) - } }, []) useLayoutEffect(() => { @@ -235,7 +210,6 @@ export function MothershipChat({ editValue={editValue} onEditValueConsumed={onEditValueConsumed} onEnterWhileEmpty={handleEnterWhileEmpty} - onPrimedDismiss={clearPrimed} /> diff --git a/apps/sim/app/workspace/[workspaceId]/home/components/user-input/user-input.tsx b/apps/sim/app/workspace/[workspaceId]/home/components/user-input/user-input.tsx index bbac9cbade..d2415318b3 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/components/user-input/user-input.tsx +++ b/apps/sim/app/workspace/[workspaceId]/home/components/user-input/user-input.tsx @@ -109,7 +109,6 @@ interface UserInputProps { userId?: string onContextAdd?: (context: ChatContext) => void onEnterWhileEmpty?: () => boolean - onPrimedDismiss?: () => void } export function UserInput({ @@ -123,7 +122,6 @@ export function UserInput({ userId, onContextAdd, onEnterWhileEmpty, - onPrimedDismiss, }: UserInputProps) { const { workspaceId } = useParams<{ workspaceId: string }>() const { data: workflowsById = {} } = useWorkflowMap(workspaceId) @@ -456,7 +454,8 @@ export function UserInput({ (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing) { e.preventDefault() - if (isSendingRef.current && !valueRef.current.trim() && onEnterWhileEmptyRef.current?.()) { + if (isSendingRef.current && !valueRef.current.trim()) { + onEnterWhileEmptyRef.current?.() return } handleSubmit() @@ -551,9 +550,8 @@ export function UserInput({ setValue(newValue) restartRecognition(newValue) - if (newValue.trim()) onPrimedDismiss?.() }, - [restartRecognition, onPrimedDismiss] + [restartRecognition] ) const handleSelectAdjust = useCallback(() => {