Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): show one Android notification per thread completion #27699

Mergedshivamhwp(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/27699/headmerged by juliusmarminge View on GitHub

Closes https://github.com/pingdotgg/t3code/issues/27447

Android showed both an alert and a retained Done card for one thread completion. Hide the matching single-thread terminal card only when its alert is shown. Preserve the card when alerts are muted, and prevent retries or reordered delivery from restoring the duplicate.

This qualifies for CONTRIBUTING.md's focused obvious-bug exception. It overlaps https://github.com/pingdotgg/t3code/pull/24933, which retains both cards when both channels are enabled. No code was borrowed.

Current verification

Head 8179efc81b44e1b962e41da8a73feee413ec7009, audited live main 7462b16f369d36af51af2e3c50bc35b45cd7284a. Rebased the four unchanged patches onto d694c44d07842a2b403b6c4dd98950ba6e1c6339 after auditing the 491-file base move. Main still contains the duplicate-card path. The native dependency and navigation changes received a fresh build and integrated pass. Subsequent main changes concern secret-provider references and leave this path unchanged. Merge-tree is clean. Required CI passes, and there are no unresolved review findings.

vp run check:changed d694c44d07842a2b403b6c4dd98950ba6e1c6339, 14 registration tests, 16 relay tests and 23 RPC tests pass at this head. A fresh independent source and evidence review passed. The complete notification module and tests remain byte-identical to the historical 119-case native run linked below.

The full T3 Code Dev app ran current-head JavaScript on POCO F4 c39d2814, Android 14. The supported native prepare workflow exited 0 on corex with fingerprint fd9dce9ea9f46dc061ad9fddf638b468e2772981. Built and installed APK SHA-256 match: 493371aaf9aaeb3c7a9ded980ab57c828f1d6cd556e1a8c382638b3d394a1b73.

Real isolated Replay turns 12 and 13 completed while the app was backgrounded. Production awareness projection, aggregation and FCM payload construction fed a disposable transport bridge into the installed app's actual AgentMessagingService.onMessageReceived(RemoteMessage). Both native notification flags, OS permission and channels were enabled; the alert channel had vibration enabled. Seven payloads matched native deliveries in turn 12, eight in turn 13. Each completion left one Done alert card. Exact retry and activity-only replay preserved its ID and post time, with zero extra motor events. Android reported one new finished positive-amplitude NOTIFICATION vibration event per completion, 956 ms and 955 ms respectively. Both validators passed, and both instrumentation runners finished successfully with code -1.

The turn 13 recording shows the actual full app, the move to Home, and the resulting shade. The turn was triggered through the isolated server CLI while backgrounded. Its initial app view includes the earlier workspace-error message from turn 11 and the successful turn 12 below it. Turn 11 failed because its disposable workspace had been removed; restoring that directory allowed turns 12 and 13 to complete. The failed attempt is excluded from their validation.

https://github.com/user-attachments/assets/e44bec6f-7e51-46ed-8475-62120047e83e

One completion card, turn 12; unrelated system notifications cropped

Exact current-head build, test results and proof boundaries

Actual validators, raw motor records, check output and independent review

Native flags were enabled through the disposable helper after app startup. Unverified live path: normal Connect login, the app's notification Settings switches and device registration, and authenticated live relay/FCM transport. No personal account was signed in. Audible sound, human tactile observation and Android 16 promoted-chip behavior remain unverified. Motor proof is physical-phone OS telemetry, without a microphone or external sensor. Web, desktop and iOS source are unchanged.

Phone cleanup restored the original APK and all 43 persistent-file hashes, removed the helper, and restored DND/silent mode. The reinstall removed Android keystore keys, so the restored dev client's encrypted connections may need re-pairing.

Reused regression proof and historical before

Boat job j_6n25jlpx7dr2eirac2of exited 0 at 244818107379f433d12c8b7d2b51cd32412b9ef1: 119 native cases passed, none skipped; ktlint and detekt passed. The complete native module and tests are byte-identical at this head. Substituting base 9def583f8e315f644708501ebcf1f3d4bb320444's production source, still unchanged on current main, reproduced eight regression failures across API 24, 26, 33 and 36. That focused harness stubs the Expo Firebase superclass; the full-app proof above exercises the actual installed service separately.

119 native cases and baseline failures; exact tested commit retained

Historical before on POCO M3 Pro, Android 13: the full app produces an alert and a Done card with both native flags enabled, using the same controlled transport boundary. Its notification-module fingerprint matches main, f0068e17c80b320115bc11e27375f6d482325b5b. APK hash e59759d57dd9f3eaf561fd36a8643b55f3b6e9e2575b3c8c7d63fd86f0522381. The original APK build commit is unknown; this is not a complete APK claimed to be built at the current base. The video shows the actual thread, background transition, Replay completion and shade.

Historical before, full app with two cards

https://github.com/user-attachments/assets/410b8cf8-2a13-4929-beb6-3621368403c3

Implemented by Claude Opus 5.5 through T3 Code; investigated, tested and reviewed by GPT-6.1 Sol through Codex.

    1. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at aea673e

      Macroscope's review found this PR approvable — This removes a redundant Android completion card when the matching alert is shown, while retaining fallback cards when alerts are blocked. The change is confined to notification presentation and local replay tracking, with relevant native and device verification reported.

      No code changes detected at 8179efc. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    2. github-actions[bot](GitHub profile, opens in a new tab) added labels📱 Native Change

    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review.

      Walkthrough

      Android notification handling now uses whether an alert was posted to determine whether a matching single-thread terminal activity card is covered. Covered cards are canceled, and stale updates cancel a card only when its stored terminal is covered. Tests cover duplicate alerts, blocked channels, unrelated activity, and reordered updates.

      Changes: Android notification handling

      Layer / File(s)Summary
      Alert eligibility and terminal identity
      apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/AgentNotifications.kt
      receive passes the alert-posting result to updateActivity. showAlert returns false for duplicate alerts and for alerts suppressed by an on-screen thread or blocked channel. Terminal identities require a completed or failed activity with one row and an absolute expiry.
      Coverage state and card behavior
      apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/AgentNotifications.kt, apps/mobile/modules/t3-agent-notifications/android/src/test/java/expo/modules/t3agentnotifications/AgentNotificationsTest.kt
      Activity updates persist covered terminal state and cancel covered cards. Shared Robolectric setup moves into AgentNotificationsFixture. Completion tests cover duplicate and replayed messages, blocked channels, unrelated activity, and reordered updates.

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix · Severity of issue fixed: Low

      Possibly related issues

      • pingdotgg/t3code#27447 — The change covers and cancels the matching single-thread activity card when a completion alert is posted, addressing the reported duplicate cards.

      Suggested labels: bugfix, size:M

      Suggested reviewers: juliusmarminge

      Merge Risk: Minimal · up to aea67

      No actionable issue remains from the reviewed Android notification changes; this is mergeable after normal checks.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title is concise, uses the expected conventional format, and clearly identifies the Android notification change.
      Linked Issues checkPassedIssue #27447 requires one visible Android completion notification and one alert event. receive() passes the result of showAlert() to updateActivity(). For a new, unblocked, background alert, `up…
      Out of Scope Changes checkPassedThe production change is limited to Android agent notification coordination. The test changes add completion and delivery-order coverage and extract a shared fixture. These changes support issue #2744…
      Description checkPassedThe description covers the problem, change, scope, verification, evidence, and agent attribution. It does not use all required section headings, but the information is mostly complete.
      Full details: Linked Issues check

      Explanation

      Issue #27447 requires one visible Android completion notification and one alert event. receive() passes the result of showAlert() to updateActivity(). For a new, unblocked, background alert, updateActivity() marks the matching single-row terminal card as covered and cancels it. The card remains for muted channels, suppressed alerts, grouped results, and unrelated paths. showAlert() deduplicates alert_id; postAlert() uses the alert channel with Notification.DEFAULT_ALL, while the activity channel remains silent. The new completion tests cover repeated delivery, missing alert fields, blocked channels, unrelated cards, and reordered delivery.

      Full details: Out of Scope Changes check

      Explanation

      The production change is limited to Android agent notification coordination. The test changes add completion and delivery-order coverage and extract a shared fixture. These changes support issue #27447. No unrelated product area or platform behavior changed.

      Finishing Touches

      Generate docstrings

      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 5b357b3b894e8255ebd3049c8ef826b93c20c9e4 and aea673e2a25a5be9854d1c6c8ff0632282fd3a78.

      Files selected for processing: 2

      • apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/AgentNotifications.kt
      • apps/mobile/modules/t3-agent-notifications/android/src/test/java/expo/modules/t3agentnotifications/AgentNotificationsTest.kt

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

    4. juliusmarminge merged this81922e6

    5. juliusmarminge closed this

Sign in to join this conversation.