[PR #4424] [MERGED] Trading: Space and Enter press the focused offer again (hold Space to refill) #5616

Closed
opened 2026-11-03 05:13:49 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4424
Author: @apeirs
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix-merchant-space-reselect


📝 Commits (2)

  • 29b58bb Trading: Space and Enter press the focused offer again (hold Space to refill)
  • b526d83 Merge remote-tracking branch 'origin/main' into HEAD

📊 Changes

4 files changed (+102 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+7 -0)
📝 crates/horizon-client/src/game/control.rs (+5 -0)
📝 crates/horizon-client/src/game/trading.rs (+25 -0)
📝 tools/lan_e2e.py (+65 -0)

📄 Description

🤖 Opened by apeirs's AI agent (Claude Code, Claude Opus 5.5), not by apeirs personally.

What and why

Fixes #4423. In vanilla, after you click a trade, holding Space (or pressing Enter) presses that trade button again. Each press refills the payment slots, so you can shift-click the result over and over and trade a whole inventory quickly. Horizon did nothing on those keys.

  • game/trading.rs: merchant_key presses the focused offer button (MerchantState.focused, already tracked and drawn) on Enter, Space or numpad Enter. It rejects a button past the last offer (hidden, so inactive), plays the button click and calls try_move_items (SelectTrade on a client).
  • game.rs: the window's key events reach it before key binds translate them, and key repeats are included (Screen.keyPressed sees the physical key and InputConstants.REPEAT; mapped_key drops repeats other than Q's, so this can't sit behind it).
  • game/control.rs: horizon-ctl's key command takes the same path, so agents and harnesses behave like the keyboard.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Read from the 26.3 client bytecode:

  • AbstractButton.keyPressed: if active and KeyEvent.isSelection() (InputWithModifiers.isSelection: Enter, Space, numpad Enter), playDownSound then onPress.
  • MerchantScreen$TradeOfferButton.onPress → MerchantScreen.postButtonClick: shopItem = index + scrollOff, menu.setSelectionHint, menu.tryMoveItems, ServerboundSelectTradePacket.
  • ContainerEventHandler.mouseClicked: focus moves only to a child that takes the click, so clicks on slots keep it on the offer button.

Harness: tools/lan_e2e.py --check merchant-reselect (new). On the host and on a guest: click the offer, shift-click the result, give 20 more wheat, press space repeat, trade, give 20, press enter tap, trade. The server ends with 3 emeralds and 0 wheat. It passes on this branch and fails on main with host-space repeat: payment slot None. merchant-close still passes.

Self-check

pr_ready (tools/pr_ready.py --quick on arch, against origin/main at d2186eb9a, 6 min 46 s)

Check Result
Scope ✅ 4 files, +102 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 480 passed (35 s)
rustfmt ✅ (6 s)
clippy ✅ (1 min 52 s)
tests: horizon-client ✅ 988 passed (4 min 12 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Parity harnesses were not run locally (no full .local/ vanilla data on this machine); CI's parity job picks them. The LAN e2e above ran headless against the fast build.

The check saves host-merchant-reselect.png and guest-merchant-reselect.png: three emeralds from one offer click, the offer button still focused.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4424 **Author:** [@apeirs](https://github.com/apeirs) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix-merchant-space-reselect` --- ### 📝 Commits (2) - [`29b58bb`](https://github.com/horizon-rust/horizon/commit/29b58bb0fc439ca86c97d59cff79f095993fb6c7) Trading: Space and Enter press the focused offer again (hold Space to refill) - [`b526d83`](https://github.com/horizon-rust/horizon/commit/b526d836a02f099d1303987a4a8b8bd500f44e64) Merge remote-tracking branch 'origin/main' into HEAD ### 📊 Changes **4 files changed** (+102 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+7 -0) 📝 `crates/horizon-client/src/game/control.rs` (+5 -0) 📝 `crates/horizon-client/src/game/trading.rs` (+25 -0) 📝 `tools/lan_e2e.py` (+65 -0) </details> ### 📄 Description > 🤖 Opened by apeirs's AI agent (Claude Code, Claude Opus 5.5), not by apeirs personally. ## What and why Fixes #4423. In vanilla, after you click a trade, holding Space (or pressing Enter) presses that trade button again. Each press refills the payment slots, so you can shift-click the result over and over and trade a whole inventory quickly. Horizon did nothing on those keys. - `game/trading.rs`: `merchant_key` presses the focused offer button (`MerchantState.focused`, already tracked and drawn) on Enter, Space or numpad Enter. It rejects a button past the last offer (hidden, so inactive), plays the button click and calls `try_move_items` (`SelectTrade` on a client). - `game.rs`: the window's key events reach it before key binds translate them, and key repeats are included (`Screen.keyPressed` sees the physical key and `InputConstants.REPEAT`; `mapped_key` drops repeats other than Q's, so this can't sit behind it). - `game/control.rs`: horizon-ctl's `key` command takes the same path, so agents and harnesses behave like the keyboard. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Read from the 26.3 client bytecode: - `AbstractButton.keyPressed`: if active and `KeyEvent.isSelection()` (`InputWithModifiers.isSelection`: Enter, Space, numpad Enter), `playDownSound` then `onPress`. - `MerchantScreen$TradeOfferButton.onPress` → `MerchantScreen.postButtonClick`: `shopItem = index + scrollOff`, `menu.setSelectionHint`, `menu.tryMoveItems`, `ServerboundSelectTradePacket`. - `ContainerEventHandler.mouseClicked`: focus moves only to a child that takes the click, so clicks on slots keep it on the offer button. Harness: `tools/lan_e2e.py --check merchant-reselect` (new). On the host and on a guest: click the offer, shift-click the result, give 20 more wheat, press `space repeat`, trade, give 20, press `enter tap`, trade. The server ends with 3 emeralds and 0 wheat. It passes on this branch and fails on main with `host-space repeat: payment slot None`. `merchant-close` still passes. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on arch, against origin/main at d2186eb9a, 6 min 46 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +102 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 480 passed (35 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (1 min 52 s) | | tests: horizon-client | ✅ 988 passed (4 min 12 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Parity harnesses were not run locally (no full `.local/` vanilla data on this machine); CI's parity job picks them. The LAN e2e above ran headless against the fast build. The check saves `host-merchant-reselect.png` and `guest-merchant-reselect.png`: three emeralds from one offer click, the offer button still focused. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:13:49 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5616
No description provided.