[react] a run that starts elsewhere moves focus from another text field into the composer

Author: samdickson22Created Sep 23, 2026Updated Sep 28, 2026
Labelsbug

Summary

unstable_focusOnRunStart (default true; applies when autoFocus is on) focuses the thread composer on every run start, including runs not started from the composer: a queued message, a resume, or a programmatic append. A user typing in another text field on the page has their focus taken mid-typing.

Type Of Work In Progress

Found while model-checking assistant-ui's runtime with TLA+ and property tests (formal verification of the composer's keyboard, IME and focus handling); reproduced on real code with a failing vitest test.

Reproduction Steps

  1. Render a thread with ComposerPrimitive.Input autoFocus and another <input> on the page.
  2. Focus the other input and type.
  3. Start a run programmatically (for example aui.thread.append(...) from a button handler, or a queued message).
  4. Focus jumps to the composer.

Expected Behavior

Starting a run does not take focus from another text field the user is typing in.

Actual Behavior

The thread composer subscribes to thread.runStart and calls focus(), which checks only autoFocus and whether the composer is disabled, not where focus currently is.

Context

  • Package(s): @assistant-ui/react 0.15.21
  • Repository state: origin/main 96e11d9c0
  • Code: packages/react/src/primitives/composer/ComposerInput.tsx:318-325 (focus), :337-346 (run-start subscription)
  • Failing test: K-5 leaves focus in another text field when a run starts elsewhere (repro test, not in a PR)

Decision needed

This is documented behaviour (the prop's JSDoc: "Whether to automatically focus the input when a new run starts"), so it is a policy question. WCAG 3.2.2 argues against moving focus away from text entry. Options: only move focus when it is on <body> or already inside the thread, only for runs started from the composer, or keep the current behaviour.

Track in Rupic

Source: assistant-ui/assistant-ui