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.
This commit is contained in:
reidliu41
2026-05-28 18:49:44 +08:00
committed by Hunter Bown
parent 4bacda64fc
commit d58f10102a
+5
View File
@@ -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/ 是标准路径吗?"
));