feat(pipeline): wire SessionPanel into App once logged in

SessionPanel composes PipelineStepper (status derived via
deriveStepsFromStatus), the ChatBubble conversation, the
ObjectiveValidationCard (shown once Agent 1 is ready to confirm) and
InputBar, all driven by useSessionStore. It's anchored to the bottom
of the avatar window (420x720) like the existing voice/update banners,
shown only once App.tsx confirms the user is actually logged in
(re-checked via getAuthStatus on every toggle-listening event, since
listening can be turned off manually without logging out).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
william
2026-10-31 22:05:41 +01:00
co-authored by Claude Sonnet 5
parent 309db80add
commit 919b82ef37
5 changed files with 236 additions and 3 deletions
@@ -145,4 +145,16 @@ describe('<App />', () => {
await new Promise((resolve) => setTimeout(resolve, 10))
expect(getWindowBounds).not.toHaveBeenCalled()
})
it('should not show the session panel when logged out', async () => {
render(<App />)
await waitFor(() => expect(getAuthStatus).toHaveBeenCalled())
expect(screen.queryByLabelText('Message')).not.toBeInTheDocument()
})
it('should show the session panel input once logged in', async () => {
getAuthStatus.mockResolvedValue({ loggedIn: true, email: 'william@example.com' })
render(<App />)
expect(await screen.findByLabelText('Message')).toBeInTheDocument()
})
})
@@ -0,0 +1,63 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { render, screen, fireEvent, waitFor } from '@testing-library/react'
import SessionPanel from '../../../src/renderer/src/components/SessionPanel'
import { useSessionStore } from '../../../src/renderer/src/stores/useSessionStore'
const create = vi.fn()
const get = vi.fn()
const sendObjectiveMessage = vi.fn()
const confirmObjective = vi.fn()
beforeEach(() => {
vi.clearAllMocks()
;(window as unknown as { api: Record<string, unknown> }).api = {
sessions: { create, get, sendObjectiveMessage, confirmObjective }
}
useSessionStore.getState().restart()
})
describe('<SessionPanel />', () => {
it('should show the pending pipeline steps and an input bar before any session exists', () => {
render(<SessionPanel />)
expect(screen.getByLabelText('Message')).toBeInTheDocument()
expect(screen.getByText('Objectif')).toBeInTheDocument()
})
it('should send the first message, creating a session, and render the conversation', async () => {
create.mockResolvedValueOnce({ id: 1, status: 'objective_discovery' })
sendObjectiveMessage.mockResolvedValueOnce({ reply: 'Quel est ton sujet ?', ready: false })
render(<SessionPanel />)
fireEvent.change(screen.getByLabelText('Message'), { target: { value: 'Je veux apprendre' } })
fireEvent.click(screen.getByRole('button', { name: 'Envoyer le message' }))
expect(await screen.findByText('Je veux apprendre')).toBeInTheDocument()
expect(await screen.findByText('Quel est ton sujet ?')).toBeInTheDocument()
})
it('should show the ObjectiveValidationCard instead of the input bar once the agent is ready', async () => {
create.mockResolvedValueOnce({ id: 1, status: 'objective_discovery' })
sendObjectiveMessage.mockResolvedValueOnce({
reply: 'Voici le recap',
ready: true,
draft: { subject: 's', professionalGoal: 'g', duration: '1 semaine' }
})
render(<SessionPanel />)
fireEvent.change(screen.getByLabelText('Message'), { target: { value: 'message' } })
fireEvent.click(screen.getByRole('button', { name: 'Envoyer le message' }))
await waitFor(() => expect(screen.getByText('Ton objectif de formation')).toBeInTheDocument())
expect(screen.queryByLabelText('Message')).not.toBeInTheDocument()
})
it('should show the store error message when a call fails', async () => {
create.mockRejectedValueOnce(new Error('Max API injoignable'))
render(<SessionPanel />)
fireEvent.change(screen.getByLabelText('Message'), { target: { value: 'message' } })
fireEvent.click(screen.getByRole('button', { name: 'Envoyer le message' }))
expect(await screen.findByText('Max API injoignable')).toBeInTheDocument()
})
})