fix: render flat-logged hands + on-demand "build replay"
Quick-logged hands (log_hand) store flat fields with no structured JSON, so the
hand viewer dead-ended with "no structured data to replay" — even when the full
street-by-street action was captured (e.g. the KhQh-vs-Louis hand). Now:
- hand.html renders a readable STATIC view of any flat hand (hero cards, board,
street narratives, result, lesson) instead of erroring; also handles empty/garbage
structured rows by falling back to the flat view.
- "▶ Build replay" button + poker.reconstruct_hand + POST /hand/{id}/reconstruct:
parse a flat hand's narrative into structured form on demand, making any
quick-logged hand replayable without an LLM call per log during live play.
- test_modes.py +1 (reconstruct wiring).
(Also reconstructed the two live Meadows hands and removed one empty hand in the DB.)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -175,6 +175,24 @@ def test_session_state_readback(lyra):
|
||||
assert "great river fold" in out
|
||||
|
||||
|
||||
def test_reconstruct_flat_hand(lyra, monkeypatch):
|
||||
_, poker, _, _ = lyra
|
||||
poker.start_session(stakes="1/3", buy_in=300)
|
||||
hid = poker.log_hand(position="UTG", hole_cards="KhQh",
|
||||
preflop="UTG raises, BTN calls", flop="Qd Qs Jc, bet, call",
|
||||
river="Kd, all in, called", showdown="hero wins", result=225)
|
||||
assert poker.get_hand(hid)["structured"] is None # flat (log_hand) — not replayable yet
|
||||
monkeypatch.setattr(poker, "parse_hand", lambda *a, **k: {
|
||||
"hero_pos": "UTG", "hero_cards": ["Kh", "Qh"],
|
||||
"players": [{"pos": "UTG"}],
|
||||
"actions": [{"street": "preflop", "pos": "UTG", "action": "raise"}],
|
||||
"board": ["Qd", "Qs", "Jc", "6d", "Kd"]})
|
||||
out = poker.reconstruct_hand(hid)
|
||||
assert out is not None
|
||||
h = poker.get_hand(hid)
|
||||
assert h["structured"]["hero_pos"] == "UTG" and len(h["structured"]["actions"]) == 1
|
||||
|
||||
|
||||
def test_undo_last_and_delete_entry(lyra):
|
||||
_, poker, modes, tools = lyra
|
||||
assert "undo_last" in modes.CASH.tools
|
||||
|
||||
Reference in New Issue
Block a user