Skip to content

Commit e0de7ef

Browse files
PR Batch Testerclaude
andcommitted
fix(web): background announcements don't repeat in-app notification toasts
The toast viewport is a polite live region, so with in-app notifications on a background thread finishing was read twice. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b803e3a commit e0de7ef

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎apps/web/src/components/BackgroundThreadAnnouncer.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { effectiveSnoozed } from "@t3tools/client-runtime/state/thread-settled";
44
import { useEffect, useRef } from "react";
55

66
import { useComposerDraftStore } from "../composerDraftStore";
7+
import { useClientSettings } from "../hooks/useSettings";
78
import { useThreadRouteTarget } from "../hooks/useThreadRouteTarget";
89
import { useQuietThreadShells } from "../state/entities";
910
import { liveShellEnvironmentIdsAtom } from "../state/shell";
@@ -22,6 +23,8 @@ import {
2223
export function BackgroundThreadAnnouncer() {
2324
const threads = useQuietThreadShells();
2425
const liveEnvironmentIds = useAtomValue(liveShellEnvironmentIdsAtom);
26+
// In-app notification toasts land in a polite live region that already speaks these.
27+
const toastsSpeak = useClientSettings((settings) => settings.inAppNotificationsEnabled);
2528
const routeTarget = useThreadRouteTarget();
2629
const routeDraftThread = useComposerDraftStore((store) =>
2730
routeTarget?.kind === "draft" ? store.getDraftSession(routeTarget.draftId) : null,
@@ -56,11 +59,11 @@ export function BackgroundThreadAnnouncer() {
5659
);
5760
memoryRef.current = memory;
5861
const region = regionRef.current;
59-
if (region === null || announcement === null) return;
62+
if (region === null || announcement === null || toastsSpeak) return;
6063
// Screen readers ignore a write that leaves the text unchanged, so a repeat
6164
// gets a trailing non-breaking space to count as new.
6265
region.textContent = region.textContent === announcement ? `${announcement} ` : announcement;
63-
}, [threads, liveEnvironmentIds, openThreadKey]);
66+
}, [threads, liveEnvironmentIds, openThreadKey, toastsSpeak]);
6467

6568
// No role="status": Orca 50 maps it to a status bar in Chromium and drops its updates.
6669
return <div ref={regionRef} aria-live="polite" className="sr-only" />;

0 commit comments

Comments
 (0)