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:
co-authored by
Claude Sonnet 5
parent
b072960012
commit
6e8a9d2f0d
@@ -1,10 +1,14 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import AvatarViewer, { type AvatarHandle } from './components/AvatarViewer'
|
||||
import AvatarStatusIndicator from './components/AvatarStatusIndicator'
|
||||
import ChatPanel from './components/ChatPanel'
|
||||
import ContextMenu from './components/ContextMenu'
|
||||
import PipelineStepper from './components/PipelineStepper'
|
||||
import ThinkingIndicator from './components/ThinkingIndicator'
|
||||
import VoiceErrorBanner from './components/VoiceErrorBanner'
|
||||
import UpdateBanner from './components/UpdateBanner'
|
||||
import SessionPanel from './components/SessionPanel'
|
||||
import { useSessionStore } from './stores/useSessionStore'
|
||||
import { deriveStepsFromStatus } from './utils/pipelineSteps'
|
||||
import { useVoiceAssistant, type VoiceState } from './voice/useVoiceAssistant'
|
||||
import { useProactiveSpeech } from './voice/useProactiveSpeech'
|
||||
|
||||
@@ -15,9 +19,15 @@ function App(): React.JSX.Element {
|
||||
const [listening, setListening] = useState(false)
|
||||
const listeningRef = useRef(listening)
|
||||
const [loggedIn, setLoggedIn] = useState(false)
|
||||
const [email, setEmail] = useState<string | null>(null)
|
||||
const [chatOpen, setChatOpen] = useState(false)
|
||||
const [contextMenu, setContextMenu] = useState<{ x: number; y: number } | null>(null)
|
||||
const [voiceState, setVoiceState] = useState<VoiceState>('idle')
|
||||
const [voiceError, setVoiceError] = useState<string | null>(null)
|
||||
const [updateStatus, setUpdateStatus] = useState<'available' | 'ready' | null>(null)
|
||||
const sessionId = useSessionStore((state) => state.sessionId)
|
||||
const sessionStatus = useSessionStore((state) => state.status)
|
||||
const restartSession = useSessionStore((state) => state.restart)
|
||||
useEffect(() => window.api.onUpdateAvailable(() => setUpdateStatus('available')), [])
|
||||
useEffect(() => window.api.onUpdateReady(() => setUpdateStatus('ready')), [])
|
||||
const voiceErrorTimer = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
@@ -47,10 +57,12 @@ function App(): React.JSX.Element {
|
||||
.then((status) => {
|
||||
setListening(status.loggedIn)
|
||||
setLoggedIn(status.loggedIn)
|
||||
setEmail(status.email)
|
||||
})
|
||||
.catch(() => {
|
||||
setListening(false)
|
||||
setLoggedIn(false)
|
||||
setEmail(null)
|
||||
})
|
||||
}, [])
|
||||
useEffect(refreshAuthStatus, [refreshAuthStatus])
|
||||
@@ -60,10 +72,38 @@ function App(): React.JSX.Element {
|
||||
useEffect(() => window.api.onToggleListening(refreshAuthStatus), [refreshAuthStatus])
|
||||
useEffect(() => window.api.onProactiveSpeech(() => setVoiceState('speaking')), [])
|
||||
|
||||
// Le stepper n'apparait que lorsqu'une session existe reellement (l'utilisateur a mentionne
|
||||
// vouloir apprendre quelque chose, pas juste parce qu'il est connecte) : voir useSessionStore,
|
||||
// sessionId n'est jamais non-null avant le premier POST /sessions reussi. La fenetre s'elargit a
|
||||
// droite pour lui faire de la place (set-pipeline-panel-visible, voir src/main/index.ts).
|
||||
useEffect(() => {
|
||||
window.api.setPipelinePanelVisible(sessionId !== null)
|
||||
}, [sessionId])
|
||||
|
||||
// Ouvre automatiquement le panneau de chat des qu'une session demarre (garde-fou : en usage
|
||||
// normal, c'est l'ouverture du chat via le menu contextuel qui permet d'envoyer le premier
|
||||
// message qui cree la session, donc le chat est deja ouvert a ce moment-la).
|
||||
const previousSessionId = useRef<number | null>(null)
|
||||
useEffect(() => {
|
||||
if (previousSessionId.current === null && sessionId !== null) setChatOpen(true)
|
||||
previousSessionId.current = sessionId
|
||||
}, [sessionId])
|
||||
|
||||
const onContextMenu = useCallback((event: React.MouseEvent) => {
|
||||
event.preventDefault()
|
||||
window.api.showContextMenu(listeningRef.current)
|
||||
setContextMenu({ x: event.clientX, y: event.clientY })
|
||||
}, [])
|
||||
const closeContextMenu = useCallback(() => setContextMenu(null), [])
|
||||
const handleLogin = useCallback(() => window.api.openLoginWindow(), [])
|
||||
const handleLogout = useCallback(() => {
|
||||
window.api.logout()
|
||||
setChatOpen(false)
|
||||
restartSession()
|
||||
}, [restartSession])
|
||||
const handleToggleListening = useCallback(() => setListening((prev) => !prev), [])
|
||||
const handleToggleChat = useCallback(() => setChatOpen((prev) => !prev), [])
|
||||
const handleQuit = useCallback(() => window.api.quitApp(), [])
|
||||
|
||||
const dragState = useRef<{
|
||||
startMouseX: number
|
||||
startMouseY: number
|
||||
@@ -125,12 +165,12 @@ function App(): React.JSX.Element {
|
||||
onMouseDown={handleMouseDown}
|
||||
onContextMenu={onContextMenu}
|
||||
>
|
||||
<AvatarViewer onReady={handleReady} />
|
||||
{voiceState === 'processing' && <ThinkingIndicator />}
|
||||
{voiceError && voiceState !== 'processing' && <VoiceErrorBanner message={voiceError} />}
|
||||
{updateStatus && <UpdateBanner status={updateStatus} />}
|
||||
{loggedIn && (
|
||||
<>
|
||||
<div className="avatar-stage">
|
||||
<AvatarViewer onReady={handleReady} />
|
||||
{voiceState === 'processing' && <ThinkingIndicator />}
|
||||
{voiceError && voiceState !== 'processing' && <VoiceErrorBanner message={voiceError} />}
|
||||
{updateStatus && <UpdateBanner status={updateStatus} />}
|
||||
{loggedIn && (
|
||||
<div className="avatar-status-anchor">
|
||||
<AvatarStatusIndicator
|
||||
status={
|
||||
@@ -142,8 +182,31 @@ function App(): React.JSX.Element {
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<SessionPanel />
|
||||
</>
|
||||
)}
|
||||
{loggedIn && chatOpen && <ChatPanel />}
|
||||
</div>
|
||||
|
||||
{sessionId !== null && (
|
||||
<div className="pipeline-stepper-anchor">
|
||||
<PipelineStepper steps={deriveStepsFromStatus(sessionStatus)} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{contextMenu && (
|
||||
<ContextMenu
|
||||
x={contextMenu.x}
|
||||
y={contextMenu.y}
|
||||
loggedIn={loggedIn}
|
||||
email={email}
|
||||
listening={listening}
|
||||
chatOpen={chatOpen}
|
||||
onClose={closeContextMenu}
|
||||
onLogin={handleLogin}
|
||||
onLogout={handleLogout}
|
||||
onToggleListening={handleToggleListening}
|
||||
onToggleChat={handleToggleChat}
|
||||
onQuit={handleQuit}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
+8
-15
@@ -1,19 +1,17 @@
|
||||
import { useEffect, useRef } from 'react'
|
||||
import { useSessionStore } from '../stores/useSessionStore'
|
||||
import { deriveStepsFromStatus } from '../utils/pipelineSteps'
|
||||
import ChatBubble from './ChatBubble'
|
||||
import InputBar from './InputBar'
|
||||
import ObjectiveValidationCard from './ObjectiveValidationCard'
|
||||
import PipelineStepper from './PipelineStepper'
|
||||
|
||||
/**
|
||||
* Panneau flottant de la session de formation (docs/Max_Composants_Frontend.md section 4) :
|
||||
* stepper + conversation + carte de validation de l'objectif + barre de saisie. N'affiche jamais
|
||||
* un statut calcule localement (voir utils/pipelineSteps.ts et la regle de PipelineStepper).
|
||||
* Panneau de conversation (docs/Max_Composants_Frontend.md section 4) : historique de messages +
|
||||
* carte de validation de l'objectif + barre de saisie. Separe du PipelineStepper (rendu a cote de
|
||||
* l'avatar par App.tsx, pas ici) - voir le retour utilisateur qui demandait cette separation.
|
||||
* N'affiche jamais un statut calcule localement.
|
||||
*/
|
||||
export default function SessionPanel(): React.JSX.Element {
|
||||
export default function ChatPanel(): React.JSX.Element {
|
||||
const {
|
||||
status,
|
||||
messages,
|
||||
objectiveDraft,
|
||||
objectiveReady,
|
||||
@@ -33,16 +31,11 @@ export default function SessionPanel(): React.JSX.Element {
|
||||
}
|
||||
}, [messages])
|
||||
|
||||
const steps = deriveStepsFromStatus(status)
|
||||
const showObjectiveCard = objectiveReady && objectiveDraft !== null && !objectiveConfirmed
|
||||
|
||||
return (
|
||||
<div className="session-panel">
|
||||
<div className="session-panel__stepper">
|
||||
<PipelineStepper steps={steps} />
|
||||
</div>
|
||||
|
||||
<div className="session-panel__chat" ref={chatRef}>
|
||||
<div className="chat-panel">
|
||||
<div className="chat-panel__messages" ref={chatRef}>
|
||||
{messages.map((message) => (
|
||||
<ChatBubble
|
||||
key={message.id}
|
||||
@@ -53,7 +46,7 @@ export default function SessionPanel(): React.JSX.Element {
|
||||
))}
|
||||
</div>
|
||||
|
||||
{error && <p className="session-panel__error">{error}</p>}
|
||||
{error && <p className="chat-panel__error">{error}</p>}
|
||||
|
||||
{showObjectiveCard && objectiveDraft ? (
|
||||
<ObjectiveValidationCard
|
||||
@@ -338,11 +338,22 @@
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
|
||||
/* ── Panneau de session (stepper + chat + saisie) ──
|
||||
Ancre en bas de la fenetre avatar (420x720, voir src/main/index.ts) pour laisser la partie
|
||||
haute/centrale libre pour l'avatar 3D, comme les bannieres existantes. A valider visuellement
|
||||
une fois l'app lancee : la hauteur de la conversation est bornee (max-height) pour ne jamais
|
||||
recouvrir tout l'avatar sur un echange long. */
|
||||
/* ── Scene avatar (colonne fixe 420px) ──
|
||||
Isole l'avatar 3D et tout ce qui lui est ancre (bannieres, badge de statut, panneau de
|
||||
conversation) dans une colonne de largeur fixe, independante de la largeur reelle de la fenetre
|
||||
(voir src/main/index.ts : la fenetre s'elargit a droite pour loger le PipelineStepper quand une
|
||||
session est active). Sans cette colonne, un panneau ancre en "left: 50%" se recentrerait sur
|
||||
toute la fenetre elargie et chevaucherait le stepper. */
|
||||
|
||||
.avatar-stage {
|
||||
position: relative;
|
||||
width: 420px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* ── Panneau de conversation (chat + saisie) ──
|
||||
Ancre en bas de la colonne avatar, comme les bannieres existantes. La hauteur est bornee
|
||||
(max-height) pour ne jamais recouvrir tout l'avatar sur un echange long. */
|
||||
|
||||
.avatar-status-anchor {
|
||||
position: absolute;
|
||||
@@ -352,7 +363,7 @@
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.session-panel {
|
||||
.chat-panel {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: 2%;
|
||||
@@ -369,16 +380,10 @@
|
||||
box-shadow: var(--shadow-panel);
|
||||
}
|
||||
|
||||
.session-panel__stepper {
|
||||
flex-shrink: 0;
|
||||
max-height: 140px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.session-panel__chat {
|
||||
.chat-panel__messages {
|
||||
flex: 1;
|
||||
min-height: 60px;
|
||||
max-height: 260px;
|
||||
max-height: 320px;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -387,12 +392,81 @@
|
||||
scrollbar-color: var(--surface-2) transparent;
|
||||
}
|
||||
|
||||
.session-panel__error {
|
||||
.chat-panel__error {
|
||||
margin: 0;
|
||||
font-size: var(--text-sm);
|
||||
color: var(--red);
|
||||
}
|
||||
|
||||
/* ── Stepper du pipeline — a cote de l'avatar, pas au-dessus ──
|
||||
Ancre sur le bord droit de la FENETRE (pas de la colonne avatar), dans l'espace supplementaire
|
||||
que main/index.ts ouvre en elargissant la fenetre (set-pipeline-panel-visible) des qu'une
|
||||
session existe reellement (voir useSessionStore : jamais affiche juste parce que l'utilisateur
|
||||
est connecte). A valider visuellement une fois l'app lancee. */
|
||||
|
||||
.pipeline-stepper-anchor {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: var(--space-3);
|
||||
transform: translateY(-50%);
|
||||
width: 160px;
|
||||
}
|
||||
|
||||
/* ── Menu contextuel ──
|
||||
Rendu cote renderer pour pouvoir etre stylise avec le design system (un menu natif Electron ne
|
||||
peut pas l'etre). Positionne en JS (ContextMenu.tsx) au clic droit. */
|
||||
|
||||
.context-menu {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
min-width: 180px;
|
||||
padding: var(--space-2) 0;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: var(--shadow-panel);
|
||||
}
|
||||
|
||||
.context-menu__item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
width: 100%;
|
||||
padding: var(--space-2) var(--space-3);
|
||||
border: none;
|
||||
background: none;
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--text-sm);
|
||||
color: var(--text-1);
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.context-menu__item:hover:not(:disabled) {
|
||||
background: var(--surface-2);
|
||||
}
|
||||
|
||||
.context-menu__item:disabled {
|
||||
color: var(--text-3);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.context-menu__item--disabled {
|
||||
color: var(--text-2);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.context-menu__check {
|
||||
margin-left: auto;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.context-menu__separator {
|
||||
height: 1px;
|
||||
margin: var(--space-1) 0;
|
||||
background: var(--border);
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.thinking__dot,
|
||||
.avatar-status__dot,
|
||||
|
||||
Reference in New Issue
Block a user