Skip to content

Commit 854b61b

Browse files
fix(mobile): screen readers hear a thread row's status and time (#34636)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
1 parent 733a200 commit 854b61b

3 files changed

Lines changed: 82 additions & 2 deletions

File tree

‎apps/mobile/src/features/threads/thread-list-v2-items.tsx‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import {
8484
resolveThreadListV2ProviderDrivers,
8585
resolveThreadListV2SwipeActions,
8686
layoutThreadListV2RowMenuActions,
87+
threadListV2RowAccessibilityLabel,
8788
type ThreadListV2Status,
8889
} from "./threadListV2";
8990
import { QueuedMessageIcon } from "./queued-message-icon";
@@ -784,8 +785,20 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
784785
: workingLabel) ?? (isUnread ? DONE_STATUS_LABEL : undefined);
785786
const recede = shouldRecedeThreadRow({ status, selected });
786787
const isRegeneratingTitle = thread.titleRegeneration != null;
787-
const rowAccessibilityLabel = `${thread.title}${providerNameLabel ? `, ${providerNameLabel}` : ""}${props.hasQueuedMessages ? ", messages queued to send" : ""}${isRegeneratingTitle ? ", regenerating title" : ""}`;
788788
const timeLabel = props.timeLabel;
789+
const rowAccessibilityLabel = threadListV2RowAccessibilityLabel({
790+
title: thread.title,
791+
variant,
792+
woke: showsWoke,
793+
// Working and waiting rows show only an icon and a duration, so name them for speech.
794+
statusLabel:
795+
statusLabel && (statusLabel.label ?? (status === "waiting" ? "Waiting" : "Working")),
796+
timeLabel,
797+
snoozeWakeLabel: snoozedRow ? props.snoozeWakeLabelText : undefined,
798+
providerNameLabel,
799+
hasQueuedMessages: props.hasQueuedMessages === true,
800+
regeneratingTitle: isRegeneratingTitle,
801+
});
789802

790803
const visitThread = useAtomCommand(threadEnvironment.visit, { reportFailure: false });
791804
const handleAcknowledgeWoke = useCallback(() => {
@@ -1581,7 +1594,12 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
15811594
threadTitle={thread.title}
15821595
>
15831596
{(close) => (
1584-
<Menu actions={menuActions} onPressAction={handleMenuAction} shouldOpenOnLongPress>
1597+
<Menu
1598+
accessibilityLabel={rowAccessibilityLabel}
1599+
actions={menuActions}
1600+
onPressAction={handleMenuAction}
1601+
shouldOpenOnLongPress
1602+
>
15851603
{rowContent(close)}
15861604
</Menu>
15871605
)}

‎apps/mobile/src/features/threads/threadListV2.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
resolveThreadListV2Status,
4545
resolveThreadListV2WokeAt,
4646
threadListV2ListItemsAreEqual,
47+
threadListV2RowAccessibilityLabel,
4748
threadHasUnseenCompletion,
4849
type ThreadListV2ListItem,
4950
} from "./threadListV2";
@@ -227,6 +228,38 @@ describe("resolveThreadListV2Status", () => {
227228
);
228229
});
229230

231+
describe("threadListV2RowAccessibilityLabel", () => {
232+
const row = {
233+
title: "Fix login",
234+
variant: "card",
235+
woke: false,
236+
statusLabel: undefined,
237+
timeLabel: "5m",
238+
snoozeWakeLabel: undefined,
239+
providerNameLabel: "Codex",
240+
hasQueuedMessages: false,
241+
regeneratingTitle: false,
242+
} as const;
243+
244+
it("speaks the status or time the row shows beside its title", () => {
245+
expect(threadListV2RowAccessibilityLabel({ ...row, statusLabel: "Approval" })).toBe(
246+
"Fix login, Approval, Codex",
247+
);
248+
expect(threadListV2RowAccessibilityLabel(row)).toBe("Fix login, 5m, Codex");
249+
expect(threadListV2RowAccessibilityLabel({ ...row, woke: true, statusLabel: "Done" })).toBe(
250+
"Fix login, Woke, Codex",
251+
);
252+
expect(
253+
threadListV2RowAccessibilityLabel({
254+
...row,
255+
variant: "slim",
256+
statusLabel: "Failed",
257+
snoozeWakeLabel: "in 2h",
258+
}),
259+
).toBe("Fix login, in 2h, Codex");
260+
});
261+
});
262+
230263
describe("resolveThreadListV2SwipeActions", () => {
231264
it("offers snooze for a presented input request and moves it onto the snoozed shelf", () => {
232265
const raw = makeRawThreadShell({

‎apps/mobile/src/features/threads/threadListV2.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,35 @@ export function resolveThreadListV2Status(
299299
return "ready";
300300
}
301301

302+
export function threadListV2RowAccessibilityLabel(input: {
303+
readonly title: string;
304+
readonly variant: "card" | "slim";
305+
readonly woke: boolean;
306+
readonly statusLabel: string | undefined;
307+
readonly timeLabel: string;
308+
readonly snoozeWakeLabel: string | undefined;
309+
readonly providerNameLabel: string | null;
310+
readonly hasQueuedMessages: boolean;
311+
readonly regeneratingTitle: boolean;
312+
}): string {
313+
// Mirrors the row's meta line: a card shows Woke, else its status, else the time.
314+
const meta =
315+
input.variant === "slim"
316+
? (input.snoozeWakeLabel ?? input.timeLabel)
317+
: input.woke
318+
? "Woke"
319+
: (input.statusLabel ?? input.timeLabel);
320+
return [
321+
input.title,
322+
meta,
323+
input.providerNameLabel,
324+
input.hasQueuedMessages ? "messages queued to send" : null,
325+
input.regeneratingTitle ? "regenerating title" : null,
326+
]
327+
.filter((part) => part !== null)
328+
.join(", ");
329+
}
330+
302331
/** Row status: a failure the user has already opened settles to ready, like Done. */
303332
export function resolveThreadListV2RowStatus(
304333
thread: Parameters<typeof resolveThreadListV2Status>[0] &

0 commit comments

Comments
 (0)