From d58f10102ace58a7dd0246fc0f5830db4bf95198 Mon Sep 17 00:00:00 2001 From: reidliu41 Date: Thu, 28 May 2026 18:49:44 +0800 Subject: [PATCH] fix(composer): allow slash-space messages Treat inputs like `/ hello` as plain user messages instead of slash commands. This lets users start a message with a literal slash while preserving normal slash command behavior for `/help`, `/model ...`, and other commands. --- crates/tui/src/tui/app.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/tui/src/tui/app.rs b/crates/tui/src/tui/app.rs index 3c49df0e..47193855 100644 --- a/crates/tui/src/tui/app.rs +++ b/crates/tui/src/tui/app.rs @@ -86,6 +86,9 @@ pub(crate) fn looks_like_slash_command_input(input: &str) -> bool { let Some(rest) = input.trim_start().strip_prefix('/') else { return false; }; + if rest.chars().next().is_some_and(|ch| ch.is_whitespace()) { + return false; + } let Some(command) = rest.split_whitespace().next() else { return rest.is_empty(); }; @@ -5010,6 +5013,8 @@ mod tests { assert!(looks_like_slash_command_input("/")); assert!(looks_like_slash_command_input("/help")); assert!(looks_like_slash_command_input("/model deepseek-v4-pro")); + assert!(!looks_like_slash_command_input("/ hello")); + assert!(!looks_like_slash_command_input(" / hello")); assert!(!looks_like_slash_command_input( "/usr/lib/x86_64-linux-gnu/ 是标准路径吗?" ));