feat: edit hands from the viewer + "not my hand" disown

Addresses "no way to edit hands" and cleaning up misattributed ones:
- hand viewer (/hand/{id}) gets an "✎ Edit this hand" panel: position, cards,
  board, your net, tag, lesson → Save (existing PATCH), plus Delete.
- "Not my hand" → POST /hand/{id}/disown → poker.disown_hand clears the flat hero
  fields and rewrites structured with hero_involved=false, so a hand mislabeled as
  Brian's becomes a clean observed hand (replay stops showing him as hero).

1 test. Full suite 156 green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-04 03:00:21 +00:00
parent 2be43848a7
commit 4ce1b05fad
4 changed files with 91 additions and 0 deletions
+22
View File
@@ -644,6 +644,28 @@ def update_hand(hand_id: int, **fields) -> dict | None:
return get_hand(hand_id)
def disown_hand(hand_id: int) -> dict | None:
"""Reclassify a hand as OBSERVED (not Brian's) — fixes one that was mislabeled
as his. Clears the flat hero fields and rewrites the structured JSON with
hero_involved=false so the replay stops showing him as hero."""
h = get_hand(hand_id)
if not h:
return None
structured = h.get("structured")
if isinstance(structured, str):
structured = _safe_json(structured)
if isinstance(structured, dict):
structured = normalize_structured({**structured, "hero_involved": False})
conn = _c()
with conn:
conn.execute(
"UPDATE poker_hands SET position = NULL, hole_cards = NULL, result = NULL, "
"structured = ? WHERE id = ?",
(json.dumps(structured) if structured else None, hand_id),
)
return get_hand(hand_id)
def list_hands(session_id: int | None = None) -> list[dict]:
sid = _resolve(session_id)
if sid is None: