M007 S04: OpeningSuggestion ignores contingency branches — shows wrong symbols when branch is active #4

Closed
opened 2026-05-15 19:19:22 +00:00 by Mark · 1 comment
Owner

Severity: HIGH
Found by: Fresh evaluation of M007 implementation
File: src/components/OpeningSuggestion.tsx:19

Problem

OpeningSuggestion always reads from the main turn sequence (activeOpening.opening.turns[activeOpening.currentTurnIndex]) even when a contingency branch is active. The branch auto-switching logic in CasualDuel.tsx correctly sets activeBranchIndex and branchTurnIndex, but the suggestion UI never uses them.

This makes S04 (Contingency Trees) non-functional from the UI — the engine correctly detects branch conditions and switches, but the player sees wrong suggested symbols.

Fix

OpeningSuggestion needs to check if activeOpening.activeBranchIndex !== null and if so, read from activeOpening.opening.contingencies[activeBranchIndex].branchTurns[branchTurnIndex] instead of the main opening.turns[currentTurnIndex].

There is also a dead function getSuggestedTurn() at engine/openings.ts:131 that already implements this logic correctly but is never imported or called — it should be used here.

**Severity:** HIGH **Found by:** Fresh evaluation of M007 implementation **File:** src/components/OpeningSuggestion.tsx:19 ## Problem OpeningSuggestion always reads from the main turn sequence (`activeOpening.opening.turns[activeOpening.currentTurnIndex]`) even when a contingency branch is active. The branch auto-switching logic in CasualDuel.tsx correctly sets `activeBranchIndex` and `branchTurnIndex`, but the suggestion UI never uses them. This makes S04 (Contingency Trees) non-functional from the UI — the engine correctly detects branch conditions and switches, but the player sees wrong suggested symbols. ## Fix OpeningSuggestion needs to check if `activeOpening.activeBranchIndex !== null` and if so, read from `activeOpening.opening.contingencies[activeBranchIndex].branchTurns[branchTurnIndex]` instead of the main `opening.turns[currentTurnIndex]`. There is also a dead function `getSuggestedTurn()` at engine/openings.ts:131 that already implements this logic correctly but is never imported or called — it should be used here.
Author
Owner

Unblocking — lint gate now passes clean (47dfc01).

Unblocking — lint gate now passes clean (47dfc01).
Mark closed this issue 2026-05-16 17:23:30 +00:00
Sign in to join this conversation.
No description provided.