fix: preserve multi-line text in slash command params#41328
fix: preserve multi-line text in slash command params#41328prathamesh04 wants to merge 1 commit into
Conversation
Add the `s` (dotall) flag to the slash command parse regex so that multi-line input is fully captured instead of being truncated at the first newline. Closes RocketChat#41324
|
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
WalkthroughThe client slash-command parser now uses dotAll matching so command parameters can include newline characters instead of stopping at the first line break. ChangesSlash-command parsing
Estimated code review effort: 1 (Trivial) | ~3 minutes Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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.
🧹 Nitpick comments (1)
apps/meteor/client/lib/chats/flows/processSlashCommand.ts (1)
13-13: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd a regression test for newline preservation.
Cover input such as
/command first line\nsecond lineand assert thatparamsremainsfirst line\nsecond line. This protects the behavior introduced here from future regex changes.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/meteor/client/lib/chats/flows/processSlashCommand.ts` at line 13, Add a regression test for the slash-command parsing flow around the message-matching logic, using input with a newline such as `/command first line\nsecond line`; assert that the extracted params preserve the leading space and newline exactly as ` first line\nsecond line`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/meteor/client/lib/chats/flows/processSlashCommand.ts`:
- Line 13: Add a regression test for the slash-command parsing flow around the
message-matching logic, using input with a newline such as `/command first
line\nsecond line`; assert that the extracted params preserve the leading space
and newline exactly as ` first line\nsecond line`.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 112dbeb1-cb0a-4baf-ba67-c3a6df98a5a0
📒 Files selected for processing (1)
apps/meteor/client/lib/chats/flows/processSlashCommand.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: CodeRabbit
- GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
apps/meteor/client/lib/chats/flows/processSlashCommand.ts
🧠 Learnings (5)
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.
Applied to files:
apps/meteor/client/lib/chats/flows/processSlashCommand.ts
📚 Learning: 2026-05-11T20:30:35.265Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 40480
File: apps/meteor/client/meteor/startup/accounts.ts:59-61
Timestamp: 2026-05-11T20:30:35.265Z
Learning: In Rocket.Chat’s Meteor client code, when calling `dispatchToastMessage` with `{ type: 'error' }`, pass the raw caught error object as `message` without manual normalization. `dispatchToastMessage` is designed to accept `message: unknown` for error toasts, so avoid converting errors to strings (e.g., `String(error)`) or extracting `error.message` before passing them.
Applied to files:
apps/meteor/client/lib/chats/flows/processSlashCommand.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.
Applied to files:
apps/meteor/client/lib/chats/flows/processSlashCommand.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.
Applied to files:
apps/meteor/client/lib/chats/flows/processSlashCommand.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.
Applied to files:
apps/meteor/client/lib/chats/flows/processSlashCommand.ts
|
This PR is ready for review — @RocketChat/backend could you take a look? |
|
Hi @julio-rocketchat, could you please review this when you get a chance? Thanks! |
Proposed changes
Add the
s(dotall) flag to the slash command parse regex so that multi-line input is fully captured instead of being truncated at the first newline.Before:
After:
The
sflag makes.match newline characters (\n), allowing the regex to capture the full multi-line text that follows the slash command.Why this change?
When a user types a slash command with multi-line text (using Shift+Enter), the client silently discards everything after the first line break. For example:
Only
@alicewas being sent to the server - the second line was lost without any warning.The server-side
parseParametersfunction already handles multi-line text correctly, so this fix aligns the client behavior with what the server already supports.How to test
yarn dsv)http://localhost:3000/msg @usernameRelated issue
Closes #41324
Summary by CodeRabbit