Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: An ended iOS Live Activity stays frozen on the Lock Screen when the app opens with no work running #16241

Closedjlipworth(GitHub profile, opens in a new tab) opened this issue 1 comment

Area

apps/mobile

Summary

#15254 dismisses ended Live Activities, but only inside LiveActivityFactory.start(), so only when the app creates a new card. Opening the app with no agent work running never calls start(). A card that iOS has already ended therefore stays frozen on the Lock Screen, and the app has no way to see it. #12656 handled this on every foreground. It was closed as superseded by #15254, but #15254 kept only the dismiss-before-start part.

Steps to reproduce

  1. iPhone, T3 Connect linked, Live Activity Updates on. Keep one card in use long enough for iOS to end it. Done is sent as an update, not an end, so one card is reused from turn to turn and can reach the ~8-hour limit in normal use. #15254's simulator method (end card A with the default dismissal policy) reproduces the ended state without the 8-hour wait.
  2. The card disappears from the Dynamic Island but stays on the Lock Screen showing its last content.
  3. Open T3 Code while no agent work is running on any linked environment, then lock the phone.

Expected behavior

Opening the app dismisses the ended card. A new card is armed the next time work runs, as it is today.

Actual behavior

The ended card stays on the Lock Screen for up to 4 hours, showing stale content that can no longer be updated. Opening the app any number of times doesn't remove it. Only swiping it away, or opening the app while a turn is running (which goes through start()), clears it.

Observed on a real iPhone: a frozen "Done" card on the Lock Screen, absent from the Dynamic Island when unlocked. New turns were arriving as plain push notifications instead of card updates, and reopening the app didn't change that. After swiping the card away, the next turn armed a fresh card and updates resumed. I didn't inspect the activity state on the device, so the ~8-hour limit is the most likely cause, not a confirmed one.

Root cause (main @ 25d5c7cacb)

  • getInstances() in expo-widgets only returns .active and .stale activities (expo/expo#48489). The foreground reconcile in apps/mobile/src/features/agent-awareness/remoteRegistration.ts (getAgentLiveActivities() at line 1084) never sees an ended card.
  • The only dismissal of ended cards is in LiveActivityFactory.start() in patches/expo-widgets@58.0.11.patch (line 28, from #15254).
  • The reconcile only calls start() when no card is visible and the relay snapshot has activeCount > 0 (remoteRegistration.ts:1117, :1138). An idle open skips it.

Suggested fix

Move the ended-card loop from start() into its own factory method in the expo-widgets patch (for example dismissEnded(), still scoped to the factory's name). Call it at the top of the foreground reconcile, before getAgentLiveActivities(), and keep calling it from start(). This restores the foreground half of #12656, which already had tests for this path. Like #15254, it needs a store build.

  • #12656: the original foreground dismissal, closed as superseded.
  • #15254: dismiss-before-start only.
  • #11939, #15728, #16229: Done cards that are never ended or removed stay alive long enough to reach the iOS limit.

Workaround

Swipe the card away on the Lock Screen, or open the app while a turn is running.

Version or commit

main @ 25d5c7cacb

  1. Note

    Grok responding on behalf of Julius.

    Triage

    Thanks again, @jlipworth! The pointers to #15254, #12656 and the upstream getInstances() change made this quick to trace.

    What I found

    • expo/expo#48489 made getInstances() return only .active and .stale activities, so an ended card that iOS still shows on the Lock Screen isn't in that list. getAgentLiveActivities() in apps/mobile/src/features/agent-awareness/agentLiveActivity.ios.ts is that call.
    • The expo-widgets@58.0.11 patch dismisses this factory's .ended activities only inside LiveActivityFactory.start(), right before Activity.request. Nothing else enumerates Activity.activities.
    • The foreground reconcile (refreshActiveLiveActivityRemoteRegistration in remoteRegistration.ts) calls startAgentLiveActivity only when getAgentLiveActivities() is empty and the relay snapshot has activeCount > 0. Opening the app with no running work never reaches start(), so the ended card stays.
    • Opening while a turn is running, or sending work from the phone (armAgentAwarenessLiveActivityForLocalWorkNow), does go through start(), which is why the card clears in those cases. Swiping the card away also works as a stopgap.
    • Sign-out has the same gap: endLocalLiveActivities only ends what getInstances() returns.
    • #12656 dismissed ended cards at the top of this reconcile and on sign-out. It was closed as superseded by #15254, which kept only the dismiss-before-start half.
    • #11939, #15728 and #16229 explain why a card can stay up long enough to hit the iOS limit. Those are separate; this one is the leftover card after iOS has already ended it.

    Likely fix area

    • One option is the split suggested in the report: a factory-scoped dismissEnded() in the expo-widgets@58.0.11 patch (still filtered by content.state.name and .ended, using .immediate dismissal), called at the top of refreshActiveLiveActivityRemoteRegistration before getAgentLiveActivities(), kept in start(), and reused in endLocalLiveActivities.
    • A dismiss failure should probably be logged without blocking registration of a visible card. Binaries without the new native method would throw, so that call likely needs a guard.
    • This needs a store build. As noted in #15254, the Expo fingerprint doesn't hash root patches/, so an OTA wouldn't ship the native method. #12656's cleanup-before-discovery tests may be reusable.

    A maintainer will decide on the fix direction.

  2. juliusmarminge added labelsbug

  3. juliusmarminge added labelsvia-triage

  4. juliusmarminge closed this

Sign in to join this conversation.