fix(desktop): harden cancellation, dispose, and lifecycle races across main services
Cancel pending result-popup measure timers on hideResultPopup; track CaptionService aux-model load state, stop deduplication, and refine abort epochs across restarts; forward per-call AbortSignal through VoiceModeService and LlmGateway to LocalLLMService and abort pull streams plus availability polling on dispose; clear aborted response pointers and gate stale mic start errors in VoiceConversationService; guard AudioCaptureService stopping resume against exited SoX processes and cleanup failed starts; abort LocalSTTService downloadModel polling on dispose; and fail closed when desktopCapturer.getSources rejects in caption loopback setup.
This commit is contained in:
parent
4bf0f0df12
commit
fc5d45312c
19 changed files with 922 additions and 94 deletions
|
|
@ -261,6 +261,36 @@ describe('VoiceModeService', () => {
|
|||
|
||||
expect(cancelReason).toBe('user')
|
||||
})
|
||||
|
||||
it('cancelSession_whileLlmProcessingInFlight_abortsPerCallSignalPassedToLlm', async () => {
|
||||
let capturedSignal: AbortSignal | undefined
|
||||
let rejectLlm: ((reason?: unknown) => void) | undefined
|
||||
mockLLM.processText.mockImplementation(((_text, _action, _lang, _prompt, options?: { signal?: AbortSignal }) => {
|
||||
capturedSignal = options?.signal
|
||||
return new Promise<string>((_resolve, reject) => {
|
||||
rejectLlm = reject
|
||||
options?.signal?.addEventListener('abort', () => reject(new Error('llm aborted')), { once: true })
|
||||
})
|
||||
}) as never)
|
||||
|
||||
const svc = getVoiceModeService()
|
||||
await svc.startSession('dictation')
|
||||
audioBus.emit('audio-data', { buffer: Buffer.alloc(16000 * 2) })
|
||||
await new Promise((r) => setTimeout(r, 850))
|
||||
const stopping = svc.stopSession()
|
||||
|
||||
await vi.waitFor(() => expect(mockLLM.processText).toHaveBeenCalledTimes(1))
|
||||
|
||||
expect(capturedSignal).toBeInstanceOf(AbortSignal)
|
||||
expect(capturedSignal?.aborted).toBe(false)
|
||||
|
||||
svc.cancelSession()
|
||||
rejectLlm?.(new Error('cleanup'))
|
||||
await stopping
|
||||
|
||||
expect(capturedSignal?.aborted).toBe(true)
|
||||
expect(mockTextInsert.insertText).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe('LLM 후처리 인자 전달', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue