diff --git a/src/main/native-chat/transcript-tool-result-identity.test.ts b/src/main/native-chat/transcript-tool-result-identity.test.ts index 1eeb3e745205..afa17b529f29 100644 --- a/src/main/native-chat/transcript-tool-result-identity.test.ts +++ b/src/main/native-chat/transcript-tool-result-identity.test.ts @@ -7,6 +7,10 @@ import type { NativeChatMessage } from '../../shared/native-chat-types' import { decodeClaudeTranscriptLine } from './transcript-line-decoders-claude' import { decodeCodexTranscriptLine } from './transcript-line-decoders-codex' import { readNativeChatTranscriptTailFile } from './transcript-tail-reader' +import { + recordedCodexAsyncRaw, + recordedCodexAsyncMessages +} from '../../shared/__fixtures__/codex-0163-async-question' const roots: string[] = [] @@ -244,3 +248,10 @@ describe('provider transcript result identity', () => { expect(codex?.blocks).toEqual([{ type: 'tool-result', output: 'done' }]) }) }) + +it('decodes the recorded Codex async question and early acceptance into the renderer contract', () => { + const messages = recordedCodexAsyncRaw + .split('\n') + .map((line, index) => decodeCodexTranscriptLine(line, `recorded-${index}`)) + expect(messages).toEqual(recordedCodexAsyncMessages) +}) diff --git a/src/renderer/src/components/dashboard-popout/DashboardPopoutRoot.test.tsx b/src/renderer/src/components/dashboard-popout/DashboardPopoutRoot.test.tsx index 66c08fbd4fd6..91daaa821bd1 100644 --- a/src/renderer/src/components/dashboard-popout/DashboardPopoutRoot.test.tsx +++ b/src/renderer/src/components/dashboard-popout/DashboardPopoutRoot.test.tsx @@ -59,7 +59,7 @@ describe('DashboardPopoutRoot', () => { expect(emitAppMenuSelectionAction).not.toBeNull() await act(async () => emitAppMenuPaste!()) - act(() => emitAppMenuSelectionAction!('select-all')) + await act(async () => emitAppMenuSelectionAction!('select-all')) window.removeEventListener(APP_MENU_PASTE_EVENT, onPaste) window.removeEventListener(APP_MENU_SELECTION_ACTION_EVENT, onSelectionAction) diff --git a/src/renderer/src/components/dictation/DictationController.startup.test.tsx b/src/renderer/src/components/dictation/DictationController.startup.test.tsx new file mode 100644 index 000000000000..d6d20ac5e78b --- /dev/null +++ b/src/renderer/src/components/dictation/DictationController.startup.test.tsx @@ -0,0 +1,102 @@ +// @vitest-environment happy-dom +import { act, cleanup, render } from '@testing-library/react' +import { afterEach, expect, it, vi } from 'vitest' +import { useAppStore } from '@/store' +import { getDefaultSettings, getDefaultVoiceSettings } from '../../../../shared/constants' +import { DictationController } from './DictationController' +import { DICTATION_CONTROL_EVENT } from './dictation-control-events' + +const audio = vi.hoisted(() => ({ + start: vi.fn(), + stop: vi.fn(), + flushBufferedAudio: vi.fn(async () => {}), + discardBufferedAudio: vi.fn(), + getCapturedChunkCount: () => 1 +})) +vi.mock('@/hooks/use-audio-capture', () => ({ useAudioCapture: () => audio })) +vi.mock('./DictationIndicator', () => ({ DictationIndicator: () => null })) + +afterEach(() => { + cleanup() + vi.unstubAllGlobals() + vi.restoreAllMocks() +}) + +it.each(['keyup', 'Stop', 'blur'] as const)( + 'owns startup synchronously and honors %s before microphone acquisition settles', + async (ending) => { + vi.spyOn(navigator, 'userAgent', 'get').mockReturnValue('Macintosh') + const settings = getDefaultSettings('/tmp') + settings.voice = { + ...getDefaultVoiceSettings(), + enabled: true, + sttModel: 'fixture', + dictationMode: 'hold' + } + useAppStore.setState({ settings, dictationState: 'idle', keybindings: {} }) + let finishCapture: (() => void) | undefined + audio.start.mockReset().mockImplementation( + () => + new Promise((resolve) => { + finishCapture = resolve + }) + ) + audio.stop.mockClear() + audio.flushBufferedAudio.mockClear() + let stopped: ((event: { sessionId: string }) => void) | undefined + const speech = { + onPartialTranscript: () => () => {}, + onFinalTranscript: () => () => {}, + onError: () => () => {}, + onStopped: (callback: typeof stopped) => { + stopped = callback + return () => { + stopped = undefined + } + }, + startDictation: vi.fn(async () => {}), + stopDictation: vi.fn(async (sessionId: string) => { + stopped?.({ sessionId }) + }) + } + vi.stubGlobal('api', { speech }) + const view = render( + <> +