Repository navigation
fix(app): respect task export choice and recover push registration - #24182
Conversation
Failure-Class: FC-split-mutation-authority
Failure-Class: FC-split-mutation-authority
Failure-Class: FC-split-mutation-authority
Failure-Class: FC-split-mutation-authority
Failure-Class: FC-split-mutation-authority
|
Verdict: well-scoped, carefully fenced fix — no blocking issues found; two UX notes worth a look before this leaves draft. Correctness (verified on 6fc6816):
UX:
Cost: one extra Security: no new permissions or data flows; the session-fencing changes reduce cross-account contamination risk (a stale owner can no longer refresh tokens or expire the replacement session), and tokens/task text stay out of the new diagnostic logs. Blast radius: USER IMPACT: tasks you create or bulk-export go to the task app you actually selected (e.g. Todoist) instead of silently landing in Apple Reminders, and push notification registration recovers on its own after delayed APNs/startup hiccups or a refused save. Still wanted as a reviewer: the two UX items above; a real-device push round ( by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Verdict: the production change is correct, carefully guarded, and well tested; I found no blocking issue - but it rewrites authenticated push-registration and export-routing behavior in one pass, so I am leaving it for human maintainer sign-off rather than a sign-off from automation. Verified on head f3d5f28:
Material dimensions:
USER IMPACT: tasks are exported to the app you actually selected (no surprise Apple Reminders entries when Todoist is chosen), and notification registration recovers on its own after sign-in delays or a missed first attempt. What I would still want: the PR body's own unchecked items (repository mobile journeys run and exact-head CI confirmation), and a ready-for-review flip when you consider it final - it is currently a draft. A human maintainer should sign off on the registration/routing rewrite before merge. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
Keep the saved export destination and session guards while forwarding the completion state supported by main.
The hosted default Java 25 fails during Gradle 8.14.2 build-script analysis. Match the emulator job pin and protect the JVM and compile jobs with the existing infrastructure contract.
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.
3 issues found across 25 files
Confidence score: 4/5
task_notification_recovery_capture.dartis not formatted, so the pre-push hook will reject the changed Dart file. Rundart formaton the block.notifications.dartsilently retries when a 200 response has a status other than'Ok'. Log the unexpected status before returningfalse.- The release note in
20261031-task-routing-push-recovery.jsonuses implementation jargon, which obscures the user-visible notification outcome. Reword it around what users can expect.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/lib/backend/http/api/notifications.dart">
<violation number="1" location="app/lib/backend/http/api/notifications.dart:29">
P3: A 200 response whose `status` is not `'Ok'` now returns `false` with no log, so the retry loop runs silently. Log the unexpected status before returning, as the removed code did.</violation>
</file>
<file name="app/integration_test/task_notification_recovery_capture.dart">
<violation number="1" location="app/integration_test/task_notification_recovery_capture.dart:96">
P3: This block is not `dart format` output, and the pre-push hook runs `dart format --set-exit-if-changed` on changed Dart files, so it will be rejected. Reformat the `ActionItemsProvider`, `TaskIntegrationProvider`, `FcmTokenRegistration`, and `runApp(MultiProvider(...))` calls with `dart format --line-length 120`.</violation>
</file>
<file name="app/changelog/unreleased/20261031-task-routing-push-recovery.json">
<violation number="1" location="app/changelog/unreleased/20261031-task-routing-push-recovery.json:2">
P3: This mobile release note uses implementation jargon (`Push registration`, `delayed setup`) instead of describing the user-visible notification outcome. Say that push notifications recover after a delay and when the user returns to the app.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| Logger.debug(data.status == 'Ok' ? "Token saved successfully" : "Token save returned ${data.status}"); | ||
| } else { | ||
| Logger.debug("Failed to save token"); | ||
| return data.status == 'Ok'; |
There was a problem hiding this comment.
P3: A 200 response whose status is not 'Ok' now returns false with no log, so the retry loop runs silently. Log the unexpected status before returning, as the removed code did.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/backend/http/api/notifications.dart, line 29:
<comment>A 200 response whose `status` is not `'Ok'` now returns `false` with no log, so the retry loop runs silently. Log the unexpected status before returning, as the removed code did.</comment>
<file context>
@@ -14,19 +14,20 @@ Future<void> syncUserTimeZoneServer({required String timeZone}) async {
- Logger.debug(data.status == 'Ok' ? "Token saved successfully" : "Token save returned ${data.status}");
- } else {
- Logger.debug("Failed to save token");
+ return data.status == 'Ok';
}
+ Logger.debug('Push token persistence deferred (status=${response?.statusCode})');
</file context>
| return data.status == 'Ok'; | |
| if (data.status == 'Ok') return true; | |
| Logger.debug('Push token save returned ${data.status}'); | |
| return false; |
| await request.response.close(); | ||
| publish(); | ||
| }); | ||
| final tasks = ActionItemsProvider( |
There was a problem hiding this comment.
P3: This block is not dart format output, and the pre-push hook runs dart format --set-exit-if-changed on changed Dart files, so it will be rejected. Reformat the ActionItemsProvider, TaskIntegrationProvider, FcmTokenRegistration, and runApp(MultiProvider(...)) calls with dart format --line-length 120.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/integration_test/task_notification_recovery_capture.dart, line 96:
<comment>This block is not `dart format` output, and the pre-push hook runs `dart format --set-exit-if-changed` on changed Dart files, so it will be rejected. Reformat the `ActionItemsProvider`, `TaskIntegrationProvider`, `FcmTokenRegistration`, and `runApp(MultiProvider(...))` calls with `dart format --line-length 120`.</comment>
<file context>
@@ -0,0 +1,179 @@
+ await request.response.close();
+ publish();
+ });
+ final tasks = ActionItemsProvider(
+ automaticAppleRemindersExport: AutomaticAppleRemindersExport(
+ permission: () async => true,
</file context>
| @@ -0,0 +1,3 @@ | |||
| { | |||
| "change": "Task exports respect your selected integration when Apple Reminders is also connected. Push registration retries delayed setup and reconnects after returning to the app." | |||
There was a problem hiding this comment.
P3: This mobile release note uses implementation jargon (Push registration, delayed setup) instead of describing the user-visible notification outcome. Say that push notifications recover after a delay and when the user returns to the app.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/changelog/unreleased/20261031-task-routing-push-recovery.json, line 2:
<comment>This mobile release note uses implementation jargon (`Push registration`, `delayed setup`) instead of describing the user-visible notification outcome. Say that push notifications recover after a delay and when the user returns to the app.</comment>
<file context>
@@ -0,0 +1,3 @@
+{
+ "change": "Task exports respect your selected integration when Apple Reminders is also connected. Push registration retries delayed setup and reconnects after returning to the app."
+}
</file context>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4ab62dd74
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| final read = ConnectionRead<Object?>(operation, deadline); | ||
| _read = read; | ||
| try { | ||
| return await read.future as T; |
There was a problem hiding this comment.
Prevent timed-out FCM writes from committing late
When the FCM POST exceeds this 20-second wrapper deadline, ConnectionRead only times out its own future; it does not cancel persist (the HTTP write deadline is 300 seconds). A retry or newer-token attempt can therefore start while the old POST is still live. Since backend/database/notifications.py overwrites the same device_key document, an older token request that completes last can replace the newly accepted token and disable push delivery. Bound or cancel the actual write, or serialize and revalidate writes before persisting a later token.
Useful? React with 👍 / 👎.
| await writes; | ||
| if (generation != _sessionGeneration || !identical(writes, _defaultWrites)) return null; | ||
| final choice = _defaultChoice; | ||
| final loading = loadFromBackend(forceRefresh: true, silent: true, refreshApplePermission: false); |
There was a problem hiding this comment.
Fence the export status read to its account
If the user switches accounts while this status GET is in flight, the new export path calls _fetchStatus without canSend; the default getTaskIntegrations therefore leaves signOutOn401 enabled. A stale 401 can be refreshed and replayed using the replacement account, and a rejected replay can expire that session; a stale account-deletion 403 can likewise expire the current session. The provider generation check only prevents applying the result, not these HTTP auth side effects. Capture the owner and pass a guard to this read and any connection-repair writes. 401s in this client are automatically refreshed and retried.
AGENTS.md reference: app/AGENTS.md:L127-L131
Useful? React with 👍 / 👎.
Failure-Class: FC-split-mutation-authority
Failure-Class: FC-split-mutation-authority
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Failure-Class: FC-split-mutation-authority
There was a problem hiding this comment.
2 issues found across 36 files
Confidence score: 3/5
- In
automatic_apple_reminders_export.dart, if the acknowledgement write fails after reminder creation, a later manual export can create a duplicate reminder. Delete the created reminder when the acknowledgement fails. - In
sign_out.dart, the push-registration ordering metadata is under a heading that conflicts with the list’s documented policy. Give it a separate comment explaining why it survives sign-out.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/lib/pages/settings/sign_out.dart">
<violation number="1" location="app/lib/pages/settings/sign_out.dart:36">
P3: This key is push-registration ordering metadata, not a display or phone-behaviour preference, so it sits under the wrong heading for this list's documented policy. Give it its own comment that says why it survives sign-out (keeps the write order monotonic across sign-in cycles).</violation>
</file>
<file name="app/lib/services/integrations/automatic_apple_reminders_export.dart">
<violation number="1" location="app/lib/services/integrations/automatic_apple_reminders_export.dart:70">
P2: If the acknowledgement write fails after `_create` succeeds, the EventKit reminder stays on the device while the task is still unexported. A later manual export creates a second reminder. Delete the created reminder when acknowledgement or the ownership check fails.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| if (!await _permission() || !current()) return false; | ||
| final reminder = await _create(item); | ||
| if (reminder == null || !current()) return false; | ||
| return await _acknowledge(item.id, reminder, current) && current(); |
There was a problem hiding this comment.
P2: If the acknowledgement write fails after _create succeeds, the EventKit reminder stays on the device while the task is still unexported. A later manual export creates a second reminder. Delete the created reminder when acknowledgement or the ownership check fails.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/services/integrations/automatic_apple_reminders_export.dart, line 70:
<comment>If the acknowledgement write fails after `_create` succeeds, the EventKit reminder stays on the device while the task is still unexported. A later manual export creates a second reminder. Delete the created reminder when acknowledgement or the ownership check fails.</comment>
<file context>
@@ -0,0 +1,77 @@
+ if (!await _permission() || !current()) return false;
+ final reminder = await _create(item);
+ if (reminder == null || !current()) return false;
+ return await _acknowledge(item.id, reminder, current) && current();
+ } catch (error) {
+ // A failed read never selects a fallback destination or logs task text.
</file context>
| 'companionAssociationPrompted', | ||
| 'autoSyncOfflineRecordings', | ||
| // Display and phone behaviour | ||
| fcmRegistrationOrderKey, |
There was a problem hiding this comment.
P3: This key is push-registration ordering metadata, not a display or phone-behaviour preference, so it sits under the wrong heading for this list's documented policy. Give it its own comment that says why it survives sign-out (keeps the write order monotonic across sign-in cycles).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/pages/settings/sign_out.dart, line 36:
<comment>This key is push-registration ordering metadata, not a display or phone-behaviour preference, so it sits under the wrong heading for this list's documented policy. Give it its own comment that says why it survives sign-out (keeps the write order monotonic across sign-in cycles).</comment>
<file context>
@@ -32,6 +33,7 @@ const Set<String> kPreferencesKeptOnSignOut = {
'companionAssociationPrompted',
'autoSyncOfflineRecordings',
// Display and phone behaviour
+ fcmRegistrationOrderKey,
SharedPreferencesUtil.appearanceDefaultMigrationKey,
SharedPreferencesUtil.appearanceModeKey,
</file context>
| fcmRegistrationOrderKey, | |
| // Push registration write order: stays monotonic across sign-in cycles | |
| fcmRegistrationOrderKey, |
Failure-Class: FC-split-mutation-authority
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce5ad1cd98
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| final Future<bool> Function(String, String, bool Function()) _acknowledge; | ||
|
|
||
| Future<bool> export(ActionItemWithMetadata item, {required bool Function() canContinue}) async { | ||
| if (!_available() || item.exported || item.appleReminderId?.isNotEmpty == true || item.status != 'active') { |
There was a problem hiding this comment.
Allow completed tasks through Apple export
When a task is created with completed: true, CanonicalTaskCreate normalizes its status to completed, so this guard returns before creating a reminder. The new path passes the completion state to addReminder, and the commit’s docs and test expect completed tasks to sync; allow completed tasks here while still rejecting archived or cancelled tasks.
Useful? React with 👍 / 👎.
## What changed and why Home conversation rows now show an accessible task badge, and Search → Has tasks browses the full server result set with query/date/folder/star filters. Both surfaces use the same current, undeleted canonical task links; completed and manually linked tasks count, while stale summary suggestions do not. Closes #20620. Source-conversation task-row links remain the separate scope of #19859. The membership join and candidate scans are bounded and read-only. Signed cursors bind the account and filters and support sparse pages. Only selected task-bearing results can receive existing paid-access recovery. The change adds no task writes, recording-content writes, backfill or Firestore indexes. Backend deployment must precede the mobile release. Reuses the shared stale-HTTP-error guards and regressions from #24182 (`e53adc5fd0`, `6fc6816804`), retaining current main's newer streaming behavior. Existing task/conversation notifications invalidate badges; old-account responses cannot repaint or expire a replacement session. The architecture, checklist, release order and local rerun commands are in `backend/docs/conversation-task-filter.md`. ## Product invariants affected - INV-DATA-1: first-party data routing/auth authority is preserved; native QA is loopback-only with synthetic identity and an isolated Firestore emulator. - INV-UI-1 / INV-UI-3: shared conversation rows, accessible localized badges and existing search/date controls; Back preserves the original Home/search route. - INV-PERF-1: mounted-row reads are batched/bounded; failures cannot create rebuild/retry loops, and the production performance shell is regenerated. ## How it was verified - Native iPhone 17 Pro / iOS 26.5 simulator: production widgets and API decoders → real loopback FastAPI routes → real Firestore emulator. Passed Home badge, matches beyond loaded Home rows, starred intersection, injected 503/retry, 403 cached-result hiding/recovery, canonical deletion refresh and Back position restoration. Final screenshots were visually reviewed. - 3 real Firestore/HTTP integration cases passed; 11 focused backend filter regressions and 16 API-surface contract tests passed. Public, app-client and integration schema checks pass; the two new routes remain first-party only. - 611 query/contract tests passed; a separate compatibility/rate-limit batch passed 149 with one existing skip. These batches overlap and are not a unique-test total. - 34 focused Flutter regressions passed, including real provider notification binding, unchanged-selection no-op, per-row badge updates, old-account responses and error paths, access-refusal redaction, malformed responses, empty continuation, failed retry, search/date compatibility, discarded visibility preference and Android large-text/semantics checks. - All 31 selected hermetic mobile journeys passed (`make mobile-verify ARGS="fast --paths ..."`). - Shared HTTP ownership regressions passed with the earlier focused batch; implementation is unchanged since that run. Authentication, Redis and external search-provider I/O in local integration are synthetic. The native host reuses production conversation rows and the production filter page; it is not the full authenticated Home shell. No physical Android TalkBack run, production deployment, store release or customer confirmation is claimed. Android semantics/large text are exercised in Flutter widget tests. All 69 selected local repository preflight checks and all 27 production-shell performance checks passed. Keep draft until required current-commit CI passes. ## Main reconciliation Verified locally at `7c4941ff329aca0f4a046e2b39249aea90c3af6d`. Merged current main, preserved every existing locale entry and both task-filter translations, and regenerated Dart localizations for all 49 locales. The Home regression now asserts the combined `• 10m` label rendered by the row. - 30 focused Flutter tests passed, including the previously failing Home case, task-filter rendering and routing, presence invalidation and stale-session HTTP guards. - 27 backend tests passed through `backend/test.sh` across the task filter and OpenAPI contracts. - `python3 scripts/l10n.py check` passed. The previously recorded simulator and Firestore checks cover the same feature behavior. All 69 local preflight checks and the normal push gates passed. ## Tests `backend/tests/unit/test_conversation_task_filter.py`, `backend/tests/integration/test_conversation_tasks_emulator.py`, executable Firestore query drivers, `app/test/unit/conversation_task_presence_test.dart`, `app/test/unit/backend/http/conversation_tasks_api_test.dart`, `app/test/widgets/conversations_with_tasks_test.dart`, and `app/integration_test/conversation_tasks_e2e_test.dart` cover the new core and recovery paths. The local QA server rejects non-loopback emulators/cloud projects and never uses customer data. ## UI evidence Production conversation rows in the synthetic QA Home host, then the production Has tasks page; both on the iOS 26.5 simulator with local emulator data.   ## Failure class (fixes) Failure-Class: FC-raw-page-limit-before-visibility-filter ## Android CI toolchain The reconciliation CI exposed a shared runner mismatch. The Android compile and JVM test jobs now set Java 21 before Flutter setup, matching the existing emulator job. Gradle 8.14.2 ran successfully with Java 21 in a local smoke probe. Actionlint, five infrastructure guard tests and the CI budget refresh passed. CI follow-up source: `5503c2dcd8ab20c10bf3989d7077370b9e64d5f6`. Product source and the tested reconciliation are unchanged by the workflow-only follow-up. ## Account and pagination follow-up Owner checks fence 401 refresh and replay across account switches. Task search advances through raw index pages while public search retains visible-result pagination. Task browse and search read candidates without restoring access until the result page is selected. The 120/hour task-presence cap remains effective under the production rate multiplier. - 34 focused Flutter tests passed on `a78454f41c`, including account switches during 401 refresh and replay, new-owner badge reads while an old request is pending, invalid cursor recovery, large page decoding on the background worker and the episode navigation test. - 148 focused backend unit tests passed with one existing skip. - Five production HTTP and Firestore emulator tests passed. Browse and search unlocked only returned task-bearing conversations. Search advanced past a page of hidden, stale and malformed hits and preserved the public response's privacy. The next page unlocked its own returned row. - The production widgets and loopback Firestore flow passed again on the dedicated iPhone 17 Pro / iOS 26.5 simulator at `241c23c540`. Coverage includes the Home badge, global results, injected 503 and 403 responses, deletion refresh and return to the original Home position. The new backend regressions use synthetic auth, entitlement and search inputs. Line-Count-Exception: backend/routers/conversations.py | 2539 -> 2574 | Share authoritative search hydration and exact-reference handling with task discovery. Keep public redaction and pagination separate from the read-only candidate path. Five Firestore emulator tests passed again with synthetic auth. They cover the document cap across search hydration and retention of folder-curated conversations. All 57 affected backend unit and inventory tests passed.
Failure-Class: FC-split-mutation-authority
There was a problem hiding this comment.
5 issues found across 40 files
Confidence score: 3/5
AppleRemindersService.swiftrejects write-only Reminders access during export, so manual and automatic task exports can fail for users with that permission. Align the export guard with the permission flow.fcm_token_registration.dartdrops a tokenless refresh that arrives during an in-flight attempt, so a timezone change or wake can go unpersisted. Schedule a rerun after the pending attempt finishes.fcm_token_registration.dartcan return fromrefresh(token: ...)before a coalesced token rotation is persisted. Await the follow-up registration before completing the returned future.AppleRemindersService.swiftfetches all reminders for each task export, making bulk export work grow with both task count and total reminders. Reuse one lookup per batch.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/lib/services/integrations/apple_reminders_service.dart">
<violation number="1" location="app/lib/services/integrations/apple_reminders_service.dart:125">
P3: This catch logs only `error.runtimeType`, which is always `PlatformException` for native failures, so the native code and message are lost. Log `code` and `message` the way `addReminder` does. The log text also says "deferred" for failures that may be permanent, such as an owner mismatch.</violation>
</file>
<file name="app/lib/services/notifications/fcm_token_registration.dart">
<violation number="1" location="app/lib/services/notifications/fcm_token_registration.dart:89">
P2: A refresh without a token that arrives while an attempt is in flight is dropped. `_run` returns the pending future without scheduling a rerun, so a timezone change or wake after the attempt's zone read is not persisted until the next refresh. Mark any refresh that arrives during flight for a rerun, not only token offers.</violation>
<violation number="2" location="app/lib/services/notifications/fcm_token_registration.dart:103">
P2: A coalesced token rotation is launched unawaited, so `refresh(token: ...)` can complete before the rotated token is persisted. Await the follow-up from `whenComplete` so the returned registration future covers both attempts.</violation>
</file>
<file name="app/ios/Runner/AppleRemindersService.swift">
<violation number="1" location="app/ios/Runner/AppleRemindersService.swift:291">
P2: Write-only Reminders authorization now makes both manual and automatic task exports fail: the permission check accepts `.writeOnly`, but this new export guard requires read access and the request path never upgrades it to full access. Request full/read access for this task-aware lookup, or handle an initial write-only export separately while preserving recovery for read-capable access.</violation>
<violation number="2" location="app/ios/Runner/AppleRemindersService.swift:311">
P2: Each task export fetches every reminder in every calendar just to find one marker. Bulk export repeats this per task, so the cost grows with tasks times total reminders. Consider one lookup per batch, or a narrower predicate such as the target list, to avoid repeated full scans.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| if (pending != null) { | ||
| if (token?.isNotEmpty == true) _again = true; | ||
| return pending; | ||
| } |
There was a problem hiding this comment.
P2: A refresh without a token that arrives while an attempt is in flight is dropped. _run returns the pending future without scheduling a rerun, so a timezone change or wake after the attempt's zone read is not persisted until the next refresh. Mark any refresh that arrives during flight for a rerun, not only token offers.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/services/notifications/fcm_token_registration.dart, line 89:
<comment>A refresh without a token that arrives while an attempt is in flight is dropped. `_run` returns the pending future without scheduling a rerun, so a timezone change or wake after the attempt's zone read is not persisted until the next refresh. Mark any refresh that arrives during flight for a rerun, not only token offers.</comment>
<file context>
@@ -0,0 +1,175 @@
+ _retry = null;
+ if (token?.isNotEmpty == true) _offeredToken = token;
+ final pending = _inFlight;
+ if (pending != null) {
+ if (token?.isNotEmpty == true) _again = true;
+ return pending;
</file context>
| if (pending != null) { | |
| if (token?.isNotEmpty == true) _again = true; | |
| return pending; | |
| } | |
| if (pending != null) { | |
| _again = true; | |
| return pending; | |
| } |
| let owner = args["ownerUid"] as? String, !owner.isEmpty, | ||
| let taskID = args["actionItemId"] as? String, !taskID.isEmpty, | ||
| owner == UserDefaults.standard.string(forKey: "flutter.uid"), | ||
| hasRemindersAccess(readRequired: true) else { |
There was a problem hiding this comment.
P2: Write-only Reminders authorization now makes both manual and automatic task exports fail: the permission check accepts .writeOnly, but this new export guard requires read access and the request path never upgrades it to full access. Request full/read access for this task-aware lookup, or handle an initial write-only export separately while preserving recovery for read-capable access.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/ios/Runner/AppleRemindersService.swift, line 291:
<comment>Write-only Reminders authorization now makes both manual and automatic task exports fail: the permission check accepts `.writeOnly`, but this new export guard requires read access and the request path never upgrades it to full access. Request full/read access for this task-aware lookup, or handle an initial write-only export separately while preserving recovery for read-capable access.</comment>
<file context>
@@ -276,7 +281,59 @@ class AppleRemindersService {
+ let owner = args["ownerUid"] as? String, !owner.isEmpty,
+ let taskID = args["actionItemId"] as? String, !taskID.isEmpty,
+ owner == UserDefaults.standard.string(forKey: "flutter.uid"),
+ hasRemindersAccess(readRequired: true) else {
+ result(FlutterError(code: "EXPORT_UNAVAILABLE", message: "Task reminder export is unavailable", details: nil))
+ return
</file context>
| final delay = retryDelays[_retryIndex++]; | ||
| _retry = Timer(delay, () => unawaited(_run(resetBudget: false))); | ||
| } | ||
| }).whenComplete(() { |
There was a problem hiding this comment.
P2: A coalesced token rotation is launched unawaited, so refresh(token: ...) can complete before the rotated token is persisted. Await the follow-up from whenComplete so the returned registration future covers both attempts.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/services/notifications/fcm_token_registration.dart, line 103:
<comment>A coalesced token rotation is launched unawaited, so `refresh(token: ...)` can complete before the rotated token is persisted. Await the follow-up from `whenComplete` so the returned registration future covers both attempts.</comment>
<file context>
@@ -0,0 +1,175 @@
+ final delay = retryDelays[_retryIndex++];
+ _retry = Timer(delay, () => unawaited(_run(resetBudget: false)));
+ }
+ }).whenComplete(() {
+ if (!identical(_inFlight, work)) return;
+ _inFlight = null;
</file context>
| 'completed': item.completed, | ||
| }); | ||
| } catch (error) { | ||
| Logger.debug('Task reminder export deferred: ${error.runtimeType}'); |
There was a problem hiding this comment.
P3: This catch logs only error.runtimeType, which is always PlatformException for native failures, so the native code and message are lost. Log code and message the way addReminder does. The log text also says "deferred" for failures that may be permanent, such as an owner mismatch.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/services/integrations/apple_reminders_service.dart, line 125:
<comment>This catch logs only `error.runtimeType`, which is always `PlatformException` for native failures, so the native code and message are lost. Log `code` and `message` the way `addReminder` does. The log text also says "deferred" for failures that may be permanent, such as an owner mismatch.</comment>
<file context>
@@ -108,6 +109,24 @@ class AppleRemindersService {
+ 'completed': item.completed,
+ });
+ } catch (error) {
+ Logger.debug('Task reminder export deferred: ${error.runtimeType}');
+ return null;
+ }
</file context>
| Logger.debug('Task reminder export deferred: ${error.runtimeType}'); | |
| final detail = error is PlatformException ? '${error.code}: ${error.message}' : '${error.runtimeType}'; | |
| Logger.debug('Task reminder export failed: $detail'); |
Use the backend completed lifecycle state and share an in-flight EventKit lookup across task exports. Failure-Class: FC-split-mutation-authority
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ec23a13f4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let status = EKEventStore.authorizationStatus(for: .reminder) | ||
| if #available(iOS 17.0, *) { | ||
| return status == .fullAccess || status == .writeOnly || status == .authorized | ||
| return status == .fullAccess || status == .authorized |
There was a problem hiding this comment.
Preserve write-only access for existing reminder operations
On iOS 17+ when a user has .writeOnly Reminders authorization, this shared helper now reports no permission. Existing paths such as batch sync and reminder creation also use it, so the change disables those operations rather than limiting full-access requirements to the new task-identity lookup. Keep write-only access for existing operations and require full access only where reminders must be read.
Useful? React with 👍 / 👎.
| await writes; | ||
| if (generation != _sessionGeneration || !identical(writes, _defaultWrites)) return null; |
There was a problem hiding this comment.
Keep timed-out default writes from overtaking the latest choice
When two default changes overlap and the first PUT takes longer than statusTimeout, setSelectedApp's ConnectionRead times out without cancelling its HTTP request; its finally then completes _defaultWrites. This resolver can therefore read the newer choice before the older PUT lands, after which that late write can overwrite the backend default and route bulk export to the superseded app. Keep the actual request in the write chain or fence default writes server-side.
Useful? React with 👍 / 👎.
Fixes #24179.
Tasks created on iPhone could also create Apple Reminders solely because EventKit permission was granted, even with Todoist selected. Bulk Export chose the first connected app instead of the saved default. Both now respect the saved destination; unknown, failed or disconnected status never falls back to Apple. Cloud export no longer waits for an unrelated EventKit permission check. Failed status lookup offers Try Again; changed selection/account and concurrent-tap guards remain.
Existing authenticated sign-in/Home/AppShell hooks share a bounded notification registrar for delayed APNs, refused saves, permission/foreground wakes and token rotation. A rotation consumed during APNs acquisition also consumes its queued wake, preventing a redundant SDK read from replacing it with an older token. Later rotations still run next. Accepted receipts deduplicate writes; account changes revoke old work without admitting a replacement owner. Intercom remains best effort. Guarded HTTP auth-error side effects recheck their owner, including replay responses, while successful receipts retain their existing behavior.
Verified runtime source:
ac60c9f56f59bf0bb90bc9ce9d164bf58e44ceca, including main integration at6d2fd72991. Current head:f3d5f28f72d28da02acba354e5e6cb2c363fc818; its only changes align two no-op test/integration fixtures with the new optional permission-refresh parameter. Earlier runtime/simulator evidence remains applicable.make preflightpassed 45 selected checks; all 65 normal bounded push gates passed, including generated output and API compatibility. Final diff reviewed; no remaining reproducible code blocker found in these flows.The simulator and backend tests substitute auth identity, persistence and external Firebase/APNs/EventKit/Todoist I/O. They do not establish real lock-screen delivery, live Todoist grant validity, physical-device behavior or this customer's account recovery. External provider contracts/configuration are unchanged. The simulator's task-create stub is not automatic-worker evidence; the new backend HTTP tests provide that separate coverage.
Main reconciliation
Verified locally at
a729784e33cf9290107d97c7d06efd81200a1583. The task provider uses one saved-destination export path and forwards the completion state supported by main. Account guards still fence the status read, native write and acknowledgement. The two fixture callbacks now accept main’s optional idempotency key.backend/test.sh.All 47 local preflight checks and the normal push gates passed.
The prior
f3d5f28f72revision passed full mobile CI. Fresh CI is required for this merge commit.Release the backend before the mobile build to enforce ordered FCM registration. The optional request and Firestore fields need no backfill. Customer-specific automatic Todoist and notification confirmation remain Support follow-up, separate from merge readiness. No historical task migration or account mutation is included.
Architecture/checklist:
app/docs/task-export-and-push-registration.md. Private simulator screenshots, receipts and commands are recorded in the case's technical review evidence.Failure-Class: FC-split-mutation-authority
Invariants: INV-DATA-1 (existing production routing), INV-UI-1 and INV-UI-3 (existing localized controls/feedback/theme), INV-PERF-1 (asynchronous SDK/network waits).
INV-TASK-2: The Apple Reminders acknowledgement updates export metadata on an existing explicitly created task. The integration inventory records that writer and the task capture admission rules stay intact.
UI-Evidence: none -- Existing layout, theme and navigation retained; retry uses existing localized feedback controls. Running iOS simulator interaction screenshots are recorded separately.
Android CI toolchain
The reconciliation CI exposed a shared runner mismatch. The Android compile and JVM test jobs now set Java 21 before Flutter setup, matching the existing emulator job. Gradle 8.14.2 ran successfully with Java 21 in a local smoke probe. Actionlint, five infrastructure guard tests and the CI budget refresh passed.
CI follow-up source:
e4ab62dd7479b7c7e3d10ecc535eed3d088fce02. Product source and the tested reconciliation are unchanged by the workflow-only follow-up.Token ordering follow-up
Registration attempts reserve a device-local order before sending. Transport retries reuse it. Firestore compares the order and commits the token and schedule timezone in one transaction. Superseded writes receive 409 and identical retries preserve newer schedule settings. Older clients can continue registering without the optional field.
869e92c68b, the 25 affected registration, notification admission and HTTP guard tests also passed after moving the order reservation to the registration owner. Coverage includes overlapping reservations after clock rollback and sign-out, and 401 refresh and replay across account switches.The repository task-writer contract suite passed all 29 tests after registering the Apple Reminders acknowledgement.
Apple Reminders acknowledgement recovery
Automatic and manual bulk export use the same account-scoped task marker saved in EventKit. A retry finds the original reminder across readable lists and reuses its identifier while preserving edits. Concurrent exports share the in-flight lookup. Duplicate requests for one task use a single native save. Manual export reports success after the owner-scoped backend link is acknowledged.
All 39 focused Flutter tests and the full Flutter analyzer ratchet passed. The completed-task test now uses the lifecycle status returned by the backend. The unchanged task-writer contract passed all 29 tests.
The updated production export paths passed on a dedicated iPhone 16 Pro simulator with iOS 26.5 and real EventKit. A loopback backend saved the completed task's link and withheld its acknowledgement. The manual retry returned the original identifier and preserved the edited reminder and its completion. Concurrent exports of two distinct tasks with the same title kept separate reminders, and duplicate requests returned the same ID. A different account's request was rejected. Authentication and the backend were synthetic.