fix(recording-tip): show "inserted" only after the text was actually inserted

The tip drew its done state on session-completed, before the async insert
ran and even when auto-insert was off or the text was empty. A failed insert
also left the screen-saver-level tip over the result popup's copy button.
session-completed now says whether an insert follows, VoiceModeService emits
text-inserted on success, and the tip hides first when the insert fails.
This commit is contained in:
Yun Chan 2026-10-21 11:35:14 +09:00
parent 06365651fc
commit e7937c877f
5 changed files with 104 additions and 12 deletions

View file

@ -353,6 +353,21 @@ describe('표시 이벤트', () => {
expect(phases).toEqual(['recording', 'thinking'])
})
it('자동 삽입이 끝나면 text-inserted 를 내보낸다(완료 이벤트는 willInsert 로 예고한다)', async () => {
const svc = getVoiceModeService()
const inserted: string[] = []
const willInsert: boolean[] = []
svc.on('session-completed', (p) => willInsert.push(p.willInsert))
svc.on('text-inserted', ({ sessionId }) => inserted.push(sessionId))
await svc.startSession('dictation')
audioBus.emit('audio-data', { buffer: SPEECH })
advanceClock(1000)
await svc.stopSession()
await vi.waitFor(() => expect(inserted).toHaveLength(1))
expect(willInsert).toEqual([true])
})
it('자동 삽입이 실패하면 insert-failed 를 내보낸다', async () => {
mockInsert.insertText.mockRejectedValueOnce(new Error('clipboard busy'))
const svc = getVoiceModeService()

View file

@ -93,11 +93,13 @@ describe('RecordingTipPresenter', () => {
expect(view.calls).toEqual(['error:x'])
})
it('완료는 "입력함"을 잠깐 보이고 숨기며, 곧바로 시작한 새 세션의 팁은 숨기지 않는다', () => {
it('입력에 성공하면 "입력함"을 잠깐 보이고 숨기며, 곧바로 시작한 새 세션의 팁은 숨기지 않는다', () => {
const view = fakeView()
const presenter = new RecordingTipPresenter(view)
presenter.onPhase('recording')
presenter.onSessionCompleted()
presenter.onSessionCompleted(true)
expect(view.calls).toEqual(['show'])
presenter.onTextInserted()
vi.advanceTimersByTime(699)
expect(view.calls).toEqual(['show', 'done'])
vi.advanceTimersByTime(1)
@ -105,11 +107,41 @@ describe('RecordingTipPresenter', () => {
const view2 = fakeView()
const presenter2 = new RecordingTipPresenter(view2)
presenter2.onSessionCompleted()
presenter2.onSessionCompleted(true)
presenter2.onTextInserted()
vi.advanceTimersByTime(300)
presenter2.onSessionStarted()
presenter2.onPhase('recording')
vi.advanceTimersByTime(2000)
expect(view2.calls).toEqual(['done', 'show'])
})
it('자동 입력을 하지 않는 완료는 "입력함" 없이 숨긴다', () => {
const view = fakeView()
const presenter = new RecordingTipPresenter(view)
presenter.onPhase('recording')
presenter.onSessionCompleted(false)
presenter.onTextInserted()
expect(view.calls).toEqual(['show', 'hide'])
})
it('입력이 실패하면 "입력함" 없이 팁을 내리고 결과 팝업을 띄운다', () => {
const view = fakeView()
const presenter = new RecordingTipPresenter(view)
presenter.onPhase('recording')
presenter.onSessionCompleted(true)
presenter.onInsertFailed('text')
vi.advanceTimersByTime(10000)
expect(view.calls).toEqual(['show', 'hide', 'result:text:10000'])
})
it('입력 결과가 오지 않으면 잠시 뒤 숨기고, 늦게 온 성공은 무시한다', () => {
const view = fakeView()
const presenter = new RecordingTipPresenter(view)
presenter.onPhase('recording')
presenter.onSessionCompleted(true)
vi.advanceTimersByTime(5000)
presenter.onTextInserted()
expect(view.calls).toEqual(['show', 'hide'])
})
})