Skip to content

Fix duplicate chat submits from Enter races and IME composition#2

Open
coconiiruzo wants to merge 1 commit into
dosco:mainfrom
coconiiruzo:fix/chat-double-submit-ime
Open

Fix duplicate chat submits from Enter races and IME composition#2
coconiiruzo wants to merge 1 commit into
dosco:mainfrom
coconiiruzo:fix/chat-double-submit-ime

Conversation

@coconiiruzo

@coconiiruzo coconiiruzo commented Jul 21, 2026

Copy link
Copy Markdown

Summary

  • Guard chat submit with a synchronous localTurnRef update so a second Enter/click cannot race ahead of React state and POST a duplicate agent turn.
  • Ignore Enter while an IME composition is active (isComposing / keyCode 229), which is a common Japanese-input footgun in chat composers.

Screenshot

One session showing before/after:

  • Before: 「こんにちは」 and 「あなたは?」 each produced two user bubbles and two agent turns.
  • After this fix: the final 「ハロー」 turn stayed a single request/response.

chat double-submit before/after

Test plan

  • Fresh chat: type Japanese with IME, press Enter once to confirm composition — message should not send
  • Press Enter again after composition ends — exactly one user message and one agent turn
  • Rapid double Enter / double click Send on English text — only one turn is created (second becomes pending queue item if first is already busy)
  • Stop and retry still work as before

Local verification: bun run check — 692 pass, 0 fail (Bun 1.3.14).

Guard submit with a synchronous localTurn ref and ignore Enter while an IME composition is active so one keypress cannot enqueue two agent turns.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to 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