fix(voice): sync voice-originated pipeline turns to the chat window
A learn-intent conversation driven entirely by voice never reached ObjectiveValidationCard: the chat window's Zustand store lives in its own isolated renderer process and only ever updated from its own direct sessions:route-message calls, never from voice-turn results handled in the main process. A user doing everything by voice could never see or confirm their objective. The main process now opens the chat window and broadcasts the voice turn (reply/ready/draft) to it whenever intent is 'learn'; the chat window's store applies it the same way it applies its own responses. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
ef0015fc2b
commit
4b45c4a644
@@ -7,12 +7,14 @@ const get = vi.fn()
|
||||
const routeMessage = vi.fn()
|
||||
const confirmObjective = vi.fn()
|
||||
const notifySessionEnded = vi.fn()
|
||||
const onVoiceTurnSynced = vi.fn(() => () => {})
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
;(window as unknown as { api: Record<string, unknown> }).api = {
|
||||
sessions: { get, routeMessage, confirmObjective },
|
||||
notifySessionEnded
|
||||
notifySessionEnded,
|
||||
onVoiceTurnSynced
|
||||
}
|
||||
useSessionStore.getState().restart()
|
||||
})
|
||||
@@ -59,6 +61,28 @@ describe('<ChatPanel />', () => {
|
||||
expect(screen.queryByLabelText('Message')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should show the ObjectiveValidationCard from a voice-originated turn, not just a typed message', async () => {
|
||||
let voiceTurnCallback: ((result: unknown) => void) | undefined
|
||||
onVoiceTurnSynced.mockImplementationOnce((callback: (result: unknown) => void) => {
|
||||
voiceTurnCallback = callback
|
||||
return () => {}
|
||||
})
|
||||
|
||||
render(<ChatPanel />)
|
||||
expect(screen.queryByText('Ton objectif de formation')).not.toBeInTheDocument()
|
||||
|
||||
voiceTurnCallback?.({
|
||||
type: 'learn',
|
||||
sessionId: 1,
|
||||
reply: 'Voici le recap (dit a voix haute)',
|
||||
ready: true,
|
||||
draft: { subject: 's', professionalGoal: 'g', duration: '1 semaine' }
|
||||
})
|
||||
|
||||
await waitFor(() => expect(screen.getByText('Ton objectif de formation')).toBeInTheDocument())
|
||||
expect(screen.getByText('Voici le recap (dit a voix haute)')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should show the store error message when a call fails', async () => {
|
||||
routeMessage.mockRejectedValueOnce(new Error('Max API injoignable'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user