-
Notifications
You must be signed in to change notification settings - Fork 13k
fix: deleting a message with multiple files doesn't delete every file #38079
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 ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: 2311bee The changes in this PR will be included in the next version bump. This PR includes changesets to release 40 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 |
WalkthroughPatch for Changes
Sequence Diagram(s)(omitted — change is a localized model query update and does not introduce multi-component sequential flow) Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
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.
No issues found across 2 files
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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/models/src/models/Messages.ts (2)
56-56: Add index forfiles._idto matchfile._idindex.Since the query now checks both
file._idandfiles._id(line 1518), you should add a corresponding sparse index forfiles._idto ensure good query performance:🔎 Proposed index addition
{ key: { 'file._id': 1 }, sparse: true }, +{ key: { 'files._id': 1 }, sparse: true }, { key: { 'mentions.username': 1 }, sparse: true },
1522-1526: Apply the same fix togetMessageByFileIdAndUsername.This method only checks
file._id, which means it won't find messages with multiple files stored in thefilesarray. For consistency with the fix ingetMessageByFileId, this method should also check both fields.🔎 Proposed fix
getMessageByFileIdAndUsername(fileID: string, userId: string): Promise<IMessage | null> { const query = { - 'file._id': fileID, + $or: [{ 'file._id': fileID }, { 'files._id': fileID }], 'u._id': userId, };
🤖 Fix all issues with AI Agents
In @packages/models/src/models/Messages.ts:
- Around line 1517-1519: Add a Mongo index for the array path by defining an
index on 'files._id' (e.g., schema.index({ 'files._id': 1 })) to match the
existing 'file._id' index, and update the query logic in
getMessageByFileIdAndUsername and findFilesByUserId to mirror getMessageByFileId
by using a $or that checks both 'file._id' and 'files._id' so messages with
either a single file or files array are matched.
📜 Review details
Configuration used: Organization 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 (2)
.changeset/smart-carpets-clean.mdpackages/models/src/models/Messages.ts
🧰 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/models/src/models/Messages.ts
⏰ 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)
.changeset/smart-carpets-clean.md (1)
1-5: LGTM!The changeset accurately documents the patch and provides a clear description of the fix.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #38079 +/- ##
===========================================
+ Coverage 70.68% 70.69% +0.01%
===========================================
Files 3148 3148
Lines 108850 108850
Branches 19547 19565 +18
===========================================
+ Hits 76937 76948 +11
+ Misses 29916 29899 -17
- Partials 1997 2003 +6
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Proposed changes (including videos or screenshots)
Issue(s)
CORE-1602
Steps to test or reproduce
Further comments
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.