The best way to control Claude Code, Codex and more from any computer or phone
fix(web): screen readers say which thread a shortcut switched to (#23676)
Co-authored-by: PR Batch Tester <agent@local.test> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
shivam committed
Oct 24, 2026 at 18:06 UTC
7f7daad98503dc049b7230465ae3863d71f197e4
10 files changed
+255
-37
apps/web/src/components/chat/ChatComposer.tsx
+2
-1
@@ -3765,7 +3765,8 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
3765
<ComposerContextActionsContext value={composerContextActions}>
3766
<ComposerPromptEditor
3767
draftKey={composerDraftTargetKey}
3768
- ariaLabel="Message"
3768
+ // Switching threads lands focus here, so the label names the thread.
3769
+ ariaLabel={activeThread ? `Message ${activeThread.title}` : "Message"}
3770
suggestionListId={composerSuggestionListId}
3771
activeSuggestionId={
3772
composerSuggestionListVisible && activeComposerMenuItem
apps/web/src/components/chat/ModelPickerContent.tsx
+21
-11
@@ -52,6 +52,7 @@ import {
52
useEnvironmentModelPreferences,
53
useToggleEnvironmentModelFavorite,
54
} from "~/hooks/useSettings";
55
+import { announce } from "~/lib/announce";
56
import { cn } from "~/lib/utils";
57
import { getVirtualizedScrollFadeClassName } from "../ui/scroll-area";
58
import { TooltipProvider } from "../ui/tooltip";
@@ -485,26 +486,26 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
486
modelSlug: string,
487
instanceId: ProviderInstanceId,
488
additive = false,
488
- ) => {
489
+ ): string | null => {
490
if (getModelDisabledReason?.(instanceId, modelSlug)) {
490
- return;
491
+ return null;
492
}
493
const options = modelOptionsByInstance.get(instanceId);
494
if (!options) {
494
- return;
495
+ return null;
496
}
497
const entry = instanceEntries.find((candidate) => candidate.instanceId === instanceId);
498
if (!entry) {
498
- return;
499
+ return null;
500
}
501
const resolvedModel = resolveSelectableModel(entry.driverKind, modelSlug, options);
501
- if (resolvedModel) {
502
- if (additive && onToggleModel) {
503
- onToggleModel(instanceId, resolvedModel);
504
- } else {
505
- onInstanceModelChange(instanceId, resolvedModel);
506
- }
502
+ if (!resolvedModel) return null;
503
+ if (additive && onToggleModel) {
504
+ onToggleModel(instanceId, resolvedModel);
505
+ } else {
506
+ onInstanceModelChange(instanceId, resolvedModel);
507
}
508
+ return resolvedModel;
509
};
510
511
const modelJumpShortcutContext = {
@@ -773,6 +774,10 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
774
});
775
setSearchQuery("");
776
handleSelectInstance(next);
777
+ announce(
778
+ next === "favorites" ? "Favorites" : (entryByInstanceId.get(next)?.displayName ?? next),
779
+ "model-picker",
780
+ );
781
return;
782
}
783
const jumpIndex = modelPickerJumpIndexFromCommand(command ?? "");
@@ -790,7 +795,12 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
795
if (!model) {
796
return;
797
}
793
- handleModelSelect(model.slug, model.instanceId);
798
+ const selectedSlug = handleModelSelect(model.slug, model.instanceId);
799
+ if (selectedSlug === null) return;
800
+ const name = flatModels.find(
801
+ (item) => item.slug === selectedSlug && item.instanceId === model.instanceId,
802
+ )?.name;
803
+ announce(`Model: ${name ?? selectedSlug}`, "model-picker");
804
};
805
806
return (
apps/web/src/components/chat/OpenInPicker.browser.test.tsx
+35
-1
@@ -1,9 +1,10 @@
1
import { AuthOrchestrationOperateScope, EnvironmentId, type EditorId } from "@t3tools/contracts";
2
import { DEFAULT_RESOLVED_KEYBINDINGS } from "@t3tools/shared/keybindings";
3
+import { Cause } from "effect";
4
import { AsyncResult } from "effect/reactivity";
5
import { describe, expect, it, vi } from "vite-plus/test";
6
6
-import { act, render as renderUi } from "../../../test/render";
7
+import { act, fakeTimers, render as renderUi } from "../../../test/render";
8
import type { RemoteOpenState } from "../../remoteOpen";
9
10
const state = vi.hoisted(() => ({
@@ -181,3 +182,36 @@ describe("host editor access", () => {
182
expect((await pressOpenFavorite()).defaultPrevented).toBe(false);
183
});
184
});
185
+
186
+describe("open in editor announcement", () => {
187
+ it("speaks only after the shortcut opened the editor, from the picker or the fallback", async () => {
188
+ await using fixture = await setup();
189
+ const { screen, renderPicker, pressOpenFavorite, FavoriteEditorFallback } = fixture;
190
+ state.allowed.add(selected);
191
+ await renderPicker();
192
+ using _timers = fakeTimers();
193
+ const regions = () => [...document.querySelectorAll('body > [aria-live="polite"]')];
194
+ const spoken = async () => {
195
+ await act(async () => vi.runAllTimers());
196
+ return regions()
197
+ .map((region) => region.textContent)
198
+ .join("");
199
+ };
200
+ const refuse = () =>
201
+ state.run.mockResolvedValueOnce(AsyncResult.failure(Cause.fail(new Error("No editor"))));
202
+
203
+ refuse();
204
+ await pressOpenFavorite();
205
+ expect(await spoken()).toBe("");
206
+ await pressOpenFavorite();
207
+ expect(await spoken()).toBe("Opened in VS Code");
208
+
209
+ for (const region of regions()) region.textContent = "";
210
+ await act(async () => screen.rerender(<FavoriteEditorFallback />));
211
+ refuse();
212
+ await pressOpenFavorite();
213
+ expect(await spoken()).toBe("");
214
+ await pressOpenFavorite();
215
+ expect(await spoken()).toBe("Opened in VS Code");
216
+ });
217
+});
apps/web/src/components/chat/OpenInPicker.tsx
+17
-14
@@ -58,6 +58,7 @@ import {
58
RustRoverIcon,
59
WebStormIcon,
60
} from "../JetBrainsIcons";
61
+import { announce } from "~/lib/announce";
62
import { cn, isMacPlatform, isWindowsPlatform } from "~/lib/utils";
63
import { shellEnvironment } from "~/state/shell";
64
import { useAtomCommand } from "~/state/use-atom-command";
@@ -240,11 +241,11 @@ export const OpenInPicker = memo(function OpenInPicker({
241
const effectiveEditors = remote.mode === "local-exec" ? availableEditors : remoteCapableEditors;
242
const [preferredEditor, setPreferredEditor] = usePreferredEditor(effectiveEditors);
243
243
- const openInEditor = (editorId: EditorId | null) => {
244
- if (!openInCwd) return;
244
+ const openInEditor = async (editorId: EditorId | null): Promise<boolean> => {
245
+ if (!openInCwd) return false;
246
const editor = editorId ?? preferredEditor;
246
- if (!editor) return;
247
- if (remote.mode === "remote-unavailable") return;
247
+ if (!editor) return false;
248
+ if (remote.mode === "remote-unavailable") return false;
249
if (remote.mode === "remote-links") {
250
const url = buildRemoteOpenUrl({
251
editor,
@@ -252,17 +253,16 @@ export const OpenInPicker = memo(function OpenInPicker({
253
absolutePath: openInCwd,
254
isFile: openInCwdIsFile,
255
});
255
- if (url === undefined) return;
256
+ if (url === undefined) return false;
257
// Only record hint-seen/preferred when the shell actually accepted
258
// the URL (an older desktop build can refuse the editor scheme).
258
- void openRemoteEditorUrl(url).then((opened) => {
259
- if (!opened) return;
260
- markRemoteHintSeen();
261
- setPreferredEditor(editor);
262
- });
263
- return;
259
+ const opened = await openRemoteEditorUrl(url);
260
+ if (!opened) return false;
261
+ markRemoteHintSeen();
262
+ setPreferredEditor(editor);
263
+ return true;
264
}
265
- if (!readEnvironmentScope(environmentId, AuthOrchestrationOperateScope)) return;
265
+ if (!readEnvironmentScope(environmentId, AuthOrchestrationOperateScope)) return false;
266
const result = openInEditorMutation({
267
environmentId,
268
input: {
@@ -272,7 +272,7 @@ export const OpenInPicker = memo(function OpenInPicker({
272
},
273
});
274
setPreferredEditor(editor);
275
- return result;
275
+ return (await result)._tag === "Success";
276
};
277
278
const openFavoriteEditorShortcutLabel = shortcutLabelForCommand(
@@ -293,7 +293,10 @@ export const OpenInPicker = memo(function OpenInPicker({
293
return;
294
295
e.preventDefault();
296
- void openInEditor(preferredEditor);
296
+ const label = editorLabelForPlatform(preferredEditor, navigator.platform);
297
+ void openInEditor(preferredEditor).then((opened) => {
298
+ if (opened) announce(`Opened in ${label}`);
299
+ });
300
};
301
window.addEventListener("keydown", handler, true);
302
return () => window.removeEventListener("keydown", handler, true);
apps/web/src/components/chat/OpenInPickerShortcut.ts
+5
@@ -2,7 +2,9 @@ import type { EditorId, EnvironmentId, ResolvedKeybindingsConfig } from "@t3tool
2
import { useEffect } from "react";
3
4
import { usePreferredEditor } from "../../editorPreferences";
5
+import { editorLabelForPlatform } from "../../editorLabels";
6
import { isOpenFavoriteEditorShortcut } from "../../keybindings";
7
+import { announce } from "../../lib/announce";
8
import { useRemoteOpenState } from "../../remoteOpen";
9
import { shellEnvironment } from "../../state/shell";
10
import { useAtomCommand } from "../../state/use-atom-command";
@@ -31,12 +33,15 @@ export function useOpenFavoriteEditorShortcut({
33
if (!openInCwd || !preferredEditor) return;
34
35
event.preventDefault();
36
+ const label = editorLabelForPlatform(preferredEditor, navigator.platform);
37
void openInEditorMutation({
38
environmentId,
39
input: {
40
cwd: openInCwd,
41
editor: preferredEditor,
42
},
43
+ }).then((result) => {
44
+ if (result._tag === "Success") announce(`Opened in ${label}`);
45
});
46
};
47
window.addEventListener("keydown", handler);
apps/web/src/components/chat/ProviderModelPicker.tsx
+5
-3
@@ -300,9 +300,11 @@ export const ProviderModelPicker = memo(function ProviderModelPicker(props: {
300
terminalOpen={props.terminalOpen ?? false}
301
onRequestClose={() => setIsMenuOpen(false)}
302
{...(props.onOpenProviderSetup ? { onOpenProviderSetup: props.onOpenProviderSetup } : {})}
303
- {...(props.getModelDisabledReason
304
- ? { getModelDisabledReason: props.getModelDisabledReason }
305
- : {})}
303
+ getModelDisabledReason={(instanceId, model) =>
304
+ props.disabled
305
+ ? "Model picker is disabled"
306
+ : (props.getModelDisabledReason?.(instanceId, model) ?? null)
307
+ }
308
onInstanceModelChange={handleInstanceModelChange}
309
/>
310
{props.selectedModels === undefined ? (
apps/web/src/components/sidebar/SidebarThreadUndoNotice.browser.test.tsx
new
+37
@@ -0,0 +1,37 @@
1
+import { describe, expect, it, vi } from "vite-plus/test";
2
+
3
+import { act, fakeTimers, render } from "../../../test/render";
4
+import { useThreadUndoNotice } from "../../hooks/showThreadUndoNotice";
5
+import { SidebarThreadUndoNotice } from "./SidebarThreadUndoNotice";
6
+
7
+const spoken = () =>
8
+ [...document.querySelectorAll('body > [aria-live="polite"]')]
9
+ .map((region) => region.textContent)
10
+ .join("");
11
+
12
+describe("SidebarThreadUndoNotice", () => {
13
+ it("speaks the notice, and drops it when the notice clears before it is spoken", async () => {
14
+ using _notice = { [Symbol.dispose]: () => useThreadUndoNotice.setState({ notice: null }) };
15
+ await using _screen = await render(<SidebarThreadUndoNotice />);
16
+ using _timers = fakeTimers();
17
+ const showSettled = () =>
18
+ act(async () =>
19
+ useThreadUndoNotice.setState({
20
+ notice: { action: "Settled", count: 1, undo: async () => {} },
21
+ }),
22
+ );
23
+
24
+ await showSettled();
25
+ await act(async () => vi.advanceTimersByTime(300));
26
+ expect(spoken()).toMatch(/^Settled 1 thread, /);
27
+
28
+ await act(async () => useThreadUndoNotice.setState({ notice: null }));
29
+ for (const region of document.querySelectorAll('body > [aria-live="polite"]')) {
30
+ region.textContent = "";
31
+ }
32
+ await showSettled();
33
+ await act(async () => useThreadUndoNotice.setState({ notice: null }));
34
+ await act(async () => vi.advanceTimersByTime(300));
35
+ expect(spoken()).toBe("");
36
+ });
37
+});
apps/web/src/components/sidebar/SidebarThreadUndoNotice.tsx
+17
-7
@@ -1,7 +1,9 @@
1
import { useAtomValue } from "@effect/atom-react";
2
+import { useEffect } from "react";
3
4
import { undoLatestThreadAction, useThreadUndoNotice } from "../../hooks/showThreadUndoNotice";
5
import { shortcutLabelForCommand } from "../../keybindings";
6
+import { announce, cancelAnnouncement } from "../../lib/announce";
7
import { primaryServerKeybindingsAtom } from "../../state/server";
8
import { Alert, AlertDescription } from "../ui/alert";
9
import { InlineButton } from "../ui/button";
@@ -10,17 +12,25 @@ export function SidebarThreadUndoNotice() {
12
const notice = useThreadUndoNotice((state) => state.notice);
13
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
14
13
- if (!notice) return null;
15
const shortcut = shortcutLabelForCommand(keybindings, "thread.undo");
15
- const noun = `${notice.action === "Discarded" ? "draft" : "thread"}${notice.count === 1 ? "" : "s"}`;
16
+ const undoLabel = shortcut ? `${shortcut} to undo` : "Undo";
17
+ const summary = notice
18
+ ? `${notice.action} ${notice.count} ${notice.action === "Discarded" ? "draft" : "thread"}${notice.count === 1 ? "" : "s"}`
19
+ : null;
20
+
21
+ // A live region that mounts already filled is skipped by screen readers, and settling
22
+ // usually moves focus to the next thread at the same moment.
23
+ useEffect(() => {
24
+ if (summary) announce(`${summary}, ${undoLabel}`, "thread-undo-notice");
25
+ else cancelAnnouncement("thread-undo-notice");
26
+ }, [summary, undoLabel]);
27
+
28
+ if (!summary) return null;
29
30
return (
18
- <Alert role="status" variant="sidebar">
31
+ <Alert role="group" variant="sidebar">
32
<AlertDescription>
20
- {notice.action} {notice.count} {noun},{" "}
21
- <InlineButton onClick={undoLatestThreadAction}>
22
- {shortcut ? `${shortcut} to undo` : "Undo"}
23
- </InlineButton>
33
+ {summary}, <InlineButton onClick={undoLatestThreadAction}>{undoLabel}</InlineButton>
34
</AlertDescription>
35
</Alert>
36
);
apps/web/src/lib/announce.browser.test.ts
new
+62
@@ -0,0 +1,62 @@
1
+import { describe, expect, it, vi } from "vite-plus/test";
2
+
3
+import { fakeTimers } from "../../test/render";
4
+import { announce, cancelAnnouncement } from "./announce";
5
+
6
+function spokenText() {
7
+ return Array.from(document.querySelectorAll('[aria-live="polite"]'), (region) =>
8
+ region.textContent?.trim(),
9
+ ).filter(Boolean);
10
+}
11
+
12
+describe("announce", () => {
13
+ it("waits for focus to settle, then speaks waiting messages together", () => {
14
+ using _timers = fakeTimers();
15
+ const composer = document.createElement("textarea");
16
+ document.body.append(composer);
17
+ using _composer = { [Symbol.dispose]: () => composer.remove() };
18
+
19
+ announce("Settled 1 thread, Ctrl+Z to undo");
20
+ announce("Model: Claude Sonnet 5.5");
21
+ vi.advanceTimersByTime(200);
22
+ composer.focus();
23
+ vi.advanceTimersByTime(200);
24
+ expect(spokenText()).toEqual([]);
25
+
26
+ vi.advanceTimersByTime(50);
27
+ expect(spokenText()).toEqual(["Settled 1 thread, Ctrl+Z to undo. Model: Claude Sonnet 5.5"]);
28
+ });
29
+
30
+ it("speaks the same message twice in a row through the other region", () => {
31
+ using _timers = fakeTimers();
32
+ const regionTexts = () =>
33
+ Array.from(document.querySelectorAll('[aria-live="polite"]'), (region) => region.textContent);
34
+
35
+ announce("Claude");
36
+ vi.runAllTimers();
37
+ const first = regionTexts();
38
+ announce("Claude");
39
+ vi.runAllTimers();
40
+
41
+ expect(regionTexts()).toEqual([...first].reverse());
42
+ expect(regionTexts()).toContain("Claude");
43
+ });
44
+
45
+ it("replaces a waiting message from the same source", () => {
46
+ using _timers = fakeTimers();
47
+
48
+ announce("Settled 1 thread, Ctrl+Z to undo", "undo");
49
+ announce("Opening in VS Code");
50
+ announce("Settled 2 threads, Ctrl+Z to undo", "undo");
51
+ vi.runAllTimers();
52
+
53
+ expect(spokenText()).toEqual(["Opening in VS Code. Settled 2 threads, Ctrl+Z to undo"]);
54
+
55
+ announce("Settled 1 thread, Ctrl+Z to undo", "undo");
56
+ announce("Opening in Zed");
57
+ cancelAnnouncement("undo");
58
+ vi.runAllTimers();
59
+
60
+ expect(spokenText()).toEqual(["Opening in Zed"]);
61
+ });
62
+});
apps/web/src/lib/announce.ts
new
+54
@@ -0,0 +1,54 @@
1
+// Screen readers skip a live region that appears already filled, and moving focus cuts off
2
+// whatever they were saying. So the regions exist before the first message lands, and
3
+// messages wait until focus has stayed put for a moment, then are spoken together.
4
+const FOCUS_SETTLE_MS = 250;
5
+
6
+let regions: readonly [HTMLElement, HTMLElement] | null = null;
7
+let pending: { message: string; source: string | undefined }[] = [];
8
+let flushTimer: ReturnType<typeof setTimeout> | undefined;
9
+
10
+function scheduleFlush() {
11
+ clearTimeout(flushTimer);
12
+ flushTimer = setTimeout(flush, FOCUS_SETTLE_MS);
13
+}
14
+
15
+function flush() {
16
+ if (!regions || pending.length === 0) return;
17
+ const [first, second] = regions;
18
+ // Alternating between two regions lets the same message be spoken twice in a row.
19
+ const target = first.textContent ? second : first;
20
+ first.textContent = "";
21
+ second.textContent = "";
22
+ target.textContent = pending.map((entry) => entry.message).join(". ");
23
+ pending = [];
24
+}
25
+
26
+function createRegion() {
27
+ const region = document.createElement("div");
28
+ region.className = "sr-only";
29
+ region.setAttribute("aria-live", "polite");
30
+ region.setAttribute("aria-atomic", "true");
31
+ document.body.append(region);
32
+ return region;
33
+}
34
+
35
+/**
36
+ * Tells screen reader users what an action did when focus alone doesn't show it. A message
37
+ * replaces one still waiting from the same `source`, so a superseded status isn't read out.
38
+ */
39
+export function announce(message: string, source?: string) {
40
+ if (!regions) {
41
+ regions = [createRegion(), createRegion()];
42
+ document.addEventListener("focusin", () => {
43
+ if (pending.length > 0) scheduleFlush();
44
+ });
45
+ }
46
+ if (source !== undefined) pending = pending.filter((entry) => entry.source !== source);
47
+ if (pending.at(-1)?.message !== message) pending.push({ message, source });
48
+ scheduleFlush();
49
+}
50
+
51
+/** Drops a message from `source` that hasn't been spoken yet, once it no longer applies. */
52
+export function cancelAnnouncement(source: string) {
53
+ pending = pending.filter((entry) => entry.source !== source);
54
+}