Skip to content

Conversation

@Sumanth2377
Copy link

@Sumanth2377 Sumanth2377 commented Dec 25, 2025

Description

Fixes #6835.
When lastOpen is 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 lastOpen is missing, we fallback to syncing from timestamp 0, guaranteeing that the state is reconciled.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of missed messages to ensure proper synchronization of updated and deleted messages in edge cases.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 25, 2025

Walkthrough

This PR fixes message deletion syncing by refining how the lastOpen timestamp is handled in the missed messages loader, ensuring 0 is treated as a valid value and preventing undefined fallbacks that blocked sync operations.

Changes

Cohort / File(s) Summary
Message sync timestamp handling
app/lib/methods/loadMissedMessages.ts
Modified getSyncMessagesFromCursor to treat 0 as a valid lastOpen value for triggering UPDATED/DELETED fetches; updated load function to use lastUpdate as fallback via nullish coalescing, preventing undefined values that could block deletion sync for stale messages.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit hops through timestamps with care,
Zero's no longer a void in the air!
Old messages deleted will now find their way,
From mobile to desktop—deleted to stay. 🐰✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a fallback to sync from 0 when lastOpen is missing to prevent ignored deletions.
Linked Issues check ✅ Passed The code changes directly address issue #6835 by implementing fallback to timestamp 0 when lastOpen is missing, enabling full reconciliation and preventing ignored deletions.
Out of Scope Changes check ✅ Passed All changes are focused on the sync mechanism for missed messages and are directly related to fixing the deletion synchronization issue in issue #6835.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 0d13c14 and 4284174.

📒 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 === 0 properly 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 lastOpenTimestamp defaults to 0 when lastUpdate is missing, guaranteeing a valid numeric timestamp for the sync operation on servers >= 7.1.0.


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.

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

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 undefined to the chat.syncMessages API when lastUpdate is 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 to 0 (epoch).

Change line 81 to:

lastOpenISOString = lastUpdate?.toISOString() ?? new Date(0).toISOString();

This ensures consistent behavior: both code paths fall back to epoch when lastOpen is 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 0d13c14 and 4284174.

📒 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 === 0 properly 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 lastOpenTimestamp defaults to 0 when lastUpdate is missing, guaranteeing a valid numeric timestamp for the sync operation on servers >= 7.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: delete message from DM not syncing between mobile and windows app

1 participant