Fix sending wrong type for incomplete command messages#6236
Fix sending wrong type for incomplete command messages#6236VelikovPetar merged 2 commits intodevelopfrom
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
WalkthroughThe changes remove the command-based EPHEMERAL message type classification from the getMessageType function, eliminating regex pattern matching for command-format text and its associated test case. The EPHEMERAL condition is narrowed to only classify messages with pending attachment uploads. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/utils/internal/MessageUtils.kt (1)
24-33:⚠️ Potential issue | 🟡 MinorKDoc is now outdated after removing the command check.
The documentation still states "If the message contains a command or has attachments to upload, the type will be [MessageType.EPHEMERAL]", but the code no longer checks for commands. Update the KDoc to reflect the current behavior.
📝 Proposed fix
/** - * Updates the type of the [Message] based on its content. + * Determines the type of the [Message] based on its content. * - * If the message contains a command or has attachments to upload, the type will be [MessageType.EPHEMERAL]. + * If the message has attachments pending upload, the type will be [MessageType.EPHEMERAL]. * If the message is a system message, the type will be [MessageType.SYSTEM]. * Otherwise, the type will be [MessageType.REGULAR], as we cannot send messages which are not regular, ephemeral, or * system. * * `@param` message The message to update. */🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@stream-chat-android-client/src/main/java/io/getstream/chat/android/client/utils/internal/MessageUtils.kt` around lines 24 - 33, Update the KDoc in MessageUtils.kt to remove the outdated "contains a command" clause: state that messages with attachments pending upload are set to MessageType.EPHEMERAL, messages flagged as system are set to MessageType.SYSTEM, and all others are MessageType.REGULAR; reference the Message class and MessageType enum in the doc so it accurately reflects the current behavior of the function that updates the message type.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@stream-chat-android-client/src/main/java/io/getstream/chat/android/client/utils/internal/MessageUtils.kt`:
- Around line 24-33: Update the KDoc in MessageUtils.kt to remove the outdated
"contains a command" clause: state that messages with attachments pending upload
are set to MessageType.EPHEMERAL, messages flagged as system are set to
MessageType.SYSTEM, and all others are MessageType.REGULAR; reference the
Message class and MessageType enum in the doc so it accurately reflects the
current behavior of the function that updates the message type.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e9988a9e-8443-4365-b24a-db0ae28ad782
📒 Files selected for processing (2)
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/utils/internal/MessageUtils.ktstream-chat-android-state/src/test/java/io/getstream/chat/android/client/utils/internal/MessageUtilsTest.kt
💤 Files with no reviewable changes (1)
- stream-chat-android-state/src/test/java/io/getstream/chat/android/client/utils/internal/MessageUtilsTest.kt
|
|
🚀 Available in v6.35.0 |



Goal
Incomplete commands (messages matching the pattern
/command) were incorrectly being assigned theephemeralmessage type due to a regex pattern ingetMessageType(). This type of messages is rejected by the backend, returning the following error forSendMessage:Implementation
Removed the
COMMAND_PATTERNregex and its associated check fromgetMessageType(). The ephemeral type is now only assigned when there are attachments pending upload (note: this type is then set toregularafter the attachments are uploaded, so we don't send theephemeraltype)🎨 UI Changes
command-before.mp4
command-after.mp4
command-disabled-after.mp4
Testing
Send a message with pattern "/command" -> It should not fail. if commands are enabled, a system message should be delivered providing more info. If commands are disabled, it should be sent as a regular message.
Summary by CodeRabbit
Bug Fixes
Tests