Skip to content

Commit afeb367

Browse files
tzachboncursoragent
andcommitted
fix(clients): screen readers hear pending async questions
The mobile row label includes 'question waiting', and the web background announcer announces a new async question once while the run keeps working. Co-authored-by: Cursor <[email protected]>
1 parent 2341460 commit afeb367

3 files changed

Lines changed: 30 additions & 8 deletions

File tree

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,11 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
695695
: workingLabel) ?? (isUnread ? DONE_STATUS_LABEL : undefined);
696696
const recede = shouldRecedeThreadRow({ status, selected });
697697
const timeLabel = props.timeLabel;
698+
const rowAccessibilityLabel = [
699+
thread.title,
700+
...(props.hasQueuedMessages ? ["messages queued to send"] : []),
701+
...(thread.hasPendingAsyncQuestion === true ? ["question waiting"] : []),
702+
].join(", ");
698703

699704
const visitThread = useAtomCommand(threadEnvironment.visit, { reportFailure: false });
700705
const handleAcknowledgeWoke = useCallback(() => {
@@ -1294,9 +1299,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
12941299
interactionOpacity={rowAppearance.interactionOpacity}
12951300
className={rowAppearance.className}
12961301
accessibilityHint={swipeAccessibilityHint}
1297-
accessibilityLabel={
1298-
props.hasQueuedMessages ? `${thread.title}, messages queued to send` : thread.title
1299-
}
1302+
accessibilityLabel={rowAccessibilityLabel}
13001303
accessibilityRole="button"
13011304
accessibilityState={{ selected }}
13021305
accessibilityActions={rowAccessibilityActions}
@@ -1327,9 +1330,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
13271330
interactionClassName={rowAppearance.interactionClassName}
13281331
interactionOpacity={rowAppearance.interactionOpacity}
13291332
accessibilityHint={swipeAccessibilityHint}
1330-
accessibilityLabel={
1331-
props.hasQueuedMessages ? `${thread.title}, messages queued to send` : thread.title
1332-
}
1333+
accessibilityLabel={rowAccessibilityLabel}
13331334
accessibilityRole="button"
13341335
accessibilityState={{ selected }}
13351336
className={rowAppearance.className}

‎apps/web/src/components/backgroundThreadAnnouncement.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,20 @@ describe("resolveBackgroundThreadRequest", () => {
186186
]),
187187
).toEqual(["Needs approval: Fix login redirect"]);
188188
});
189+
190+
it("announces an async question once, while the run works and after it ends", () => {
191+
const asyncQuestion = (running: boolean) =>
192+
resolveBackgroundThreadRequest({
193+
hasPendingApprovals: false,
194+
hasPendingUserInput: !running,
195+
hasPendingAsyncQuestion: running,
196+
pendingSubagentRequest: null,
197+
source: { pendingRuntimeRequest: question("question-1") },
198+
});
199+
const asked = [{ threads: [login()] }, { threads: [login(asyncQuestion(true))] }];
200+
expect(speak(asked)).toEqual(["Needs your input: Fix login redirect"]);
201+
expect(speak([...asked, { threads: [login(asyncQuestion(false))] }])).toEqual([
202+
"Needs your input: Fix login redirect",
203+
]);
204+
});
189205
});

‎apps/web/src/components/backgroundThreadAnnouncement.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,20 @@ export interface BackgroundThreadSnapshot {
2121
export function resolveBackgroundThreadRequest(
2222
thread: Pick<
2323
SidebarThreadSummary,
24-
"hasPendingApprovals" | "hasPendingUserInput" | "pendingSubagentRequest"
24+
| "hasPendingApprovals"
25+
| "hasPendingUserInput"
26+
| "hasPendingAsyncQuestion"
27+
| "pendingSubagentRequest"
2528
> & {
2629
readonly source: Pick<SidebarThreadSummary["source"], "pendingRuntimeRequest">;
2730
},
2831
): Pick<BackgroundThreadSnapshot, "request" | "requestId"> {
2932
const ownRequestId = thread.source.pendingRuntimeRequest?.id ?? null;
3033
if (thread.hasPendingApprovals) return { request: "approval", requestId: ownRequestId };
3134
if (thread.pendingSubagentRequest === "approval") return { request: "approval", requestId: null };
32-
if (thread.hasPendingUserInput) return { request: "input", requestId: ownRequestId };
35+
if (thread.hasPendingUserInput || thread.hasPendingAsyncQuestion) {
36+
return { request: "input", requestId: ownRequestId };
37+
}
3338
if (thread.pendingSubagentRequest === "user_input") return { request: "input", requestId: null };
3439
return { request: null, requestId: null };
3540
}

0 commit comments

Comments
 (0)