feat(room): Embed Link Previews by channel#40861
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: a1d753d The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 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 |
There was a problem hiding this comment.
3 issues found across 9 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/useEditRoomInitialValues.ts">
<violation number="1" location="apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/useEditRoomInitialValues.ts:56">
P1: `disableLinkPreviews` is added to form initial values but never sent to the server in the save handler. In `EditRoomInfo.tsx`, `handleUpdateRoomData` destructures `disableLinkPreviews` from `formData` and then calls `saveAction({ ...data, ... })` without ever including `disableLinkPreviews`. The server endpoint `/v1/rooms.saveRoomSettings` does handle this field (see `saveRoomSettings.ts:355`), so the toggle will appear to work but changes will never be persisted.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| @@ -18,6 +18,7 @@ export type EditRoomInfoFormData = { | |||
| archived: boolean; | |||
There was a problem hiding this comment.
P1: disableLinkPreviews is added to form initial values but never sent to the server in the save handler. In EditRoomInfo.tsx, handleUpdateRoomData destructures disableLinkPreviews from formData and then calls saveAction({ ...data, ... }) without ever including disableLinkPreviews. The server endpoint /v1/rooms.saveRoomSettings does handle this field (see saveRoomSettings.ts:355), so the toggle will appear to work but changes will never be persisted.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/useEditRoomInitialValues.ts, line 56:
<comment>`disableLinkPreviews` is added to form initial values but never sent to the server in the save handler. In `EditRoomInfo.tsx`, `handleUpdateRoomData` destructures `disableLinkPreviews` from `formData` and then calls `saveAction({ ...data, ... })` without ever including `disableLinkPreviews`. The server endpoint `/v1/rooms.saveRoomSettings` does handle this field (see `saveRoomSettings.ts:355`), so the toggle will appear to work but changes will never be persisted.</comment>
<file context>
@@ -52,6 +53,7 @@ export const useEditRoomInitialValues = (room: IRoomWithRetentionPolicy): Partia
joinCodeRequired: !!joinCodeRequired,
systemMessages: Array.isArray(sysMes) ? sysMes : [],
hideSysMes: Array.isArray(sysMes) ? !!sysMes?.length : !!sysMes,
+ disableLinkPreviews: !!disableLinkPreviews,
encrypted,
...(canEditRoomRetentionPolicy &&
</file context>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ 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). (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (3)📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-05-06T12:21:44.083ZApplied to files:
🔇 Additional comments (2)
WalkthroughAdds a per-channel ChangesPer-Channel Link Preview Control
Sequence DiagramsequenceDiagram
participant Client
participant saveRoomSettings as MeteorMethod:saveRoomSettings
participant RoomsModel as Rooms.saveDisableLinkPreviewsById
participant DB
participant AfterSaveOEmbed as AfterSaveOEmbed/rocketUrlParser
Client->>saveRoomSettings: submit dirty fields incl. disableLinkPreviews
saveRoomSettings->>RoomsModel: call saveDisableLinkPreviewsById(rid, value)
RoomsModel->>DB: updateOne({_id: rid}, { $set/$unset disableLinkPreviews })
DB-->>RoomsModel: update result
RoomsModel-->>saveRoomSettings: result
Client->>AfterSaveOEmbed: send message with url and rid
AfterSaveOEmbed->>DB: findOne({_id: rid}, { disableLinkPreviews: 1 })
DB-->>AfterSaveOEmbed: { disableLinkPreviews: true/false }
alt disableLinkPreviews true
AfterSaveOEmbed-->>AfterSaveOEmbed: return message unchanged (skip OEmbed)
else
AfterSaveOEmbed-->>AfterSaveOEmbed: continue URL/OEmbed processing
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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)
apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsx (1)
154-197:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winCritical:
disableLinkPreviewswill never be saved to the server.The
disableLinkPreviewsparameter is destructured at line 157 but never included in the payload sent tosaveAction. Fields handled viagetDirtyFields(likeroomName,roomDescription, etc.) must remain in theformDatarest parameter, not be destructured separately.Compare with retention fields (lines 179-187): when a field is destructured, it must be explicitly added to the payload. Currently,
disableLinkPreviewsis destructured but missing from the payload.🐛 Fix: Remove from parameter destructuring
const handleUpdateRoomData = useEffectEvent( async ({ hideSysMes, - disableLinkPreviews, joinCodeRequired, retentionEnabled,After this change,
disableLinkPreviewswill remain informDataand be included viagetDirtyFields, just like other boolean toggles (readOnly,reactWhenReadOnly, etc.).🤖 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/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsx` around lines 154 - 197, The handler handleUpdateRoomData is destructuring disableLinkPreviews out of the incoming EditRoomInfoFormData so it never reaches getDirtyFields and thus is not sent to saveAction; remove disableLinkPreviews from the destructured parameters (leave it in the rest formData) so getDirtyFields can capture it, or alternatively explicitly add disableLinkPreviews to the payload passed to saveAction (in the saveAction call near the spread of data) if you prefer an explicit approach; locate handleUpdateRoomData, getDirtyFields, and the saveAction payload to apply the change.
🤖 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.
Outside diff comments:
In
`@apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsx`:
- Around line 154-197: The handler handleUpdateRoomData is destructuring
disableLinkPreviews out of the incoming EditRoomInfoFormData so it never reaches
getDirtyFields and thus is not sent to saveAction; remove disableLinkPreviews
from the destructured parameters (leave it in the rest formData) so
getDirtyFields can capture it, or alternatively explicitly add
disableLinkPreviews to the payload passed to saveAction (in the saveAction call
near the spread of data) if you prefer an explicit approach; locate
handleUpdateRoomData, getDirtyFields, and the saveAction payload to apply the
change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7b2ce3ab-041f-4a7d-a059-7ce3e67e370e
📒 Files selected for processing (10)
.changeset/embed-link-previews.mdapps/meteor/app/channel-settings/server/methods/saveRoomSettings.tsapps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsxapps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/useEditRoomInitialValues.tsapps/meteor/server/services/messages/hooks/AfterSaveOEmbed.tspackages/core-typings/src/IRoom.tspackages/i18n/src/locales/en.i18n.jsonpackages/model-typings/src/models/IRoomsModel.tspackages/models/src/models/Rooms.tspackages/rest-typings/src/v1/rooms.ts
📜 Review details
⏰ 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). (1)
- 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:
packages/model-typings/src/models/IRoomsModel.tspackages/core-typings/src/IRoom.tsapps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/useEditRoomInitialValues.tspackages/models/src/models/Rooms.tsapps/meteor/server/services/messages/hooks/AfterSaveOEmbed.tspackages/rest-typings/src/v1/rooms.tsapps/meteor/app/channel-settings/server/methods/saveRoomSettings.tsapps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsx
🧠 Learnings (8)
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.
Applied to files:
.changeset/embed-link-previews.md
📚 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:
packages/model-typings/src/models/IRoomsModel.tspackages/core-typings/src/IRoom.tsapps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/useEditRoomInitialValues.tspackages/models/src/models/Rooms.tsapps/meteor/server/services/messages/hooks/AfterSaveOEmbed.tspackages/rest-typings/src/v1/rooms.tsapps/meteor/app/channel-settings/server/methods/saveRoomSettings.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:
packages/model-typings/src/models/IRoomsModel.tspackages/core-typings/src/IRoom.tsapps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/useEditRoomInitialValues.tspackages/models/src/models/Rooms.tsapps/meteor/server/services/messages/hooks/AfterSaveOEmbed.tspackages/rest-typings/src/v1/rooms.tsapps/meteor/app/channel-settings/server/methods/saveRoomSettings.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:
packages/model-typings/src/models/IRoomsModel.tspackages/core-typings/src/IRoom.tsapps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/useEditRoomInitialValues.tspackages/models/src/models/Rooms.tsapps/meteor/server/services/messages/hooks/AfterSaveOEmbed.tspackages/rest-typings/src/v1/rooms.tsapps/meteor/app/channel-settings/server/methods/saveRoomSettings.tsapps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsx
📚 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/views/room/contextualBar/Info/EditRoomInfo/useEditRoomInitialValues.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/views/room/contextualBar/Info/EditRoomInfo/useEditRoomInitialValues.ts
📚 Learning: 2026-05-11T23:14:59.316Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 40469
File: packages/rest-typings/src/v1/users.ts:337-337
Timestamp: 2026-05-11T23:14:59.316Z
Learning: In Rocket.Chat REST endpoint typings (e.g., packages/rest-typings/src/v1/users.ts and other rest-typings files), keep the established convention of deriving field types from the domain model (e.g., use IUser indexed access like IUser['statusExpiresAt']) rather than swapping individual fields to serialized primitives (like string) in an ad-hoc way. If a truly different “serialized” representation is needed, perform the refactor consistently across the codebase (not just a single endpoint/field) and ensure all related REST typings stay aligned with the shared serialization types.
Applied to files:
packages/rest-typings/src/v1/rooms.ts
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.
Applied to files:
apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsx
🔇 Additional comments (10)
.changeset/embed-link-previews.md (1)
1-10: LGTM!packages/core-typings/src/IRoom.ts (1)
35-36: LGTM!packages/model-typings/src/models/IRoomsModel.ts (1)
305-305: LGTM!packages/models/src/models/Rooms.ts (1)
1900-1912: LGTM!packages/rest-typings/src/v1/rooms.ts (1)
385-385: LGTM!Also applies to: 470-470
apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts (1)
51-51: LGTM!Also applies to: 355-357, 394-394
apps/meteor/server/services/messages/hooks/AfterSaveOEmbed.ts (1)
11-11: LGTM!Also applies to: 339-344
apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/useEditRoomInitialValues.ts (1)
21-21: LGTM!Also applies to: 39-39, 56-56, 82-82
apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsx (1)
496-509: LGTM!packages/i18n/src/locales/en.i18n.json (1)
2527-2527: LGTM!
d52038b to
a1d753d
Compare
Proposed changes
Closes #7734.
This PR adds a per-channel setting to disable link previews. When enabled, the setting skips OEmbed metadata fetching and rendering for that specific room, overriding the global link preview setting.
disableLinkPreviewstoIRoomschema and@rocket.chat/modelsmethods.RoomsSaveRoomSettingsPropsand validation schemas in@rocket.chat/rest-typings.AfterSaveOEmbed.tsto abort URL parsing whendisableLinkPreviewsis true.Issue(s)
Closes #7734
How to test or reproduce
Screenshots
N/A
Types of changes
Checklist
Summary by CodeRabbit