feat: undo / delete logged entries (fix fat-fingered live logging)
Previously the only delete was whole-session, so a mis-logged stack or a
mis-parsed hand was stuck on the HUD. Now:
- undo_last tool ("scratch that") — deletes the most recent hand/stack/read/
scar/confidence/reset in the live session; added to the Cash toolset.
- poker.delete_hand/stack/read/ritual + delete_entry dispatch + undo_last.
- DELETE /session/entry/{kind}/{id} endpoint.
- HUD: per-row × delete buttons on hands, confidence-bank, and scar-note rows
(stack/read deletes via the tool). Row ids now surfaced in the hud() bundle.
- test_modes.py +2 (undo_last across kinds, tool handler); 46 green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -117,6 +117,25 @@ def _log_stack(args: dict, ctx: dict) -> str:
|
||||
return f"Stack ${amount:g} logged" + (f" (net {net:+.0f})." if net is not None else ".")
|
||||
|
||||
|
||||
def _undo_last(args: dict, ctx: dict) -> str:
|
||||
what = (args.get("what") or "").strip().lower()
|
||||
aliases = {"hands": "hand", "stacks": "stack", "reads": "read",
|
||||
"scar_note": "scar", "confidence_bank": "confidence",
|
||||
"scar note": "scar", "confidence": "confidence", "note": "ritual"}
|
||||
what = aliases.get(what, what)
|
||||
valid = ("hand", "stack", "read", "scar", "confidence", "reset", "ritual")
|
||||
if what not in valid:
|
||||
return f"Tell me what to undo — one of: {', '.join(valid)}."
|
||||
try:
|
||||
removed = poker.undo_last(what)
|
||||
except ValueError:
|
||||
return "No live session to undo anything in."
|
||||
if not removed:
|
||||
return f"Nothing logged to undo for '{what}'."
|
||||
logbus.log("info", "undo last", what=what, removed=removed[:60])
|
||||
return f"Scratched the last {what} — removed {removed}."
|
||||
|
||||
|
||||
def _scar_note(args: dict, ctx: dict) -> str:
|
||||
content = (args.get("content") or "").strip()
|
||||
if not content:
|
||||
@@ -370,6 +389,13 @@ TOOLS.update({
|
||||
"add_buyin": {"handler": _add_buyin, "spec": _f(
|
||||
"add_buyin", "Record a rebuy / additional buy-in in the live session.",
|
||||
{"amount": {**_N, "description": "Amount added"}}, ["amount"])},
|
||||
"undo_last": {"handler": _undo_last, "spec": _f(
|
||||
"undo_last",
|
||||
"Undo/delete the most recent logged entry in the live session when Brian says "
|
||||
"'scratch that', 'delete that', 'that was wrong', etc. Specify what: 'hand', "
|
||||
"'stack', 'read', 'scar', 'confidence', or 'reset'.",
|
||||
{"what": {**_S, "description": "hand | stack | read | scar | confidence | reset"}},
|
||||
["what"])},
|
||||
"log_stack": {"handler": _log_stack, "spec": _f(
|
||||
"log_stack",
|
||||
"Record Brian's CURRENT total chip stack in the live session. Call whenever "
|
||||
|
||||
Reference in New Issue
Block a user