Repository navigation
fix(sync): mutual completion timestamp, persistent error notifications, per-device result indicator - #308
Merged
Conversation
Two devices previously disagreed on when a sync finished. The receiving device generates one completion timestamp when the final page succeeds, persists it locally, and returns it in the paginated_sync_complete payload via a new SyncCompletionService shared by all three server-role emitters (api.dart, android and desktop server sync services). The old logic in api.dart read the client's own stale lastSyncDate from the request and skipped the update entirely when that value was null - which is exactly what happens on a first sync, so the receiving side never recorded one. That null-skip is gone; the lookup now only needs the IP/device-id pair, not the client's date.
The client used to record its own DateTime.now() as the sync date, disagreeing with whatever the server just persisted. Each entity page's response now stashes the server's returned timestamp per device (ServerPaginationHandler), and the client's completion step reads it back instead of the local clock - falling back to DateTime.now() with a logged warning only when a peer omits it (older version). Also drops the 100ms delay + verification retry that used to run after every sync date update: it was a workaround for a timing issue that no longer applies once both sides agree on one server-generated value. Confirmed by running the full suite before and after removal with no new failures.
Sync errors used to auto-dismiss after 5 seconds, and a loading notification firing mid-error would silently replace it before anyone saw it. showError is now persistent - no dismiss timer is scheduled - and a visible persistent error can only be replaced by another error, never by a transient loading/info/success call, which becomes a no-op instead. The overlay's only existing dismiss affordance turned out to be its auto-dismiss timer, not a user control - a persistent notification with no timer would have been permanently unclosable. Added a close icon button that renders only when the notification has no duration.
Adds a small result icon next to each device's last-sync timestamp: a green check when that device's most recent sync attempt this session completed, an orange warning when it failed, nothing before any attempt. The state is tracked per device id on the page's existing sync-status listener rather than a second subscription per list item, so two devices can show different results at once. Translated across all 22 locales.
ahmet-cetinkaya
marked this pull request as ready for review
September 8, 2026 12:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 Context
Closes #88. The sync device list gave no reliable signal of what actually happened: one side often showed "never synced" forever, error messages vanished before they could be read (or got silently replaced by a loading pop-up), and there was no way to tell at a glance whether a device's last sync succeeded.
⚙️ Implementation Details
Mutual completion timestamp (root cause of "never synced"). The date was written by both sides at different moments with different values — and the receiving side skipped the write entirely on first sync, because it read the client's own stale
lastSyncDatefrom the request and bailed when that was null. Now the receiving device generates one completion timestamp when the final page succeeds, persists it, and returns it in the existingpaginated_sync_completepayload; the sending device stores that same value instead of its own clock. Both sides end up with byte-identical dates. ASyncCompletionServicefactors this out of the three server-role emitters that used to duplicate it.Also removed a 100ms delay + retry-verification patch that predated this fix — it was working around timing symptoms of the underlying disagreement. Confirmed the full suite stays green without it.
Persistent error notifications.
showErrorno longer auto-dismisses; a visible error can only be replaced by another error, never silently dropped by a loading/info pop-up. Turned up a real gap while building this: the overlay's only "dismiss" mechanism was its auto-dismiss timer — a persistent notification with no timer would have been permanently unclosable. Added a close button that only appears on persistent notifications.Per-device result indicator. A small green check / orange warning next to each device's last-sync time, driven by the existing sync-status stream (no new subscription), so two devices can show different results at once. Translated across all 22 locales.
📋 Checklist for Reviewer
rps formatclean,fvm flutter analyzereports no issues,rps test:localeconfirms all 22 locales complete.Note
Verified end-to-end with two real, isolated app instances syncing over an actual localhost WebSocket (not mocks): both sides landed on the identical microsecond-precision timestamp, confirmed via a temporary probe removed before commit. The notification fix was verified the same way against the real production error path, including a mutation check (temporarily reverting the fix reproduced the old ~4s auto-dismiss). Raising the app window under this Wayland session to capture a screenshot did not work (same limitation as PR #307); the logging-based verification was used instead, as the plan anticipated.