fix(voice): preserve existing TUI drafts
This commit is contained in:
parent
f1c45f5727
commit
0ca78e5f32
|
|
@ -895,15 +895,19 @@ describe('createGatewayEventHandler', () => {
|
|||
|
||||
it('leaves voice transcripts editable when voice.submit_mode is draft', async () => {
|
||||
const ctx = buildCtx([])
|
||||
let composerInput = 'existing draft'
|
||||
|
||||
ctx.gateway.rpc = vi.fn(async (method: string) =>
|
||||
method === 'config.get' ? { config: { voice: { submit_mode: 'draft' } } } : null
|
||||
)
|
||||
ctx.composer.setInput = vi.fn((next: string | ((current: string) => string)) => {
|
||||
composerInput = typeof next === 'function' ? next(composerInput) : next
|
||||
})
|
||||
const onEvent = createGatewayEventHandler(ctx)
|
||||
|
||||
onEvent({ payload: { text: ' edit this first ' }, type: 'voice.transcript' } as any)
|
||||
|
||||
await vi.waitFor(() => expect(ctx.composer.setInput).toHaveBeenCalledWith('edit this first'))
|
||||
await vi.waitFor(() => expect(composerInput).toBe('existing draft edit this first'))
|
||||
expect(ctx.submission.submitRef.current).not.toHaveBeenCalled()
|
||||
expect(ctx.gateway.rpc).toHaveBeenCalledWith('config.get', { key: 'full' })
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ describe('voice.submit_mode live composer rendering', () => {
|
|||
const submit = vi.fn()
|
||||
|
||||
function Harness() {
|
||||
const [input, setInput] = useState('')
|
||||
const [input, setInput] = useState('existing draft')
|
||||
|
||||
const handler = useMemo(
|
||||
() =>
|
||||
|
|
@ -87,7 +87,7 @@ describe('voice.submit_mode live composer rendering', () => {
|
|||
await delay(10)
|
||||
}
|
||||
|
||||
expect(output).toContain('editable voice draft')
|
||||
expect(output).toContain('existing draft editable voice draft')
|
||||
expect(submit).not.toHaveBeenCalled()
|
||||
} finally {
|
||||
instance.unmount()
|
||||
|
|
|
|||
|
|
@ -953,7 +953,7 @@ export function createGatewayEventHandler(ctx: GatewayEventHandlerContext): (ev:
|
|||
const submitMode = normalizeVoiceSubmitMode(cfg?.config?.voice?.submit_mode)
|
||||
|
||||
if (submitMode === 'draft') {
|
||||
setInput(text)
|
||||
setInput(current => (current.trim() ? `${current.trimEnd()} ${text}` : text))
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue