-
Notifications
You must be signed in to change notification settings - Fork 12.8k
fix: Editing encrypted message attachment description #37270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
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 |
🦋 Changeset detectedLatest commit: caab433 The changes in this PR will be included in the next version bump. This PR includes changesets to release 41 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughAdds a runtime type and type guard for encrypted attachments, uses that guard in message parsing so encrypted attachment descriptions are parsed for editing, updates a changeset, and extends an E2E test to verify editing encrypted attachment descriptions. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI as Message UI
participant Parser as parseMessageTextToAstMarkdown
participant Typings as isEncryptedMessageAttachment
participant Renderer as Message Renderer
User->>UI: Trigger edit and submit new attachment description
UI->>Parser: Re-parse message attachment
Parser->>Typings: isEncryptedMessageAttachment(attachment)?
alt encrypted
Typings-->>Parser: true
Parser->>Parser: compute descriptionMd via textToMessageToken
else not encrypted
Typings-->>Parser: false
Parser->>Parser: compute descriptionMd based on translated or fallback
end
Parser-->>Renderer: Updated message AST with descriptionMd
Renderer->>UI: Render updated attachment description
UI-->>User: Show edited description
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentBase.ts (1)
32-34: Type guard implementation is functional but minimal.The guard checks that
encryptionexists and is an object, which is sufficient for the current use case in parsing logic. However, note that it doesn't validate the deep structure (presence ofivandkeyproperties). If stronger runtime type guarantees are needed elsewhere in the codebase, consider validating the encryption object structure:export const isEncryptedMessageAttachment = (attachment: MessageAttachmentBase): attachment is EncryptedMessageAttachment => { return attachment?.encryption !== undefined && typeof attachment.encryption === 'object' && typeof attachment.encryption.iv === 'string' && typeof attachment.encryption.key === 'object'; };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
.changeset/healthy-colts-notice.md(1 hunks)apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts(2 hunks)apps/meteor/tests/e2e/e2e-encryption/e2ee-file-encryption.spec.ts(2 hunks)packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentBase.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
apps/meteor/tests/e2e/**/*.spec.ts
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
apps/meteor/tests/e2e/**/*.spec.ts: All Playwright test files must be located under apps/meteor/tests/e2e/ and use the .spec.ts extension (e.g., login.spec.ts)
Use descriptive test names that clearly communicate expected behavior
Use test.beforeAll() and test.afterAll() for setup and teardown
Use test.step() to organize complex test scenarios
Group related tests in the same file
Utilize Playwright fixtures (test, page, expect) consistently
Prefer web-first assertions (e.g., toBeVisible, toHaveText)
Use expect matchers (toEqual, toContain, toBeTruthy, toHaveLength, etc.) instead of assert statements
Maintain test isolation between test cases
Ensure a clean state for each test execution
Ensure tests run reliably in parallel without shared state conflicts
Files:
apps/meteor/tests/e2e/e2e-encryption/e2ee-file-encryption.spec.ts
apps/meteor/tests/e2e/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
apps/meteor/tests/e2e/**/*.{ts,tsx,js,jsx}: Write concise, technical TypeScript/JavaScript with accurate typing
Follow DRY by extracting reusable logic into helper functions or page objects
Avoid code comments in the implementation
Files:
apps/meteor/tests/e2e/e2e-encryption/e2ee-file-encryption.spec.ts
apps/meteor/tests/e2e/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
apps/meteor/tests/e2e/**/*.{ts,tsx}: Avoid using page.locator(); prefer semantic locators like page.getByRole, page.getByLabel, page.getByText, and page.getByTitle
Store commonly used locators in variables/constants for reuse
Use page.waitFor() with specific conditions and avoid hardcoded timeouts
Implement proper wait strategies for dynamic content
Follow the Page Object Model pattern consistently
Files:
apps/meteor/tests/e2e/e2e-encryption/e2ee-file-encryption.spec.ts
🧠 Learnings (1)
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
PR: RocketChat/Rocket.Chat#0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use descriptive test names that clearly communicate expected behavior
Applied to files:
apps/meteor/tests/e2e/e2e-encryption/e2ee-file-encryption.spec.ts
🧬 Code graph analysis (1)
apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts (1)
packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentBase.ts (1)
isEncryptedMessageAttachment(32-34)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: CodeQL-Build
- GitHub Check: CodeQL-Build
🔇 Additional comments (6)
.changeset/healthy-colts-notice.md (1)
1-6: LGTM!The changeset format is correct and accurately describes the fix for both affected packages.
apps/meteor/tests/e2e/e2e-encryption/e2ee-file-encryption.spec.ts (2)
41-41: LGTM!The updated test name clearly communicates the expected behavior, including both encryption and editing functionality.
63-73: Well-structured test step that verifies the edit flow.The test correctly exercises the editing functionality for encrypted attachment descriptions and aligns with the PR objectives.
apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts (2)
10-10: LGTM!The import is correctly placed and necessary for the type guard used in the parsing logic.
81-84: Core fix correctly implemented.By treating encrypted attachments similarly to translated attachments, this ensures that edited descriptions are always freshly parsed, preventing stale
descriptionMdfrom being displayed. This directly addresses the bug where edited encrypted attachment descriptions weren't visible.packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentBase.ts (1)
25-30: LGTM!The type correctly extends
MessageAttachmentBaseby making theencryptionproperty required, enabling proper type narrowing for encrypted attachments.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #37270 +/- ##
===========================================
- Coverage 67.61% 67.59% -0.03%
===========================================
Files 3338 3338
Lines 113721 113723 +2
Branches 20662 20655 -7
===========================================
- Hits 76895 76869 -26
- Misses 34143 34168 +25
- Partials 2683 2686 +3
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
cardoso
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍 just minor changes
packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentBase.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentBase.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: 📦 Build Packages
- GitHub Check: CodeQL-Build
- GitHub Check: CodeQL-Build
🔇 Additional comments (1)
packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentBase.ts (1)
25-27: LGTM! Clean type definition for encrypted attachments.The use of
Required<MessageAttachmentBase>['encryption']to narrow the type is idiomatic TypeScript and provides good type safety for encrypted attachments.
packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentBase.ts
Show resolved
Hide resolved
cardoso
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to comment something similar to the bot, but in theory it shouldn't matter, unless we're violating the interface somewhere with any. You can make the change, but otherwise LGTM 👍
…Chat#37270)" This reverts commit 5c7e8ec.
Proposed changes (including videos or screenshots)
Fixes editing of encrypted message attachment description. The attachment description was editable but edited message wasn't visible to user due to a small bug.
Issue(s)
Steps to test or reproduce
Further comments
CORE-1468
Summary by CodeRabbit
Bug Fixes
Tests