@@ -29,6 +29,7 @@ import {
2929 alertForActivityRows ,
3030 attentionTransitionRows ,
3131 hiddenEnvironmentIds ,
32+ sameEnvironmentIds ,
3233 terminalTransitionRows ,
3334 shouldAlertForActivity ,
3435} from "./agentActivityAlerts.ts" ;
@@ -200,6 +201,7 @@ const make = Effect.gen(function* () {
200201 if ( ! target ) return ;
201202 const preferences = decodePreferences ( target . preferences_json ) ;
202203 if ( Option . isNone ( preferences ) ) return ;
204+ const currentHiddenEnvironmentIds = hiddenEnvironmentIds ( preferences . value ) ;
203205
204206 // Re-read at consumption to honor current links, tokens, preferences, and thread states.
205207 const states = preferences . value . liveActivitiesEnabled
@@ -288,7 +290,14 @@ const make = Effect.gen(function* () {
288290 }
289291 const displayedAggregate = preferences . value . liveActivitiesEnabled ? aggregate : null ;
290292 const active = ( displayedAggregate ?. activeCount ?? 0 ) > 0 ;
291- if ( ! displayedAggregate && ! alert && ! previousAggregate && job . state !== null ) return ;
293+ if (
294+ ! displayedAggregate &&
295+ ! alert &&
296+ ! previousAggregate &&
297+ job . state !== null &&
298+ sameEnvironmentIds ( target . last_hidden_environment_ids , currentHiddenEnvironmentIds )
299+ )
300+ return ;
292301 const data : Record < string , string > = {
293302 t3_kind : "agent_activity" ,
294303 device_id : job . deviceId ,
@@ -334,9 +343,7 @@ const make = Effect.gen(function* () {
334343 kind : active ? "live_activity_update" : "live_activity_end" ,
335344 // Retain terminal rows as the baseline so finished-card replays cannot alert again.
336345 aggregate : preferences . value . liveActivitiesEnabled ? aggregate : null ,
337- hiddenEnvironmentIds : preferences . value . liveActivitiesEnabled
338- ? hiddenEnvironmentIds ( preferences . value )
339- : null ,
346+ hiddenEnvironmentIds : currentHiddenEnvironmentIds ,
340347 deliveredAt : DateTime . formatIso ( now ) ,
341348 } ) ;
342349 }
0 commit comments