Announce streamed replies and move focus after a thread switch
The gap
docs/architecture/chat.md lists this under Known gaps:
No live region announces streamed text, and focus does not move to the conversation heading after a thread switch; the dashboard design asks for both.
Why it matters
A screen reader user sends a message and hears "Thinking", from the one live region chat has. Then nothing. The reply streams into the transcript, finishes, and is never announced, so the only way to learn that an answer arrived is to go looking for it. The rest of the chat surface is carefully labelled — regions, citation buttons, icon-only controls — which makes this the one gap that undoes the others.
Switching threads has the mirror problem: the whole conversation is replaced and nothing says so. A sighted user sees the transcript change; a screen reader user is left wherever they were.
Where
surfsense_local/frontend/src/features/chat/thread-panel.tsx— the<section aria-label="Conversation">and its<header>. Note there is no heading element in it at all: the thread title is aButtonthat opens rename. "Move focus to the conversation heading" therefore means introducing one first.message.tsxandchat-viewport.tsx— where a reply's completion is observable.- Reuse, do not reinvent:
reply-thinking.tsxalready has therole="status"sr-only span pattern for this feature, andinstall-progress.tsxhas thesr-only+aria-live="polite"form. For focus-a-heading-on-change,studio/viewers/quiz/review-screen.tsxandscore-screen.tsxalready do it with aheadingRef. selectThread()inuse-chat-runtime.tsis the one place a thread switch happens.
What done looks like
- A completed reply is announced. Do not announce the token stream — a polite region fed every delta produces continuous interruption and is worse than silence. Announcing that the reply finished, or announcing the finished text once, are the two sane readings, and picking between them is yours. Say which you chose.
- The conversation has a real heading, and after a thread switch focus lands on it.
- Both work with the existing
role="status"region for "Thinking" rather than fighting it: one turn should not produce two regions talking over each other. - Delete the Known gaps line from
docs/architecture/chat.mdand add what you built to the doc's Accessibility list.
What not to change
The composer input carries unstable_focusOnThreadSwitched, so focus already moves on a thread switch — to the composer. That is deliberate: it is what lets someone switch threads and start typing. Moving focus to a heading instead is a behaviour change for everyone, not an addition, so work out how the two coexist before you wire the second one up. This is the one real trap in this issue.
How to verify
reply-thinking.test.tsx shows how this feature's live region is asserted (screen.getByRole("status")), and dashboard-page.test.tsx drives a thread switch end to end. Write the failing tests first.
cd surfsense_local/frontend
pnpm test
# from the repo root, because the PR edits a doc
cd ../.. && python scripts/check_docs.pyBefore you start
Read CONTRIBUTING.md and the chat doc, including its Accessibility section, which is the standard the rest of this surface already meets. React work in surfsense_local/frontend follows the frontend-workflow skill and interface strings follow the translate skill, both described in AGENTS.md. Open your PR against dev, not main. Comment here to claim this.
Source: MODSetter/SurfSense