feat: poker session history — browse, delete, and Lyra lookup

Answers three gaps: no way to delete a single poker session (only clear_all),
no way to browse past sessions, and Lyra could only see aggregate stats.

- poker.list_sessions() (per-session summary + hand count + recap flag) and
  poker.delete_session() (removes a session + its hands/reads/observations/
  stacks/rituals; keeps the persistent villain file).
- /history page (date, stakes, venue, net, hours, recap link, per-row delete with
  confirm) + /history/data + DELETE /history/{id}. Nav links from chat + HUD.
- recent_sessions read tool, added to the shared lookups so Lyra can answer
  "how'd my last few sessions go?" in either mode.
- Delete is UI/CLI only — deliberately not a Lyra tool.
- test_modes.py +2 (list/delete, recent_sessions); 44 green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-20 00:21:48 +00:00
parent 35c973df05
commit e1e89c07e4
8 changed files with 223 additions and 3 deletions
+29
View File
@@ -175,6 +175,35 @@ def test_session_state_readback(lyra):
assert "great river fold" in out
def test_list_and_delete_session(lyra):
_, poker, _, tools = lyra
keep = poker.start_session(venue="Meadows", stakes="1/3", buy_in=300)
poker.end_session(cash_out=400, session_id=keep)
drop = poker.start_session(venue="Bellagio", stakes="2/5", buy_in=500)
poker.log_hand(position="BTN", hole_cards="AKs", session_id=drop)
poker.log_stack(620, session_id=drop)
poker.log_ritual("scar", content="punt", session_id=drop)
sessions = poker.list_sessions()
assert {s["id"] for s in sessions} == {keep, drop}
assert next(s for s in sessions if s["id"] == drop)["hands"] == 1
removed = poker.delete_session(drop)
assert removed["poker_sessions"] == 1 and removed["poker_hands"] == 1
assert removed["poker_stack_log"] == 1 and removed["poker_rituals"] == 1
assert {s["id"] for s in poker.list_sessions()} == {keep} # only the survivor
assert poker.get_session(drop) is None
def test_recent_sessions_tool(lyra):
_, poker, modes, tools = lyra
assert "recent_sessions" in modes.TALK.tools # available even when just talking
poker.import_session(date="2026-06-01", venue="Meadows", stakes="1/3",
buy_in_total=300, cash_out=520, hours=5)
out = tools.dispatch("recent_sessions", {}, {})
assert "Meadows" in out and "+220" in out
def test_rituals_require_live_session(lyra):
_, poker, _, tools = lyra
# tools degrade gracefully (no exception) when nothing is open