Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(relay): an iPad no longer gets a Done alert for every unrelated publish #15015

Mergedjuliusmarmingemerged 0 commits intomain fromt3code/relay-push-spammerged by juliusmarminge View on GitHub

juliusmarmingecommented

iPads and iPhones using regular push notifications could receive the same Done alert whenever an unrelated thread published or a subagent was removed. The fallback selected the first row of the user’s activity aggregate, which could still contain a different thread’s recent completion.

Build fallback alerts from the published thread’s state. The publisher now uses one APNs delivery path, carrying that state separately from the Live Activity aggregate. Tombstones and unrelated running updates stay silent; an unrelated thread needing input gets its own text and deep link. Notification-only environment links still work, and their notification setting gates iOS fallback pushes. Existing aggregate Live Activity selection, replay, delivery-time checks, and Android behavior are preserved.

Maintainer takeover of the original work by @juliusmarminge in #15015. Retained the original history, merged current main, replaced argument-only tests with publisher-to-signed-queue coverage, and removed the parallel notification-only aggregate path and redundant comments.

Verification on headless Linux:

  • Before → after: 111 → 111 passing tests across ApnsDeliveries.test.ts (51), AgentActivityPublisher.test.ts (16), and FcmDeliveries.test.ts (44). Current main has 110. The original already added only one net test, so the cleanup strengthens observable coverage without growing the suite.
  • Regression proof: with main’s two production files, the selected three cases fail: four stale Done alerts are queued, and link opt-out still queues alerts. Restoring this implementation makes all three pass. The regression also checks an unrelated input notification’s identity, body, and deep link.
  • pnpm exec vp test run infra/relay/src/agentActivity/{ApnsDeliveries,AgentActivityPublisher,FcmDeliveries}.test.ts: 111 passed.
  • Relay-only typecheck and lint/formatting on the four changed files passed.
  • Independent whole-PR adversarial review: GPT-6-Sol and Claude Opus 5.5, round 1. Both found no correctness blockers; optional typing and delivery-count logging suggestions were left out of this focused fix.

This is nonvisual relay behavior; the signed-queue integration tests provide before/after proof. No production relay was deployed and no live APNs, physical iOS/iPadOS, Android, macOS, Windows, or Electron desktop run was performed. A relay deploy and device smoke test remain for a human. This does not deduplicate repeated publication of the same completed state or change aggregate Live Activity alert policy.

Implemented and tested with GPT-6.1-Sol and GPT-6-Astra through the Codex harness in T3 Code; independently reviewed by GPT-6-Sol (Codex) and Claude Opus 5.5 (Claude Agent).

Fixes pingdotgg/t3code#28932

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

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

      Approvability

      Verdict: Approved at 24406cf

      Macroscope's review found this PR approvable — Fallback Apple notifications now use the currently published thread instead of potentially unrelated aggregate activity. Existing notification preferences, freshness checks, and replay suppression remain in place, keeping the change narrowly scoped.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire4.9 KiB4.9 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.7 KiB3.7 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.1 KiB1.1 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.4 KiB20.4 KiB0 B (0.0%)29.3 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire4.9 KiB4.9 KiB−41 B (−0.8%)6.8 KiB✅
      ClaudeThread snapshot wire3.7 KiB3.7 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB−41 B (−3.4%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded20.8 KiB20.7 KiB−41 B (−0.2%)29.3 KiB✅
      ClaudeLive turn messages21−1 (−50.0%)8✅

      Baseline: 22e9d35 · PR result: 1a7f6e7 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 106.1 KiB
      • Claude decoded thread snapshot: 106.4 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    5. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      APNs fallback notifications now use the published agent activity state instead of selecting an activity from the aggregate. AgentActivityPublisher passes that state through one APNs delivery call. Android delivery remains unchanged.

      Changes: State-Based APNs Delivery

      Layer / File(s)Summary
      Select and enqueue notifications from thread state
      infra/relay/src/agentActivity/ApnsDeliveries.ts, infra/relay/src/agentActivity/ApnsDeliveries.test.ts
      sendForTarget accepts optional thread state. Fallback notifications use that state and skip missing, expired, or non-alertable states. The separate push-notification operation is removed. Tests cover state-based selection and alert payloads.
      Pass published state through publisher delivery
      infra/relay/src/agentActivity/AgentActivityPublisher.ts, infra/relay/src/agentActivity/AgentActivityPublisher.test.ts
      The publisher uses one APNs sendForTarget call and passes state only when notifications are enabled. Tests check queued notification content and the disabled-notification case. Android delivery remains unchanged.

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

      Change: Bug fix · Severity of issue fixed: Medium

      Possibly related issues

      • pingdotgg/t3code#25582: This change updates the notification-only fallback path, but does not add a phase-transition guard for title-only republishing.
      • pingdotgg/t3code#11938: This change uses published state for fallback notifications, but does not deduplicate repeated completed states.

      Suggested reviewers: ryanrhughes, t3dotgg

      Merge Risk: Minimal · up to 24406

      This change stops unrelated publishes from producing Done alerts on iOS, and unrelated threads that need input now get their own alert. No merge-blocking risk was found. Deployment and a device smoke test are still pending, as the author notes.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title clearly and concisely describes the primary fix: preventing unrelated publishes from triggering repeated Done alerts on iPads.
      Description checkPassedThe description covers the problem, implementation, scope, linked issue, verification results, limitations, and human follow-up. It provides specific tests and observed outcomes instead of only statin…
      Linked Issues checkPassedIssue #28932 requires fallback alerts to use the published thread, remain silent for starting/running states, honor completion and attention settings, and avoid alerts when notifications are disabled.…
      Out of Scope Changes checkPassedThe changed production code stays within issue #28932. It replaces the notification-only aggregate path with state-based fallback selection and updates the shared APNs delivery path. The changed tests…
      Full details: Description check

      Explanation

      The description covers the problem, implementation, scope, linked issue, verification results, limitations, and human follow-up. It provides specific tests and observed outcomes instead of only stating that tests passed.

      Full details: Linked Issues check

      Explanation

      Issue #28932 requires fallback alerts to use the published thread, remain silent for starting/running states, honor completion and attention settings, and avoid alerts when notifications are disabled. AgentActivityPublisher.ts passes the published state separately from the Live Activity aggregate. ApnsDeliveries.ts builds fallback payloads from that state and applies shouldAlertForActivity, expiry checks, and notification preferences. The tests cover stale aggregate rows, unrelated running and waiting states, input and approval alerts, notification-only links, and notification opt-out. Aggregate Live Activity and Android paths remain separate.

      Full details: Out of Scope Changes check

      Explanation

      The changed production code stays within issue #28932. It replaces the notification-only aggregate path with state-based fallback selection and updates the shared APNs delivery path. The changed tests provide publisher-to-queue and APNs regression coverage for that behavior. No unrelated product behavior is demonstrated.

      Finishing Touches

      Generate docstrings

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

      • Commit to this branch
      • Create a new PR
      • Autopilot · 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 1a7f6e7249eecbb1d68b0e6fb043c22b5e906c9a and 24406cf0bd497dbdb4b54ce791b8dc450842c495.

      Files selected for processing: 4

      • infra/relay/src/agentActivity/AgentActivityPublisher.test.ts
      • infra/relay/src/agentActivity/AgentActivityPublisher.ts
      • infra/relay/src/agentActivity/ApnsDeliveries.test.ts
      • infra/relay/src/agentActivity/ApnsDeliveries.ts

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

    6. juliusmarminge assignedjuliusmarminge

    7. Taking over this one as maintainer for batch ssh-relay-remote-12. I’ll retain the original branch and author history, merge current main, simplify the regression coverage, and run independent implementation and adversarial review passes. No merge is planned.

    8. @@ -508,3 +511,4 @@
      508511 },
      509512 );
      510513
      514+ it.effect("push-only alerts describe the published thread, never a stale aggregate row", () => {
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      This repeats the push-only delivery setup in the preceding test. Could you fold these stale-aggregate cases into that existing test instead of adding a separate it?

      Posted via Macroscope — Test Signal
    9. The automated pipeline stopped on this pull request and will not merge it:

      the proof has no capture anyone can open:

      • Repeated Input and Done alerts on base were not observed.
      • Suppression of unrelated running updates and state clears on head was not verified.
      • Eligible notifications' text and deep links, and disabled-environment notification suppression, remain unverified.
      • Real proof requires isolated authenticated relays running both commits, valid APNs credentials, and a registered APNs-capable iOS device. The scenario fixture's direct pairing does not exercise the hosted relay.

      It stays open for a person to finish or close.

    10. tanstack-source added labelsbug

    11. juliusmarminge merged this51e1346

    12. juliusmarminge closed this

Sign in to join this conversation.