Skip to content

fix: unknown slash commands crash & incorrect handling#1157

Open
deepak0x wants to merge 2 commits intoRocketChat:developfrom
deepak0x:fix-slash-command-crash
Open

fix: unknown slash commands crash & incorrect handling#1157
deepak0x wants to merge 2 commits intoRocketChat:developfrom
deepak0x:fix-slash-command-crash

Conversation

@deepak0x
Copy link
Contributor

@deepak0x deepak0x commented Feb 16, 2026

This PR fixes a bug where the app crashed if a user typed an unknown slash command (for example, /hello) and pressed Enter.

Now, unknown slash commands are treated as command attempts instead of normal chat messages. If the command does not exist on the server, the user will see a "No such command" message.


Closes: #1144

Screenshots
Screenshot from 2026-02-17 01-40-40

Changes Made

1. packages/react/src/views/CommandList/CommandsList.js

  • Added a safety check in handleKeyPress.
  • Prevents the app from trying to access data when the command list is empty.
  • This fixes the crash.

2. packages/react/src/hooks/useShowCommands.js

  • Updated the logic so the command list is not shown when there are no matching commands.
  • Keeps the UI clean and avoids unexpected behavior.

3. packages/react/src/views/ChatInput/ChatInput.js

handleCommandExecution

  • Now tries to execute all slash commands using the API.
  • Even if the command is not in the local list, it is sent to the server.
  • If the server returns a 400 error (invalid command), a "No such command" toast is shown.

sendMessage

  • Prevents slash commands from being sent as normal chat messages.
  • Ensures they are handled only as commands.

@deepak0x
Copy link
Contributor Author

deepak0x commented Feb 16, 2026

hey @Spiral-Memory
Pls check this pr if you get time ;)
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug : Crash when typing unknown slash command (e.g., /hello)

1 participant