@devries-cameron20 / t3code-1 / commits / 0cf482b08b
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): make composer suggestions usable with screen readers (#10154)

Co-authored-by: Khai Shern, Toh <khaishern8235@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

Andrew Johnson committed Sep 30, 2026 at 20:54 UTC 0cf482b08bca0249ec94fbcbd0eb04fff28d9b3d
6 files changed +126 -6
apps/web/src/components/ComposerPromptEditorTiptap.tsx
+25 -1
@@ -121,6 +121,11 @@ export interface ComposerPromptEditorProps {
121 skills: ReadonlyArray<ServerProviderSkill>;
122 disabled: boolean;
123 placeholder: string;
124 + ariaLabel?: string | undefined;
125 + /** Identifies an editor with suggestions, even while its list is closed. */
126 + suggestionListId?: string | undefined;
127 + /** References the highlighted option only while its list is rendered. */
128 + activeSuggestionId?: string | undefined;
129 containerClassName?: string;
130 className?: string;
131 placeholderClassName?: string;
@@ -592,6 +597,9 @@ function ComposerPromptEditorTiptapInner(props: ComposerPromptEditorProps) {
597 skills,
598 disabled,
599 placeholder,
600 + ariaLabel,
601 + suggestionListId,
602 + activeSuggestionId,
603 containerClassName,
604 className,
605 placeholderClassName,
@@ -752,9 +760,25 @@ function ComposerPromptEditorTiptapInner(props: ComposerPromptEditorProps) {
760 ),
761 "data-testid": "composer-editor",
762 "data-composer-rich-text": richText ? "true" : "false",
763 + role: "textbox",
764 + "aria-multiline": "true",
765 + ...(ariaLabel ? { "aria-label": ariaLabel } : {}),
766 + ...(disabled ? { "aria-readonly": "true" } : {}),
767 + ...(!disabled && suggestionListId
768 + ? {
769 + "aria-autocomplete": "list",
770 + "aria-haspopup": "listbox",
771 + ...(activeSuggestionId
772 + ? {
773 + "aria-controls": suggestionListId,
774 + "aria-activedescendant": activeSuggestionId,
775 + }
776 + : {}),
777 + }
778 + : {}),
779 "aria-placeholder": placeholder,
780 }),
757 - [className, placeholder, richText],
781 + [activeSuggestionId, ariaLabel, className, disabled, placeholder, richText, suggestionListId],
782 );
783
784 const editor = useEditor(
apps/web/src/components/chat/ChatComposer.tsx
+33 -3
@@ -58,6 +58,7 @@ import {
58 type ReactNode,
59 useCallback,
60 useEffect,
61 + useId,
62 useImperativeHandle,
63 useLayoutEffect,
64 useMemo,
@@ -245,7 +246,11 @@ import { useEnvironmentQuery } from "~/state/query";
246 import { useDebouncedValue } from "~/state/queries";
247 import { ProviderModelPicker } from "./ProviderModelPicker";
248 import { resolveModelPickerSelectedModel } from "./ModelPickerContent";
248 -import { type ComposerCommandItem, ComposerCommandMenu } from "./ComposerCommandMenu";
249 +import {
250 + type ComposerCommandItem,
251 + ComposerCommandMenu,
252 + composerSuggestionOptionId,
253 +} from "./ComposerCommandMenu";
254 import { ComposerPendingApprovalActions } from "./ComposerPendingApprovalActions";
255 import { CompactComposerControlsMenu } from "./CompactComposerControlsMenu";
256 import { ComposerImageThumbnail } from "./ComposerImageThumbnail";
@@ -2108,6 +2113,8 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
2113 resetTrigger: resetComposerTrigger,
2114 } = useComposerTriggerState(() => detectComposerTrigger(prompt, prompt.length));
2115 const [composerHighlightedItemId, setComposerHighlightedItemId] = useState<string | null>(null);
2116 + const composerSuggestionId = useId();
2117 + const composerSuggestionListId = `${composerSuggestionId}-${encodeURIComponent(draftId ?? activeThreadId ?? "new")}-suggestions`;
2118 // Active ArrowUp recall. Cleared on edit and on thread switch.
2119 const promptHistoryPositionRef = useRef<ComposerPromptHistoryPosition | null>(null);
2120 const [composerHighlightedSearchKey, setComposerHighlightedSearchKey] = useState<string | null>(
@@ -2502,7 +2509,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
2509
2510 const composerMenuOpen = Boolean(composerTrigger);
2511 const composerMenuSearchKey = composerTrigger
2505 - ? `${composerTrigger.kind}:${composerTrigger.query.trim().toLowerCase()}`
2512 + ? `${composerSuggestionListId}:${composerTrigger.kind}:${composerTrigger.query.trim().toLowerCase()}`
2513 : null;
2514 const activeComposerMenuItem = useMemo(() => {
2515 const activeItemId = resolveComposerMenuActiveItemId({
@@ -2529,6 +2536,8 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
2536 );
2537
2538 const isComposerApprovalState = activePendingApproval !== null;
2539 + const composerSuggestionsVisible = composerMenuOpen && !isComposerApprovalState;
2540 + const composerSuggestionListVisible = composerSuggestionsVisible && composerMenuItems.length > 0;
2541 const activePendingUserInput = pendingUserInputs[0] ?? null;
2542 const isChoiceOnlyPendingQuestion =
2543 activePendingProgress?.activeQuestion?.allowCustomAnswer === false;
@@ -3176,6 +3185,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
3185 // ------------------------------------------------------------------
3186 useEffect(() => {
3187 setComposerHighlightedItemId(null);
3188 + setComposerHighlightedSearchKey(null);
3189 setComposerSubmissionError(null);
3190 setProviderInputSubmissionError(null);
3191 setComposerCursor(collapseExpandedComposerCursor(promptRef.current, promptRef.current.length));
@@ -6454,9 +6464,19 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
6464 </ComposerCommandMenuLayer>
6465 )}
6466
6457 - {composerMenuOpen && !isComposerApprovalState && (
6467 + <div role="status" aria-atomic="true" className="sr-only">
6468 + {composerSuggestionsVisible && composerMenuItems.length === 0
6469 + ? isComposerMenuLoading
6470 + ? composerTriggerKind === "pull-request"
6471 + ? "Finding pull request..."
6472 + : "Searching workspace files..."
6473 + : composerMenuEmptyState
6474 + : ""}
6475 + </div>
6476 + {composerSuggestionsVisible && (
6477 <ComposerCommandMenuLayer anchor={composerMenuAnchor}>
6478 <ComposerCommandMenu
6479 + listId={composerSuggestionListId}
6480 items={composerMenuItems}
6481 resolvedTheme={resolvedTheme}
6482 isLoading={isComposerMenuLoading}
@@ -6845,6 +6865,16 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
6865 ) : null}
6866 <ComposerContextActionsContext value={composerContextActions}>
6867 <ComposerPromptEditor
6868 + ariaLabel="Message"
6869 + suggestionListId={composerSuggestionListId}
6870 + activeSuggestionId={
6871 + composerSuggestionListVisible && activeComposerMenuItem
6872 + ? composerSuggestionOptionId(
6873 + composerSuggestionListId,
6874 + activeComposerMenuItem.id,
6875 + )
6876 + : undefined
6877 + }
6878 editorRef={composerEditorRef}
6879 richTextEnabled={settings.composerRichTextEnabled}
6880 value={
apps/web/src/components/chat/ComposerCommandMenu.test.tsx
+28 -1
@@ -2,12 +2,37 @@ import { renderToStaticMarkup } from "react-dom/server";
2 import { ProviderDriverKind } from "@t3tools/contracts";
3 import { describe, expect, it } from "vite-plus/test";
4
5 -import { ComposerCommandMenu } from "./ComposerCommandMenu";
5 +import { ComposerCommandMenu, composerSuggestionOptionId } from "./ComposerCommandMenu";
6 +
7 +describe("composerSuggestionOptionId", () => {
8 + it("keeps whitespace, escape-like paths, and malformed UTF-16 distinct", () => {
9 + const paths = [
10 + "docs/my file.md",
11 + "docs/my_file.md",
12 + "docs/my%20file.md",
13 + "docs/my\tfile.md",
14 + "docs/\ud800.md",
15 + "docs/\ud801.md",
16 + "docs/\udc00.md",
17 + "docs/\ufffd.md",
18 + "docs/\\ud800.md",
19 + "docs/\ud83d\ude80.md",
20 + ];
21 + const ids = paths.map((path) => composerSuggestionOptionId("suggestions", `path:file:${path}`));
22 +
23 + expect(new Set(ids).size).toBe(paths.length);
24 + for (const id of ids) expect(id).not.toMatch(/\s|[\ud800-\udfff]/u);
25 + expect(composerSuggestionOptionId("other-composer", paths[0]!)).not.toBe(
26 + composerSuggestionOptionId("suggestions", paths[0]!),
27 + );
28 + });
29 +});
30
31 describe("ComposerCommandMenu", () => {
32 it("renders slash commands with their descriptions", () => {
33 const markup = renderToStaticMarkup(
34 <ComposerCommandMenu
35 + listId="test-suggestions"
36 items={[
37 {
38 id: "slash:model",
@@ -33,6 +58,7 @@ describe("ComposerCommandMenu", () => {
58 it("shows the app source for an app skill", () => {
59 const markup = renderToStaticMarkup(
60 <ComposerCommandMenu
61 + listId="test-suggestions"
62 items={[
63 {
64 id: "skill:codex:browser",
@@ -67,6 +93,7 @@ describe("ComposerCommandMenu", () => {
93 it("shows the repo source for a slash skill", () => {
94 const markup = renderToStaticMarkup(
95 <ComposerCommandMenu
96 + listId="test-suggestions"
97 items={[
98 {
99 id: "skill:codex:ask-matt",
apps/web/src/components/chat/ComposerCommandMenu.tsx
+22 -1
@@ -69,6 +69,7 @@ export type ComposerCommandItem =
69 };
70
71 export const ComposerCommandMenu = memo(function ComposerCommandMenu(props: {
72 + listId: string;
73 items: ComposerCommandItem[];
74 resolvedTheme: "light" | "dark";
75 isLoading: boolean;
@@ -104,11 +105,16 @@ export const ComposerCommandMenu = memo(function ComposerCommandMenu(props: {
105 data-composer-command-drawer="true"
106 >
107 {props.items.length > 0 ? (
107 - <CommandList className="max-h-72 min-h-0 scroll-pb-6">
108 + <CommandList
109 + id={props.listId}
110 + aria-label={props.triggerKind ? LISTBOX_LABEL_BY_TRIGGER[props.triggerKind] : undefined}
111 + className="max-h-72 min-h-0 scroll-pb-6"
112 + >
113 <CommandGroup>
114 {props.items.map((item) => (
115 <ComposerCommandMenuItem
116 key={item.id}
117 + optionId={composerSuggestionOptionId(props.listId, item.id)}
118 item={item}
119 triggerKind={props.triggerKind}
120 resolvedTheme={props.resolvedTheme}
@@ -143,6 +149,7 @@ export const ComposerCommandMenu = memo(function ComposerCommandMenu(props: {
149 });
150
151 const ComposerCommandMenuItem = memo(function ComposerCommandMenuItem(props: {
152 + optionId: string;
153 item: ComposerCommandItem;
154 triggerKind: ComposerTriggerKind | null;
155 resolvedTheme: "light" | "dark";
@@ -159,6 +166,8 @@ const ComposerCommandMenuItem = memo(function ComposerCommandMenuItem(props: {
166
167 return (
168 <CommandItem
169 + render={<div id={props.optionId} />}
170 + aria-selected={props.isActive}
171 value={props.item.id}
172 data-composer-item-id={props.item.id}
173 active={props.isActive}
@@ -211,6 +220,18 @@ const ComposerCommandMenuItem = memo(function ComposerCommandMenuItem(props: {
220 );
221 });
222
223 +export function composerSuggestionOptionId(listId: string, itemId: string): string {
224 + // JSON escapes lone UTF-16 surrogates before URI encoding without losing identity.
225 + return `${listId}-${encodeURIComponent(JSON.stringify(itemId))}`;
226 +}
227 +
228 +const LISTBOX_LABEL_BY_TRIGGER: Record<ComposerTriggerKind, string> = {
229 + path: "Files and folders",
230 + "pull-request": "Pull requests",
231 + "slash-command": "Commands",
232 + skill: "Skills",
233 +};
234 +
235 const SKILL_SOURCE_ICON_BY_KIND: Record<ProviderSkillSourceKind, LucideIcon> = {
236 app: BlocksIcon,
237 repo: FolderIcon,
apps/web/src/components/chat/composerMenuHighlight.test.ts
+17
@@ -48,4 +48,21 @@ describe("resolveComposerMenuActiveItemId", () => {
48 }),
49 ).toBe("top");
50 });
51 +
52 + it("clears the active result while async results are empty and resolves against restored results", () => {
53 + const search = {
54 + highlightedItemId: "second",
55 + currentSearchKey: "path:src",
56 + highlightedSearchKey: "path:src",
57 + };
58 + const cleared = resolveComposerMenuActiveItemId({ ...search, items: [] });
59 + expect(cleared).toBeNull();
60 + expect(
61 + resolveComposerMenuActiveItemId({
62 + ...search,
63 + highlightedItemId: cleared,
64 + items: [{ id: "new-result" }, { id: "second" }],
65 + }),
66 + ).toBe("new-result");
67 + });
68 });
apps/web/src/components/settings/SettingsFontPreviews.tsx
+1
@@ -39,6 +39,7 @@ export function PromptFontPreview() {
39 return (
40 <div className="mt-1 mb-2 rounded-lg border border-border bg-background px-3 py-2">
41 <ComposerPromptEditor
42 + ariaLabel="Prompt font preview"
43 editorRef={editorRef}
44 value={prompt}
45 cursor={cursor}