Skip to content

Enter key submits form during streaming because querySelector('button[type="submit"]') returns null #439

@gustavlagneborg

Description

@gustavlagneborg

Bug

When PromptInputSubmit is in the generating/streaming state it renders with
type="button" instead of type="submit" to act as a stop button. This means
form.querySelector('button[type="submit"]') in PromptInputTextarea returns
null.

The Enter key guard checks submitButton?.disabled, which evaluates to
undefined when submitButton is null — so the guard never fires and
form.requestSubmit() is called anyway, allowing users to submit a new message
while the model is still streaming.

Fix

// before
if (submitButton?.disabled) {

// after
if (!submitButton || submitButton.disabled) {
No submit button in the DOM  we're in stop/generating mode → block submission.

Steps to reproduce

  1. Send a message and wait for the model to start streaming
  2. Type anything in the textarea and press Enter
  3. The form submits mid-stream

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions