File tree Expand file tree Collapse file tree
apps/web/src/components/chat Expand file tree Collapse file tree Original file line number Diff line number Diff 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" ;
148148import { VoiceInputErrorPill } from "./VoiceInputErrorPill" ;
149149import { COMPOSER_PILL_SLOT_BUTTON_CLASS_NAME } from "./ComposerPrimaryActions" ;
150150import 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 }
Original file line number Diff line number Diff 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.
99124const SPEECH_BAR_SAMPLE_OFFSETS = [ 1 , 0 , 2 ] as const ;
You can’t perform that action at this time.
0 commit comments