[PR #4214] [MERGED] A chat message the server deletes becomes the deleted marker #5492

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4214
Author: @d3grando
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3518-delete-chat


📝 Commits (3)

  • 9432147 A chat message the server deletes becomes the deleted marker
  • f646dc1 Merge hr/main into fix-3518-delete-chat
  • b513f1b Merge hr/main into fix-3518-delete-chat

📊 Changes

9 files changed (+355 additions, -42 deletions)

View changed files

📝 crates/horizon-client-render/src/chat.rs (+118 -9)
📝 crates/horizon-client-render/src/chat_tests.rs (+59 -0)
📝 crates/horizon-client/src/game/remote.rs (+112 -24)
📝 crates/horizon-protocol/src/packets/play.rs (+33 -0)
📝 crates/horizon-protocol/src/secure_chat.rs (+24 -0)
📝 tools/port_map/client-002.tsv (+2 -2)
📝 tools/port_map/client-003.tsv (+1 -1)
📝 tools/port_map/client2-010.tsv (+3 -3)
📝 tools/port_map/rest-011.tsv (+3 -3)

📄 Description

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

What and why

When a server deleted a player's chat message (Paper's Player#deleteMessage, which moderation and anti-spam plugins use), the line stayed on screen in Horizon. Vanilla replaces it with the grey "This chat message has been deleted by the server." line.

Root cause: ClientboundDeleteChatPacket (31) was only a constant in ids.rs, so Horizon never decoded it. The deletion names its message by signature, as a full signature or as an index into the connection's MessageSignatureCache. Horizon had neither: the PlayerChat handler threw p.signature away, the client kept no signature cache, and chat lines carried no signature.

The fix:

  • horizon-protocol: decodes DeleteChat (a MessageSignature.Packed) and adds SignatureCache::unpack (MessageSignature.Packed.unpack) next to the existing pack/push.
  • remote.rs: each connection keeps a MessageSignatureCache. On every PlayerChat the client unpacks the last-seen list against it, then pushes the list and the signature, as ClientPacketListener.handlePlayerChat does. The signature goes with the line, both into the Chat Delay queue and into the chat. The cache starts empty again after a reconfiguration, because vanilla builds a new ClientPacketListener there.
  • handleDeleteChat: if the message is still held back by Chat Delay, it is dropped from the queue and never shows (ChatListener.removeFromDelayedMessageQueue). Otherwise ChatComponent.deleteMessage handles it:
    • a message that has been on screen for 60 ticks becomes the deleted-marker line right away. The marker uses the grey italic chat.deleted_marker text, the system indicator, and the original message's added time.
    • a newer message goes into the deletion queue, and ChatComponent.tick (called at the end of the HUD tick) replaces it once its 60 ticks are up.
  • Bad packed id: if a deletion or a message's last-seen list names an empty cache slot, the client disconnects with multiplayer.disconnect.invalid_packet, as vanilla does.
  • Port ledger: the missing rows for these methods now point at the new ports.

Not covered: LastSeenMessagesTracker.ignorePending. The Horizon client doesn't sign or acknowledge chat, so it has no tracker to update.

Part of #3518: the tracker rows ClientPacketListener.handleDeleteChat, ChatComponent.deleteMessage, ChatComponent.deleteMessageOrDelay and ChatComponent.processMessageDeletionQueue.

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 with javap from the 26.3 client.jar:

  • ClientPacketListener.handleDeleteChat: unpack, or disconnect with INVALID_PACKET; removeFromDelayedMessageQueue, otherwise ChatComponent.deleteMessage.
  • ClientPacketListener.handlePlayerChat: SignedMessageBody.Packed.unpack(messageSignatureCache), then MessageSignatureCache.push(body, signature).
  • MessageSignature.Packed (stream codec: id + 1, 0 = full 256-byte signature) and Packed.unpack; LastSeenMessages.Packed.unpack; MessageSignatureCache.unpack.
  • ChatComponent.deleteMessage, deleteMessageOrDelay (addedTime + 60, createDeletedMarker, refreshTrimmedMessages), processMessageDeletionQueue and tick, called from Hud.tick. DELETED_CHAT_MESSAGE is chat.deleted_marker in GRAY and ITALIC, tagged GuiMessageTag.system() with GuiMessageSource.SYSTEM_SERVER.
  • ChatListener.removeFromDelayedMessageQueue.

Vanilla's own server never sends this packet (no class in the jar except the packet registration constructs it), so no parity harness can produce one. The checks are:

  • unit tests for the 60-tick rule, the marker and the cache resolution;
  • a wire-bytes decode test;
  • an end-to-end run against a vanilla 26.3 dedicated server behind a small proxy that acts as a moderation plugin: it sends a signed PlayerChat, then a DeleteChat, either with the full signature or with a cache slot.

Self-check

tools/pr_ready.py doesn't run on Windows (it needs SIGHUP), so I ran the steps by hand. tools/port_ledger.py build needs the decompiled sources, which this machine doesn't have.

cargo fmt --all -- --check                                              # ok
cargo clippy -p horizon-protocol --all-targets -- -D warnings           # ok
cargo clippy -p horizon-client-render --all-targets -- -D warnings      # ok
cargo clippy -p horizon-client --all-targets -- -D warnings             # ok
cargo test -p horizon-protocol --lib                                    # 112 passed
cargo test -p horizon-protocol --lib -- secure_chat:: delete_chat clientbound_round_trips   # 8 passed
cargo test -p horizon-client-render --lib chat::tests                   # 13 passed
cargo test -p horizon-client --bin horizon-client chat                  # 4 passed
cargo test -p horizon-client --lib lan::hub                             # 1 passed, 1 ignored

New tests:

  • chat::tests::a_deleted_message_shows_60_ticks_then_becomes_the_marker
  • secure_chat::tests::packed_signatures_resolve_against_the_cache
  • packets::play::tests::delete_chat_decodes_a_packed_signature
  • two DeleteChat entries in clientbound_round_trips

Before the fix (main's chat.rs, and without SignatureCache::unpack and the DeleteChat packet), the new tests fail to build:

error[E0599]: no method named `unpack` found for struct `secure_chat::SignatureCache`
error[E0599]: no variant ... named `DeleteChat` found for enum `packets::play::Clientbound`
error[E0599]: no method named `delete_message_with` / `process_deletions` / `add_signed_message` found for struct `chat::Chat`
error[E0609]: no field `deletions` on type `chat::Chat`

After the fix: 8 passed (protocol), 13 passed (chat).

In game (Windows):

  • Vanilla 26.3 dedicated server through the injecting proxy: the deleted line became the marker. A deletion sent the same instant as its message kept the line for about 3 s, then swapped it for the marker. A deletion by cache slot 0 worked. With Chat Delay at 3 s, a queued message that was deleted never showed. An unknown slot (100) took the player to "The server sent an invalid packet", as in vanilla.
  • Single player (server thread) and a LAN guest: chat in both directions still arrives, with no disconnects from the new last-seen unpacking.

Screenshots

  • Before: after a moderator deletes Steve's second line, it is still in the chat, 4 s after the deletion.
  • After, same scene and timing: the line is replaced by the grey italic "This chat message has been deleted by the server." with the system bar at its left. The lines around it are unchanged.
  • After, deleted at once: a line deleted the instant it arrived stays readable for 60 ticks (first shot), then turns into the marker (second shot).

🤖 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/4214 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3518-delete-chat` --- ### 📝 Commits (3) - [`9432147`](https://github.com/horizon-rust/horizon/commit/9432147489a889bd93306246a81542860e23e30b) A chat message the server deletes becomes the deleted marker - [`f646dc1`](https://github.com/horizon-rust/horizon/commit/f646dc1e0ddac0fce0e348bab2091d878008947b) Merge hr/main into fix-3518-delete-chat - [`b513f1b`](https://github.com/horizon-rust/horizon/commit/b513f1b1525a89b884f669b21ee9757f9b06557d) Merge hr/main into fix-3518-delete-chat ### 📊 Changes **9 files changed** (+355 additions, -42 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/chat.rs` (+118 -9) 📝 `crates/horizon-client-render/src/chat_tests.rs` (+59 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+112 -24) 📝 `crates/horizon-protocol/src/packets/play.rs` (+33 -0) 📝 `crates/horizon-protocol/src/secure_chat.rs` (+24 -0) 📝 `tools/port_map/client-002.tsv` (+2 -2) 📝 `tools/port_map/client-003.tsv` (+1 -1) 📝 `tools/port_map/client2-010.tsv` (+3 -3) 📝 `tools/port_map/rest-011.tsv` (+3 -3) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why When a server deleted a player's chat message (Paper's `Player#deleteMessage`, which moderation and anti-spam plugins use), the line stayed on screen in Horizon. Vanilla replaces it with the grey "This chat message has been deleted by the server." line. Root cause: `ClientboundDeleteChatPacket` (31) was only a constant in `ids.rs`, so Horizon never decoded it. The deletion names its message by signature, as a full signature or as an index into the connection's `MessageSignatureCache`. Horizon had neither: the `PlayerChat` handler threw `p.signature` away, the client kept no signature cache, and chat lines carried no signature. The fix: - **horizon-protocol:** decodes `DeleteChat` (a `MessageSignature.Packed`) and adds `SignatureCache::unpack` (`MessageSignature.Packed.unpack`) next to the existing `pack`/`push`. - **remote.rs:** each connection keeps a `MessageSignatureCache`. On every `PlayerChat` the client unpacks the last-seen list against it, then pushes the list and the signature, as `ClientPacketListener.handlePlayerChat` does. The signature goes with the line, both into the Chat Delay queue and into the chat. The cache starts empty again after a reconfiguration, because vanilla builds a new `ClientPacketListener` there. - **`handleDeleteChat`:** if the message is still held back by Chat Delay, it is dropped from the queue and never shows (`ChatListener.removeFromDelayedMessageQueue`). Otherwise `ChatComponent.deleteMessage` handles it: - a message that has been on screen for 60 ticks becomes the deleted-marker line right away. The marker uses the grey italic `chat.deleted_marker` text, the system indicator, and the original message's added time. - a newer message goes into the deletion queue, and `ChatComponent.tick` (called at the end of the HUD tick) replaces it once its 60 ticks are up. - **Bad packed id:** if a deletion or a message's last-seen list names an empty cache slot, the client disconnects with `multiplayer.disconnect.invalid_packet`, as vanilla does. - **Port ledger:** the `missing` rows for these methods now point at the new ports. Not covered: `LastSeenMessagesTracker.ignorePending`. The Horizon client doesn't sign or acknowledge chat, so it has no tracker to update. Part of #3518: the tracker rows `ClientPacketListener.handleDeleteChat`, `ChatComponent.deleteMessage`, `ChatComponent.deleteMessageOrDelay` and `ChatComponent.processMessageDeletionQueue`. ## 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 with javap from the 26.3 client.jar: - `ClientPacketListener.handleDeleteChat`: unpack, or disconnect with `INVALID_PACKET`; `removeFromDelayedMessageQueue`, otherwise `ChatComponent.deleteMessage`. - `ClientPacketListener.handlePlayerChat`: `SignedMessageBody.Packed.unpack(messageSignatureCache)`, then `MessageSignatureCache.push(body, signature)`. - `MessageSignature.Packed` (stream codec: id + 1, 0 = full 256-byte signature) and `Packed.unpack`; `LastSeenMessages.Packed.unpack`; `MessageSignatureCache.unpack`. - `ChatComponent.deleteMessage`, `deleteMessageOrDelay` (`addedTime + 60`, `createDeletedMarker`, `refreshTrimmedMessages`), `processMessageDeletionQueue` and `tick`, called from `Hud.tick`. `DELETED_CHAT_MESSAGE` is `chat.deleted_marker` in GRAY and ITALIC, tagged `GuiMessageTag.system()` with `GuiMessageSource.SYSTEM_SERVER`. - `ChatListener.removeFromDelayedMessageQueue`. Vanilla's own server never sends this packet (no class in the jar except the packet registration constructs it), so no parity harness can produce one. The checks are: - unit tests for the 60-tick rule, the marker and the cache resolution; - a wire-bytes decode test; - an end-to-end run against a vanilla 26.3 dedicated server behind a small proxy that acts as a moderation plugin: it sends a signed `PlayerChat`, then a `DeleteChat`, either with the full signature or with a cache slot. ## Self-check `tools/pr_ready.py` doesn't run on Windows (it needs SIGHUP), so I ran the steps by hand. `tools/port_ledger.py build` needs the decompiled sources, which this machine doesn't have. ``` cargo fmt --all -- --check # ok cargo clippy -p horizon-protocol --all-targets -- -D warnings # ok cargo clippy -p horizon-client-render --all-targets -- -D warnings # ok cargo clippy -p horizon-client --all-targets -- -D warnings # ok cargo test -p horizon-protocol --lib # 112 passed cargo test -p horizon-protocol --lib -- secure_chat:: delete_chat clientbound_round_trips # 8 passed cargo test -p horizon-client-render --lib chat::tests # 13 passed cargo test -p horizon-client --bin horizon-client chat # 4 passed cargo test -p horizon-client --lib lan::hub # 1 passed, 1 ignored ``` New tests: - `chat::tests::a_deleted_message_shows_60_ticks_then_becomes_the_marker` - `secure_chat::tests::packed_signatures_resolve_against_the_cache` - `packets::play::tests::delete_chat_decodes_a_packed_signature` - two `DeleteChat` entries in `clientbound_round_trips` Before the fix (main's `chat.rs`, and without `SignatureCache::unpack` and the `DeleteChat` packet), the new tests fail to build: ``` error[E0599]: no method named `unpack` found for struct `secure_chat::SignatureCache` error[E0599]: no variant ... named `DeleteChat` found for enum `packets::play::Clientbound` error[E0599]: no method named `delete_message_with` / `process_deletions` / `add_signed_message` found for struct `chat::Chat` error[E0609]: no field `deletions` on type `chat::Chat` ``` After the fix: 8 passed (protocol), 13 passed (chat). In game (Windows): - **Vanilla 26.3 dedicated server through the injecting proxy:** the deleted line became the marker. A deletion sent the same instant as its message kept the line for about 3 s, then swapped it for the marker. A deletion by cache slot 0 worked. With Chat Delay at 3 s, a queued message that was deleted never showed. An unknown slot (100) took the player to "The server sent an invalid packet", as in vanilla. - **Single player (server thread) and a LAN guest:** chat in both directions still arrives, with no disconnects from the new last-seen unpacking. ## Screenshots - **Before:** after a moderator deletes Steve's second line, it is still in the chat, 4 s after the deletion. - **After, same scene and timing:** the line is replaced by the grey italic "This chat message has been deleted by the server." with the system bar at its left. The lines around it are unchanged. - **After, deleted at once:** a line deleted the instant it arrived stays readable for 60 ticks (first shot), then turns into the marker (second shot). 🤖 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:12:57 +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#5492
No description provided.