refactor(pipeline): the text bar is not a chat, Max always replies by voice

Two pieces of direct user feedback, addressed together since they touch
the same files:

1. ObjectiveValidationCard now lives in its own dedicated, movable
   window (objectiveWindow.ts / ObjectiveWindowRoot.tsx), independent
   of the text input window. Confirming an objective must never depend
   on opening that window, including when the whole exchange happens
   by voice. Both sendTextTurn and voice-turn open/feed this window
   through the same shared handleRouteMessageResult code path, so text
   and voice behave identically - no more special-casing one channel.

2. The "chat window" was never meant to be a chat: it's an alternate
   text entry point for the exact same voice pipeline. Removed the
   message history/ChatBubble display and the old
   sessions:route-message + voice-turn-synced plumbing that existed to
   sync a conversation transcript across windows. Replaced with a new
   text-turn IPC handler mirroring voice-turn (routeMessage ->
   handleRouteMessageResult -> synthesizeSpeech) minus the STT step;
   the reply is relayed to the avatar window via the existing
   proactive-speech channel and spoken aloud, never displayed. The
   input window shrinks accordingly (560px -> 100px tall) and no
   longer auto-opens when a session starts, since there is nothing to
   show there anymore - it only opens on explicit user request.

useProactiveSpeech now accepts an onStateChange callback so the avatar
status indicator correctly flips back to idle once a text-turn reply
finishes playing (it previously only ever got set to 'speaking', never
reset - a latent gap this reuse surfaced).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
william
2026-11-01 10:52:09 +01:00
co-authored by Claude Sonnet 5
parent 4b45c4a644
commit 85da9fcad0
19 changed files with 482 additions and 399 deletions
@@ -0,0 +1,73 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { render, screen, fireEvent, waitFor, act } from '@testing-library/react'
import ObjectiveWindowRoot from '../../../src/renderer/src/components/ObjectiveWindowRoot'
import { useSessionStore } from '../../../src/renderer/src/stores/useSessionStore'
const confirmObjective = vi.fn()
const notifySessionEnded = vi.fn()
let objectiveReadyCallback: ((sessionId: number, draft: unknown) => void) | undefined
const onObjectiveReady = vi.fn((callback: (sessionId: number, draft: unknown) => void) => {
objectiveReadyCallback = callback
return () => {}
})
beforeEach(() => {
vi.clearAllMocks()
objectiveReadyCallback = undefined
;(window as unknown as { api: Record<string, unknown> }).api = {
sessions: { confirmObjective, get: vi.fn() },
notifySessionEnded,
onObjectiveReady
}
useSessionStore.getState().restart()
})
/**
* Fenetre independante du chat texte (retour utilisateur direct : la confirmation de l'objectif
* ne doit jamais dependre d'ouvrir la conversation, y compris quand tout l'echange se fait au
* vocal). Son etat vient exclusivement du relais "objective-ready" du main process.
*/
describe('<ObjectiveWindowRoot />', () => {
it('should render nothing before the main process relays a ready objective', () => {
const { container } = render(<ObjectiveWindowRoot />)
expect(container).toBeEmptyDOMElement()
})
it('should show the card once the main process relays a ready objective (text or voice, same path)', () => {
render(<ObjectiveWindowRoot />)
act(() =>
objectiveReadyCallback?.(1, {
subject: 'Facturation freelance',
professionalGoal: 'Facturer sans erreur',
duration: '2 semaines'
})
)
expect(screen.getByText('Ton objectif de formation')).toBeInTheDocument()
expect(screen.getByText('Facturation freelance')).toBeInTheDocument()
})
it('should confirm the objective via the store, independently of any chat window', async () => {
confirmObjective.mockResolvedValueOnce({})
;(window as unknown as { api: { sessions: Record<string, unknown> } }).api.sessions.get = vi
.fn()
.mockResolvedValueOnce({ id: 1, status: 'objective_validated' })
render(<ObjectiveWindowRoot />)
act(() =>
objectiveReadyCallback?.(1, {
subject: 'Facturation freelance',
professionalGoal: 'Facturer sans erreur',
duration: '2 semaines'
})
)
fireEvent.click(
screen.getByRole('button', { name: "C'est exactement ca, confirmer l'objectif" })
)
await waitFor(() => expect(confirmObjective).toHaveBeenCalledWith(1))
expect(await screen.findByText(/Objectif enregistre/)).toBeInTheDocument()
})
})