[PR #4893] [MERGED] Chat: native mods' commands join the tree the chat colours and completes #5923

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4893
Author: @sirrayi
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: fix/mod-commands-chat


📝 Commits (3)

  • a01203c Chat: native mods' commands join the tree the chat colours and completes
  • 8c7779e Merge main
  • 73958d8 Merge hr/main; renumber native_commands to API 35; leave a name the game has alone

📊 Changes

5 files changed (+111 additions, -9 deletions)

View changed files

📝 crates/horizon-client/src/game/chat.rs (+77 -4)
📝 crates/horizon-client/src/game/native_hooks.rs (+12 -1)
📝 crates/horizon-client/src/game/remote.rs (+13 -4)
📝 docs/native-mods.md (+4 -0)
📝 native-hooks.json (+5 -0)

📄 Description

🤖 Opened by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi themselves.

What and why

Fixes #4613. A native mod's command runs — native_command gets the typed text and its ran out-param
works — but the chat box does not know it exists: /flyspeed is drawn as an unknown command while you
type it, Tab never completes it, and /help never lists it.

This is the gap #456 and #463 closed for WebAssembly mods. Dispatcher::with_mod_commands
(crates/horizon-command/src/lib.rs:756) still does exactly what is needed and says so in its own doc
comment, but since WebAssembly code mods were removed its only callers are two tests
(horizon-client-render/src/chat_tests.rs:216, horizon-command/src/tests.rs:673), so native mods never
got it.

The change is the hook point plus one call site:

  • Game::native_commands(&mut self, commands: &mut Vec<&'static str>) in game/native_hooks.rs: a native
    mod pushes the command names it answers, without their slash. API 22 → 23 (native-hooks.json,
    docs/native-mods.md).
  • chat::chat_tree_for builds the tree the chat parses, colours and completes with as base.with_mod_commands(names),
    where base is the server's tree or the game's own. It is called where that base changes — once per
    connection, and again when ClientboundCommandsPacket arrives — not at each keystroke, and the mods are
    asked then rather than per key. Remote::commands: Option<Dispatcher> becomes
    Remote::chat_tree: Dispatcher, so the chat and the completion provider always see one built tree.

What does not change: with no mod claiming a name the tree is the game's own, node for node; a name the
game already has keeps that command; argument completion is out of scope (mods cannot declare argument
types, as noted in #463), so the command name itself is the whole ask.

Why this cannot change vanilla behaviour

Native mods are a Horizon feature, so there is nothing here to be 1:1 with — but the concern that matters
is that a player without native mods must see no difference at all, and that is checkable:
Dispatcher::with_mod_commands (crates/horizon-command/src/lib.rs:756) is let mut d = self.clone(); and
then only adds a node per name it is given, so an empty list returns the tree unchanged. The new test asserts
that directly (plain.nodes.len() == vanilla.nodes.len() and plain.find("flyspeed").is_none()), and the
chat's tree is built from the same base it was before.

The one place a mod can now reach something it could not before is its own command name appearing in the
chat's tree; that is the point of the fix and is inert without a mod.

Kind

  • feature: something new for players (listed under New in the release notes)

Vanilla reference

Horizon-only: vanilla has no mod hook points. The command tree it adds to is
Dispatcher/CommandDispatcher-shaped and already carries the mod id MOD_COMMAND that
Dispatcher::with_mod_commands assigns.

New test chat::tests::native_mod_commands_join_the_chat_tree: with no names the tree has the game's own
node count; with flyspeed the name is found, parses to MOD_COMMAND with the rest of the line as its
argument (what native_command receives), and is offered by client_suggestions for /fly; a name the
game already has keeps that command.

No harness: this is client UI plumbing, which the parity harnesses do not cover.

Self-check

cargo fmt --all -- --check                                    ✅
cargo test -p horizon-client --bins <new test>                 1 passed; 0 failed
cargo clippy -p horizon-client --bins --tests -- -D warnings   ✅

python3 tools/pr_ready.py was not finished here: this machine has no prepared vanilla data
(.local/), so its harness half only lists what CI must run, and its workspace-wide passes compete for the
build cache with other work on the machine. CI's verify runs the workspace fmt/clippy/tests.

Screenshots

A mod command turns from red to known while typing, and Tab completes it. I have no native mod or
prepared resources on this machine to capture it; the tree contents are asserted by the test instead.


🔄 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/4893 **Author:** [@sirrayi](https://github.com/sirrayi) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/mod-commands-chat` --- ### 📝 Commits (3) - [`a01203c`](https://github.com/horizon-rust/horizon/commit/a01203c3b27dcf3ed100443b058fbc5253a681dd) Chat: native mods' commands join the tree the chat colours and completes - [`8c7779e`](https://github.com/horizon-rust/horizon/commit/8c7779e17f279e759433fe4caea163f774d11a9c) Merge main - [`73958d8`](https://github.com/horizon-rust/horizon/commit/73958d83973812f825142c57e65687c27871cea0) Merge hr/main; renumber native_commands to API 35; leave a name the game has alone ### 📊 Changes **5 files changed** (+111 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/chat.rs` (+77 -4) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+12 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+13 -4) 📝 `docs/native-mods.md` (+4 -0) 📝 `native-hooks.json` (+5 -0) </details> ### 📄 Description > 🤖 Opened by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi themselves. ## What and why Fixes #4613. A native mod's command runs — `native_command` gets the typed text and its `ran` out-param works — but the chat box does not know it exists: `/flyspeed` is drawn as an unknown command while you type it, Tab never completes it, and `/help` never lists it. This is the gap #456 and #463 closed for WebAssembly mods. `Dispatcher::with_mod_commands` (`crates/horizon-command/src/lib.rs:756`) still does exactly what is needed and says so in its own doc comment, but since WebAssembly code mods were removed its only callers are two tests (`horizon-client-render/src/chat_tests.rs:216`, `horizon-command/src/tests.rs:673`), so native mods never got it. The change is the hook point plus one call site: - `Game::native_commands(&mut self, commands: &mut Vec<&'static str>)` in `game/native_hooks.rs`: a native mod pushes the command names it answers, without their slash. API 22 → 23 (`native-hooks.json`, `docs/native-mods.md`). - `chat::chat_tree_for` builds the tree the chat parses, colours and completes with as `base.with_mod_commands(names)`, where `base` is the server's tree or the game's own. It is called where that base changes — once per connection, and again when `ClientboundCommandsPacket` arrives — not at each keystroke, and the mods are asked then rather than per key. `Remote::commands: Option<Dispatcher>` becomes `Remote::chat_tree: Dispatcher`, so the chat and the completion provider always see one built tree. What does not change: with no mod claiming a name the tree is the game's own, node for node; a name the game already has keeps that command; argument completion is out of scope (mods cannot declare argument types, as noted in #463), so the command name itself is the whole ask. ## Why this cannot change vanilla behaviour Native mods are a Horizon feature, so there is nothing here to be 1:1 *with* — but the concern that matters is that a player without native mods must see no difference at all, and that is checkable: `Dispatcher::with_mod_commands` (`crates/horizon-command/src/lib.rs:756`) is `let mut d = self.clone();` and then only adds a node per name it is given, so an empty list returns the tree unchanged. The new test asserts that directly (`plain.nodes.len() == vanilla.nodes.len()` and `plain.find("flyspeed").is_none()`), and the chat's tree is built from the same base it was before. The one place a mod can now reach something it could not before is its own command name appearing in the chat's tree; that is the point of the fix and is inert without a mod. ## Kind - [x] feature: something new for players (listed under New in the release notes) ## Vanilla reference Horizon-only: vanilla has no mod hook points. The command tree it adds to is `Dispatcher`/`CommandDispatcher`-shaped and already carries the mod id `MOD_COMMAND` that `Dispatcher::with_mod_commands` assigns. New test `chat::tests::native_mod_commands_join_the_chat_tree`: with no names the tree has the game's own node count; with `flyspeed` the name is found, parses to `MOD_COMMAND` with the rest of the line as its argument (what `native_command` receives), and is offered by `client_suggestions` for `/fly`; a name the game already has keeps that command. No harness: this is client UI plumbing, which the parity harnesses do not cover. ## Self-check ``` cargo fmt --all -- --check ✅ cargo test -p horizon-client --bins <new test> 1 passed; 0 failed cargo clippy -p horizon-client --bins --tests -- -D warnings ✅ ``` `python3 tools/pr_ready.py` was not finished here: this machine has no prepared vanilla data (`.local/`), so its harness half only lists what CI must run, and its workspace-wide passes compete for the build cache with other work on the machine. CI's `verify` runs the workspace fmt/clippy/tests. ## Screenshots A mod command turns from red to known while typing, and Tab completes it. I have no native mod or prepared resources on this machine to capture it; the tree contents are asserted by the test instead. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:15:56 +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#5923
No description provided.