Skip to content

Commit 53c8236

Browse files
fix: disable engine analysis during drill play via enabled flag
The analysis controller's useEngineAnalysis hook has its own internal tree controller that navigates the drill's game tree. Even though we stopped syncing currentNode, the internal controller still tracked tree changes and fired stockfish.streamEvaluations() — which calls stopEvaluation() and kills the background analysis's in-progress evaluation (explaining depth 8 instead of 18). Added an 'enabled' parameter to useEngineAnalysis and useAnalysisController. During drill play (analysisEnabled=false, continueAnalyzingMode=false), both Maia and Stockfish effects in useEngineAnalysis are completely skipped. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 471ab4d commit 53c8236

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/hooks/useAnalysisController/useAnalysisController.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const useAnalysisController = (
2626
game: AnalyzedGame,
2727
initialOrientation?: 'white' | 'black',
2828
enableAutoSave = true,
29+
enableEngineAnalysis = true,
2930
) => {
3031
const defaultOrientation = initialOrientation
3132
? initialOrientation
@@ -86,6 +87,7 @@ export const useAnalysisController = (
8687
deepAnalysisController.progress.isAnalyzing
8788
? deepAnalysisController.config.targetDepth
8889
: 18,
90+
enableEngineAnalysis,
8991
)
9092

9193
const availableMoves = useMemo(() => {

src/hooks/useAnalysisController/useEngineAnalysis.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const useEngineAnalysis = (
1515
currentMaiaModel: string,
1616
setAnalysisState: React.Dispatch<React.SetStateAction<number>>,
1717
targetDepth = 18,
18+
enabled = true,
1819
) => {
1920
const maia = useContext(MaiaEngineContext)
2021
const stockfish = useContext(StockfishEngineContext)
@@ -78,7 +79,7 @@ export const useEngineAnalysis = (
7879
}
7980

8081
useEffect(() => {
81-
if (!currentNode) return
82+
if (!currentNode || !enabled) return
8283

8384
const board = new Chess(currentNode.fen)
8485
const nodeFen = currentNode.fen
@@ -163,10 +164,11 @@ export const useEngineAnalysis = (
163164
inProgressAnalyses,
164165
maia,
165166
setAnalysisState,
167+
enabled,
166168
])
167169

168170
useEffect(() => {
169-
if (!currentNode) return
171+
if (!currentNode || !enabled) return
170172

171173
const shouldForceStockfishRerun =
172174
stockfishDebugRerunToken > lastConsumedStockfishRerunTokenRef.current
@@ -281,5 +283,6 @@ export const useEngineAnalysis = (
281283
stockfishDebugRerunToken,
282284
currentNode?.analysis.maia?.[currentMaiaModel]?.policy,
283285
currentNode?.mainChild?.move,
286+
enabled,
284287
])
285288
}

src/pages/openings/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ const OpeningsPage: NextPage = () => {
180180
},
181181
controller.currentDrill?.playerColor || 'white',
182182
false, // Disable auto-saving on openings page
183+
controller.analysisEnabled || controller.continueAnalyzingMode, // Disable engine analysis during drill play
183184
)
184185

185186
// Sync analysis controller with current node — only when analysis is active

0 commit comments

Comments
 (0)