Log
12e981706f99
fix(review): the timeline waits while an own move is being analysed
public
fix(review): the timeline waits while an own move is being analysed
While the engine was answering a move made on the analysis board, a
playback step (e.g. after Space) moved the board to another node, and the
pending move was then pushed onto a position where it is illegal. The strip
of captured pieces showed None and drawing raised. _playback_apply now waits
until the move is in; the strip skips such entries instead of crashing.
Regression tests for both.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
modified
schach/diagram.py
+3 −1
@@ -245,7 +245,9 @@ class BoardPainter:
245 245 if replay. is_en_passant(move): 246 246 result[replay. turn]. append(chess. Piece(chess. PAWN, not replay. turn)) 247 247 elif replay. is_capture(move) and not replay. is_castling(move): 248 - result[replay. turn]. append(replay. piece_at(move. to_square)) 248 + piece = replay. piece_at(move. to_square) 249 + if piece is not None : # Zug passt nicht zur Stellung (push prüft nicht): nicht abstürzen 250 + result[replay. turn]. append(piece) 249 251 replay. push(move) 250 252 self . _captures_key, self . _captures = key, result 251 253 captured = {c: list (p) for c, p in self . _captures. items()}
modified
schach/review.py
+2 −0
@@ -419,6 +419,8 @@ class ReviewMixin:
419 419 shown = recording. at(self . playback[" frames " ], self . _playback_ms()) 420 420 if shown == self . playback[" shown " ] and not force: 421 421 return 422 + if self . demo is not None and self . demo. get(" busy " ): 423 + return # selbst gezogener Zug wird noch berechnet; danach holt der nächste Takt das nach 422 424 self . playback[" shown " ] = shown 423 425 path, shapes = shown 424 426 node = self . game_tree. game if self . game_tree is not None else None
modified
tests/test_drawing.py
+15 −0
@@ -40,3 +40,18 @@ class ToggleTest(unittest.TestCase):
40 40 41 41 if __name__ == " __main__ " : 42 42 unittest. main() 43 + 44 + 45 +class CapturesTest (unittest. TestCase): 46 + def test_history_that_does_not_fit_the_start_does_not_crash (self ): 47 + """Gefunden am 24.11.2026 vom Zufallstest (seltene Ausnahme beim Zeichnen): steht ein Zug 48 + auf dem Brett, der dort nicht legal ist (push prüft das nicht), meldet python-chess einen 49 + Schlagzug auf ein leeres Feld; im Streifen stand dann None. Ursache: siehe 50 + test_zustand_regression.BusyTest.""" 51 + from schach import diagram 52 + 53 + board = chess. Board() 54 + board. push_san(" e4 " ) 55 + board. push(chess. Move(chess. E4, chess. E5)) # push prüft nicht: Weiß zieht, obwohl Schwarz dran ist 56 + captured = diagram. Diagram(board). _captured_by() 57 + self . assertNotIn(None , captured[chess. WHITE] + captured[chess. BLACK])
modified
tests/test_zustand_regression.py
+24 −0
@@ -31,6 +31,12 @@ class _Media:
31 31 def get_playing (self ): 32 32 return self . playing 33 33 34 + def get_ended (self ): 35 + return False 36 + 37 + def get_timestamp (self ): 38 + return 0 39 + 34 40 35 41 class _Revealer : 36 42 def __init__ (self ):
@@ -176,5 +182,23 @@ class GeschlossenTest(unittest.TestCase)
176 182 method(closed) # darf nichts anfassen 177 183 178 184 185 +class BusyTest (unittest. TestCase): 186 + def test_zeitleiste_wartet_auf_den_selbst_gezogenen_zug (self ): 187 + """Gefunden am 24.11.2026 (Ursache des seltenen None im Streifen der geschlagenen Figuren): 188 + Während die Engine einen selbst gezogenen Zug auf dem Analysebrett berechnet („busy“), 189 + setzte _playback_apply (etwa nach der Leertaste) das Brett auf einen anderen Knoten. 190 + _demo_refresh legte den Zug dann auf eine Stellung, in der er gar nicht legal ist.""" 191 + win = FakeWindow(played(" e4 " , " e5 " ), mode= " review " ) 192 + win. start_playback() 193 + before = win. demo[" node " ] 194 + win. demo[" busy " ] = chess. Move. from_uci(" g1f3 " ) # gerade selbst gezogen, Antwort kommt noch 195 + win. playback[" frames " ] = [(0 , (chess. Move. from_uci(" e2e4 " ),), ())] # Zeitleiste: nach 1. e4 196 + win. _playback_apply(force= True ) 197 + self . assertIs(win. demo[" node " ], before) 198 + win. demo[" busy " ] = False # Antwort ist da: jetzt darf die Zeitleiste wieder 199 + win. _playback_apply(force= True ) 200 + self . assertEqual(win. demo[" node " ]. move, chess. Move. from_uci(" e2e4 " )) 201 + 202 + 179 203 if __name__ == " __main__ " : 180 204 unittest. main()