refactor: code review improvements
- Add 30s timeout to Stockfish evaluation to prevent hanging promises - Add FEN validation and depth cap (max 30) to Stockfish API route - Create ErrorBoundary component with specialized fallbacks for chess game and tutor - Extract useChessSounds hook for better audio management - Add React.memo to EvaluationBar and CapturedPieces for performance - Add useMemo to CapturedPieces for sorted pieces calculation - Improve tacticDetection to return empty array instead of "none" type - Add filterMeaningfulTactics and hasTactics helper functions - Translate hardcoded UI strings (stockfishLevel, download, evalChange) - Update translations for EN, DE, FR, IT, PL - Add uuid to Jest transformIgnorePatterns for ESM compatibility - Update tests to use new filterMeaningfulTactics function
This commit is contained in:
@@ -14,7 +14,7 @@ import ReactMarkdown from "react-markdown";
|
||||
|
||||
import { useTranslation } from '@/lib/i18n/useTranslation';
|
||||
import { SupportedLanguage } from '@/lib/i18n/translations';
|
||||
import { DetectedTactic } from '@/lib/tacticDetection';
|
||||
import { DetectedTactic, filterMeaningfulTactics } from '@/lib/tacticDetection';
|
||||
import { useDebug } from '@/contexts/DebugContext';
|
||||
import { MoveHistoryItem } from './GameOverModal';
|
||||
import { parseGeminiError, GeminiErrorInfo, isGeminiError } from '@/lib/geminiErrorHandler';
|
||||
@@ -582,7 +582,7 @@ INSTRUCTIONS:
|
||||
// Tactical Analysis Instruction
|
||||
let tacticalInstruction = "";
|
||||
if (missedTactics && missedTactics.length > 0) {
|
||||
const meaningfulTactics = missedTactics.filter(t => t.tactic_type !== 'none');
|
||||
const meaningfulTactics = filterMeaningfulTactics(missedTactics);
|
||||
if (meaningfulTactics.length > 0) {
|
||||
const tacticDescriptions = meaningfulTactics.map(t => {
|
||||
let desc = `- ${t.tactic_type.toUpperCase()}`;
|
||||
|
||||
Reference in New Issue
Block a user