Repository navigation
Add the notification activity remote and service - #26076
Merged
Merged
Conversation
Collaborator
Generated by 🚫 Danger |
Contributor
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 34949 | |
| Version | PR #26076 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | a06319d | |
| Installation URL | 5ttkgd47pfs28 |
Contributor
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 34949 | |
| Version | PR #26076 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | a06319d | |
| Installation URL | 3gu2c17m24t8g |
crazytonyli
force-pushed
the
task/notification-activity-remote
branch
2 times, most recently
from
September 25, 2026 03:59
a35bf26 to
07b84ed
Compare
crazytonyli
marked this pull request as ready for review
September 25, 2026 04:50
jkmassel
approved these changes
Oct 13, 2026
12 tasks
Base automatically changed from
bugfix/notification-sync-account-guard
to
trunk
October 13, 2026 04:38
Callers can then tell a client error from a server error when the error code is unrecognized.
Add NotificationActivityServiceRemote to WordPressKit: a focused GET me?fields=has_unseen_notes for the account-wide unseen-notifications flag and a POST notifications/seen. A missing or malformed has_unseen_notes is an error, not false, so callers can preserve the last known state. The seen time is sent as Unix seconds, because the endpoint casts it to an integer. Only success true acknowledges a seen write; client errors that a retry cannot fix are reported as rejections.
Introduce NotificationActivityService, the single main-actor owner of the in-app Notifications bell: an observable has_unseen_notes flag, the local clear on opening Notifications, and the sole notifications/seen submit-and-retry. It refreshes on foreground, sync updates, and PingHub activity and reconnects. Per-account work lives in a private session object that the service replaces on sign-out or account change, so a stale result cannot reach the new account; a revision guard discards a fetch that raced a local clear. Seen timestamps never move backward, and only rejected seen writes count toward a persisted cap. NotificationActivityStore persists an account-scoped snapshot.
crazytonyli
force-pushed
the
task/notification-activity-remote
branch
from
October 13, 2026 04:39
07b84ed to
a06319d
Compare
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.


Description
applicationIconBadgeNumberis deprecated. The Notifications bell and tab badge need shared account-scoped state so they no longer depend on reading the app icon badge count. The next PR connects this service to the UI.WordPress.com's
has_unseen_notesflag indicates notification activity since the account last marked Notifications as seen, including on another client. It supplies the new-activity state for the bell and tab badge. “Seen” records a visit to Notifications; individual notifications keep their read/unread status.NotificationActivityServicefetches this flag and preserves the last known value when a request fails.notifications/seenwhen Notifications opens. Pending updates survive restarts and retry after transient failures. A timestamp the server rejects is dropped, because retrying the same value cannot succeed.The existing iOS client sends an ISO 8601 date string, but
notifications/seenexpects Unix seconds. The server converts a string beginning with"2026-"to2026, so it can report success without advancing the last-seen timestamp.NotificationActivityServiceRemoteconverts the date to Unix seconds before submitting it. The next PR switches callers to the new service and removes the old implementation.Scenarios
Each item is a situation a user can hit, what the service does, and why.
New activity arrives while the app is open. A push, a PingHub event, or a completed notification sync is a reason to refresh, not proof of new activity: an edited old note or a mark-seen from another device produces the same signals. The service re-fetches
has_unseen_notesinstead of setting the bell directly.The user opens Notifications. The bell clears immediately and locally, before any network call. The newest timestamp the list actually shows is sent to
notifications/seen. Opening a list that has not loaded yet clears locally but sends nothing; a fabricated timestamp could mark unseen content seen.A refresh that started before the user opened Notifications finishes afterwards. A revision counter advances on every local clear and activity event. A fetch whose starting revision is stale is discarded and repeated, so a slow response carrying the pre-visit
truecannot relight a bell the user just cleared. This is the regression that reverted the earlier badge migration (#24877, #24928).Notifications stays on screen. No fetch runs while a list is visible, because the bell is held clear regardless. Leaving the screen triggers the refresh. On iPad a new list can appear before the old one disappears, so visibility is counted per list.
The user opened Notifications while offline. The local clear and the pending seen timestamp are persisted and survive a relaunch. The next foreground, reconnect, or activity trigger retries the write, with no attempt limit for transient failures. No fetch runs while the write is pending: the server would still report the pre-visit
true.The server rejects the seen timestamp. The timestamp is dropped after one rejection and the flag is re-fetched. Retrying the same value cannot succeed, and a timestamp kept pending would block every refresh forever, even after a relaunch.
The visible list loads newer content. The newer timestamp replaces the pending one. Seen only moves forward: anything at or before the acknowledged timestamp is skipped, and one write is in flight at a time.
The seen write succeeds. The acknowledged timestamp advances, a newer pending timestamp drains first, and then the flag is re-fetched, so activity newer than the visit can light the bell again.
The user viewed Notifications on the web or another device.
has_unseen_notesis account-wide, so the next refresh clears this device's bell.A refresh fails. Transport, authentication, and decoding errors keep the last known state. A missing or non-Boolean
has_unseen_notesis an error rather thanfalse, so a bad response cannot invent a cleared bell.Push notifications or app badges are disabled. The bell is driven by the WordPress.com flag and does not depend on either.
The app relaunches. The saved snapshot restores only when its account UUID matches the current default account, so the last known bell state is available before the first fetch, including offline.
The user signs out or switches accounts. Saved state and the pending write are discarded, and the per-account session is replaced. A late response or a list callback still bound to the previous account is ignored, so it cannot mark the new account seen with the old account's timestamp. Signing back into the same account starts fresh.
The token is invalidated without an account change.
WPAccount.handleInvalidTokenposts the same notification as an account change. The service sees the same account UUID and keeps the session, including the pending seen write; network work pauses until credentials return. A same-account re-auth posts nothing the service observes, so every account-gated entry point re-resolves credentials itself.The app is in the background. Refreshes and seen retries wait for the foreground.