mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
Keep voice mode listening after empty sends and transcription errors, and let failed sends be resent
This commit is contained in:
1 parent
6904cfbc58
commit
99b8d854d4
5 files changed
+522
-40
No files matched your search
@@ -18,7 +18,7 @@ export type VoicePhase =
|
||||
|
||||
export type VoicePauseReason = 'user' | 'background' | 'no-speech' | 'error'
|
||||
|
||||
export type VoiceFailureSource = 'capture' | 'send' | 'playback'
|
||||
export type VoiceFailureSource = 'capture' | 'send' | 'playback' | 'transcription'
|
||||
|
||||
export type VoiceSessionStatus = SessionStatus['type']
|
||||
|
||||
@@ -46,6 +46,7 @@ export type VoiceConversationEvent =
|
||||
| { type: 'turn-sent'; baselineId: string | null }
|
||||
| { type: 'turn-started'; baselineId: string | null }
|
||||
| { type: 'send-failed'; message: string }
|
||||
| { type: 'resend'; busy: boolean; baselineId: string | null }
|
||||
| { type: 'status'; busy: boolean }
|
||||
| { type: 'speak-start' }
|
||||
| { type: 'speech-ended' }
|
||||
@@ -83,6 +84,7 @@ export interface VoiceConversationLabelInput {
|
||||
error?: string | null
|
||||
failureSource?: VoiceFailureSource | null
|
||||
isStartingCapture?: boolean
|
||||
canResend?: boolean
|
||||
}
|
||||
|
||||
export function reduceVoiceConversation(
|
||||
@@ -129,6 +131,25 @@ export function reduceVoiceConversation(
|
||||
error: event.message,
|
||||
failureSource: 'send',
|
||||
}
|
||||
case 'resend':
|
||||
if (state.phase !== 'paused') return state
|
||||
return event.busy
|
||||
? {
|
||||
...state,
|
||||
phase: 'working',
|
||||
sawBusy: true,
|
||||
baselineId: event.baselineId,
|
||||
pauseReason: null,
|
||||
error: null,
|
||||
failureSource: null,
|
||||
}
|
||||
: {
|
||||
...state,
|
||||
phase: 'sending',
|
||||
pauseReason: null,
|
||||
error: null,
|
||||
failureSource: null,
|
||||
}
|
||||
case 'status':
|
||||
if (state.phase !== 'working') return state
|
||||
if (!event.busy || state.sawBusy) return state
|
||||
@@ -267,7 +288,7 @@ export function isVoiceTurnComplete(input: VoiceTurnCompletionInput): boolean {
|
||||
}
|
||||
|
||||
export function voiceConversationLabel(input: VoiceConversationLabelInput): string {
|
||||
const { phase, pauseReason, pendingApproval, error, isStartingCapture } = input
|
||||
const { phase, pauseReason, pendingApproval, error, failureSource, isStartingCapture } = input
|
||||
|
||||
switch (phase) {
|
||||
case 'listening':
|
||||
@@ -282,7 +303,13 @@ export function voiceConversationLabel(input: VoiceConversationLabelInput): stri
|
||||
return isStartingCapture ? 'Starting…' : 'Adding to queue'
|
||||
case 'paused':
|
||||
if (pauseReason === 'no-speech') return "Didn't catch that"
|
||||
if (pauseReason === 'error') return error?.trim() || 'Something went wrong'
|
||||
if (pauseReason === 'error') {
|
||||
if (failureSource === 'send') return "Couldn't send your message"
|
||||
if (failureSource === 'capture') return 'Microphone problem'
|
||||
if (failureSource === 'playback') return "Couldn't read the reply"
|
||||
if (failureSource === 'transcription') return "Transcription isn't working"
|
||||
return error?.trim() || 'Something went wrong'
|
||||
}
|
||||
return 'Paused'
|
||||
case 'off':
|
||||
return ''
|
||||
@@ -318,9 +345,10 @@ export function voiceConversationHint(input: VoiceConversationLabelInput): strin
|
||||
case 'paused':
|
||||
if (pauseReason === 'no-speech') return 'Tap to talk'
|
||||
if (pauseReason === 'error') {
|
||||
return failureSource === 'capture'
|
||||
? 'Allow microphone access, then tap to retry'
|
||||
: 'Tap to retry'
|
||||
if (failureSource === 'capture') return 'Allow microphone access, then tap to retry'
|
||||
if (failureSource === 'send') return input.canResend ? 'Tap to resend' : 'Tap to retry'
|
||||
if (failureSource === 'transcription') return 'Tap to try again'
|
||||
return 'Tap to retry'
|
||||
}
|
||||
return isPlaybackPaused ? 'Tap to continue' : 'Tap to talk'
|
||||
case 'off':
|
||||
|
||||
Reference in new issue
Block a user