Repository navigation
feat(notifications): sync notification state through v2 - #395
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Code review summaryReviewed head: Process: an adversarial review of this PR's diff with each candidate finding independently verified before any fix, a simplify pass for medium and larger PRs, and a whole-stack review across contract conformance, authority and failure handling, data integrity, user-visible behavior and cross-PR integration. Verified findings: none. Validation: this branch builds on its own for iOS, tvOS and macOS, and its focused tests passed. The completed stack passed the full iOS suite (1981 tests) and tvOS suite (1792 tests) with 0 failures, the macOS build and the v1 path guard. The final stack was also exercised on iOS and tvOS simulators against a v1/v2 bridge server: sign-in (password and QR), restore, browse, search, detail, favorites and watchlist, playback (direct play, transcode, subtitles, stop), audiobooks, downloads with offline playback, settings, requests, profiles, push registration and diagnostics. Server logs showed no Remaining: no open verified findings. Merge in stack order. Mergeability: 8/10 — conditional. The approach holds up and every verified finding is fixed. Conditions: this PR's CI must pass (it was pending at review time), and the owner still plans a physical-device check of the completed stack. Review by Claude Opus 5.5 ( |
f00649d to
b5c3966
Compare
a89fa96 to
576679a
Compare
b5c3966 to
1888b11
Compare
The APNs wake, foreground-push and tap handlers caught up the inbox with GET /api/v1/notifications/sync, read one page per wake, and kept a `since` cursor keyed only by server and profile id. The v2 client method `notificationSync(cursor:auth:)` already existed but had no callers. The coordinator now captures the request owner once and reads GET /api/v2/notifications/sync page by page, up to 100 pages per sync. It keeps each page's `sync_cursor` (not `page.next_cursor`) tagged with the owner that received it, so another account, credential generation or profile starts from the server's initial snapshot. A failed page keeps the last completed checkpoint; a rejected cursor (`invalid_cursor`) restarts from the initial snapshot once; hitting the page bound is logged and the next sync resumes from the checkpoint. The v1 response models, the query helper, the 404/405 "endpoint unsupported" branch and their tests are deleted, and new StubURLProtocol tests cover the checkpoint, owner change, failure, rejected cursor and page bound. Stack-PR: W5-V Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
576679a to
5452dc7
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
The iOS notification inbox catch-up now pages through
GET /api/v2/notifications/syncwith an owner-tagged checkpoint.Problem
On iOS, the notification inbox catch-up after an APNs wake, a foreground push or a notification tap still calls
GET /api/v1/notifications/sync. It reads one page per wake, sends asincecursor, and resets that cursor based only on the server id and profile id. The v2 client methodAPIv2Client.notificationSync(cursor:auth:)already existed and validated the v2 page, but nothing called it.Solution
ApplePushNotificationSyncCoordinatornow readsGET /api/v2/notifications/syncthrough the sharedSiloAPI.shared.apiV2Client.CapturedOrdinaryRequestAuth) once per sync and requires a selected profile. The v2 method sendsX-Profile-Id(plusX-Profile-Tokenfor PIN-locked profiles) insidewithOwnerFence.page.has_moreis true, up to 100 pages per sync (invariant I10). When a sync hits the cap, the coordinator logs it and the next sync resumes from the checkpoint. It never truncates silently.sync_cursoras the checkpoint, notpage.next_cursor, so the final page still moves the checkpoint forward. The checkpoint is tagged with its owner and is sent again only whensameCredentialIdentitymatches. A change of account, credential generation or profile starts over from the server's initial snapshot.invalid_cursorproblem type, the coordinator clears it and restarts from the initial snapshot once.homeSectionsShouldRefreshonce at the end, as before.apiandtokenStorein its initializer so tests can inject them.refreshFromRemoteNotification()still retargets the active server first, then callssync().Deleted:
ApplePushNotificationSyncResponse,ApplePushNotificationSyncItem,ApplePushNotificationSyncWire(the v1 endpoint constant andsincequery), the 404/405 "endpoint not available" branch, and their two tests inApplePushRegistrationTests. This covers inventory rows 128 and E2.This is a read, so there is no write failure-outcome table. On any error, including an uncertain one, the sync returns
falseand keeps the last confirmed checkpoint. A read has no side effects to hold or replay.Validation
ApplePushNotificationSyncTests,ApplePushRegistrationTestsandApplePushOrderedRegistrationTests, 36 tests, 0 failures. On tvOS the new class is iOS-only, so that run only confirms the tvOS test target compiles.ApplePushNotificationSyncTestsrun onStubURLProtocolwith a realTokenStore,HTTPClientandAPIv2Client. They cover:limit=50andX-Profile-Id, and later syncs resume from the lastsync_cursoracross ahas_morepageinvalid_cursorrestarts from the initial snapshot oncescripts/ci/check-no-api-v1.shpasses.Risks and follow-ups
has_moreis false), so it costs one request.notificationSyncstays inAPIv2Client.swift, where it already lived. It was not moved to a per-domain extension file.AI disclosure
Code and description written by Claude Opus 5.5 (
claude-opus-5-5) agents in Claude Code (T3 Code), orchestrated by a Claude Code workflow.Part 47 of 50 in the Apple API v2 stack. Base:
apiv2-stack/46-push-display-v2. Merge in order from the bottom of the stack. The plan and full index are in PR 01.🤖 Generated with Claude Code