The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): fold the HUD's voice controls into one menu
Brooklyn Nicholson701314c6dd7e
diff --git a/apps/desktop/src/app/chat/composer/control-classes.ts b/apps/desktop/src/app/chat/composer/control-classes.tsnew file mode 100644index 00000000000..82285928c7b--- /dev/null+++ b/apps/desktop/src/app/chat/composer/control-classes.ts@@ -0,0 +1,25 @@+import { cn } from '@/lib/utils'++// Shared class names for the composer's control row, in a module of their own+// so both the row (`controls.tsx`) and the menus it renders can wear them+// without importing each other in a cycle.++export const ICON_BTN = 'size-(--composer-control-size) shrink-0 rounded-md'++export const GHOST_ICON_BTN = cn(+ ICON_BTN,+ 'text-(--ui-text-tertiary) hover:bg-(--chrome-action-hover) hover:text-foreground'+)++// Send/voice-conversation primary: solid foreground-on-background circle+// (reads as black-on-white in light mode, white-on-black in dark mode) to+// match the reference composer's high-contrast CTA. Keeps the pill itself+// neutral and lets the action visually dominate the row.+export const PRIMARY_ICON_BTN = cn(+ 'size-(--composer-control-primary-size,var(--composer-control-size)) shrink-0 rounded-full p-0',+ 'bg-foreground text-background hover:bg-foreground/90',+ 'disabled:bg-foreground/30 disabled:text-background disabled:opacity-100'+)++/** A toggle that is currently ON — dictation, spoken replies, the wake word. */+export const ACTIVE_ICON_BTN = 'bg-primary/10 text-primary hover:bg-primary/15 hover:text-primary'diff --git a/apps/desktop/src/app/chat/composer/controls.tsx b/apps/desktop/src/app/chat/composer/controls.tsxindex 286493d0066..c5ce2c24624 100644--- a/apps/desktop/src/app/chat/composer/controls.tsx+++ b/apps/desktop/src/app/chat/composer/controls.tsx@@ -7,26 +7,18 @@ import { useI18n } from '@/i18n'import { triggerHaptic } from '@/lib/haptics'import { AudioLines, Ear, EarOff, iconSize, Layers3, Loader2, Square, Volume2, VolumeX } from '@/lib/icons'import { cn } from '@/lib/utils'+import { $hudMode } from '@/store/hud'import { $wakeWord, toggleWakeWord } from '@/store/wake-word'+import { ACTIVE_ICON_BTN, GHOST_ICON_BTN, PRIMARY_ICON_BTN } from './control-classes'import type { ConversationStatus } from './hooks/use-voice-conversation'import { ModelPill } from './model-pill'import type { ChatBarState, VoiceStatus } from './types'+import { VoiceMenu } from './voice-menu'-export const ICON_BTN = 'size-(--composer-control-size) shrink-0 rounded-md'-export const GHOST_ICON_BTN = cn(- ICON_BTN,- 'text-(--ui-text-tertiary) hover:bg-(--chrome-action-hover) hover:text-foreground'-)-// Send/voice-conversation primary: solid foreground-on-background circle-// (reads as black-on-white in light mode, white-on-black in dark mode) to-// match the reference composer's high-contrast CTA. Keeps the pill itself-// neutral and lets the action visually dominate the row.-export const PRIMARY_ICON_BTN = cn(- 'size-(--composer-control-primary-size,var(--composer-control-size)) shrink-0 rounded-full p-0',- 'bg-foreground text-background hover:bg-foreground/90',- 'disabled:bg-foreground/30 disabled:text-background disabled:opacity-100'-)+// Re-exported: `context-menu.tsx` and other row neighbours have always reached+// for these here, and the row is where they read as belonging.+export { ACTIVE_ICON_BTN, GHOST_ICON_BTN, ICON_BTN, PRIMARY_ICON_BTN } from './control-classes'interface ConversationProps {active: boolean@@ -70,6 +62,7 @@ export function ComposerControls({}) {const { t } = useI18n()const c = t.composer+ const hudMode = useStore($hudMode)if (conversation.active) {return <ConversationPill {...conversation} disabled={disabled} />@@ -84,9 +77,27 @@ export function ComposerControls({return (<div className="ml-auto flex shrink-0 items-center gap-(--composer-control-gap)"><ModelPill compact={compactModelPill} disabled={disabled} model={state.model} />- <DictationButton disabled={disabled} onToggle={onDictate} state={state.voice} status={voiceStatus} />- <AutoSpeakButton active={autoSpeak} disabled={disabled} onToggle={onToggleAutoSpeak} />- <WakeWordButton disabled={disabled} />+ {/* The HUD is a Spotlight bar a few hundred pixels wide, so the four+ separate voice toggles fold into one menu there and leave the row to+ the input. The docked composer has the width and keeps them inline —+ same controls, same state, different budget. */}+ {hudMode ? (+ <VoiceMenu+ autoSpeak={autoSpeak}+ disabled={disabled}+ onDictate={onDictate}+ onStartConversation={conversation.onStart}+ onToggleAutoSpeak={onToggleAutoSpeak}+ state={state}+ voiceStatus={voiceStatus}+ />+ ) : (+ <>+ <DictationButton disabled={disabled} onToggle={onDictate} state={state.voice} status={voiceStatus} />+ <AutoSpeakButton active={autoSpeak} disabled={disabled} onToggle={onToggleAutoSpeak} />+ <WakeWordButton disabled={disabled} />+ </>+ )}{showQueueButton ? (<Tip label={<TipKeybindLabel actionId="composer.queue" text={c.queueMessage} />}><Button@@ -272,7 +283,7 @@ function AutoSpeakButton({ active, disabled, onToggle }: { active: boolean; disaclassName={cn(GHOST_ICON_BTN,'p-0',- active && 'bg-primary/10 text-primary hover:bg-primary/15 hover:text-primary'+ active && ACTIVE_ICON_BTN)}disabled={disabled}onClick={() => {@@ -321,7 +332,7 @@ function WakeWordButton({ disabled, pausedForVoice = false }: { disabled: booleaclassName={cn(GHOST_ICON_BTN,'p-0',- wake.listening && !pausedForVoice && 'bg-primary/10 text-primary hover:bg-primary/15 hover:text-primary'+ wake.listening && !pausedForVoice && ACTIVE_ICON_BTN)}disabled={disabled || pausedForVoice || wake.pending}onClick={() => {@@ -365,7 +376,7 @@ function DictationButton({GHOST_ICON_BTN,'p-0','data-[active=true]:bg-accent data-[active=true]:text-foreground',- status === 'recording' && 'bg-primary/10 text-primary hover:bg-primary/15 hover:text-primary',+ status === 'recording' && ACTIVE_ICON_BTN,status === 'transcribing' && 'bg-primary/10 text-primary')}data-active={active}diff --git a/apps/desktop/src/app/chat/composer/voice-menu.tsx b/apps/desktop/src/app/chat/composer/voice-menu.tsxnew file mode 100644index 00000000000..b5e371bef5e--- /dev/null+++ b/apps/desktop/src/app/chat/composer/voice-menu.tsx@@ -0,0 +1,162 @@+import { useStore } from '@nanostores/react'++import { Button } from '@/components/ui/button'+import { Codicon } from '@/components/ui/codicon'+import {+ DropdownMenu,+ DropdownMenuCheckboxItem,+ DropdownMenuContent,+ DropdownMenuItem,+ dropdownMenuRow,+ DropdownMenuSeparator,+ DropdownMenuTrigger+} from '@/components/ui/dropdown-menu'+import { Tip } from '@/components/ui/tooltip'+import { useI18n } from '@/i18n'+import { triggerHaptic } from '@/lib/haptics'+import { AudioLines, Ear, EarOff, iconSize, Loader2, Square, Volume2, VolumeX } from '@/lib/icons'+import { cn } from '@/lib/utils'+import { $wakeWord, toggleWakeWord } from '@/store/wake-word'++import { ACTIVE_ICON_BTN, GHOST_ICON_BTN } from './control-classes'+import type { ChatBarState, VoiceStatus } from './types'++export interface VoiceMenuProps {+ autoSpeak: boolean+ disabled: boolean+ state: ChatBarState+ voiceStatus: VoiceStatus+ onDictate: () => void+ onStartConversation: () => void+ onToggleAutoSpeak: () => void+}++/**+ * Every voice control behind one trigger: dictation, spoken replies, the+ * "hey hermes" wake word, and starting a full conversation.+ *+ * The bar carried four separate icon buttons — mic, speaker, ear, and the+ * voice-conversation primary — which is most of a Spotlight-width composer+ * spent on toggles that are set once and rarely touched. Collapsing them costs+ * one click on the rare change and gives the row back to the input.+ *+ * The trigger is not a static glyph: it REPORTS the loudest live voice state+ * (recording, transcribing, listening for the wake word, speaking replies), so+ * folding the controls away never hides the fact that something is listening.+ * A collapsed menu that looked idle while the mic was hot would be a worse+ * trade than the space it saves.+ */+export function VoiceMenu({+ autoSpeak,+ disabled,+ state,+ voiceStatus,+ onDictate,+ onStartConversation,+ onToggleAutoSpeak+}: VoiceMenuProps) {+ const { t } = useI18n()+ const c = t.composer+ const wake = useStore($wakeWord)++ const phrase = wake.phrase || 'hey hermes'+ const dictating = state.voice.active || voiceStatus !== 'idle'+ const wakeListening = wake.listening+ // Anything live keeps the trigger lit, so a folded menu can never look idle+ // while the mic is open.+ const active = dictating || wakeListening || autoSpeak++ const dictationLabel =+ voiceStatus === 'recording'+ ? c.stopDictation+ : voiceStatus === 'transcribing'+ ? c.transcribingDictation+ : c.voiceDictation++ const wakeLabel = wakeListening ? c.wakeWordListening(phrase) : c.wakeWordOff(phrase)+ const triggerLabel = dictating ? dictationLabel : wakeListening ? wakeLabel : c.voiceControls++ return (+ <DropdownMenu>+ <Tip label={wake.notice && !dictating ? `${triggerLabel} — ${wake.notice}` : triggerLabel}>+ <DropdownMenuTrigger asChild>+ <Button+ aria-label={triggerLabel}+ className={cn(GHOST_ICON_BTN, 'p-0', active && ACTIVE_ICON_BTN)}+ disabled={disabled}+ size="icon"+ type="button"+ variant="ghost"+ >+ {voiceStatus === 'recording' ? (+ <Square className={cn('fill-current', iconSize.xs)} />+ ) : voiceStatus === 'transcribing' ? (+ <Loader2 className={cn('animate-spin', iconSize.sm)} />+ ) : wakeListening ? (+ <Ear className={iconSize.sm} />+ ) : (+ <Codicon name="mic" size="0.875rem" />+ )}+ </Button>+ </DropdownMenuTrigger>+ </Tip>+ <DropdownMenuContent align="end" className="min-w-52">+ <DropdownMenuItem+ className={dropdownMenuRow}+ disabled={disabled}+ onSelect={() => {+ triggerHaptic('open')+ onStartConversation()+ }}+ >+ <AudioLines className={iconSize.sm} />+ {c.startVoice}+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ {/* Checkbox items, because all three are toggles the user is reading+ the CURRENT state of — the reason they were pressed-state buttons+ before. A plain row would fold that state away with the menu. */}+ <DropdownMenuCheckboxItem+ checked={dictating}+ className={dropdownMenuRow}+ disabled={disabled || !state.voice.enabled || voiceStatus === 'transcribing'}+ onSelect={event => {+ // Keep the menu open: dictation is a mode you watch, and closing+ // on select hides the recording state the trigger just entered.+ event.preventDefault()+ triggerHaptic(dictating ? 'close' : 'open')+ onDictate()+ }}+ >+ {dictationLabel}+ </DropdownMenuCheckboxItem>+ <DropdownMenuCheckboxItem+ checked={autoSpeak}+ className={dropdownMenuRow}+ disabled={disabled}+ onSelect={event => {+ event.preventDefault()+ triggerHaptic(autoSpeak ? 'close' : 'open')+ onToggleAutoSpeak()+ }}+ >+ {autoSpeak ? <Volume2 className={iconSize.sm} /> : <VolumeX className={iconSize.sm} />}+ {autoSpeak ? c.stopSpeakingReplies : c.speakReplies}+ </DropdownMenuCheckboxItem>+ <DropdownMenuCheckboxItem+ checked={wakeListening}+ className={dropdownMenuRow}+ disabled={disabled || wake.pending}+ onSelect={event => {+ event.preventDefault()+ triggerHaptic(wakeListening ? 'close' : 'open')+ void toggleWakeWord()+ }}+ >+ {wakeListening ? <Ear className={iconSize.sm} /> : <EarOff className={iconSize.sm} />}+ {wakeLabel}+ </DropdownMenuCheckboxItem>+ </DropdownMenuContent>+ </DropdownMenu>+ )+}diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex d848009254b..5ed5db56862 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -1765,6 +1765,7 @@ export const ar = defineLocale({endShort: 'إنهاء',stopDictation: 'إيقاف الإملاء',transcribingDictation: 'جار تفريغ الإملاء',+ voiceControls: 'صوت',voiceDictation: 'إملاء صوتي',lookupLoading: 'جار البحث...',lookupNoMatches: 'لا توجد نتائج',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex f4217322e02..5e94e4c4f09 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -2253,6 +2253,7 @@ export const en: Translations = {endShort: 'End',stopDictation: 'Stop dictation',transcribingDictation: 'Transcribing dictation',+ voiceControls: 'Voice',voiceDictation: 'Voice dictation',speakReplies: 'Read replies aloud',stopSpeakingReplies: 'Stop reading replies aloud',diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 550f16062d5..7864578edce 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -1954,6 +1954,7 @@ export const ja = defineLocale({endShort: '終了',stopDictation: '口述を停止',transcribingDictation: '口述を文字起こし中',+ voiceControls: '音声',voiceDictation: '音声口述',speakReplies: '返信を読み上げる',stopSpeakingReplies: '返信の読み上げを停止',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 47210ce65be..afd3fda1504 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -1913,6 +1913,7 @@ export interface Translations {endShort: stringstopDictation: stringtranscribingDictation: string+ voiceControls: stringvoiceDictation: stringspeakReplies: stringstopSpeakingReplies: stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex 51ac0958784..23a3232625e 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -1892,6 +1892,7 @@ export const zhHant = defineLocale({endShort: '結束',stopDictation: '停止聽寫',transcribingDictation: '正在轉寫聽寫',+ voiceControls: '語音',voiceDictation: '語音聽寫',speakReplies: '朗讀回覆',stopSpeakingReplies: '停止朗讀回覆',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex 46708723c51..613679cd728 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -2439,6 +2439,7 @@ export const zh: Translations = {endShort: '结束',stopDictation: '停止听写',transcribingDictation: '正在转写听写',+ voiceControls: '语音',voiceDictation: '语音听写',speakReplies: '朗读回复',stopSpeakingReplies: '停止朗读回复',