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): key mini ASR status to the current bind epoch
Max531db916fb1c
diff --git a/docs/plans/2026-10-12-desktop-mini-delivery.md b/docs/plans/2026-10-12-desktop-mini-delivery.mdindex ac138aa56..d2908164a 100644--- a/docs/plans/2026-10-12-desktop-mini-delivery.md+++ b/docs/plans/2026-10-12-desktop-mini-delivery.md@@ -60,10 +60,9 @@ 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. 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.+microphone start. ASR status is keyed to the current bind/epoch, so a previous+available result cannot start a capture on the next one. 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).@@ -143,7 +142,7 @@ 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 forungated 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 existing+ ASR read is pending); `npx vitest run src/pet` is 134 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 ee8ccec82..c6d9ca45d 100644--- a/ui/src/pet/PetPage.test.tsx+++ b/ui/src/pet/PetPage.test.tsx@@ -1685,6 +1685,25 @@ describe('desktop mini v2 interaction contract', () => {});+ it('clears a previous ASR-available cache when the authorization epoch changes', async () => {+ const status = deferred<{ ok: boolean; json: () => Promise<unknown> }>();+ let asrCalls = 0;+ class Dictation { done = new Promise<string>(() => {}); start = async () => {}; finish = () => {}; abort = () => {}; }+ await withVoiceEnv(() => true, Dictation, async () => {+ vi.stubGlobal('fetch', vi.fn(() => {+ asrCalls += 1;+ return asrCalls === 1 ? Promise.resolve({ ok: true, json: async () => ({ available: true }) }) : status.promise;+ }));+ devBind('S'); render(<PetPage />); tapHotkey();+ expect(await screen.findByLabelText('pet.voice.open')).toBeTruthy();+ await emit((h) => h.onAuthorizationChanged?.({}));+ await waitFor(() => expect(screen.queryByLabelText('pet.voice.open')).toBeNull());+ await act(async () => status.resolve({ ok: true, json: async () => ({ available: false }) }));+ await waitFor(() => expect(screen.queryByLabelText('pet.voice.open')).toBeNull());+ expect(pose()).not.toBe('listening');+ });+ });+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> }>();const start = vi.fn(async () => {});diff --git a/ui/src/pet/PetPage.tsx b/ui/src/pet/PetPage.tsxindex 8ab609a86..306217124 100644--- a/ui/src/pet/PetPage.tsx+++ b/ui/src/pet/PetPage.tsx@@ -716,7 +716,7 @@ 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 });+ const [asr, setAsr] = useState<{ epoch: PetSurfaceEpoch; enabled: boolean; available: boolean; checked: boolean; maxFileBytes?: number }>({ epoch, enabled, available: false, checked: false });const [preview, setPreview] = useState('');const [listening, setListening] = useState(false);// A failed capture or transcription falls back to text with this note.@@ -724,20 +724,20 @@ function usePetVoice({ enabled, epoch, draft, onOpenComposer }: { enabled: booletype 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;+ const asrForEpoch = asr.epoch === epoch && asr.enabled === enabled ? asr : { epoch, enabled, available: false, checked: false };+ const available = enabled && supported && asrForEpoch.available;// 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.+ // unfocused, so this read does not wait for activation. Status is keyed to+ // this bind/epoch: a previous available result cannot start a capture on+ // the next one. Settings changes take effect on that next epoch.useEffect(() => {if (!enabled) return;let alive = true;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) setAsr({ available: false, checked: false });- else setAsr({ available: Boolean(value.available), checked: true, maxFileBytes: value.max_file_bytes });- }).catch(() => { if (alive && epoch.isCurrent()) setAsr({ available: false, checked: false }); });+ if (value === null) setAsr({ epoch, enabled, available: false, checked: false });+ else setAsr({ epoch, enabled, available: Boolean(value.available), checked: true, maxFileBytes: value.max_file_bytes });+ }).catch(() => { if (alive && epoch.isCurrent()) setAsr({ epoch, enabled, available: false, checked: false }); });return () => { alive = false; };}, [enabled, epoch]);const stop = useCallback((commit: boolean) => {@@ -757,7 +757,7 @@ function usePetVoice({ enabled, epoch, draft, onOpenComposer }: { enabled: booleif (!epoch.isCurrent() || !available || captureRef.current) return;const before = draft;const capture: Capture = {- dictation: new ShowPageVoiceDictation({ before, after: '', maxFileBytes: asr.maxFileBytes, onPreview: (text) => { if (epoch.isCurrent()) setPreview(text); } }),+ dictation: new ShowPageVoiceDictation({ before, after: '', maxFileBytes: asrForEpoch.maxFileBytes, onPreview: (text) => { if (epoch.isCurrent()) setPreview(text); } }),ending: false,cancelled: false,};@@ -788,12 +788,12 @@ function usePetVoice({ enabled, epoch, draft, onOpenComposer }: { enabled: boole// Release may precede microphone permission or pipeline startup.if (capture.ending && !capture.cancelled) capture.dictation.finish();}).catch((reason: unknown) => { fail(reason); capture.dictation.abort(); });- }, [asr.maxFileBytes, available, epoch, draft, onOpenComposer]);+ }, [asrForEpoch.maxFileBytes, available, epoch, draft, onOpenComposer]);const cancel = useCallback(() => stop(false), [stop]);const 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 };+ return { available, cloudRequired: asrForEpoch.checked && !asrForEpoch.available, listening, preview, error, clearError, start, stop, cancel };}type VoiceFailure = 'startFailed' | 'empty' | 'failed';