Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@yash-rajpal
Copy link
Member

@yash-rajpal yash-rajpal commented Oct 21, 2025

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

  • Create an encrypted room
  • Send an encrypted attachment with description
  • Edit the description

Further comments

CORE-1468

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue preventing editing of encrypted message attachment descriptions; users can now update file attachment descriptions in encrypted messages.
  • Tests

    • End-to-end coverage updated to verify editing of encrypted file descriptions.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Oct 21, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is targeting the wrong base branch. It should target 7.13.0, but it targets 7.12.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Oct 21, 2025

🦋 Changeset detected

Latest commit: caab433

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/core-typings Patch
@rocket.chat/meteor Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/models Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 21, 2025

Walkthrough

Adds 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

Cohort / File(s) Change summary
Changeset entry
.changeset/healthy-colts-notice.md
Adds changeset noting patch releases for @rocket.chat/core-typings and @rocket.chat/meteor with description "Fixes editing of encrypted message attachment description."
Core typings
packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentBase.ts
Introduces exported EncryptedMessageAttachment type and exported isEncryptedMessageAttachment type guard to detect attachments with encryption at runtime.
Client parsing logic
apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts
Imports and uses isEncryptedMessageAttachment when deciding to compute attachment.descriptionMd, ensuring encrypted attachments are parsed with textToMessageToken even if not translated.
E2E test
apps/meteor/tests/e2e/e2e-encryption/e2ee-file-encryption.spec.ts
Renames test description and adds steps to edit an encrypted attachment description, submit the edit, and assert the updated description is rendered.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • aleksandernsilva
  • dougfabris

Poem

🐇 I fixed the key and found the thread,
The hidden note now wakes from bed.
With guards and parsing, clean and bright,
Encrypted descriptions write just right.
Hooray — hop on, edits take flight! ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "fix: Editing encrypted message attachment description" directly summarizes the main objective of the changeset, which is to fix the ability to edit descriptions on encrypted message attachments. The title is concise, specific, and clear enough for a teammate to understand the primary change when scanning commit history. It accurately reflects what the code changes accomplish without being vague or overly broad.
Linked Issues Check ✅ Passed The pull request satisfactorily addresses the objectives from CORE-1468. The code adds a new EncryptedMessageAttachment type and isEncryptedMessageAttachment type guard CORE-1468 to enable proper identification of encrypted attachments. The parseMessageTextToAstMarkdown.ts changes CORE-1468 now correctly handle encrypted attachment descriptions by applying the translation logic to encrypted attachments, ensuring edited descriptions are properly parsed and displayed. Additionally, the E2E test has been updated with the verification steps suggested in the linked issue CORE-1468, including opening the message menu, editing, and asserting the updated description is visible.
Out of Scope Changes Check ✅ Passed All code changes in this pull request are directly related to fixing the encrypted message attachment description editing functionality. The addition of the EncryptedMessageAttachment type and type guard provides necessary infrastructure for identifying encrypted attachments. The changes to parseMessageTextToAstMarkdown.ts specifically address the root cause by ensuring encrypted attachments are handled consistently with translated attachments. The E2E test update includes only the verification steps suggested in the linked issue. No unrelated refactoring, cleanup, or scope-creeping changes are present.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/edit-e2ee-description

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yash-rajpal yash-rajpal marked this pull request as ready for review October 21, 2025 14:17
@yash-rajpal yash-rajpal requested review from a team as code owners October 21, 2025 14:17
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 encryption exists 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 of iv and key properties). 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 0870d72 and bff2218.

📒 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 descriptionMd from 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 MessageAttachmentBase by making the encryption property required, enabling proper type narrowing for encrypted attachments.

@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.59%. Comparing base (9828d5c) to head (caab433).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
e2e 57.39% <66.66%> (+<0.01%) ⬆️
unit 71.55% <20.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@cardoso cardoso left a 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

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.

📥 Commits

Reviewing files that changed from the base of the PR and between bff2218 and 09769cd.

📒 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.

Copy link
Member

@cardoso cardoso left a 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 👍

@yash-rajpal yash-rajpal added the stat: QA assured Means it has been tested and approved by a company insider label Oct 22, 2025
@yash-rajpal yash-rajpal added this to the 7.13.0 milestone Oct 22, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Oct 22, 2025
@kodiakhq kodiakhq bot merged commit 5c7e8ec into develop Oct 27, 2025
48 checks passed
@kodiakhq kodiakhq bot deleted the fix/edit-e2ee-description branch October 27, 2025 14:29
amaricbrown04-maker added a commit to amaricbrown04-maker/Rocket.Chat that referenced this pull request Nov 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants