Skip to content

Commit 8ad0c8e

Browse files
shivamhwpclaude
authored andcommitted
fix(web): dictation can be cancelled by touch again (#33897)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 95c6709 commit 8ad0c8e

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

‎apps/web/src/components/chat/ChatComposer.tsx‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ import {
144144
useEnvironmentSpeechInput,
145145
useSpeechUnavailableReason,
146146
} from "../../speech/useEnvironmentSpeechInput";
147-
import { ComposerSpeechButton } from "./ComposerSpeechButton";
147+
import { ComposerSpeechButton, ComposerSpeechCancelButton } from "./ComposerSpeechButton";
148148
import { VoiceInputErrorPill } from "./VoiceInputErrorPill";
149149
import { COMPOSER_PILL_SLOT_BUTTON_CLASS_NAME } from "./ComposerPrimaryActions";
150150
import type { AssistantCitationSourceAnchor } from "~/lib/assistantTextSelection";
@@ -3837,6 +3837,15 @@ export function ChatComposer(props: ChatComposerProps) {
38373837
onDismiss={() => speechInput.cancel()}
38383838
/>
38393839
) : null}
3840+
{speechInput.available &&
3841+
speechInput.state.phase !== "idle" &&
3842+
speechInput.state.phase !== "error" ? (
3843+
<ComposerSpeechCancelButton
3844+
state={speechInput.state}
3845+
shortcutLabel="Esc"
3846+
onCancel={() => speechInput.cancel()}
3847+
/>
3848+
) : null}
38403849
<VoiceInputSetup
38413850
environmentId={speechInput.transcriptionEnvironmentId}
38423851
open={speechInput.setup.open}

‎apps/web/src/components/chat/ComposerSpeechButton.tsx‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,31 @@ function ShortcutTooltip(props: {
9494
);
9595
}
9696

97+
export function ComposerSpeechCancelButton(props: {
98+
state: VoiceInputState;
99+
shortcutLabel?: string | null;
100+
onCancel(): void;
101+
}) {
102+
if (props.state.phase === "idle") return null;
103+
const label = props.state.phase === "error" ? "Dismiss voice input error" : "Cancel voice input";
104+
105+
return (
106+
<ShortcutTooltip label={label} shortcut={props.shortcutLabel}>
107+
<Button
108+
type="button"
109+
size="icon-sm-pill"
110+
variant="ghost"
111+
aria-label={label}
112+
onPointerDown={keepFocus}
113+
onClick={props.onCancel}
114+
className="shrink-0"
115+
>
116+
<XIcon />
117+
</Button>
118+
</ShortcutTooltip>
119+
);
120+
}
121+
97122
// Each bar reads the level a sample apart, so the three never move in lockstep, and the
98123
// middle bar reaches highest so loud speech reads as a wave rather than a flat block.
99124
const SPEECH_BAR_SAMPLE_OFFSETS = [1, 0, 2] as const;

0 commit comments

Comments
 (0)