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:
co-authored by
Claude Sonnet 5
parent
309db80add
commit
919b82ef37
@@ -1,8 +1,10 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import AvatarViewer, { type AvatarHandle } from './components/AvatarViewer'
|
||||
import AvatarStatusIndicator from './components/AvatarStatusIndicator'
|
||||
import ThinkingIndicator from './components/ThinkingIndicator'
|
||||
import VoiceErrorBanner from './components/VoiceErrorBanner'
|
||||
import UpdateBanner from './components/UpdateBanner'
|
||||
import SessionPanel from './components/SessionPanel'
|
||||
import { useVoiceAssistant, type VoiceState } from './voice/useVoiceAssistant'
|
||||
import { useProactiveSpeech } from './voice/useProactiveSpeech'
|
||||
|
||||
@@ -12,6 +14,7 @@ function App(): React.JSX.Element {
|
||||
// ci-dessous qui verifie l'etat de connexion au demarrage.
|
||||
const [listening, setListening] = useState(false)
|
||||
const listeningRef = useRef(listening)
|
||||
const [loggedIn, setLoggedIn] = useState(false)
|
||||
const [voiceState, setVoiceState] = useState<VoiceState>('idle')
|
||||
const [voiceError, setVoiceError] = useState<string | null>(null)
|
||||
const [updateStatus, setUpdateStatus] = useState<'available' | 'ready' | null>(null)
|
||||
@@ -38,12 +41,23 @@ function App(): React.JSX.Element {
|
||||
// Restaure l'ecoute par defaut si l'app demarre deja connectee (ex: redemarrage apres une
|
||||
// connexion precedente dans la meme session OS, bien qu'aucune session ne soit persistee entre
|
||||
// deux lancements de Max pour l'instant).
|
||||
useEffect(() => {
|
||||
const refreshAuthStatus = useCallback(() => {
|
||||
window.api
|
||||
.getAuthStatus()
|
||||
.then((status) => setListening(status.loggedIn))
|
||||
.catch(() => setListening(false))
|
||||
.then((status) => {
|
||||
setListening(status.loggedIn)
|
||||
setLoggedIn(status.loggedIn)
|
||||
})
|
||||
.catch(() => {
|
||||
setListening(false)
|
||||
setLoggedIn(false)
|
||||
})
|
||||
}, [])
|
||||
useEffect(refreshAuthStatus, [refreshAuthStatus])
|
||||
// toggle-listening est aussi envoye a la connexion/deconnexion (voir index.ts) : on en profite
|
||||
// pour revalider loggedIn aupres du main process plutot que de le deduire de l'etat d'ecoute
|
||||
// (l'utilisateur peut couper l'ecoute manuellement sans se deconnecter).
|
||||
useEffect(() => window.api.onToggleListening(refreshAuthStatus), [refreshAuthStatus])
|
||||
useEffect(() => window.api.onProactiveSpeech(() => setVoiceState('speaking')), [])
|
||||
|
||||
const onContextMenu = useCallback((event: React.MouseEvent) => {
|
||||
@@ -115,6 +129,22 @@ function App(): React.JSX.Element {
|
||||
{voiceState === 'processing' && <ThinkingIndicator />}
|
||||
{voiceError && voiceState !== 'processing' && <VoiceErrorBanner message={voiceError} />}
|
||||
{updateStatus && <UpdateBanner status={updateStatus} />}
|
||||
{loggedIn && (
|
||||
<>
|
||||
<div className="avatar-status-anchor">
|
||||
<AvatarStatusIndicator
|
||||
status={
|
||||
voiceState === 'recording'
|
||||
? 'waiting'
|
||||
: voiceState === 'speaking'
|
||||
? 'speaking'
|
||||
: 'idle'
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<SessionPanel />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
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).
|
||||
*/
|
||||
export default function SessionPanel(): React.JSX.Element {
|
||||
const {
|
||||
status,
|
||||
messages,
|
||||
objectiveDraft,
|
||||
objectiveReady,
|
||||
objectiveConfirmed,
|
||||
loading,
|
||||
error,
|
||||
sendMessage,
|
||||
confirmObjective,
|
||||
restart
|
||||
} = useSessionStore()
|
||||
const chatRef = useRef<HTMLDivElement | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const chat = chatRef.current
|
||||
if (chat && typeof chat.scrollTo === 'function') {
|
||||
chat.scrollTo({ top: chat.scrollHeight })
|
||||
}
|
||||
}, [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}>
|
||||
{messages.map((message) => (
|
||||
<ChatBubble
|
||||
key={message.id}
|
||||
role={message.role}
|
||||
content={message.content}
|
||||
timestamp={message.timestamp}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{error && <p className="session-panel__error">{error}</p>}
|
||||
|
||||
{showObjectiveCard && objectiveDraft ? (
|
||||
<ObjectiveValidationCard
|
||||
objective={objectiveDraft}
|
||||
onConfirm={confirmObjective}
|
||||
onRestart={restart}
|
||||
/>
|
||||
) : (
|
||||
<InputBar
|
||||
placeholder="Explique a Max ce que tu veux apprendre..."
|
||||
disabled={loading}
|
||||
onSend={(text) => void sendMessage(text)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -338,6 +338,61 @@
|
||||
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. */
|
||||
|
||||
.avatar-status-anchor {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: calc(2% + 64vh + var(--space-2));
|
||||
transform: translateX(-50%);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.session-panel {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: 2%;
|
||||
transform: translateX(-50%);
|
||||
width: min(94%, 380px);
|
||||
max-height: 64vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
padding: var(--space-3);
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-panel);
|
||||
}
|
||||
|
||||
.session-panel__stepper {
|
||||
flex-shrink: 0;
|
||||
max-height: 140px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.session-panel__chat {
|
||||
flex: 1;
|
||||
min-height: 60px;
|
||||
max-height: 260px;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--surface-2) transparent;
|
||||
}
|
||||
|
||||
.session-panel__error {
|
||||
margin: 0;
|
||||
font-size: var(--text-sm);
|
||||
color: var(--red);
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.thinking__dot,
|
||||
.avatar-status__dot,
|
||||
|
||||
Reference in New Issue
Block a user