8000 fix(sync): mutual completion timestamp, persistent error notifications, per-device result indicator by ahmet-cetinkaya · Pull Request #308 · ahmet-cetinkaya/whph · GitHub
[go: up one dir, main page]

Skip to content

fix(sync): mutual completion timestamp, persistent error notifications, per-device result indicator - #308

Merged
ahmet-cetinkaya merged 4 commits into
mainfrom
fix/sync-indicator-88
Sep 8, 2026
Merged

ahmet-cetinkaya merged 4 commits into
mainfrom
fix/sync-indicator-88

Conversation

@ahmet-cetinkaya
Copy link
Copy Markdown
Owner

🚀 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 lastSyncDate from 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 existing paginated_sync_complete payload; the sending device stores that same value instead of its own clock. Both sides end up with byte-identical dates. A SyncCompletionService factors 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. showError no 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

  • Tests passed locally — full suite green (2452 tests), zero new failures.
  • Commit history is clean and descriptive — 4 commits, each independently buildable and tested.
  • Documentation updated (if applicable) — N/A, no user docs cover sync internals.
  • Code quality standards met — rps format clean, fvm flutter analyze reports no issues, rps test:locale confirms 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.

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 ahmet-cetinkaya added bug Something isn't working enhancement New feature or request ui User interface and user experience issues labels Sep 7, 2026
@ahmet-cetinkaya ahmet-cetinkaya self-assigned this Sep 7, 2026
@ahmet-cetinkaya
ahmet-cetinkaya marked this pull request as ready for review September 8, 2026 12:49
@ahmet-cetinkaya
ahmet-cetinkaya merged commit 2c0e539 into main Sep 8, 2026
3 checks passed
@ahmet-cetinkaya
ahmet-cetinkaya deleted the fix/sync-indicator-88 branch September 8, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request ui User interface and user experience issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Clearer sync indicator

1 participant

0