Skip to content

Commit 11d52d1

Browse files
nicofishmanclaude
andcommitted
fix(relay): dismiss read Android alerts with notifications turned off
The visited state was only read behind the notifications preference, so alerts posted before the user turned notifications off stayed visible. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 6025be7 commit 11d52d1

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

‎infra/relay/src/agentActivity/FcmDeliveries.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,22 @@ describe("dismissing read threads", () => {
758758
expect(h.sent[0]?.data.dismiss_group).toBe(visitedGroup);
759759
}).pipe(Effect.provide(h.layer));
760760
});
761+
762+
it.effect("dismisses even after notifications were turned off", () => {
763+
const h = harness();
764+
return Effect.gen(function* () {
765+
const delivery = yield* FcmDeliveries.FcmDeliveries;
766+
yield* delivery.process(h.job);
767+
h.current.target.preferences_json = encodeJson({
768+
...preferences,
769+
notificationsEnabled: false,
770+
});
771+
h.current.state = { ...state, phase: "completed", visited: true };
772+
yield* delivery.process({ ...h.job, state: h.current.state });
773+
expect(h.sent.at(-1)?.alert).toBe(false);
774+
expect(h.sent.at(-1)?.data.dismiss_group).toBe(visitedGroup);
775+
}).pipe(Effect.provide(h.layer));
776+
});
761777
});
762778

763779
describe("delivery policy regressions", () => {

‎infra/relay/src/agentActivity/FcmDeliveries.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,18 +225,21 @@ export const make = Effect.gen(function* () {
225225
// Deletion jobs can observe another thread's newly completed state. They
226226
// update the card, but must leave that transition for its own alert job.
227227
let acknowledgeAggregate = job.state !== null || job.replay === true || aggregate === null;
228+
const state = job.state
229+
? yield* rows.getForUserThread({
230+
userId: job.userId,
231+
environmentId: job.state.environmentId,
232+
threadId: job.state.threadId,
233+
})
234+
: null;
235+
// Also clears alerts posted before notifications were turned off.
236+
if (state?.visited) dismissGroup = alertGroup(state);
228237
if (job.state && preferences.value.notificationsEnabled) {
229-
const state = yield* rows.getForUserThread({
230-
userId: job.userId,
231-
environmentId: job.state.environmentId,
232-
threadId: job.state.threadId,
233-
});
234238
if (
235239
!previousAggregate &&
236240
(!state || state.phase !== job.state.phase || state.updatedAt !== job.state.updatedAt)
237241
)
238242
return;
239-
if (state?.visited) dismissGroup = alertGroup(state);
240243
const link = yield* links.getForUser({
241244
userId: job.userId,
242245
environmentId: job.state.environmentId,

0 commit comments

Comments
 (0)