fix(composer): allow slash-space messages#2316
Conversation
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.
There was a problem hiding this comment.
Code Review
This pull request updates the slash command input detection logic in crates/tui/src/tui/app.rs to ensure that a slash followed immediately by whitespace is not classified as a slash command, and adds corresponding unit tests. The reviewer suggested a more idiomatic Rust approach using starts_with(char::is_whitespace) instead of manually checking the first character.
| if rest.chars().next().is_some_and(|ch| ch.is_whitespace()) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
| assert!(!looks_like_slash_command_input("/ hello")); | ||
| assert!(!looks_like_slash_command_input(" / hello")); |
There was a problem hiding this comment.
The new guard only checks the very first character after
/, so "/ hello" (tab) and "/ hello" (newline) are also deflected — that's probably intentional, but a tab case in the existing test block would make the contract explicit without adding overhead.
| assert!(!looks_like_slash_command_input("/ hello")); | |
| assert!(!looks_like_slash_command_input(" / hello")); | |
| assert!(!looks_like_slash_command_input("/ hello")); | |
| assert!(!looks_like_slash_command_input(" / hello")); | |
| assert!(!looks_like_slash_command_input("/\thello")); |
|
hi @Hmbown please help to take a look when you have time. thanks. |
|
will do - thanks as always 🙂 |
Summary
Fixes #2310.
CodeWhale currently treats any input that starts with
/as a slash command. That means a user cannot send a normal message such as/ hello; it is parsed as a command and fails with an unknown-command error.This PR updates the slash-command classifier so

/followed immediately by whitespace is treated as plain text. Normal commands such as/helpand/model deepseek-v4-procontinue to work as before.from: input / hi
to:

Testing
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-featurescargo test --workspace --all-featuresChecklist
Greptile Summary
This PR fixes a classifier bug where any input starting with
/(slash followed by whitespace) was incorrectly treated as a slash command instead of plain text. The fix is a single guard added tolooks_like_slash_command_inputinapp.rs.looks_like_slash_command_input: if the character immediately after the leading/is whitespace, the function returnsfalse, letting the input flow through as a normal message."/ hello"and" / hello", confirming the new behaviour without touching any callers.Confidence Score: 5/5
Safe to merge — the change is a minimal, well-tested guard that only affects the slash-space edge case and leaves all existing command paths intact.
The guard is inserted before any command-word parsing, so /help, /model …, and bare / all continue along the same code path as before. The only callers of looks_like_slash_command_input branch on its boolean result, so returning false for '/ hello' correctly routes it to the plain-message path in every call site.
No files require special attention.
Important Files Changed
looks_like_slash_command_inputso/ hello-style inputs are treated as plain text, and extends the unit-test block with two matching assertions.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[User presses Enter] --> B[submit_input] B --> C{looks_like_slash_command_input?} C -->|strip leading whitespace then strip '/' prefix → prefix absent| D[return false] C -->|next char is whitespace e.g. '/ hello'| E[return false — NEW] C -->|rest is empty e.g. bare '/'| F[return true] C -->|command word contains '/' e.g. absolute path| G[return false] C -->|command word is clean e.g. '/help'| H[return true] D --> I[Send as plain message, add to history] E --> I G --> I F --> J[execute_command_input] H --> JComments Outside Diff (1)
crates/tui/src/tui/app.rs, line 5012 (link)slash_command_classifier_treats_absolute_path_as_messageno longer describes the new cases ("/ hello"," / hello"), which are about slash-space messages rather than filesystem paths. A broader name would keep the intent clear for future readers.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Reviews (1): Last reviewed commit: "fix(composer): allow slash-space message..." | Re-trigger Greptile