Add unified FEN/PGN import with auto-detection

- Create chessFormatDetector utility for automatic format detection
- Update StartScreen with textarea supporting both FEN and PGN input
- Add real-time format detection with visual feedback indicators
- Update translations for all 4 languages (EN, DE, FR, IT)
- Add markdown rendering for Tutor chat messages
- Add comprehensive tests for format detection (20 tests)
- Update game initialization to handle both FEN and PGN formats

This completes the fix/stale-analysis-data branch with:
- Fixed stale evaluation data in hint/best move requests
- Clarified AI's dual role (opponent + tutor) to prevent hint rejection
- Stored complete evaluation history (P0, P1, P2) for all moves
- Improved end-game analysis with better mistake detection
- Fixed duplicate analysis runs with useRef flag
- Added markdown rendering for formatted analysis output
- Added unified FEN/PGN import with auto-detection
This commit is contained in:
Stefan
2025-11-25 17:54:25 +01:00
parent 4d5ec5ecc3
commit cd6cab367a
10 changed files with 1736 additions and 115 deletions
+28 -8
View File
@@ -32,6 +32,10 @@ export interface Translations {
chooseCoach: string;
importPosition: string;
importPositionPlaceholder: string;
formatDetected: string;
formatFen: string;
formatPgn: string;
formatInvalid: string;
apiKeyRequired: string;
colorSelection: string;
playAsWhite: string;
@@ -123,8 +127,12 @@ const en: Translations = {
resumeGame: 'Resume Previous Game',
startNewGame: 'Start New Game instead...',
chooseCoach: 'Choose Your Coach:',
importPosition: 'Import Position (Optional FEN)',
importPositionPlaceholder: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
importPosition: 'Import Position or Game (FEN or PGN)',
importPositionPlaceholder: 'Paste FEN position or PGN game here...',
formatDetected: 'Format detected:',
formatFen: 'FEN Position',
formatPgn: 'PGN Game',
formatInvalid: 'Invalid format - please paste a valid FEN or PGN',
apiKeyRequired: 'Please enter a valid API Key to continue.',
colorSelection: 'Choose Your Color:',
playAsWhite: 'Play as White',
@@ -206,8 +214,12 @@ const de: Translations = {
resumeGame: 'Vorheriges Spiel fortsetzen',
startNewGame: 'Stattdessen neues Spiel starten...',
chooseCoach: 'Wähle deinen Trainer:',
importPosition: 'Position importieren (Optional FEN)',
importPositionPlaceholder: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
importPosition: 'Position oder Partie importieren (FEN oder PGN)',
importPositionPlaceholder: 'FEN-Position oder PGN-Partie hier einfügen...',
formatDetected: 'Format erkannt:',
formatFen: 'FEN-Position',
formatPgn: 'PGN-Partie',
formatInvalid: 'Ungültiges Format - bitte gültiges FEN oder PGN einfügen',
apiKeyRequired: 'Bitte geben Sie einen gültigen API-Schlüssel ein, um fortzufahren.',
colorSelection: 'Wähle deine Farbe:',
playAsWhite: 'Als Weiß spielen',
@@ -289,8 +301,12 @@ const fr: Translations = {
resumeGame: 'Reprendre la partie précédente',
startNewGame: 'Démarrer une nouvelle partie...',
chooseCoach: 'Choisissez votre coach :',
importPosition: 'Importer une position (FEN optionnel)',
importPositionPlaceholder: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
importPosition: 'Importer une position ou partie (FEN ou PGN)',
importPositionPlaceholder: 'Collez une position FEN ou partie PGN ici...',
formatDetected: 'Format détecté :',
formatFen: 'Position FEN',
formatPgn: 'Partie PGN',
formatInvalid: 'Format invalide - veuillez coller un FEN ou PGN valide',
apiKeyRequired: 'Veuillez entrer une clé API valide pour continuer.',
colorSelection: 'Choisissez votre couleur :',
playAsWhite: 'Jouer Blancs',
@@ -372,8 +388,12 @@ const it: Translations = {
resumeGame: 'Riprendi partita precedente',
startNewGame: 'Inizia nuova partita...',
chooseCoach: 'Scegli il tuo allenatore:',
importPosition: 'Importa posizione (FEN opzionale)',
importPositionPlaceholder: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
importPosition: 'Importa posizione o partita (FEN o PGN)',
importPositionPlaceholder: 'Incolla posizione FEN o partita PGN qui...',
formatDetected: 'Formato rilevato:',
formatFen: 'Posizione FEN',
formatPgn: 'Partita PGN',
formatInvalid: 'Formato non valido - incolla un FEN o PGN valido',
apiKeyRequired: 'Inserisci una chiave API valida per continuare.',
colorSelection: 'Scegli il tuo colore:',
playAsWhite: 'Gioca Bianco',