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): stop refreshing mini ASR status on window focus
Maxb28796d62c42
diff --git a/docs/plans/2026-10-12-desktop-mini-delivery.md b/docs/plans/2026-10-12-desktop-mini-delivery.mdindex a389acc9d..ac138aa56 100644--- a/docs/plans/2026-10-12-desktop-mini-delivery.md+++ b/docs/plans/2026-10-12-desktop-mini-delivery.md@@ -60,10 +60,10 @@ still denies it, and hotkey/hold still falls back to text in that case. ASRstatus is read as soon as voice may be used (the pet window starts unfocused,so this read does not wait for focus). A press-and-hold that arrives beforethe first read settles opens text immediately; it does not queue a later-microphone start. 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.+microphone start. Settings changes made elsewhere take effect on the next+bind/epoch, not on window focus: a live refresh of a previously-true status+reopened the pending-vs-available state machine. 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).@@ -142,9 +142,8 @@ keeps its page-coloured plate solely to cover the surrounding web-page text.- Focused pet, voice ownership, dictation-wrapper and bridge suites: 156 testsat the original desktop-mini delivery. This PR adds PetPage cases for- ungated production voice (failure notes, ASR refresh, stop-while-listening,- and text fallback while the first ASR read is pending); `npx vitest run- src/pet` is 136 passing. The original parity sweep also ran all 15 existing+ ungated production voice (failure notes, and text fallback while the first+ ASR read is pending); `npx vitest run src/pet` is 133 passing. The original parity sweep also ran all 15 existingsession-action hook tests, including “Show in pet”, and 13 session-actioncomponent tests: 184 passing UI tests in that baseline.The five retained-card regressions were also run against isolated copies ofdiff --git a/ui/src/pet/PetPage.test.tsx b/ui/src/pet/PetPage.test.tsxindex 484146cc5..ee8ccec82 100644--- a/ui/src/pet/PetPage.test.tsx+++ b/ui/src/pet/PetPage.test.tsx@@ -1684,44 +1684,6 @@ describe('desktop mini v2 interaction contract', () => {});});- it('shows the microphone once transcription is turned on elsewhere and the window is reactivated', async () => {- let asr = false;- class Dictation { done = new Promise<string>(() => {}); start = async () => {}; finish = () => {}; abort = () => {}; }- await withVoiceEnv(() => asr, Dictation, async () => {- devBind('S'); render(<PetPage />); tapHotkey();- await screen.findByRole('textbox');- await waitFor(() => expect(fetch).toHaveBeenCalled());- expect(screen.queryByLabelText('pet.voice.open')).toBeNull();- asr = true;- const focus = vi.spyOn(document, 'hasFocus').mockReturnValue(false);- act(() => { window.dispatchEvent(new Event('blur')); });- focus.mockReturnValue(true);- act(() => { window.dispatchEvent(new Event('focus')); });- expect(await screen.findByLabelText('pet.voice.open')).toBeTruthy();- focus.mockRestore();- });- });-- it('keeps the stop control while listening even if transcription is turned off meanwhile', async () => {- let asr = true;- const finish = vi.fn();- class Dictation { done = new Promise<string>(() => {}); start = async () => {}; finish = finish; abort = () => {}; }- await withVoiceEnv(() => asr, Dictation, async () => {- devBind('S'); render(<PetPage />); tapHotkey();- await screen.findByRole('textbox');- await userEvent.click(await screen.findByLabelText('pet.voice.open'));- expect(pose()).toBe('listening');- asr = false;- const focus = vi.spyOn(document, 'hasFocus').mockReturnValue(false);- act(() => { window.dispatchEvent(new Event('blur')); });- focus.mockReturnValue(true);- act(() => { window.dispatchEvent(new Event('focus')); });- await waitFor(() => expect(fetch).toHaveBeenCalledTimes(2));- await userEvent.click(await screen.findByLabelText('pet.voice.stop'));- expect(finish).toHaveBeenCalled();- focus.mockRestore();- });- });it('opens text while the first ASR status read is still pending, and does not start voice when it later succeeds', async () => {const status = deferred<{ ok: boolean; json: () => Promise<unknown> }>();diff --git a/ui/src/pet/PetPage.tsx b/ui/src/pet/PetPage.tsxindex 39d0a199d..8ab609a86 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 { onPageReactivated, usePageActive } from '@/lib/pageActivity';+import { usePageActive } from '@/lib/pageActivity';import { usePendingVaultRequests } from '@/lib/usePendingVaultRequests';import { ShowPageVoiceDictation } from '@/lib/showPageVoiceDictation';import { VoiceTranscriptionError } from '@/lib/voiceTranscription';@@ -721,27 +721,25 @@ function usePetVoice({ enabled, epoch, draft, onOpenComposer }: { enabled: booleconst [listening, setListening] = useState(false);// A failed capture or transcription falls back to text with this note.const [error, setError] = useState<VoiceFailure | null>(null);- 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;- // 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)), []);+ // Read ASR status as soon as voice may be used. The pet window is created+ // unfocused, so this read does not wait for activation. Settings changes+ // made elsewhere take effect on the next bind/epoch, not on window focus:+ // a live refresh of a previously-true status reopened the pending-vs-+ // available state machine that leaked across review rounds.useEffect(() => {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 }));void fetch('/api/asr/status', { credentials: 'same-origin' }).then((response) => response.ok ? response.json() : null).then((value) => {if (!alive || !epoch.isCurrent()) return;- if (value === null) unknown();+ if (value === null) setAsr({ available: false, checked: false });else setAsr({ available: Boolean(value.available), checked: true, maxFileBytes: value.max_file_bytes });- }).catch(() => { if (alive && epoch.isCurrent()) unknown(); });+ }).catch(() => { if (alive && epoch.isCurrent()) setAsr({ available: false, checked: false }); });return () => { alive = false; };- }, [enabled, epoch, asrReads]);+ }, [enabled, epoch]);const stop = useCallback((commit: boolean) => {const capture = captureRef.current;if (!capture) return;