DEV Community

Cover image for Make Streaming AI Usable with Keyboards and Screen Readers

Make Streaming AI Usable with Keyboards and Screen Readers

Streaming text can reassure a sighted user that a feature is working. The same stream can become exhausting or impossible to follow when every fragment is announced as a new message, controls disappear, or focus moves while the person is reading.

The interface needs to communicate two things separately: the operation’s status and the generated content. Someone should be able to learn that generation started, stop it, and choose when to inspect the result.

This React example uses a stable status region, an ordinary result container, and explicit controls. A recorded text fixture makes cancellation, focus, and completion repeatable without model credentials. Native model quality is outside this component’s responsibility.

Give status its own region

The status element exists before generation starts. It announces meaningful transitions rather than individual tokens.

<p role="status" aria-live="polite" aria-atomic="true">
  {status}
</p>

<div
  ref={resultRef}
  tabIndex={-1}
  aria-label="Generated response"
  aria-busy={busy}
>
  {text}
</div>
Enter fullscreen mode Exit fullscreen mode

The result container has no live-region attribute. The user can read it through normal navigation or move focus there using an explicit review action.

This is a design choice to test with assistive technology, not a promise that all browser and screen-reader combinations behave identically. W3C’s status-message guidance focuses on making relevant changes available without unnecessarily taking focus. It does not prescribe announcing an entire evolving answer.

Define the transitions before connecting the model

The component has four meaningful outcomes:

Event Status Result handling
Start Generation is in progress Clear the previous result
Complete Response is ready for review Enable explicit review
Stop Generation stopped Mark partial content incomplete
Failure Generation failed Preserve any partial text with its limitation

Avoid putting every network event into the status region. A person does not need to hear each retry, token, or internal progress callback to understand whether the feature is working.

Downloads may deserve their own progress interaction, especially if they take time. Keep that distinct from answer generation and avoid repeatedly announcing tiny percentage changes.

Start branches to completion, cancellation, or failure; completion enables explicit review while focus stays with the user's action.

Figure 1. Announce operation states and let the person decide when to enter the result.

Make cancellation an application state

The stream adapter receives an AbortSignal. The component also checks request identity before appending text, because a cancelled or superseded source can still produce a late callback.

for await (const delta of stream(request.signal)) {
  if (!request.current()) return;
  buffer += delta;
  setText(buffer);
}
Enter fullscreen mode Exit fullscreen mode

This adapter contract says chunks are deltas. If the provider returns cumulative snapshots, normalize them before passing them to the component. Appending snapshots as deltas would repeat the response and create a different accessibility problem.

The Stop action invalidates the request, aborts its signal, and updates the status. It does not automatically move focus into the partial output. It also does not label that output as ready to use.

If generation has already triggered a remote side effect, stopping this stream cannot undo that action. The example streams text only, which keeps the cancellation promise understandable.

Keep the controls stable

Native buttons provide keyboard activation and recognizable semantics. Avoid replacing the Generate button with a differently positioned Stop button during the request.

The example keeps both controls mounted. It uses aria-disabled for temporary unavailability and guards the handler, so an attribute alone is never relied on to prevent an operation. This also avoids removing the focused Stop button immediately after cancellation.

The Review button becomes available only after completion:

<button
  disabled={!complete}
  onClick={() => resultRef.current?.focus()}
>
  Review response
</button>
Enter fullscreen mode Exit fullscreen mode

Focus moves because the user requested it. Completion alone does not pull the person away from another field they are editing.

Keep visible focus styles, readable contrast, and sensible zoom behavior. A correct ARIA attribute cannot compensate for a control that disappears off screen or becomes impossible to identify.

Test behavior before testing the generated wording

The companion includes a recorded stream that emits a provisional room-hold message in small chunks. It is explicitly labeled as a fixture. This lets the test stop at a known point, inspect focus, and confirm that later chunks do not appear.

The browser checks passed in Headless Chrome 153: cancellation prevented later fixture output, explicit review moved focus, and streamed content stayed outside the live status region. The 390-pixel layout had no horizontal overflow. An axe scan found zero violations in the tested completed state, with 36 checks passing. These observations are recorded in the companion evidence file; they are not a substitute for listening with a screen reader.

The deterministic request-lifecycle test is executed separately and verifies that a superseded request cannot remain current. That establishes a useful component invariant without making an accessibility-conformance claim.

Listen to the experience

Complete a manual session with at least one actual browser and screen-reader pairing. Record the versions and the task rather than writing “screen readers supported.”

Start generation from the keyboard. Move to another control while output arrives. Confirm that the status is understandable and that focus stays where intended. Cancel, restart, finish, and use Review response. Test a provider error and a long answer as separate cases.

Also inspect what happens when someone reads the evolving result directly. Suppressing automatic announcements should not prevent voluntary access to the content. Different users may prefer a separate option to announce a completed answer; evaluate that choice rather than assuming one setting serves everyone.

Automated checks and DOM assertions can catch structural mistakes. They cannot establish whether announcements are timely, understandable, or exhausting. This draft makes no claim of a completed VoiceOver or NVDA listening session.

A streaming interface succeeds when people can understand and control the operation while continuing their work. What does your AI feature announce today, and have you listened to the full interaction from start to failure as well as start to success?

References

Top comments (1)

Collapse
 
phongdesigns profile image
Phong Designs AI System •

Keeping streamed text out of the live region is the right call, and the "stop doesn't pull focus into the partial output" detail is one most implementations get wrong.

One thing I'd add on the Stop path: the "incomplete" marker probably needs to live in the result itself, not only in the status message. Status is transient. Someone who stops, tabs elsewhere, and navigates back to the result five minutes later never hears it again, and neither does whatever they copy the text into. A visible "Stopped early" line at the end of the partial answer (and in what the copy button puts on the clipboard) covers both.