Fix stale state and formatting in sync dialog#2299
Conversation
The dialog was only refreshed on open and on user-triggered sync, so state (last sync date, pending counts) went stale when another client pushed changes and a background sync arrived while the dialog was open. Subscribe to projectEventBus.onSync and refresh on Success events. Extracted the existing refresh trio into refreshStatus() since it's now used in three places.
onSync fires a cached event immediately on subscribe, doubling up with onOpen's refresh; user-clicked sync similarly races the resulting sync event. Reuse the in-flight promise so overlapping calls share one round-trip.
Intl.DurationFormat hides zero-valued fields by default, so an absDiffMs below the smallest requested unit (e.g. <1s for seconds) was emitting an empty string and the "Last sync: " label briefly showed nothing right after a fresh sync. Fall back to a forced-display zero so Intl handles plurals correctly across styles and locales. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Benign race during page refresh: .NET completes a JS->.NET call whose JS-side registry was already torn down. Add to the existing ignore-list. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The 500ms onClose timer wiped state to undefined; combined with the refreshStatus dedupe (a784c90) it permanently stranded the dialog without data when the user reopened during the close-animation window. Removing onClose: data persists in memory while the dialog is closed (bits-ui keeps content mounted but hidden), so the next open shows the previous values until refreshStatus overwrites them. Also moved the projectEventBus.onSync subscription below the pendingRefresh declaration: onSync invokes its callback synchronously with a cached event, which can reach refreshStatus and hit the TDZ. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR enhances sync status display and error handling. It fixes relative date formatting to treat zero time differences as "past," adds comprehensive tests, refactors SyncDialog with event-driven status refresh using a cached helper, and filters WebView teardown errors. ChangesSync & Date Formatting Enhancements
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
UI unit Tests 1 files 60 suites 32s ⏱️ Results for commit df417c3. ♻️ This comment has been updated with latest results. |
C# Unit Tests165 tests 165 ✅ 20s ⏱️ Results for commit df417c3. ♻️ This comment has been updated with latest results. |
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
Convert the cfg helper from an arrow expression to a function declaration to match the project's ESLint config. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
5320fe3 to
424a5bb
Compare
The pendingRefresh dedupe returned the same promise to all overlapping callers, including onSync handlers triggered by another client's push. That meant the in-flight refresh (started before the push landed) would resolve with pre-sync data and no follow-up would fire. Mark refreshStatus calls from the onSync handler as forceFresh so they queue a rerun after the in-flight refresh finishes. Other overlapping calls (cached-event-on-subscribe, post-syncLexboxToLocal) still dedupe, preserving the original round-trip savings in those flows. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Four small fixes:
formatRelativeDate— fall back to a forced-display zero so the "Last sync:" label doesn't flash empty when the diff is below the smallest requested unit.