세션 완료 후 즉시 idle 복귀 (텍스트 삽입 비동기 분리)
- _completeSession: hideRecordingTip + IDLE 복귀를 먼저 실행 - 텍스트 삽입은 세션과 무관하게 비동기 (다음 핫키 즉시 사용 가능) - 삽입 await 중 다음 press가 세션을 꼬이게 하는 버그 수정
This commit is contained in:
parent
84b9d906be
commit
0c79af6b03
1 changed files with 8 additions and 17 deletions
|
|
@ -476,36 +476,27 @@ class VoiceModeService extends EventEmitter {
|
||||||
private async _completeSession(finalText: string): Promise<void> {
|
private async _completeSession(finalText: string): Promise<void> {
|
||||||
if (!this._session) return
|
if (!this._session) return
|
||||||
|
|
||||||
this._setRecognitionState(RecognitionState.COMPLETED)
|
|
||||||
this._setAudioState(AudioState.STOPPED)
|
|
||||||
|
|
||||||
const session = { ...this._session }
|
const session = { ...this._session }
|
||||||
logger.info(`Session completed: "${finalText.substring(0, 50)}${finalText.length > 50 ? '...' : ''}"`)
|
logger.info(`Session completed: "${finalText.substring(0, 50)}${finalText.length > 50 ? '...' : ''}"`)
|
||||||
|
|
||||||
// Speakly 패턴: RecordingTip 숨김
|
// Speakly 패턴: 먼저 RecordingTip 숨기고 IDLE 복귀 (다음 핫키 즉시 사용 가능)
|
||||||
hideRecordingTip()
|
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) {
|
if (configGet('autoInsert') && finalText.length > 0) {
|
||||||
try {
|
try {
|
||||||
const insertMethod = configGet('insertMethod')
|
const insertMethod = configGet('insertMethod')
|
||||||
await getTextInsertService().insertText(finalText, insertMethod)
|
await getTextInsertService().insertText(finalText, insertMethod)
|
||||||
insertSuccess = true
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.warn(`Text insert failed: ${error instanceof Error ? error.message : String(error)}`)
|
logger.warn(`Text insert failed: ${error instanceof Error ? error.message : String(error)}`)
|
||||||
}
|
// 삽입 실패 시 ResultPopup에 텍스트 표시
|
||||||
}
|
|
||||||
|
|
||||||
// Speakly 패턴: 삽입 실패 시 ResultPopup에 텍스트 표시
|
|
||||||
if (!insertSuccess && finalText.length > 0) {
|
|
||||||
showResultPopup(finalText, 10000)
|
showResultPopup(finalText, 10000)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.emit('session-completed', { session, finalText })
|
|
||||||
|
|
||||||
// IDLE로 복귀
|
|
||||||
this._resetToIdle()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private _cancelSession(reason: 'user' | 'timeout' | 'too-short'): void {
|
private _cancelSession(reason: 'user' | 'timeout' | 'too-short'): void {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue