[GH-ISSUE #4613] Native mod commands run but aren't in the chat tree: shown as unknown, no Tab completion (regression of #463 for native mods) #1396

Closed
opened 2026-11-02 15:46:38 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @ImmortalWhisper on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/4613

Originally assigned to: @sirrayi on GitHub.

What happens

A native mod's command runs, but the chat box doesn't know it exists: while typing, /flyspeed is drawn as an unknown command (red), Tab never completes it, and /help never lists it.

This is the same symptom as #456, which #463 fixed — but that fix went through the WebAssembly mod path, and native mods replaced it without getting an equivalent. So for native mods this is a regression of #463.

Repro

  1. Build a native mod whose native_command hook handles /flyspeed and sets *ran = true (any native mod with a command does the same).
  2. Type /flyspeed 2 — it works, the mod answers in chat.
  3. Type /fly and press Tab — nothing happens, and the line is coloured as invalid.

Mod used to reproduce: https://github.com/ImmortalWhisper/Fly-Speed (native, hooks 1, five hook points). The coords HUD native example shows it too.

Why

Game::chat_tree (crates/horizon-client/src/game/chat.rs) has exactly two sources:

pub(super) fn chat_tree(remote: &Option<Remote>) -> &Dispatcher {
    match remote.as_ref().and_then(|r| r.commands.as_ref()) {
        Some(tree) => tree,
        None => vanilla::game_dispatcher(),
    }
}

Dispatcher::with_mod_commands (crates/horizon-command/src/lib.rs:756) still exists and does exactly what is needed — its doc comment says "This tree plus the commands mods own (docs/mods.md), so the chat colours and completes them like the others" — but in current main its only callers are tests (horizon-client-render/src/chat_tests.rs:216, horizon-command/src/tests.rs:673). In 45ecf7b the WASM path reached it through ModsState::remote_dispatcher(); that branch is gone now that WebAssembly code mods were removed.

Nothing is missing on the execution side: client_mod_command → native_command already receives the typed text and honours ran, which is why the command works.

Suggested fix

A hook that says which command names a native mod owns, and one call site that merges them:

// game/native_hooks.rs
pub(super) fn native_commands(&mut self, commands: &mut Vec<&'static str>) {
    let _ = commands;
}

Then where the client builds Commands { dispatcher: chat_tree(&self.remote) }, use a cached chat_tree(...).with_mod_commands(names) instead of the bare tree. The tree would need rebuilding when the remote tree changes (one connection), which with_mod_commands already supports since it returns an owned Dispatcher.

If a new hook point is too much, folding the names into native_mods' NativeMod struct would do, but a dedicated hook keeps the command list out of the options row.

Not asked for: argument completion. Mods can't declare argument types (as noted in #463), so completing the command name itself is the whole ask.

Environment

  • Horizon Nightly 1da354b, native build native-1da354b-2536038d1db8, Windows x64.
  • Behaviour confirmed by reading the generated build under native/stage and the shipped horizon-client.exe.
Originally created by @ImmortalWhisper on GitHub (Oct 30, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/4613 Originally assigned to: @sirrayi on GitHub. **What happens** A native mod's command runs, but the chat box doesn't know it exists: while typing, `/flyspeed` is drawn as an unknown command (red), Tab never completes it, and `/help` never lists it. This is the same symptom as #456, which #463 fixed — but that fix went through the WebAssembly mod path, and native mods replaced it without getting an equivalent. So for native mods this is a regression of #463. **Repro** 1. Build a native mod whose `native_command` hook handles `/flyspeed` and sets `*ran = true` (any native mod with a command does the same). 2. Type `/flyspeed 2` — it works, the mod answers in chat. 3. Type `/fly` and press Tab — nothing happens, and the line is coloured as invalid. Mod used to reproduce: https://github.com/ImmortalWhisper/Fly-Speed (native, `hooks` 1, five hook points). The coords HUD native example shows it too. **Why** `Game::chat_tree` (`crates/horizon-client/src/game/chat.rs`) has exactly two sources: ```rust pub(super) fn chat_tree(remote: &Option<Remote>) -> &Dispatcher { match remote.as_ref().and_then(|r| r.commands.as_ref()) { Some(tree) => tree, None => vanilla::game_dispatcher(), } } ``` `Dispatcher::with_mod_commands` (`crates/horizon-command/src/lib.rs:756`) still exists and does exactly what is needed — its doc comment says "This tree plus the commands mods own (`docs/mods.md`), so the chat colours and completes them like the others" — but in current `main` its only callers are tests (`horizon-client-render/src/chat_tests.rs:216`, `horizon-command/src/tests.rs:673`). In 45ecf7b the WASM path reached it through `ModsState::remote_dispatcher()`; that branch is gone now that WebAssembly code mods were removed. Nothing is missing on the execution side: `client_mod_command` → `native_command` already receives the typed text and honours `ran`, which is why the command works. **Suggested fix** A hook that says which command names a native mod owns, and one call site that merges them: ```rust // game/native_hooks.rs pub(super) fn native_commands(&mut self, commands: &mut Vec<&'static str>) { let _ = commands; } ``` Then where the client builds `Commands { dispatcher: chat_tree(&self.remote) }`, use a cached `chat_tree(...).with_mod_commands(names)` instead of the bare tree. The tree would need rebuilding when the remote tree changes (one connection), which `with_mod_commands` already supports since it returns an owned `Dispatcher`. If a new hook point is too much, folding the names into `native_mods`' `NativeMod` struct would do, but a dedicated hook keeps the command list out of the options row. **Not asked for:** argument completion. Mods can't declare argument types (as noted in #463), so completing the command name itself is the whole ask. **Environment** - Horizon Nightly `1da354b`, native build `native-1da354b-2536038d1db8`, Windows x64. - Behaviour confirmed by reading the generated build under `native/stage` and the shipped `horizon-client.exe`.
Author
Owner

@sirrayi commented on GitHub (Oct 30, 2026):

/claim

<!-- gh-comment-id:6535208905 --> @sirrayi commented on GitHub (Oct 30, 2026): /claim
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#1396
No description provided.