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:
Yun Chan 2026-11-14 15:06:25 +09:00
parent 4bf0f0df12
commit fc5d45312c
19 changed files with 922 additions and 94 deletions

View file

@ -6,6 +6,7 @@
// - realtime-token 은 주입된 자격 증명 포트로 호출한다 (item 2)
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { desktopCapturer, session } from 'electron'
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
const handlers = vi.hoisted(() => new Map<string, (event: unknown, params?: unknown) => Promise<unknown>>())
@ -136,3 +137,25 @@ describe('realtime-token 은 자격 증명 포트를 쓴다', () => {
expect(invokeFn).toHaveBeenCalledWith('realtime-token', {})
})
})
describe('systemAudio:enableLoopback 예외 처리', () => {
it('enableLoopback_getSourcesRejects_invokesCallbackWithEmptyObject', async () => {
const mod = await import('../../../src/main/ipc/caption-handlers')
mod.registerCaptionHandlers()
const regResult = await invoke(IPC_CHANNELS.SYSTEM_AUDIO.ENABLE_LOOPBACK)
expect(regResult.success).toBe(true)
const setHandlerCalls = vi.mocked(session.defaultSession.setDisplayMediaRequestHandler).mock.calls
const mediaHandler = setHandlerCalls[0]?.[0] as
| ((request: unknown, callback: (streams: Record<string, unknown>) => void) => Promise<void>)
| undefined
expect(typeof mediaHandler).toBe('function')
vi.mocked(desktopCapturer.getSources).mockRejectedValueOnce(new Error('screen capture failed'))
const callback = vi.fn()
await expect(mediaHandler!({}, callback)).resolves.toBeUndefined()
expect(callback).toHaveBeenCalledWith({})
})
})