From 48eff0fcbbed6e98265377b80311d3538c88a933 Mon Sep 17 00:00:00 2001 From: chexit Date: Sat, 21 Nov 2026 13:04:42 +0300 Subject: [PATCH] Control socket chat reaches client mods on the server-thread path (#147 3.1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The #147 step 3.1 bench must measure a real battle on the default server-thread single-player path, where the window is a client of its own integrated server. Two control-socket handlers bypassed the client mod there: - chat sent raw to the server (send_chat) in remote mode, skipping the chat-box's client-mod interception (handle_chat_input -> mod_command), so /airdef deploy|wave|stats never reached the client-side mod and no battle deployed (fingerprints null, tick fuel 395K vs 12.7M in-frame). - chat-log read the connection's raw buffer (remote_chat), which never holds a client mod's own lines (they land in ui.chat via add_mod_chat_line; the server's lines are mirrored into ui.chat by chat_line). Both now behave as the player's chat box: chat routes through handle_chat_input (client-mod command first, else the server), chat-log reads the player-visible ui.chat. status.chat (remote_chat) is unchanged; the in-frame path is unchanged. Harness only — no sim rule, frequency, limit or combat decision touched. Co-Authored-By: Kimi Code --- crates/horizon-client/src/game/control.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/horizon-client/src/game/control.rs b/crates/horizon-client/src/game/control.rs index e7a1567ec..d778fe856 100644 --- a/crates/horizon-client/src/game/control.rs +++ b/crates/horizon-client/src/game/control.rs @@ -592,11 +592,15 @@ impl Game<'_> { } "chat" => { let text = line.trim_start().strip_prefix("chat").unwrap_or("").trim(); - if self.remote.is_some() { - self.send_chat(text); - return ok(); + // As if typed in the chat box (`handle_chat_input`): a client + // mod's command is intercepted first, else the line goes to the + // server. The socket used to send raw to the server in remote + // mode, which never reached a client mod — the #147 step 3.1 + // bench needs `/airdef` to deploy a battle on the default + // server-thread path too. + if self.remote.is_none() { + self.require_world()?; } - self.require_world()?; self.handle_chat_input(text); Ok(Some( json!({ "ok": true, "chat": self.ui.chat.recent_lines(5) }), @@ -695,9 +699,12 @@ impl Game<'_> { } "chat-log" => { let n = words.get(1).map_or(Ok(10), |n| n.parse())?; - let lines = self - .remote_chat(n) - .unwrap_or_else(|| self.ui.chat.recent_lines(n)); + // The chat the player sees: the server's lines are mirrored here + // (`chat_line`) and a client mod's own lines land here too + // (`add_mod_chat_line`), which the connection's raw buffer + // (`remote_chat`) never holds — the #147 step 3.1 bench reads the + // mod's `/airdef stats` feedback on the server-thread path. + let lines = self.ui.chat.recent_lines(n); Ok(Some(json!({ "chat": lines }))) } "stats" => {