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
+15
View File
@@ -113,6 +113,21 @@ def create_app() -> FastAPI:
bundle = await asyncio.to_thread(poker.hud)
return bundle or {"session": None}
@app.get("/history")
async def history_page() -> FileResponse:
"""Browsable list of past poker sessions."""
return FileResponse(str(_STATIC / "history.html"))
@app.get("/history/data")
async def history_data(limit: int = 100, include_review: bool = False) -> dict:
return {"sessions": poker.list_sessions(limit=limit, include_review=include_review)}
@app.delete("/history/{session_id}")
async def history_delete(session_id: int) -> dict:
removed = await asyncio.to_thread(poker.delete_session, session_id)
logbus.log("info", "poker session deleted", id=session_id, removed=removed)
return {"ok": True, "removed": removed}
@app.post("/v1/chat/completions")
async def chat_completions(request: Request) -> dict:
body = await request.json()