The best way to control Claude Code, Codex and more from any computer or phone
fix(web): screen readers hear when a thread is pinned or an action is undone (#25901)
Julius Marminge committed
Nov 11, 2026 at 15:36 UTC
25d2239f9bbc55774b3b6750b733cb2204a138e6
4 files changed
+63
-8
apps/web/src/hooks/showThreadUndoNotice.test.ts
+21
@@ -1,3 +1,4 @@
1
+import { Cause } from "effect";
2
import { AsyncResult } from "effect/reactivity";
3
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
4
@@ -88,4 +89,24 @@ describe("thread undo notice", () => {
89
await notice().undo();
90
expect(cancelAnnouncement).toHaveBeenCalledWith("thread-undo-notice");
91
});
92
+
93
+ it("announces that the undo happened, naming the undone action", async () => {
94
+ const { options } = setup();
95
+ showThreadUndoNotice(options);
96
+ vi.mocked(announce).mockClear();
97
+ await notice().undo();
98
+ expect(announce).toHaveBeenCalledExactlyOnceWith("Undid unpin of 1 thread");
99
+ });
100
+
101
+ it("does not announce an undo that failed", async () => {
102
+ const { options, add } = setup();
103
+ showThreadUndoNotice({
104
+ ...options,
105
+ undo: async () => AsyncResult.failure(Cause.fail(new Error("offline"))),
106
+ });
107
+ vi.mocked(announce).mockClear();
108
+ await notice().undo();
109
+ expect(add).toHaveBeenCalledOnce();
110
+ expect(announce).not.toHaveBeenCalled();
111
+ });
112
});
apps/web/src/hooks/showThreadUndoNotice.ts
+21
-3
@@ -28,9 +28,21 @@ type UndoNotice = {
28
29
export const useThreadUndoNotice = create<{ notice: UndoNotice | null }>(() => ({ notice: null }));
30
31
+const UNDONE_ACTION = {
32
+ Settled: "settle",
33
+ Snoozed: "snooze",
34
+ Unpinned: "unpin",
35
+ Archived: "archive",
36
+ Discarded: "discard",
37
+} satisfies Record<UndoOptions["action"], string>;
38
+
39
+function countLabel(action: UndoOptions["action"], count: number) {
40
+ const noun = action === "Discarded" ? "draft" : "thread";
41
+ return `${count} ${noun}${count === 1 ? "" : "s"}`;
42
+}
43
+
44
function threadUndoNoticeSummary(notice: Pick<UndoNotice, "action" | "count">): string {
32
- const noun = notice.action === "Discarded" ? "draft" : "thread";
33
- return `${notice.action} ${notice.count} ${noun}${notice.count === 1 ? "" : "s"}`;
45
+ return `${notice.action} ${countLabel(notice.action, notice.count)}`;
46
}
47
48
export function threadUndoLabel(keybindings: Parameters<typeof shortcutLabelForCommand>[0]) {
@@ -87,6 +99,7 @@ function refreshNotice() {
99
// Claim before awaiting to prevent repeated actions restoring a group twice.
100
for (const entry of current) entry.claim.finish();
101
refreshNotice();
102
+ let undone = 0;
103
await Promise.all(
104
current.map(async ({ undo, failureTitle }) => {
105
const reportFailure = (error: unknown) => {
@@ -100,7 +113,8 @@ function refreshNotice() {
113
};
114
try {
115
const result = await undo();
103
- if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
116
+ if (result._tag === "Success") undone++;
117
+ else if (!isAtomCommandInterrupted(result)) {
118
reportFailure(squashAtomCommandFailure(result));
119
}
120
} catch (error) {
@@ -108,6 +122,10 @@ function refreshNotice() {
122
}
123
}),
124
);
125
+ // Failures already raise a toast, so only what was actually restored is spoken.
126
+ if (undone > 0) {
127
+ announce(`Undid ${UNDONE_ACTION[latest.action]} of ${countLabel(latest.action, undone)}`);
128
+ }
129
},
130
});
131
}
apps/web/src/hooks/useThreadActions.ts
+9
-5
@@ -35,6 +35,7 @@ import { vcsEnvironment } from "../state/vcs";
35
import { useNewThreadHandler } from "./useHandleNewThread";
36
import { refreshArchivedThreadsForEnvironment } from "../lib/archivedThreadsState";
37
import { releaseComposerDraftUploads } from "../lib/composerDraftUploads";
38
+import { announce } from "../lib/announce";
39
import { readLocalApi } from "../localApi";
40
import {
41
readEnvironmentServerConfigLoaded,
@@ -727,7 +728,7 @@ export function useThreadActions() {
728
});
729
};
730
730
- const pinThread = async (target: ScopedThreadRef, opts: { orderKey?: string } = {}) => {
731
+ const sendPin = async (target: ScopedThreadRef, opts: { orderKey?: string } = {}) => {
732
if (!readEnvironmentServerConfigLoaded(target.environmentId)) {
733
return AsyncResult.failure(
734
Cause.fail(
@@ -752,6 +753,12 @@ export function useThreadActions() {
753
});
754
};
755
756
+ const pinThread = async (target: ScopedThreadRef, opts: { orderKey?: string } = {}) => {
757
+ const result = await sendPin(target, opts);
758
+ if (result._tag === "Success") announce("Pinned 1 thread");
759
+ return result;
760
+ };
761
+
762
const unpinThread = async (target: ScopedThreadRef) => {
763
if (!readEnvironmentServerConfigLoaded(target.environmentId)) {
764
return AsyncResult.failure(
@@ -947,10 +954,7 @@ export function useThreadActions() {
954
case "unsnooze":
955
return unsnoozeThread(target);
956
case "pin":
950
- return pinThread(
951
- target,
952
- step.orderKey === undefined ? {} : { orderKey: step.orderKey },
953
- );
957
+ return sendPin(target, step.orderKey === undefined ? {} : { orderKey: step.orderKey });
958
case "snooze":
959
return snoozeThreadMutation({
960
environmentId: target.environmentId,
apps/web/src/hooks/useThreadActions.undo.test.ts
+12
@@ -6,6 +6,7 @@ import { useThreadActions } from "./useThreadActions";
6
import { threadEnvironment } from "../state/threads";
7
import { toastManager } from "../components/ui/toast";
8
import { useThreadUndoNotice } from "./showThreadUndoNotice";
9
+import { announce } from "../lib/announce";
10
11
const commands = vi.hoisted(() => ({
12
pin: vi.fn(),
@@ -44,6 +45,7 @@ vi.mock("../composerDraftStore", () => ({ useComposerDraftStore: () => vi.fn() }
45
vi.mock("../lib/composerDraftUploads", () => ({ releaseComposerDraftUploads: vi.fn() }));
46
vi.mock("../terminalUiStateStore", () => ({ useTerminalUiStateStore: () => vi.fn() }));
47
vi.mock("../uiStateStore", () => ({ useUiStateStore: () => vi.fn() }));
48
+vi.mock("../lib/announce", () => ({ announce: vi.fn(), cancelAnnouncement: vi.fn() }));
49
vi.mock("../lib/archivedThreadsState", () => ({ refreshArchivedThreadsForEnvironment: vi.fn() }));
50
const threadShell = vi.hoisted(() => ({
51
title: "Thread",
@@ -139,12 +141,22 @@ describe("concurrent thread action Undo", () => {
141
);
142
});
143
144
+describe("pin", () => {
145
+ it("announces that the thread was pinned", async () => {
146
+ vi.mocked(announce).mockClear();
147
+ await useThreadActions().pinThread(target);
148
+ expect(announce).toHaveBeenCalledExactlyOnceWith("Pinned 1 thread");
149
+ });
150
+});
151
+
152
describe("unpin Undo", () => {
153
it("restores the original snooze after restoring the pin", async () => {
154
threadShell.pinnedAt = "2026-01-01T00:00:00.000Z";
155
threadShell.snoozedUntil = "2030-01-01T09:00:00.000Z";
156
await useThreadActions().unpinThread(target);
157
+ vi.mocked(announce).mockClear();
158
await currentUndo()();
159
+ expect(announce).not.toHaveBeenCalledWith("Pinned 1 thread");
160
expect(commands.pin).toHaveBeenCalledExactlyOnceWith({
161
environmentId: target.environmentId,
162
input: { threadId: target.threadId, orderKey: "a0" },