Stop the tool from throwing a pot away without saying so #49

Closed
jheaps wants to merge 0 commits from feature/casino-holdem-fewer-taps into master
Owner

Two ways to lose a hand's money by accident, both found by walking the settle flow and checking the chip count afterwards. Stacked on #48.

1. Next Hand destroyed an unresolved pot silently

Starting the next hand clears every seat's contribution, so money still in the middle simply vanished.

Measured at a four-handed table with $8 in the pot: the table went from 800 chips to 792, and the toast said "Next hand — button on seat 3. Blinds posted." — not a word about the eight chips that had just left.

It now asks, names the amount, and says what will happen to it:

Throw away $8?
There's still money in the middle from this hand. Starting the next one takes it off the table without paying anybody — use Resolve Pot if somebody won it.

Confirming still works and the toast now reports what went. The undo was always there, but a dealer can't undo something they were never told about.

2. The wizard's "Close" abandoned a payout that looked finished

After picking winners and confirming, the wizard shows "Final Payouts — Ann $8" above two buttons: Start Next Hand and Close. Close pays nobody.

Under that heading, with a name and an amount beside it, a dealer taps Close believing the pot has been pushed — and walks away with the chips still in the middle and the hand unlogged. The button now reads "Cancel — don't pay yet", with a line underneath spelling out that nothing has been paid.

The warning had to measure the right thing

My first version counted the pot badge, which was wrong in a way the tests caught before it shipped.

The table-wide base pot is a standing ante — the mode for a dealer who isn't tracking stacks at all — and it re-applies to the next hand rather than being lost with this one. Quoting it would have put a confirmation in front of exactly those dealers before every single hand, for money that wasn't going anywhere.

HoldemState.unresolvedContributions() measures precisely the fields startNextHand clears: banked contributions, chip counts, and whatever is still in front of players on this street. Verified both ways in the browser — a base-pot table showing a $100 pot is not asked at all; a stack-tracking table with $8 live is.

Validation

6 new tests (115 total, all passing): the quoted number equals what actually leaves the table, mid-street chips are included, a settled hand leaves nothing to warn about, five settled hands conserve every chip, an empty table has no phantom pot, and a standing ante is never warned about.

Playwright end to end: warning fires and cancels cleanly (800 chips kept, hand not advanced); confirming discards and reports it; base-pot table not nagged; the wizard's Cancel leaves the pot intact and unlogged while Start Next Hand still pays correctly and conserves the chip count. No console errors.

Checked and left alone

I also probed dedicated-dealer mode, counterclockwise play (blinds, first to act, button orbit fairness, repost-on-button-move) and save() scaling. All correct — save is bounded at ~1.2ms by the 200-hand history cap, so the persistence cost I flagged on #48 isn't worth chasing. The fold-to-one-player settle is already a single "Award pot to Dee" tap, so there was nothing to win there either.

Two ways to lose a hand's money by accident, both found by walking the settle flow and checking the chip count afterwards. Stacked on #48. ## 1. Next Hand destroyed an unresolved pot silently Starting the next hand clears every seat's contribution, so money still in the middle simply vanished. **Measured** at a four-handed table with $8 in the pot: the table went from **800 chips to 792**, and the toast said *"Next hand — button on seat 3. Blinds posted."* — not a word about the eight chips that had just left. It now asks, names the amount, and says what will happen to it: > **Throw away $8?** > There's still money in the middle from this hand. Starting the next one takes it off the table without paying anybody — use Resolve Pot if somebody won it. Confirming still works and the toast now reports what went. The undo was always there, but a dealer can't undo something they were never told about. ## 2. The wizard's "Close" abandoned a payout that looked finished After picking winners and confirming, the wizard shows **"Final Payouts — Ann $8"** above two buttons: *Start Next Hand* and *Close*. Close pays nobody. Under that heading, with a name and an amount beside it, a dealer taps Close believing the pot has been pushed — and walks away with the chips still in the middle and the hand unlogged. The button now reads **"Cancel — don't pay yet"**, with a line underneath spelling out that nothing has been paid. ## The warning had to measure the right thing My first version counted the **pot badge**, which was wrong in a way the tests caught before it shipped. The table-wide base pot is a *standing ante* — the mode for a dealer who isn't tracking stacks at all — and it re-applies to the next hand rather than being lost with this one. Quoting it would have put a confirmation in front of exactly those dealers **before every single hand**, for money that wasn't going anywhere. `HoldemState.unresolvedContributions()` measures precisely the fields `startNextHand` clears: banked contributions, chip counts, and whatever is still in front of players on this street. Verified both ways in the browser — a base-pot table showing a **$100 pot is not asked at all**; a stack-tracking table with **$8 live is**. ## Validation 6 new tests (**115 total, all passing**): the quoted number equals what actually leaves the table, mid-street chips are included, a settled hand leaves nothing to warn about, five settled hands conserve every chip, an empty table has no phantom pot, and a standing ante is never warned about. Playwright end to end: warning fires and cancels cleanly (800 chips kept, hand not advanced); confirming discards and reports it; base-pot table not nagged; the wizard's Cancel leaves the pot intact and unlogged while Start Next Hand still pays correctly and conserves the chip count. No console errors. ## Checked and left alone I also probed dedicated-dealer mode, counterclockwise play (blinds, first to act, button orbit fairness, repost-on-button-move) and `save()` scaling. All correct — save is bounded at ~1.2ms by the 200-hand history cap, so the persistence cost I flagged on #48 isn't worth chasing. The fold-to-one-player settle is already a single **"Award pot to Dee"** tap, so there was nothing to win there either.
jheaps changed target branch from feature/casino-holdem-render-perf to master 2026-09-01 09:30:15 -06:00
jheaps added 1 commit 2026-09-01 09:30:15 -06:00
Two ways to lose a hand's money by accident, both found by walking the settle
flow and checking the chip count afterwards.

Next Hand destroyed an unresolved pot silently

Starting the next hand clears every seat's contribution, so money still in the
middle simply vanished. Measured at a four-handed table with $8 in the pot: the
table went from 800 chips to 792, and the toast said "Next hand — button on seat
3. Blinds posted." — not a word about the eight chips that had just left.

It now asks, names the amount, and says what will happen to it. Confirming still
works and the toast says what went. The undo was always there, but a dealer
can't undo something they were never told about.

The wizard's "Close" abandoned a payout that looked finished

After picking winners and confirming, the wizard shows "Final Payouts — Ann $8"
above two buttons: "Start Next Hand" and "Close". Close pays nobody. Under that
heading, with a name and an amount beside it, a dealer taps Close believing the
pot has been pushed — and walks away with the chips still in the middle and the
hand unlogged. The button now says "Cancel — don't pay yet", with a line
underneath spelling out that nothing has been paid.

The warning measures the right thing

The first version counted the pot badge, which was wrong in a way the tests
caught before it shipped: the table-wide base pot is a standing ante for dealers
who don't track stacks, and it re-applies to the next hand rather than being
lost. Quoting it would have put a confirmation in front of those dealers before
every single hand — a nag, on the simplest way to run a table, for money that
wasn't going anywhere.

HoldemState.unresolvedContributions() measures exactly the fields startNextHand
clears: banked contributions, chip counts, and whatever is still in front of
players on this street. Verified both ways in the browser — a base-pot table
showing a $100 pot is not asked at all, a stack-tracking table with $8 live is.

6 tests (115 total): the quoted number equals what actually leaves the table,
mid-street chips are included, a settled hand leaves nothing to warn about, five
settled hands conserve every chip, an empty table has no phantom pot, and a
standing ante is never warned about.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015bnp7xKUPFFSpwkYNFaPgb
jheaps closed this pull request 2026-09-01 09:32:15 -06:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jheaps/JoshHeaps.Net#49