The best way to control Claude Code, Codex and more from any computer or phone
fix(web): citation jumps move focus to the cited response (#37813)
Julius Marminge committed
Nov 16, 2026 at 16:05 UTC
4b758f49ec52ab58a0bd9647e28c9e2911945c88
2 files changed
+25
apps/web/src/components/chat/AssistantCitationSource.tsx
+10
@@ -204,6 +204,14 @@ function observeAssistantCitationSource({
204
if (rect.bottom <= scrollRect.top || rect.top >= scrollRect.bottom) return;
205
activation.scrolled = true;
206
request.onComplete();
207
+ // Screen readers follow focus, not scroll; leave someone already typing alone.
208
+ const active = root.ownerDocument.activeElement;
209
+ if (
210
+ !(active instanceof HTMLElement) ||
211
+ !(active.isContentEditable || active.matches("input, textarea, select"))
212
+ ) {
213
+ root.focus({ preventScroll: true });
214
+ }
215
if (!range) {
216
toastManager.add({
217
type: "warning",
@@ -359,6 +367,8 @@ export function AssistantCitationSource({
367
return (
368
<div
369
ref={rootRef}
370
+ tabIndex={-1}
371
+ className="outline-none"
372
data-assistant-citation-source={messageId}
373
data-assistant-citation-environment={threadRef?.environmentId}
374
data-assistant-citation-thread={threadRef?.threadId}
apps/web/src/components/chat/MessagesTimeline.browser.test.tsx
+15
@@ -1254,6 +1254,21 @@ describe("MessagesTimeline citations", () => {
1254
);
1255
});
1256
1257
+ it("moves focus to the cited response so screen readers follow it", async () => {
1258
+ await using _screen = await renderTimeline(
1259
+ [
1260
+ message("A question", {}, "question"),
1261
+ message("the cited answer", { role: "assistant" }, "cited"),
1262
+ ],
1263
+ { citationRequest: CITATION_REQUEST, citationHistory: { _tag: "found" } },
1264
+ );
1265
+ await vi.waitFor(() => {
1266
+ const cited = document.querySelector("[data-citation-highlighted]");
1267
+ expect(cited?.textContent).toContain("the cited answer");
1268
+ expect(cited?.contains(document.activeElement)).toBe(true);
1269
+ });
1270
+ });
1271
+
1272
it("opens the superseded attempt that folds the cited response", async () => {
1273
const runId = RunId.make("run-steered");
1274
const attempt = (id: string, ordinal: number, status: "superseded" | "running") => ({