-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(sync): fallback to sync from 0 if lastOpen is missing to prevent ignored deletions #6864
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
base: develop
Are you sure you want to change the base?
fix(sync): fallback to sync from 0 if lastOpen is missing to prevent ignored deletions #6864
Conversation
WalkthroughThis PR fixes message deletion syncing by refining how the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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)
🔇 Additional comments (2)
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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/lib/methods/loadMissedMessages.ts (1)
76-86: Fix fallback behavior for older server versions to prevent API validation error.The older server path (< 7.1.0) on line 81 can pass
undefinedto thechat.syncMessagesAPI whenlastUpdateis missing, which causes a 400 error ("The 'lastUpdate' query parameter must be a valid date"). This conflicts with the newer server path (≥ 7.1.0, line 70) which explicitly falls back to0(epoch).Change line 81 to:
lastOpenISOString = lastUpdate?.toISOString() ?? new Date(0).toISOString();This ensures consistent behavior: both code paths fall back to epoch when
lastOpenis missing, matching the PR objective of "fallback to sync from 0 if lastOpen is missing".
📜 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 (1)
app/lib/methods/loadMissedMessages.ts
🔇 Additional comments (2)
app/lib/methods/loadMissedMessages.ts (2)
24-27: LGTM! Correct handling of timestamp 0.The explicit check
lastOpen === 0properly treats Unix epoch (0) as a valid timestamp, ensuring that a full sync from the beginning is triggered when falling back to 0. This correctly implements the fix for ignored deletions.
66-71: LGTM! Ensures numeric timestamp fallback.The nullish coalescing operator correctly ensures
lastOpenTimestampdefaults to 0 whenlastUpdateis missing, guaranteeing a valid numeric timestamp for the sync operation on servers >= 7.1.0.
Description
Fixes #6835.
When
lastOpenis missing (e.g., after a crash or bad state), the app was skipping the sync process for missed messages entirely. This caused deletions that happened while offline to be ignored, resulting in "zombie" messages.This fix ensures that if
lastOpenis missing, we fallback to syncing from timestamp0, guaranteeing that the state is reconciled.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.