[PR #2891] [MERGED] Books: page click events work, run_command ones included #4674

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2891
Author: @socksprox
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @rdbtCVS

Base: main ← Head: t3/clickable-book-links


📝 Commits (3)

  • e36cd17 Books: page click events work, run_command ones included
  • ae82c1b Merge remote-tracking branch 'origin/main' into cg24/f2891
  • 46c84a8 Merge main into #2891: main has run_command click events since

📊 Changes

2 files changed (+18 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/game/books.rs (+17 -3)
📝 crates/horizon-client/src/game/chat.rs (+1 -1)

📄 Description

🤖 Opened by socksprox's AI agent (Devin, SWE-2), not by socksprox himself.

What and why

Every link in a written book was dead. Two gaps:

  • view_pages only turned a Tag::Compound page into a Text; a Tag::List component (the list form ComponentSerialization also accepts — servers behind ViaVersion send it, and read_text already handles it for display) fell back to Text::literal, losing every click_event on the page.
  • run_command was never parsed into a ClickEvent, so a server's "click to run" text (e.g. a rules book's I Agree) had nothing to act on.

The book's click handler now follows Screen.defaultHandleClickEvent: open_url through the link-confirm flow, run_command sent unsigned like clickCommandAction (client mods first, then the server or the local dispatcher, no chat history), suggest_command into the chat box, and copy_to_clipboard. Chat's own click match gains the run_command arm via a shared click_command, and ClickEvent gains the variant plus its JSON form.

Overlap note: #2661 adds the same ClickEvent::RunCommand plumbing for chat clicks. Whichever lands second resolves a small conflict (the enum variant, its parse and serialize arms, and the near-identical click_command helper); the book fix itself (view_pages, book_follow_link) doesn't overlap.

Vanilla reference

  • BookViewScreen.handleClickEvent / Screen.defaultHandleClickEvent / clickCommandAction (ClientPacketListener.sendUnattendedCommand), ComponentSerialization.CODEC taking a component or a list of them, WrittenBookContent's Filterable<Component> pages.
  • No harness covers this: pr_ready reports no vanilla data here, so CI's parity job picks the affected harnesses.

Self-check

pr_ready (tools/pr_ready.py on MacBookPro, against origin/main at df08ffda3, 1 min 20 s)

Check Result
Scope ✅ 4 files, +38 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 365 passed (1 min 0 s)
rustfmt ✅ (6 s)
clippy ✅ (2 s)
tests: horizon-client, horizon-client-core ✅ 1369 passed (10 s)
doc tests ✅ 0 passed (2 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 (no vanilla data here): 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)

🤖 Generated with Devin


🔄 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/2891 **Author:** [@socksprox](https://github.com/socksprox) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `t3/clickable-book-links` --- ### 📝 Commits (3) - [`e36cd17`](https://github.com/horizon-rust/horizon/commit/e36cd17dd1a8040ee8c020aebbbde46e3268997e) Books: page click events work, run_command ones included - [`ae82c1b`](https://github.com/horizon-rust/horizon/commit/ae82c1b6939c11efa9a4fd7c889188267dd4e95d) Merge remote-tracking branch 'origin/main' into cg24/f2891 - [`46c84a8`](https://github.com/horizon-rust/horizon/commit/46c84a8b2413978de2a57301b7126b03b58b5720) Merge main into #2891: main has run_command click events since ### 📊 Changes **2 files changed** (+18 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/books.rs` (+17 -3) 📝 `crates/horizon-client/src/game/chat.rs` (+1 -1) </details> ### 📄 Description > 🤖 Opened by socksprox's AI agent (Devin, SWE-2), not by socksprox himself. ## What and why Every link in a written book was dead. Two gaps: - `view_pages` only turned a `Tag::Compound` page into a `Text`; a `Tag::List` component (the list form `ComponentSerialization` also accepts — servers behind ViaVersion send it, and `read_text` already handles it for display) fell back to `Text::literal`, losing every `click_event` on the page. - `run_command` was never parsed into a `ClickEvent`, so a server's "click to run" text (e.g. a rules book's **I Agree**) had nothing to act on. The book's click handler now follows `Screen.defaultHandleClickEvent`: `open_url` through the link-confirm flow, `run_command` sent unsigned like `clickCommandAction` (client mods first, then the server or the local dispatcher, no chat history), `suggest_command` into the chat box, and `copy_to_clipboard`. Chat's own click match gains the `run_command` arm via a shared `click_command`, and `ClickEvent` gains the variant plus its JSON form. Overlap note: #2661 adds the same `ClickEvent::RunCommand` plumbing for chat clicks. Whichever lands second resolves a small conflict (the enum variant, its parse and serialize arms, and the near-identical `click_command` helper); the book fix itself (`view_pages`, `book_follow_link`) doesn't overlap. ## Vanilla reference - `BookViewScreen.handleClickEvent` / `Screen.defaultHandleClickEvent` / `clickCommandAction` (`ClientPacketListener.sendUnattendedCommand`), `ComponentSerialization.CODEC` taking a component or a list of them, `WrittenBookContent`'s `Filterable<Component>` pages. - No harness covers this: pr_ready reports no vanilla data here, so CI's parity job picks the affected harnesses. ## Self-check **pr_ready** (`tools/pr_ready.py` on MacBookPro, against origin/main at df08ffda3, 1 min 20 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +38 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 365 passed (1 min 0 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (2 s) | | tests: horizon-client, horizon-client-core | ✅ 1369 passed (10 s) | | doc tests | ✅ 0 passed (2 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 (no vanilla data here): 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) | 🤖 Generated with [Devin](https://devin.ai) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:07:06 +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#4674
No description provided.