feat(ui): separate chat and pipeline stepper, move stepper beside the avatar

Per user feedback after visually testing the app: the chat and the
pipeline stepper were a single combined panel, which the user wanted
split. Rename SessionPanel to ChatPanel (chat history + objective
validation + input bar only, no stepper), rendered only while a new
chatOpen flag is true - toggled via the context menu's "Ecrire un
message" item, not shown automatically on login.

The PipelineStepper now lives directly in App.tsx and only mounts once
useSessionStore.sessionId is set (i.e. the user has actually started a
training session, not just logged in). It's anchored to the right edge
of the window, vertically centered, instead of stacked above the
avatar: the window itself grows from 420 to 620px wide via the new
set-pipeline-panel-visible IPC call whenever a session becomes active,
and shrinks back when it doesn't. A new .avatar-stage wrapper keeps the
avatar/chat panel's own layout anchored to a fixed 420px column so it
doesn't re-center across the wider window.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
william
2026-10-31 22:39:04 +01:00
co-authored by Claude Sonnet 5
parent b072960012
commit 6e8a9d2f0d
5 changed files with 272 additions and 64 deletions
+94 -16
View File
@@ -1,6 +1,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { render, screen, act, fireEvent, waitFor } from '@testing-library/react'
import type { VoiceState } from '../../../src/renderer/src/voice/useVoiceAssistant'
import { useSessionStore } from '../../../src/renderer/src/stores/useSessionStore'
vi.mock('../../../src/renderer/src/components/AvatarViewer', () => ({
default: ({ onReady }: { onReady: (handle: unknown) => void }) => {
@@ -29,9 +30,14 @@ vi.mock('../../../src/renderer/src/voice/useProactiveSpeech', () => ({
let onUpdateAvailableCb: (() => void) | undefined
let onUpdateReadyCb: (() => void) | undefined
const showContextMenu = vi.fn()
const getWindowBounds = vi.fn(async () => ({ x: 0, y: 0, width: 100, height: 100 }))
const setWindowPosition = vi.fn()
const openLoginWindow = vi.fn()
const logout = vi.fn()
const quitApp = vi.fn()
const setPipelinePanelVisible = vi.fn()
const sessionsCreate = vi.fn()
const sessionsSendObjectiveMessage = vi.fn()
const getAuthStatus = vi.fn(async (): Promise<{ loggedIn: boolean; email: string | null }> => ({
loggedIn: false,
email: null
@@ -49,10 +55,19 @@ function setupWindowApi(): void {
}),
onToggleListening: vi.fn(() => () => {}),
onProactiveSpeech: vi.fn(() => () => {}),
showContextMenu,
getWindowBounds,
setWindowPosition,
getAuthStatus
getAuthStatus,
openLoginWindow,
logout,
quitApp,
setPipelinePanelVisible,
sessions: {
create: sessionsCreate,
get: vi.fn(),
sendObjectiveMessage: sessionsSendObjectiveMessage,
confirmObjective: vi.fn()
}
}
}
@@ -62,6 +77,7 @@ describe('<App />', () => {
beforeEach(() => {
vi.clearAllMocks()
setupWindowApi()
useSessionStore.getState().restart()
})
it('should render the avatar viewer', () => {
@@ -103,24 +119,37 @@ describe('<App />', () => {
expect(screen.getByText(/prochaine fermeture/)).toBeInTheDocument()
})
it('should request the context menu with the current listening state', () => {
// Faux par defaut (ecoute non activee tant qu'aucun compte n'est connecte, voir
// getAuthStatus ci-dessus qui renvoie loggedIn: false).
it('should open the custom context menu on right-click', () => {
render(<App />)
const container = screen.getByTestId('avatar-viewer').parentElement!
fireEvent.contextMenu(container, { clientX: 20, clientY: 30 })
expect(screen.getByRole('menu')).toBeInTheDocument()
})
it('should call openLoginWindow when "Me connecter" is clicked from the menu', () => {
render(<App />)
const container = screen.getByTestId('avatar-viewer').parentElement!
fireEvent.contextMenu(container)
expect(showContextMenu).toHaveBeenCalledWith(false)
fireEvent.click(screen.getByRole('menuitem', { name: 'Me connecter' }))
expect(openLoginWindow).toHaveBeenCalled()
})
it('should enable listening once getAuthStatus reports an existing session', async () => {
getAuthStatus.mockResolvedValueOnce({ loggedIn: true, email: 'william@example.com' })
it('should call logout and reset the session when "Se deconnecter" is clicked', async () => {
getAuthStatus.mockResolvedValue({ loggedIn: true, email: 'william@example.com' })
render(<App />)
await waitFor(() => expect(getAuthStatus).toHaveBeenCalled())
const container = screen.getByTestId('avatar-viewer').parentElement!
fireEvent.contextMenu(container)
fireEvent.click(screen.getByRole('menuitem', { name: 'Se deconnecter' }))
expect(logout).toHaveBeenCalled()
})
it('should call quitApp when "Quitter" is clicked', () => {
render(<App />)
const container = screen.getByTestId('avatar-viewer').parentElement!
await waitFor(() => {
fireEvent.contextMenu(container)
expect(showContextMenu).toHaveBeenCalledWith(true)
})
fireEvent.contextMenu(container)
fireEvent.click(screen.getByRole('menuitem', { name: 'Quitter' }))
expect(quitApp).toHaveBeenCalled()
})
it('should start dragging the window on mouse down and stop on mouse up', async () => {
@@ -146,15 +175,64 @@ describe('<App />', () => {
expect(getWindowBounds).not.toHaveBeenCalled()
})
it('should not show the session panel when logged out', async () => {
it('should not show the chat 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 () => {
it('should not show the chat panel right after login, until "Ecrire un message" is used', async () => {
getAuthStatus.mockResolvedValue({ loggedIn: true, email: 'william@example.com' })
render(<App />)
await waitFor(() => expect(getAuthStatus).toHaveBeenCalled())
expect(screen.queryByLabelText('Message')).not.toBeInTheDocument()
})
it('should open the chat panel via the context menu and shrink the pipeline panel back on toggle off', async () => {
getAuthStatus.mockResolvedValue({ loggedIn: true, email: 'william@example.com' })
render(<App />)
await waitFor(() => expect(getAuthStatus).toHaveBeenCalled())
const container = screen.getByTestId('avatar-viewer').parentElement!
fireEvent.contextMenu(container)
fireEvent.click(screen.getByRole('menuitem', { name: 'Ecrire un message' }))
expect(await screen.findByLabelText('Message')).toBeInTheDocument()
fireEvent.contextMenu(container)
fireEvent.click(screen.getByRole('menuitem', { name: 'Ecrire un message' }))
expect(screen.queryByLabelText('Message')).not.toBeInTheDocument()
})
it('should not show the pipeline stepper before a session exists', async () => {
getAuthStatus.mockResolvedValue({ loggedIn: true, email: 'william@example.com' })
render(<App />)
await waitFor(() => expect(getAuthStatus).toHaveBeenCalled())
expect(screen.queryByText('Objectif')).not.toBeInTheDocument()
expect(setPipelinePanelVisible).toHaveBeenCalledWith(false)
})
it('should show the pipeline stepper and widen the window once a session is created', async () => {
getAuthStatus.mockResolvedValue({ loggedIn: true, email: 'william@example.com' })
sessionsCreate.mockResolvedValueOnce({ id: 1, status: 'objective_discovery' })
sessionsSendObjectiveMessage.mockResolvedValueOnce({
reply: 'Quel est ton sujet ?',
ready: false
})
render(<App />)
await waitFor(() => expect(getAuthStatus).toHaveBeenCalled())
const container = screen.getByTestId('avatar-viewer').parentElement!
fireEvent.contextMenu(container)
fireEvent.click(screen.getByRole('menuitem', { name: 'Ecrire un message' }))
fireEvent.change(await screen.findByLabelText('Message'), {
target: { value: 'Je veux apprendre' }
})
fireEvent.click(screen.getByRole('button', { name: 'Envoyer le message' }))
await waitFor(() => expect(screen.getByText('Objectif')).toBeInTheDocument())
expect(setPipelinePanelVisible).toHaveBeenCalledWith(true)
})
})
@@ -1,6 +1,6 @@
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 ChatPanel from '../../../src/renderer/src/components/ChatPanel'
import { useSessionStore } from '../../../src/renderer/src/stores/useSessionStore'
const create = vi.fn()
@@ -16,18 +16,18 @@ beforeEach(() => {
useSessionStore.getState().restart()
})
describe('<SessionPanel />', () => {
it('should show the pending pipeline steps and an input bar before any session exists', () => {
render(<SessionPanel />)
describe('<ChatPanel />', () => {
it('should show an input bar and no pipeline steps before any session exists', () => {
render(<ChatPanel />)
expect(screen.getByLabelText('Message')).toBeInTheDocument()
expect(screen.getByText('Objectif')).toBeInTheDocument()
expect(screen.queryByText('Objectif')).not.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 />)
render(<ChatPanel />)
fireEvent.change(screen.getByLabelText('Message'), { target: { value: 'Je veux apprendre' } })
fireEvent.click(screen.getByRole('button', { name: 'Envoyer le message' }))
@@ -43,7 +43,7 @@ describe('<SessionPanel />', () => {
draft: { subject: 's', professionalGoal: 'g', duration: '1 semaine' }
})
render(<SessionPanel />)
render(<ChatPanel />)
fireEvent.change(screen.getByLabelText('Message'), { target: { value: 'message' } })
fireEvent.click(screen.getByRole('button', { name: 'Envoyer le message' }))
@@ -54,7 +54,7 @@ describe('<SessionPanel />', () => {
it('should show the store error message when a call fails', async () => {
create.mockRejectedValueOnce(new Error('Max API injoignable'))
render(<SessionPanel />)
render(<ChatPanel />)
fireEvent.change(screen.getByLabelText('Message'), { target: { value: 'message' } })
fireEvent.click(screen.getByRole('button', { name: 'Envoyer le message' }))