All files / web/src/components/toys/euclid/chat EuclidChatPanel.tsx

0% Statements 0/71
0% Branches 0/1
0% Functions 0/1
0% Lines 0/71

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72                                                                                                                                               
'use client'

/**
 * Euclid-specific chat panel — thin wrapper around CharacterChatPanel.
 *
 * Wires in Euclid's character definition and geometric entity markers.
 */

import type React from 'react'
import { CharacterChatPanel } from '@/lib/character/CharacterChatPanel'
import type { DebugCompactionProps } from '@/lib/character/CharacterChatPanel'
import type { ChatMessage, ChatCallState } from '@/lib/character/types'
import type { EuclidEntityRef } from './parseGeometricEntities'
import { useGeometryTeacher } from '../GeometryTeacherContext'

interface EuclidChatPanelProps {
  messages: ChatMessage[]
  isStreaming: boolean
  onSend: (text: string) => void
  onClose: () => void
  onHighlight: (entity: EuclidEntityRef | null) => void
  renderEntity?: (entity: EuclidEntityRef, displayText: string, index: number) => React.ReactNode
  /** Drag handlers for the header — when provided, header becomes drag handle */
  onDragPointerDown?: (e: React.PointerEvent) => void
  onDragPointerMove?: (e: React.PointerEvent) => void
  onDragPointerUp?: (e: React.PointerEvent) => void
  isDragging?: boolean
  /** Square off the bottom-right corner to connect with the quad */
  squareBottomRight?: boolean
  /** When set, shows compaction controls between messages (debug mode) */
  debugCompaction?: DebugCompactionProps
  /** When set, the chat panel acts as the voice call UI */
  callState?: ChatCallState
}

export function EuclidChatPanel({
  messages,
  isStreaming,
  onSend,
  onClose,
  onHighlight,
  renderEntity,
  onDragPointerDown,
  onDragPointerMove,
  onDragPointerUp,
  isDragging,
  squareBottomRight,
  debugCompaction,
  callState,
}: EuclidChatPanelProps) {
  const { definition, entityMarkers } = useGeometryTeacher()
  return (
    <CharacterChatPanel
      character={definition}
      entityMarkers={entityMarkers}
      messages={messages}
      isStreaming={isStreaming}
      onSend={onSend}
      onClose={onClose}
      onHighlight={onHighlight}
      renderEntity={renderEntity}
      onDragPointerDown={onDragPointerDown}
      onDragPointerMove={onDragPointerMove}
      onDragPointerUp={onDragPointerUp}
      isDragging={isDragging}
      squareBottomRight={squareBottomRight}
      debugCompaction={debugCompaction}
      callState={callState}
    />
  )
}