@@ -83,6 +83,11 @@ const activityPushTokenListeners = new WeakSet<LiveActivity<AgentActivityProps>>
8383// foreground after real time away still triggers a replay. Cleared on
8484// sign-out/identity change alongside the device registration state.
8585const ACTIVITY_TOKEN_REREGISTER_INTERVAL_MS = 60_000 ;
86+ // Locally started activities carry the same stale window the relay puts on
87+ // every push (STALE_AFTER_SECONDS in ApnsClient.ts), so a card whose relay
88+ // registration never lands still degrades instead of looking alive forever.
89+ const LIVE_ACTIVITY_STALE_AFTER_MS = 10 * 60_000 ;
90+ const liveActivityStaleDate = ( ) => new Date ( Date . now ( ) + LIVE_ACTIVITY_STALE_AFTER_MS ) ;
8691const registeredActivityPushTokens = new Map < string , number > ( ) ;
8792let androidDeviceReplayedAt : number | null = null ;
8893let pushTokenSubscription : { remove : ( ) => void } | null = null ;
@@ -527,25 +532,28 @@ function armAgentAwarenessLiveActivityForLocalWorkNow(input: {
527532 return ;
528533 }
529534 const nowIso = new Date ( Date . now ( ) ) . toISOString ( ) ;
530- const activity = startAgentLiveActivity ( {
531- title : "T3 Code" ,
532- subtitle : "Agent work in progress" ,
533- activeCount : 1 ,
534- updatedAt : nowIso ,
535- activities : [
536- {
537- environmentId : "" ,
538- threadId : "" ,
539- projectTitle : input . projectTitle ,
540- threadTitle : input . threadTitle ,
541- modelTitle : "" ,
542- phase : "starting" ,
543- status : "Connecting" ,
544- updatedAt : nowIso ,
545- deepLink : "/" ,
546- } ,
547- ] ,
548- } ) ;
535+ const activity = startAgentLiveActivity (
536+ {
537+ title : "T3 Code" ,
538+ subtitle : "Agent work in progress" ,
539+ activeCount : 1 ,
540+ updatedAt : nowIso ,
541+ activities : [
542+ {
543+ environmentId : "" ,
544+ threadId : "" ,
545+ projectTitle : input . projectTitle ,
546+ threadTitle : input . threadTitle ,
547+ modelTitle : "" ,
548+ phase : "starting" ,
549+ status : "Connecting" ,
550+ updatedAt : nowIso ,
551+ deepLink : "/" ,
552+ } ,
553+ ] ,
554+ } ,
555+ liveActivityStaleDate ( ) ,
556+ ) ;
549557 if ( ! activity ) {
550558 return ;
551559 }
@@ -1131,13 +1139,16 @@ export function refreshActiveLiveActivityRemoteRegistration(): Effect.Effect<
11311139 const aggregate = snapshot . aggregate ;
11321140 const primed = yield * Effect . try ( {
11331141 try : ( ) =>
1134- startAgentLiveActivity ( {
1135- title : aggregate . title ,
1136- subtitle : aggregate . subtitle ,
1137- activeCount : aggregate . activeCount ,
1138- updatedAt : aggregate . updatedAt ,
1139- activities : aggregate . activities ,
1140- } ) ,
1142+ startAgentLiveActivity (
1143+ {
1144+ title : aggregate . title ,
1145+ subtitle : aggregate . subtitle ,
1146+ activeCount : aggregate . activeCount ,
1147+ updatedAt : aggregate . updatedAt ,
1148+ activities : aggregate . activities ,
1149+ } ,
1150+ liveActivityStaleDate ( ) ,
1151+ ) ,
11411152 catch : ( cause ) =>
11421153 new AgentAwarenessOperationError ( {
11431154 operation : "prime-live-activity" ,
0 commit comments