[PR #3238] [MERGED] Chat and book links: a show_dialog click event opens its dialog #4862

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3238
Author: @masa-masa-0314
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @ludovic111

Base: main ← Head: fix/show-dialog-click


📝 Commits (1)

  • 4d47706 Chat and books: open a show_dialog click event's dialog

📊 Changes

5 files changed (+20 additions, -1 deletions)

View changed files

📝 crates/horizon-client-core/src/component.rs (+5 -0)
📝 crates/horizon-client-core/src/text.rs (+8 -0)
📝 crates/horizon-client/src/game/books.rs (+3 -0)
📝 crates/horizon-client/src/game/chat.rs (+3 -0)
📝 crates/horizon-client/src/game/dialogs.rs (+1 -1)

📄 Description

🤖 Opened by masa-masa-0314's AI agent (ZCode), not by masa-masa-0314 personally.

What and why

Fixes #3204. A server may hang a show_dialog click event on a chat line or a book page — ClickEvent$Action.SHOW_DIALOG allows it from a server, and it is how a server offers a dialog without the show_dialog packet. Vanilla opens the dialog when the player clicks the text (Screen.defaultHandleGameClickEvent). Horizon dropped the click event while parsing the component — there was no arm for it in component.rs and no ClickEvent variant to carry it — so clicking the text did nothing.

The dialog now survives as ClickEvent::ShowDialog, written as a Tag because that is what a component carries: a minecraft:dialog registry id, or the inline dialog. It parses from click_event (json_to_tag), round-trips back out through Text::component() for mods and the agent, and both click handlers — chat_click and the book screen's — open it with show_dialog_ref, the same path a server's show_dialog packet takes.

Vanilla reference

  • net.minecraft.network.chat.ClickEvent$Action — SHOW_DIALOG is constructed with allowFromServer = true (the enum's static initializer passes iconst_1; OPEN_FILE is the one that passes iconst_0).
  • net.minecraft.network.chat.Style$Serializer — the field is click_event, and the action's own codec is ClickEvent$ShowDialog.CODEC with a dialog field (Holder<Dialog>: registry id or inline).
  • net.minecraft.client.gui.screens.Screen.defaultHandleGameClickEvent handles ClickEvent.ShowDialog → ClientPacketListener.showDialog(holder, screen), which builds the dialog screen with screen as its previous screen. ChatScreen.handleComponentClicked and BookViewScreen.handleClickEvent both fall through to it.

Self-check

pr_ready (tools/pr_ready.py --base upstream/main on DESKTOP-3050AHP, against upstream/main at fe84cc07a, 6 min 8 s)

Check Result
Scope ✅ 5 files, +20 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 401 run, FAILED (failures=2, errors=7, skipped=1) (1 min 40 s)
rustfmt ✅ (13 s)
clippy ✅ (50 s)
tests: horizon-client, horizon-client-core ❌ 1092 passed, 2 failed (2 min 40 s)
doc tests ✅ 0 passed (41 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

The two horizon-client failures are this Windows machine's pre-existing ones (save::tests::session_lock_is_exclusive and crash::tests::stacks_start_at_the_panicking_frame), which fail the same way on clean upstream/main here. The Python failures (test_parity_reach, test_port_harness, test_port_publish) are also the same on clean upstream/main on this machine; they need the maintainer's horizon-parity tree.

Verified end to end on this machine with the fast build and the control socket, in a creative single-player world:

/tellraw @a {"text":"OPEN","click_event":{"action":"show_dialog","dialog":{"type":"minecraft:notice","title":{"text":"From chat"},"body":[{"type":"minecraft:plain_message","contents":{"text":"Clicked through chat."}}]}}}

Clicking the line in the open chat screen opens the dialog (below); Escape closes it back to the chat screen, as the dialog's previous screen. A run_command link on a neighbouring line still runs its command.

the dialog a chat link opens
If the image does not load, open it on GitHub.

The book arm is the same three-line dispatch (BookViewScreen.handleClickEvent falls through to the same handler). It is not exercised here: a written book page given as a JSON component renders as its literal text in Horizon today, so a styled page with a click event cannot be produced from the command line — a separate gap from this one.

Screenshots

Above: the dialog opened by clicking a chat link, over the chat screen.

🤖 Generated with ZCode


🔄 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/3238 **Author:** [@masa-masa-0314](https://github.com/masa-masa-0314) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/show-dialog-click` --- ### 📝 Commits (1) - [`4d47706`](https://github.com/horizon-rust/horizon/commit/4d477067c3204e1152b1b46c319b6dead85ebf15) Chat and books: open a show_dialog click event's dialog ### 📊 Changes **5 files changed** (+20 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-core/src/component.rs` (+5 -0) 📝 `crates/horizon-client-core/src/text.rs` (+8 -0) 📝 `crates/horizon-client/src/game/books.rs` (+3 -0) 📝 `crates/horizon-client/src/game/chat.rs` (+3 -0) 📝 `crates/horizon-client/src/game/dialogs.rs` (+1 -1) </details> ### 📄 Description > 🤖 Opened by masa-masa-0314's AI agent (ZCode), not by masa-masa-0314 personally. ## What and why Fixes #3204. A server may hang a `show_dialog` click event on a chat line or a book page — `ClickEvent$Action.SHOW_DIALOG` allows it from a server, and it is how a server offers a dialog without the `show_dialog` packet. Vanilla opens the dialog when the player clicks the text (`Screen.defaultHandleGameClickEvent`). Horizon dropped the click event while parsing the component — there was no arm for it in `component.rs` and no `ClickEvent` variant to carry it — so clicking the text did nothing. The dialog now survives as `ClickEvent::ShowDialog`, written as a `Tag` because that is what a component carries: a `minecraft:dialog` registry id, or the inline dialog. It parses from `click_event` (`json_to_tag`), round-trips back out through `Text::component()` for mods and the agent, and both click handlers — `chat_click` and the book screen's — open it with `show_dialog_ref`, the same path a server's `show_dialog` packet takes. ## Vanilla reference - `net.minecraft.network.chat.ClickEvent$Action` — `SHOW_DIALOG` is constructed with `allowFromServer = true` (the enum's static initializer passes `iconst_1`; `OPEN_FILE` is the one that passes `iconst_0`). - `net.minecraft.network.chat.Style$Serializer` — the field is `click_event`, and the action's own codec is `ClickEvent$ShowDialog.CODEC` with a `dialog` field (`Holder<Dialog>`: registry id or inline). - `net.minecraft.client.gui.screens.Screen.defaultHandleGameClickEvent` handles `ClickEvent.ShowDialog` → `ClientPacketListener.showDialog(holder, screen)`, which builds the dialog screen with `screen` as its *previous* screen. `ChatScreen.handleComponentClicked` and `BookViewScreen.handleClickEvent` both fall through to it. ## Self-check **pr_ready** (`tools/pr_ready.py --base upstream/main` on DESKTOP-3050AHP, against upstream/main at fe84cc07a, 6 min 8 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +20 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 401 run, FAILED (failures=2, errors=7, skipped=1) (1 min 40 s) | | rustfmt | ✅ (13 s) | | clippy | ✅ (50 s) | | tests: horizon-client, horizon-client-core | ❌ 1092 passed, 2 failed (2 min 40 s) | | doc tests | ✅ 0 passed (41 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 | The two `horizon-client` failures are this Windows machine's pre-existing ones (`save::tests::session_lock_is_exclusive` and `crash::tests::stacks_start_at_the_panicking_frame`), which fail the same way on clean `upstream/main` here. The Python failures (`test_parity_reach`, `test_port_harness`, `test_port_publish`) are also the same on clean `upstream/main` on this machine; they need the maintainer's `horizon-parity` tree. Verified end to end on this machine with the fast build and the control socket, in a creative single-player world: ``` /tellraw @a {"text":"OPEN","click_event":{"action":"show_dialog","dialog":{"type":"minecraft:notice","title":{"text":"From chat"},"body":[{"type":"minecraft:plain_message","contents":{"text":"Clicked through chat."}}]}}} ``` Clicking the line in the open chat screen opens the dialog (below); Escape closes it back to the chat screen, as the dialog's previous screen. A `run_command` link on a neighbouring line still runs its command. ![the dialog a chat link opens](https://github.com/masa-masa-0314/horizon/blob/pr-screenshots/chat-show-dialog.png?raw=true) <sub>If the image does not load, [open it on GitHub](https://github.com/masa-masa-0314/horizon/blob/pr-screenshots/chat-show-dialog.png).</sub> The book arm is the same three-line dispatch (`BookViewScreen.handleClickEvent` falls through to the same handler). It is not exercised here: a written book page given as a JSON component renders as its literal text in Horizon today, so a styled page with a click event cannot be produced from the command line — a separate gap from this one. ## Screenshots Above: the dialog opened by clicking a chat link, over the chat screen. 🤖 Generated with ZCode --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:08:28 +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#4862
No description provided.