fix(mobile): dismiss ended Live Activities on foreground #12656
main fromrefs/pull/12656/head·opened View on GitHubWhat Changed#
Dismiss ended T3 Code Live Activities when the iOS app refreshes its activity registration, before arming an activity for local work, and when signing out. The cleanup leaves active and stale activities available for their existing update-token registration.
Extend the existing expo-widgets patch with a factory-scoped native dismissal method. Await cleanup before discovering the current activity so a card created by another foreground path during that wait is reused. Cleanup errors are logged without preventing registration of the active card. Local arming captures the current registration generation and cancels if sign-out, account replacement, or provider teardown occurs while preferences or native cleanup are pending. A same-account token refresh still allows arming to finish.
Why#
A reported iPhone showed a small “Agent work completed” card above the current aggregate card. The small card remained for more than five minutes and survived reopening T3 Code, while new updates continued to arrive on the large card.
expo-widgets only returns active/stale activities from getInstances(). Consequently, the existing duplicate-card cleanup cannot see an ended activity that iOS still displays on the Lock Screen. Expo documents this deliberate exclusion in https://github.com/expo/expo/pull/48489. The native dismissal pass enumerates matching ended activities directly and ends them with immediate dismissal.
This change requires a new native iOS build; an OTA JavaScript update alone cannot add the native method. The failure-handling path keeps registration working when the native method is unavailable.
Validation#
- 50 tests pass in
remoteRegistration.test.tsandliveActivityPreferences.test.ts. - The two new cleanup-order regression tests fail against the original registration implementation and pass with this change.
- Six session-cancellation regression cases fail with the generation guards removed and pass with them restored; a seventh confirms same-account token refresh still permits arming.
- Mobile TypeScript check and lint of the four changed TypeScript files pass.
- Native iOS development-client build and installation pass with Xcode 27.0 (27A266a).
- Simulator verification passes on iPhone 18 Pro / iOS 27.0: the original registration code leaves the completed card visible; the PR code dismisses it while preserving the active ActivityKit ID. A subsequent local content update succeeds and appears on the remaining card.
The change applies to iOS registration, foreground refresh, local arming, and activity shutdown. The non-iOS adapter supplies a no-op; no server, provider, or wire-contract changes are needed.
UI Changes#
Verified with a temporary simulator fixture that creates real activities using the production T3 widget and invokes the production registration code. The before run uses remoteRegistration.ts from the PR parent; the after run uses the original fix commit 0b2006d. The subsequent session-cancellation guard is covered by the focused regression tests above; the native patch is unchanged. Both runs use the rebuilt native binary (the original JS does not call the new native cleanup method). No test-only code is committed.
| Before: completed card remains alongside aggregate | After: one aggregate, updated after cleanup |
|---|---|
![]() | ![]() |
Videos: before clip, cleanup and successful update. Verification notes and fixture source are hosted as evidence assets on the contributor fork; no PR assets are committed.
The active ActivityKit ID is unchanged across both runs and after the successful update. Returning to the app exercises foreground registration without replacing the active card. The fixture uses a token provider returning null, so this verifies local ActivityKit cleanup and update continuity, not remote APNs delivery or cloud authentication.
The build used a temporary checkout without spaces because the existing Expo Widgets build script fails on the original Coding Projects path. CocoaPods 1.17.0 was installed as a prerequisite. No build workaround is included in this PR.
Checklist#
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes
- I included a video for animation/interaction changes
Model: GPT-6. Harness: Codex.
Summary by CodeRabbit#
- Bug Fixes
- Ended Live Activities are automatically dismissed before activities are started, refreshed, or when signing out.
- Prevents duplicate Live Activities during refreshes and concurrent updates.
- Active Live Activity registration continues even if cleanup fails.
- Pending activity setup is canceled when preferences are disabled or the session changes.
- Live Activity presentation is improved across supported widget rendering modes and device capabilities.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
@coderabbitai resume
⚠️ Action not completed
Already reviewed the last commit. Use
@coderabbitai full reviewto rerun a review of the entire changeset.@coderabbitai full review
✅ Action performed
Full review finished.
juliusmarminge added labelsmacroscope-review
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This focused fix adds native iOS Live Activity dismissal and changes foreground/sign-out behavior across account-session transitions. Because those transitions govern account-associated lock-screen content, the change warrants human review despite its limited scope and added regression tests.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Note
Grok responding on behalf of Julius.
Superseded by #15254, which landed the same fix in
LiveActivityFactory.start()on the currentexpo-widgets@58.0.11patch: dismiss this factory's ended activities before requesting a new card so an expired Lock Screen zombie no longer stacks beside the live one.Closing this PR rather than merging — do not merge. Thanks for the earlier patch work on the older
expo-widgets@57tree.juliusmarminge closed this
Sign in to join this conversation.


No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
d47a07ae-d773-4310-b36a-9a8d17dacb44📥 Commits
Reviewing files that changed from the base of the PR and between 7445aa733ada33e45289e5aa5055f79142556513 and 29f6998be47fa2909f8657adcc77414476bd9085.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml📒 Files selected for processing (5)
apps/mobile/src/features/agent-awareness/agentLiveActivity.ios.tsapps/mobile/src/features/agent-awareness/agentLiveActivity.tsapps/mobile/src/features/agent-awareness/remoteRegistration.test.tsapps/mobile/src/features/agent-awareness/remoteRegistration.tspatches/expo-widgets@57.0.15.patchIncluded review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Walkthrough#
The change adds ended Live Activity dismissal to Expo Widgets and integrates cleanup into agent-awareness registration, local arming, and activity-ending flows. Tests cover ordering, failures, concurrent discovery, session changes, and token refresh.
Changes#
Agent Live Activity cleanup
patches/expo-widgets@57.0.15.patchdismissEndedInstances(), forwards it to iOS, dismisses ended activities on supported versions, and adds Live Activity environment fields.apps/mobile/src/features/agent-awareness/agentLiveActivity.ios.ts,apps/mobile/src/features/agent-awareness/agentLiveActivity.ts,apps/mobile/src/features/agent-awareness/remoteRegistration.tsapps/mobile/src/features/agent-awareness/remoteRegistration.test.tsPriority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Sequence Diagram(s)#
Suggested reviewers:
juliusmarmingeMerge Risk: ⚪ Minimal · up to
29f69Provider remounts preserve the signed-in user’s Live Activity as intended, while sign-out still cleans it up. No actionable merge-blocking risk remains.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.