세션 완료 후 즉시 idle 복귀 (텍스트 삽입 비동기 분리)

- _completeSession: hideRecordingTip + IDLE 복귀를 먼저 실행
- 텍스트 삽입은 세션과 무관하게 비동기 (다음 핫키 즉시 사용 가능)
- 삽입 await 중 다음 press가 세션을 꼬이게 하는 버그 수정
This commit is contained in:
Yun Chan 2026-04-05 10:39:13 +09:00
parent 84b9d906be
commit 0c79af6b03

View file

@ -476,36 +476,27 @@ class VoiceModeService extends EventEmitter {
private async _completeSession(finalText: string): Promise<void> {
if (!this._session) return
this._setRecognitionState(RecognitionState.COMPLETED)
this._setAudioState(AudioState.STOPPED)
const session = { ...this._session }
logger.info(`Session completed: "${finalText.substring(0, 50)}${finalText.length > 50 ? '...' : ''}"`)
// Speakly 패턴: RecordingTip 숨김
// Speakly 패턴: 먼저 RecordingTip 숨기고 IDLE 복귀 (다음 핫키 즉시 사용 가능)
hideRecordingTip()
this._setRecognitionState(RecognitionState.COMPLETED)
this._setAudioState(AudioState.STOPPED)
this.emit('session-completed', { session, finalText })
this._resetToIdle()
// 텍스트 삽입 (autoInsert 설정 확인)
let insertSuccess = false
// 텍스트 삽입은 세션과 무관하게 비동기 실행 (세션 블로킹 방지)
if (configGet('autoInsert') && finalText.length > 0) {
try {
const insertMethod = configGet('insertMethod')
await getTextInsertService().insertText(finalText, insertMethod)
insertSuccess = true
} catch (error) {
logger.warn(`Text insert failed: ${error instanceof Error ? error.message : String(error)}`)
}
}
// Speakly 패턴: 삽입 실패 시 ResultPopup에 텍스트 표시
if (!insertSuccess && finalText.length > 0) {
// 삽입 실패 시 ResultPopup에 텍스트 표시
showResultPopup(finalText, 10000)
}
this.emit('session-completed', { session, finalText })
// IDLE로 복귀
this._resetToIdle()
}
}
private _cancelSession(reason: 'user' | 'timeout' | 'too-short'): void {