Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(desktop): read mini ASR status on mount and hold voice summons for it
Max601a47337571
diff --git a/docs/plans/2026-10-12-desktop-mini-delivery.md b/docs/plans/2026-10-12-desktop-mini-delivery.mdindex 0fb1461e3..f85fcc479 100644--- a/docs/plans/2026-10-12-desktop-mini-delivery.md+++ b/docs/plans/2026-10-12-desktop-mini-delivery.md@@ -57,8 +57,12 @@ everywhere. The owner has since removed that gate so the captured-speech handoffcan be verified on a real desktop test prerelease. Pet voice now appearswhenever Web Locks, `getUserMedia` and ASR are all available; missing Web Locksstill denies it, and hotkey/hold still falls back to text in that case. ASR-status is re-read whenever the pet window becomes active, so enabling or-disabling transcription in settings takes effect without restarting the pet.+status is read as soon as voice may be used (the pet window starts unfocused,+so this read does not wait for focus), and a held-hotkey summon waits for that+first read. Each window reactivation re-reads it, so a settings change takes+effect without restarting the pet; a failed re-read keeps the last known status.+Availability gates only starting a capture; an active capture keeps its stop+control.A microphone or transcription failure reopens the text input with the pre-voicedraft and a short note; the mini does not keep the failed recording for retry(the main Composer does).diff --git a/ui/src/pet/PetPage.test.tsx b/ui/src/pet/PetPage.test.tsxindex 911da8178..7aed4f528 100644--- a/ui/src/pet/PetPage.test.tsx+++ b/ui/src/pet/PetPage.test.tsx@@ -1634,6 +1634,9 @@ describe('desktop mini v2 interaction contract', () => {expect(screen.queryByText('Session B')).toBeNull();});+ // A tapped (not held) hotkey opens the text input once voice status is known.+ const tapHotkey = () => { summon('listen'); summon('release'); };+async function withVoiceEnv(asrAvailable: () => boolean, dictation: unknown, body: () => Promise<void>) {vi.doMock('@/lib/showPageVoiceDictation', () => ({ ShowPageVoiceDictation: dictation }));const locks = Object.getOwnPropertyDescriptor(navigator, 'locks');@@ -1670,7 +1673,7 @@ describe('desktop mini v2 interaction contract', () => {}await withVoiceEnv(() => true, Dictation, async () => {({ VoiceTranscriptionError: TranscriptionError } = await import('@/lib/voiceTranscription'));- devBind('S'); render(<PetPage />); summon('listen');+ devBind('S'); render(<PetPage />); tapHotkey();const input = await screen.findByRole('textbox');await userEvent.type(input, 'typed before voice');await userEvent.click(await screen.findByLabelText('pet.voice.open'));@@ -1685,7 +1688,7 @@ describe('desktop mini v2 interaction contract', () => {let asr = false;class Dictation { done = new Promise<string>(() => {}); start = async () => {}; finish = () => {}; abort = () => {}; }await withVoiceEnv(() => asr, Dictation, async () => {- devBind('S'); render(<PetPage />); summon('listen');+ devBind('S'); render(<PetPage />); tapHotkey();await screen.findByRole('textbox');await waitFor(() => expect(fetch).toHaveBeenCalled());expect(screen.queryByLabelText('pet.voice.open')).toBeNull();@@ -1704,7 +1707,7 @@ describe('desktop mini v2 interaction contract', () => {const finish = vi.fn();class Dictation { done = new Promise<string>(() => {}); start = async () => {}; finish = finish; abort = () => {}; }await withVoiceEnv(() => asr, Dictation, async () => {- devBind('S'); render(<PetPage />); summon('listen');+ devBind('S'); render(<PetPage />); tapHotkey();await screen.findByRole('textbox');await userEvent.click(await screen.findByLabelText('pet.voice.open'));expect(pose()).toBe('listening');@@ -1720,6 +1723,20 @@ describe('desktop mini v2 interaction contract', () => {});});+ it('holds a voice summon until the first ASR status read settles', async () => {+ const status = deferred<{ ok: boolean; json: () => Promise<unknown> }>();+ class Dictation { done = new Promise<string>(() => {}); start = async () => {}; finish = () => {}; abort = () => {}; }+ await withVoiceEnv(() => true, Dictation, async () => {+ vi.stubGlobal('fetch', vi.fn(() => status.promise));+ devBind('S'); render(<PetPage />); summon('listen');+ await act(async () => new Promise((resolve) => setTimeout(resolve, 15)));+ expect(screen.queryByRole('textbox')).toBeNull();+ expect(pose()).not.toBe('listening');+ await act(async () => status.resolve({ ok: true, json: async () => ({ available: true }) }));+ await waitFor(() => expect(pose()).toBe('listening'));+ });+ });+it('discards voice preview and final text from the previous authorization epoch', async () => {const done = deferred<string>();let preview!: (text: string) => void;@@ -1741,7 +1758,7 @@ describe('desktop mini v2 interaction contract', () => {vi.stubGlobal('fetch', vi.fn(async () => ({ ok: true, json: async () => ({ available: true }) })));vi.resetModules();({ PetPage } = await import('./PetPage'));- devBind('S'); render(<PetPage />); summon('listen');+ devBind('S'); render(<PetPage />); tapHotkey();const input = await screen.findByRole('textbox');await userEvent.type(input, 'typed before voice');await userEvent.click(await screen.findByLabelText('pet.voice.open'));diff --git a/ui/src/pet/PetPage.tsx b/ui/src/pet/PetPage.tsxindex 66bd515b9..8692496b3 100644--- a/ui/src/pet/PetPage.tsx+++ b/ui/src/pet/PetPage.tsx@@ -10,7 +10,7 @@ import { Button } from '@/components/ui/button';import { Markdown } from '@/components/ui/markdown';import { QuickReplies } from '@/components/workbench/QuickReplies';import { harnessItemNativeId } from '@/lib/backgroundActivity';-import { usePageActive } from '@/lib/pageActivity';+import { onPageReactivated, usePageActive } from '@/lib/pageActivity';import { usePendingVaultRequests } from '@/lib/usePendingVaultRequests';import { ShowPageVoiceDictation } from '@/lib/showPageVoiceDictation';import { VoiceTranscriptionError } from '@/lib/voiceTranscription';@@ -418,12 +418,12 @@ const PetSurface: React.FC = () => {}, [setPanel, voice.stop, voice.listening, composing]);useOnSummon(onSummon);useEffect(() => {- if (!listenPending || !binding || !canChat || !expanded) return;+ if (!listenPending || !binding || !canChat || !expanded || voice.pending) return;petComposer.takeListen();if (uncertain) { setDetailOpen(true); return; }if (voice.available && hotkeyHeld.current) voice.start();else openComposer(draft);- }, [listenPending, binding, canChat, expanded, voice.available, voice.start, openComposer, draft, uncertain]);+ }, [listenPending, binding, canChat, expanded, voice.pending, voice.available, voice.start, openComposer, draft, uncertain]);useEffect(() => {const onBlur = () => { if (!voice.listening && !draft.trim()) void setPanel(false); };window.addEventListener('blur', onBlur);@@ -716,26 +716,33 @@ function useHitRegions(rootRef: React.RefObject<HTMLDivElement | null>, epoch?:}function usePetVoice({ enabled, epoch, draft, onOpenComposer }: { enabled: boolean; epoch: PetSurfaceEpoch; draft: string; onOpenComposer: (text?: string) => void }) {- const [asr, setAsr] = useState<{ available: boolean; checked: boolean; maxFileBytes?: number }>({ available: false, checked: false });+ // `settled` turns true once the first status read has finished either way.+ const [asr, setAsr] = useState<{ available: boolean; checked: boolean; settled: boolean; maxFileBytes?: number }>({ available: false, checked: false, settled: false });const [preview, setPreview] = useState('');const [listening, setListening] = useState(false);// A failed capture or transcription falls back to text with this note.const [error, setError] = useState<VoiceFailure | null>(null);- const pageActive = usePageActive();+ const [asrReads, setAsrReads] = useState(0);type Capture = { dictation: ShowPageVoiceDictation; ending: boolean; cancelled: boolean };const captureRef = useRef<Capture | null>(null);const supported = typeof navigator !== 'undefined' && Boolean(navigator.locks && navigator.mediaDevices?.getUserMedia);const available = enabled && supported && asr.available;- // The pet window outlives settings changes made elsewhere, so ASR status is- // re-read whenever the window becomes active again.+ // Read ASR status as soon as voice may be used; the pet window is created+ // unfocused, so the first read cannot wait for activation. The window also+ // outlives settings changes made elsewhere, so each reactivation re-reads it.+ useEffect(() => onPageReactivated(() => setAsrReads((count) => count + 1)), []);useEffect(() => {- if (!enabled || !pageActive) return;+ if (!enabled) return;let alive = true;+ // A failed re-read keeps the last known status instead of flapping to off.+ const unknown = () => setAsr((current) => (current.checked ? current : { available: false, checked: false, settled: true }));void fetch('/api/asr/status', { credentials: 'same-origin' }).then((response) => response.ok ? response.json() : null).then((value) => {- if (alive && epoch.isCurrent()) setAsr({ available: Boolean(value?.available), checked: value !== null, maxFileBytes: value?.max_file_bytes });- }).catch(() => { if (alive && epoch.isCurrent()) setAsr({ available: false, checked: false }); });+ if (!alive || !epoch.isCurrent()) return;+ if (value === null) unknown();+ else setAsr({ available: Boolean(value.available), checked: true, settled: true, maxFileBytes: value.max_file_bytes });+ }).catch(() => { if (alive && epoch.isCurrent()) unknown(); });return () => { alive = false; };- }, [enabled, epoch, pageActive]);+ }, [enabled, epoch, asrReads]);const stop = useCallback((commit: boolean) => {const capture = captureRef.current;if (!capture) return;@@ -789,7 +796,9 @@ function usePetVoice({ enabled, epoch, draft, onOpenComposer }: { enabled: booleconst clearError = useCallback(() => setError(null), []);useEffect(() => cancel, [epoch, enabled, cancel]);useEffect(() => () => setError(null), [epoch, enabled]);- return { available, cloudRequired: asr.checked && !asr.available, listening, preview, error, clearError, start, stop, cancel };+ // Until the first status read settles, a voice summon cannot tell voice from text.+ const pending = enabled && supported && !asr.settled;+ return { available, pending, cloudRequired: asr.checked && !asr.available, listening, preview, error, clearError, start, stop, cancel };}type VoiceFailure = 'startFailed' | 'empty' | 'failed';