Skip to content

fix(deployed-chat): prevent multiple simultaneous messages - #1893

Merged
Sg312 merged 1 commit into
stagingfrom
fix/deployed-chat-multiple-messages
Nov 11, 2025
Merged

fix(deployed-chat): prevent multiple simultaneous messages#1893
Sg312 merged 1 commit into
stagingfrom
fix/deployed-chat-multiple-messages

Conversation

@Sg312

Copy link
Copy Markdown
Collaborator

Summary

Deployed chat - prevent multiple simultaneous messages

Fixes #(issue)

Type of Change

  • Bug fix

Testing

Manual

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercelBot commented Nov 11, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedNov 11, 2025 6:32pm

@Sg312
Sg312 merged commit 41f3d50 into stagingNov 11, 2025
9 checks passed
@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Added isStreaming guard in handleSubmit function to prevent users from sending multiple messages simultaneously while a response is being streamed.

Key Changes:

  • Added early return in handleSubmit (line 170) to check isStreaming state before processing message submission
  • This guard prevents race conditions where rapid clicks/Enter presses could trigger multiple API requests
  • Complements the existing guard in handleSendMessage (line 298) which checks isLoading
  • Works in conjunction with the useChatStreaming hook that manages the isStreamingResponse state

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk - it's a well-targeted bug fix that adds defensive logic without breaking existing functionality
  • The change is a single-line guard that prevents a clear race condition. It follows the existing pattern used in handleSendMessage and integrates properly with the streaming state management. The fix is minimal, focused, and doesn't introduce new complexity or side effects
  • No files require special attention

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/app/chat/components/input/input.tsx5/5Added isStreaming guard to handleSubmit to prevent multiple simultaneous messages from being sent

Sequence Diagram

sequenceDiagram
participant User
participant ChatInput
participant ChatClient
participant API
participant StreamHandler
User->>ChatInput: Click Send/Press Enter
ChatInput->>ChatInput: Check if isStreaming
alt isStreaming is true
ChatInput-->>User: Return early (prevent duplicate)
else isStreaming is false
ChatInput->>ChatInput: Validate input/files
ChatInput->>ChatClient: Call onSubmit(value, isVoiceInput, files)
ChatClient->>ChatClient: handleSendMessage()
ChatClient->>ChatClient: Add user message to state
ChatClient->>API: POST /api/chat/{identifier}
API-->>ChatClient: Stream response
ChatClient->>StreamHandler: handleStreamedResponse()
StreamHandler->>StreamHandler: Set isStreamingResponse = true
loop Process stream chunks
StreamHandler->>ChatClient: Update message content
ChatClient-->>User: Display streaming response
end
StreamHandler->>StreamHandler: Set isStreamingResponse = false
StreamHandler-->>ChatClient: Stream complete
ChatClient-->>User: Final response displayed
end
Loading

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1waleedlatif1 mentioned this pull request Nov 12, 2025
10 tasks
@waleedlatif1
waleedlatif1 deleted the fix/deployed-chat-multiple-messages branch November 18, 2025 01:28
Sign up for freeto 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.

1 participant

@Sg312