The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 02:00 UTC
fix(mobile): keep Android live activity independent of alerts (#24933)
Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Alex committed
Nov 8, 2026 at 21:41 UTC
06f8b99f4675568fa035cd9dd8e6aecb95caef75
9 files changed
+277
-47
apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/AgentActivityPresentation.kt
+1
-1
@@ -115,7 +115,7 @@ internal class ActivityPresentation(data: Map<String, String>, private val activ
115
}
116
117
val chip = when {
118
- !active -> null
118
+ !active -> if (phase == ActivityPhase.FAILED) "Failed" else "Done"
119
phase == null -> data["activity_chip"]?.takeIf { it.isNotBlank() }?.take(7) ?: "Active"
120
phase == ActivityPhase.RUNNING && activeCount > 1 ->
121
"${if (activeCount > 9) "9+" else activeCount} live"
apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/AgentNotifications.kt
+7
-7
@@ -297,21 +297,21 @@ object AgentNotifications {
297
)
298
val presentation = ActivityPresentation(data, active)
299
val openThread = contentIntent(context, scheme, data["activity_path"], ACTIVITY_ID)
300
+ // Retained results still need Android's ongoing flag to remain promoted.
301
+ val ongoing = active || Build.VERSION.SDK_INT >= 36
302
val builder = base(context, ACTIVITY_CHANNEL)
301
- .setOngoing(active).setOnlyAlertOnce(true).setSilent(true)
303
+ .setOngoing(ongoing).setOnlyAlertOnce(true).setSilent(true)
304
.setTimeoutAfter(remainingMs)
305
// Live Updates must remain uncolorized to qualify for promotion.
306
.setColorized(false)
305
- .setRequestPromotedOngoing(active)
306
- .setShortCriticalText(presentation.chip)
307
+ .setRequestPromotedOngoing(ongoing)
308
+ .setShortCriticalText(if (ongoing) presentation.chip else null)
309
.setContentIntent(openThread)
310
.setDeleteIntent(dismissIntent)
311
presentation.applyTo(builder, context)
312
val action = presentation.action
311
- if (action != null) {
312
- if (openThread != null) builder.addAction(0, action, openThread)
313
- builder.addAction(0, "Dismiss", dismissIntent)
314
- }
313
+ if (action != null && openThread != null) builder.addAction(0, action, openThread)
314
+ if (ongoing) builder.addAction(0, "Dismiss", dismissIntent)
315
manager(context).notify(ACTIVITY_TAG, ACTIVITY_ID, builder.build())
316
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
317
// Notification timeouts were added in API 26. One inexact alarm also
apps/mobile/modules/t3-agent-notifications/android/src/test/java/expo/modules/t3agentnotifications/AgentNotificationsTest.kt
+112
-9
@@ -3,6 +3,7 @@ package expo.modules.t3agentnotifications
3
import android.app.Activity
4
import android.app.AlarmManager
5
import android.app.Application
6
+import android.app.NotificationChannel
7
import android.app.Notification
8
import android.app.NotificationManager
9
import android.content.ComponentName
@@ -264,7 +265,7 @@ class AgentNotificationsTest : AgentNotificationsFixture() {
265
}
266
267
@Test
267
- fun finishedCardIsRetainedSilentlyWithoutOngoingFlagAndExpiresAtTheOriginalDeadline() {
268
+ fun finishedCardIsRetainedSilentlyAndExpiresAtTheOriginalDeadline() {
269
lifecycle.currentState = Lifecycle.State.RESUMED
270
val expiresAt = System.currentTimeMillis() + 15 * 60 * 1000L
271
val finished = update("finished", false) + mapOf(
@@ -275,7 +276,7 @@ class AgentNotificationsTest : AgentNotificationsFixture() {
276
AgentNotifications.receive(context, finished)
277
val card = manager.activeNotifications.single().notification
278
assertEquals("Agent work failed", card.extras.getString(Notification.EXTRA_TITLE))
278
- assertFalse(card.flags and Notification.FLAG_ONGOING_EVENT != 0)
279
+ assertEquals(Build.VERSION.SDK_INT >= 36, card.flags and Notification.FLAG_ONGOING_EVENT != 0)
280
assertTimeout(card, 1..15 * 60 * 1000L)
281
AgentNotifications.receive(
282
context,
@@ -413,10 +414,22 @@ class AgentNotificationsTest : AgentNotificationsFixture() {
414
"android.app.Notification\$BigTextStyle",
415
card.extras.getString(Notification.EXTRA_TEMPLATE)
416
)
416
- assertEquals(active, NotificationCompat.isRequestPromotedOngoing(card))
417
+ assertEquals(
418
+ active || Build.VERSION.SDK_INT >= 36,
419
+ NotificationCompat.isRequestPromotedOngoing(card)
420
+ )
421
if (!active) {
418
- assertEquals(null, card.extras.getString(NotificationCompat.EXTRA_SHORT_CRITICAL_TEXT))
419
- assertEquals(0, card.actions?.size ?: 0)
422
+ assertEquals(
423
+ if (Build.VERSION.SDK_INT < 36) {
424
+ null
425
+ } else if (phase == "failed") {
426
+ "Failed"
427
+ } else {
428
+ "Done"
429
+ },
430
+ card.extras.getString(NotificationCompat.EXTRA_SHORT_CRITICAL_TEXT)
431
+ )
432
+ assertEquals(if (Build.VERSION.SDK_INT >= 36) 1 else 0, card.actions?.size ?: 0)
433
}
434
}
435
}
@@ -566,7 +579,7 @@ class AgentNotificationsTest : AgentNotificationsFixture() {
579
}
580
581
@Test
569
- fun liveUpdateChipChangesWithActivityAndClearsOnCompletion() {
582
+ fun liveUpdateChipChangesWithActivityAndShowsDoneOnCompletion() {
583
lifecycle.currentState = Lifecycle.State.RESUMED
584
AgentNotifications.receive(context, update("work", true))
585
assertEquals(
@@ -590,9 +603,13 @@ class AgentNotificationsTest : AgentNotificationsFixture() {
603
)
604
)
605
val finishedCard = manager.activeNotifications.single().notification
593
- assertEquals(null, finishedCard.extras.getString(NotificationCompat.EXTRA_SHORT_CRITICAL_TEXT))
594
- assertFalse(NotificationCompat.isRequestPromotedOngoing(finishedCard))
595
- assertFalse(finishedCard.flags and Notification.FLAG_ONGOING_EVENT != 0)
606
+ val promoted = Build.VERSION.SDK_INT >= 36
607
+ assertEquals(
608
+ if (promoted) "Done" else null,
609
+ finishedCard.extras.getString(NotificationCompat.EXTRA_SHORT_CRITICAL_TEXT)
610
+ )
611
+ assertEquals(promoted, NotificationCompat.isRequestPromotedOngoing(finishedCard))
612
+ assertEquals(promoted, finishedCard.flags and Notification.FLAG_ONGOING_EVENT != 0)
613
}
614
615
@Test
@@ -635,6 +652,92 @@ class AgentNotificationsTest : AgentNotificationsFixture() {
652
}
653
}
654
655
+@RunWith(RobolectricTestRunner::class)
656
+@Config(sdk = [26, 33, 36], manifest = Config.NONE)
657
+class AgentNotificationChannelsTest {
658
+ @Test
659
+ fun mutedAlertChannelKeepsTheSameActivityThroughCompletionUntilDismissedOrExpired() {
660
+ val context = RuntimeEnvironment.getApplication()
661
+ val manager = context.getSystemService(NotificationManager::class.java)
662
+ shadowOf(manager).setNotificationsEnabled(true)
663
+ AgentNotifications.clear(context)
664
+ AgentNotifications.configure(context, "device", "user", "t3code-dev", true)
665
+ val running = mapOf(
666
+ "device_id" to "device",
667
+ "user_id" to "user",
668
+ "updated_at" to System.currentTimeMillis().toString(),
669
+ "active" to "true",
670
+ "activity_title" to "Agent activity"
671
+ )
672
+ manager.createNotificationChannel(
673
+ NotificationChannel("agent-alerts", "Agent alerts", NotificationManager.IMPORTANCE_NONE)
674
+ )
675
+ AgentNotifications.receive(context, running)
676
+ val initialCard = manager.activeNotifications.single()
677
+ assertEquals("t3-agent-activity", initialCard.tag)
678
+
679
+ AgentNotifications.configure(context, "device", "user", "t3code-dev", true)
680
+ AgentNotifications.receive(
681
+ context,
682
+ running + mapOf(
683
+ "activity_phase" to "waiting_for_approval",
684
+ "activity_attention_count" to "1"
685
+ )
686
+ )
687
+ val card = manager.activeNotifications.single().notification
688
+ assertEquals("Approve", card.extras.getString(NotificationCompat.EXTRA_SHORT_CRITICAL_TEXT))
689
+
690
+ val finished = running + mapOf(
691
+ "active" to "false",
692
+ "activity_phase" to "completed",
693
+ "activity_line_0" to "Done\tTest thread\tTest project",
694
+ "activity_expires_at" to (System.currentTimeMillis() + 900000).toString()
695
+ )
696
+ AgentNotifications.receive(context, finished)
697
+ AgentNotifications.receive(context, finished)
698
+ val completedCard = manager.activeNotifications.single()
699
+ assertEquals(initialCard.id, completedCard.id)
700
+ assertEquals(initialCard.tag, completedCard.tag)
701
+ assertEquals("agent-activity", completedCard.notification.channelId)
702
+ assertEquals(
703
+ "Test thread",
704
+ completedCard.notification.extras.getString(Notification.EXTRA_TITLE)
705
+ )
706
+ assertEquals(
707
+ "Done Test project",
708
+ completedCard.notification.extras.getCharSequence(Notification.EXTRA_TEXT).toString()
709
+ )
710
+ val promoted = Build.VERSION.SDK_INT >= 36
711
+ assertEquals(promoted, NotificationCompat.isRequestPromotedOngoing(completedCard.notification))
712
+ assertEquals(
713
+ promoted,
714
+ completedCard.notification.flags and Notification.FLAG_ONGOING_EVENT != 0
715
+ )
716
+ assertEquals(
717
+ if (promoted) "Done" else null,
718
+ completedCard.notification.extras.getString(NotificationCompat.EXTRA_SHORT_CRITICAL_TEXT)
719
+ )
720
+
721
+ if (promoted) {
722
+ val dismiss = completedCard.notification.actions.single()
723
+ assertEquals("Dismiss", dismiss.title.toString())
724
+ AgentActivityDismissReceiver().onReceive(context, shadowOf(dismiss.actionIntent).savedIntent)
725
+ } else {
726
+ AgentNotifications.dismiss(context)
727
+ }
728
+ AgentNotifications.receive(context, finished)
729
+ assertTrue(manager.activeNotifications.isEmpty())
730
+
731
+ AgentNotifications.receive(context, running)
732
+ assertEquals("t3-agent-activity", manager.activeNotifications.single().tag)
733
+ AgentNotifications.receive(
734
+ context,
735
+ finished + ("activity_expires_at" to (System.currentTimeMillis() - 1).toString())
736
+ )
737
+ assertTrue(manager.activeNotifications.isEmpty())
738
+ }
739
+}
740
+
741
@RunWith(RobolectricTestRunner::class)
742
@Config(sdk = [24, 26, 33, 36], manifest = Config.NONE)
743
class AgentNotificationsCompletionTest : AgentNotificationsFixture() {
apps/mobile/src/features/agent-awareness/registrationPayload.ts
+10
-2
@@ -21,11 +21,19 @@ export function makeRelayDeviceRegistrationRequest(
21
readonly preferences: Preferences;
22
} & (
23
| { readonly platform?: "ios"; readonly iosMajorVersion: number }
24
- | { readonly platform: "android"; readonly androidApiLevel: number }
24
+ | {
25
+ readonly platform: "android";
26
+ readonly androidApiLevel: number;
27
+ readonly notificationPermissionGranted: boolean;
28
+ }
29
),
30
): RelayDeviceRegistrationRequest {
31
const pushAvailable = supportsAgentAwarenessPush();
28
- const liveActivitiesEnabled = pushAvailable && input.preferences.liveActivitiesEnabled !== false;
32
+ const liveActivitiesEnabled =
33
+ pushAvailable &&
34
+ input.preferences.liveActivitiesEnabled !== false &&
35
+ (input.platform !== "android" ||
36
+ (input.notificationPermissionGranted && Boolean(input.pushToken)));
37
return {
38
deviceId: input.deviceId,
39
label: input.label,
apps/mobile/src/features/agent-awareness/remoteRegistration.test.ts
+89
-3
@@ -114,6 +114,8 @@ vi.mock("../../state/server", () => ({
114
}));
115
116
vi.mock("expo-notifications", () => ({
117
+ AndroidImportance: { NONE: 0, HIGH: 4 },
118
+ getNotificationChannelAsync: vi.fn(() => Promise.resolve(null)),
119
addPushTokenListener: vi.fn(() => ({ remove: vi.fn() })),
120
getDevicePushTokenAsync: vi.fn(() => Promise.resolve({ type: "ios", data: "apns-token" })),
121
getPermissionsAsync: vi.fn(() => Promise.resolve({ granted: true })),
@@ -248,6 +250,11 @@ describe("makeRelayDeviceRegistrationRequest", () => {
250
type: "ios",
251
data: "apns-token",
252
});
253
+ vi.mocked(Notifications.getPermissionsAsync).mockReset();
254
+ vi.mocked(Notifications.getPermissionsAsync).mockResolvedValue({
255
+ granted: true,
256
+ } as Awaited<ReturnType<typeof Notifications.getPermissionsAsync>>);
257
+ vi.mocked(Notifications.getNotificationChannelAsync).mockResolvedValue(null);
258
vi.unstubAllGlobals();
259
vi.stubGlobal("__DEV__", false);
260
secureStore.clear();
@@ -260,6 +267,7 @@ describe("makeRelayDeviceRegistrationRequest", () => {
267
vi.mocked(loadAgentAwarenessRegistrationRecord).mockClear();
268
vi.mocked(clearAgentAwarenessRegistrationRecord).mockClear();
269
vi.mocked(loadOrCreateAgentAwarenessDeviceId).mockResolvedValue("device-1");
270
+ vi.mocked(loadPreferences).mockResolvedValue({ liveActivitiesEnabled: false });
271
widgetMocks.getInstances.mockReset();
272
widgetMocks.getInstances.mockReturnValue([]);
273
widgetMocks.start.mockClear();
@@ -634,6 +642,7 @@ describe("makeRelayDeviceRegistrationRequest", () => {
642
it.effect.each(["ios", "android"] as const)(
643
"does not enable %s notifications when a token rotates after permission is revoked",
644
(os) => {
645
+ vi.mocked(loadPreferences).mockResolvedValue({ liveActivitiesEnabled: true });
646
vi.spyOn(Platform, "OS", "get").mockReturnValue(os);
647
vi.spyOn(Platform, "Version", "get").mockReturnValue(os === "ios" ? 18 : 36);
648
vi.mocked(Notifications.getDevicePushTokenAsync).mockResolvedValue({
@@ -660,7 +669,7 @@ describe("makeRelayDeviceRegistrationRequest", () => {
669
return Effect.gen(function* () {
670
yield* runBackgroundOperations();
671
expect(registrations.at(-1)).toMatchObject({
663
- preferences: { notificationsEnabled: true },
672
+ preferences: { notificationsEnabled: true, liveActivitiesEnabled: true },
673
});
674
vi.mocked(Notifications.getPermissionsAsync).mockResolvedValueOnce({
675
granted: false,
@@ -669,9 +678,21 @@ describe("makeRelayDeviceRegistrationRequest", () => {
678
listener({ type: os, data: "rotated" });
679
yield* runBackgroundOperations();
680
expect(registrations.at(-1)).toMatchObject({
672
- preferences: { notificationsEnabled: false },
681
+ preferences: { notificationsEnabled: false, liveActivitiesEnabled: os === "ios" },
682
});
674
- expect(registrations.at(-1)).not.toHaveProperty("pushToken");
683
+ if (os === "android") {
684
+ expect(registrations.at(-1)).toMatchObject({ pushToken: "rotated" });
685
+ vi.mocked(Notifications.getPermissionsAsync).mockResolvedValueOnce({
686
+ granted: false,
687
+ } as Awaited<ReturnType<typeof Notifications.getPermissionsAsync>>);
688
+ yield* refreshAgentAwarenessRegistration();
689
+ expect(registrations.at(-1)).toMatchObject({
690
+ pushToken: "initial",
691
+ preferences: { notificationsEnabled: false, liveActivitiesEnabled: false },
692
+ });
693
+ } else {
694
+ expect(registrations.at(-1)).not.toHaveProperty("pushToken");
695
+ }
696
}).pipe(
697
Effect.provideService(FetchHttpClient.Fetch, globalThis.fetch),
698
Effect.provide(
@@ -682,6 +703,71 @@ describe("makeRelayDeviceRegistrationRequest", () => {
703
);
704
},
705
);
706
+ it.effect.each(["blocked", "unavailable"] as const)(
707
+ "keeps Android push delivery registered when the alert channel is %s",
708
+ (channelState) => {
709
+ vi.mocked(loadPreferences).mockResolvedValue({ liveActivitiesEnabled: true });
710
+ vi.spyOn(Platform, "OS", "get").mockReturnValue("android");
711
+ vi.spyOn(Platform, "Version", "get").mockReturnValue(36);
712
+ vi.mocked(Notifications.getDevicePushTokenAsync).mockResolvedValue({
713
+ type: "android",
714
+ data: "fcm-token",
715
+ });
716
+ vi.mocked(Notifications.getNotificationChannelAsync).mockResolvedValue({
717
+ id: "agent-alerts",
718
+ name: "Agent alerts",
719
+ importance: Notifications.AndroidImportance.NONE,
720
+ } as Awaited<ReturnType<typeof Notifications.getNotificationChannelAsync>>);
721
+ if (channelState === "unavailable") {
722
+ vi.mocked(Notifications.getNotificationChannelAsync).mockRejectedValue(
723
+ new Error("Android channel lookup failed"),
724
+ );
725
+ }
726
+ const registrations: unknown[] = [];
727
+ vi.stubGlobal("fetch", async (input: RequestInfo | URL, init?: RequestInit) => {
728
+ const request = new Request(input, init);
729
+ if (request.url.endsWith("/v1/client/dpop-token")) {
730
+ return Response.json({
731
+ access_token: "dpop",
732
+ issued_token_type: "urn:ietf:params:oauth:token-type:access_token",
733
+ token_type: "DPoP",
734
+ expires_in: 300,
735
+ scope: "mobile:registration",
736
+ });
737
+ }
738
+ registrations.push(await request.json());
739
+ return Response.json({ ok: true });
740
+ });
741
+ Constants.expoConfig!.extra = { relay: { url: "https://relay.example.test" } };
742
+ setAgentAwarenessRelayTokenProvider(() => Promise.resolve("clerk"), "user-a");
743
+ return Effect.gen(function* () {
744
+ yield* runBackgroundOperations();
745
+ expect(registrations.at(-1)).toMatchObject({
746
+ pushToken: "fcm-token",
747
+ preferences: { notificationsEnabled: false, liveActivitiesEnabled: true },
748
+ });
749
+ expect(getAgentAwarenessRegistrationStatus()).toBe("registered");
750
+
751
+ const listener = vi.mocked(Notifications.addPushTokenListener).mock.calls.at(-1)![0];
752
+ listener({ type: "android", data: "rotated-fcm-token" });
753
+ yield* runBackgroundOperations();
754
+ expect(registrations.at(-1)).toMatchObject({
755
+ pushToken: "rotated-fcm-token",
756
+ preferences: { notificationsEnabled: false, liveActivitiesEnabled: true },
757
+ });
758
+
759
+ vi.mocked(Notifications.getNotificationChannelAsync).mockResolvedValue(null);
760
+ yield* refreshAgentAwarenessRegistration();
761
+ expect(registrations.at(-1)).toMatchObject({
762
+ pushToken: "fcm-token",
763
+ preferences: { notificationsEnabled: true },
764
+ });
765
+ }).pipe(
766
+ Effect.provideService(FetchHttpClient.Fetch, globalThis.fetch),
767
+ Effect.provide(layerRelayTest),
768
+ );
769
+ },
770
+ );
771
it.effect("preserves relay rejection errors with React Native response headers", () => {
772
vi.spyOn(Platform, "OS", "get").mockReturnValue("android");
773
vi.mocked(Notifications.getDevicePushTokenAsync).mockResolvedValue({
apps/mobile/src/features/agent-awareness/remoteRegistration.ts
+34
-6
@@ -261,7 +261,7 @@ function iosMajorVersion(): number {
261
const nativePushTokenRegistration = Effect.fn("remoteRegistration.nativePushTokenRegistration")(
262
function* (observedPushToken?: string) {
263
if (!canRegisterPushNotifications() || !supportsAgentAwarenessPush()) {
264
- return { notificationsEnabled: false, pushToken: null };
264
+ return { notificationsEnabled: false, pushToken: null, notificationPermissionGranted: false };
265
}
266
const permissions = yield* Effect.tryPromise({
267
try: () => Notifications.getPermissionsAsync(),
@@ -271,11 +271,31 @@ const nativePushTokenRegistration = Effect.fn("remoteRegistration.nativePushToke
271
cause,
272
}),
273
});
274
- if (!permissions.granted) {
275
- return { notificationsEnabled: false, pushToken: null };
274
+ // Android FCM data delivery is independent of notification presentation permission.
275
+ if (!permissions.granted && Platform.OS !== "android") {
276
+ return { notificationsEnabled: false, pushToken: null, notificationPermissionGranted: false };
277
}
278
+ const alertsEnabled =
279
+ permissions.granted &&
280
+ (Platform.OS === "android" && Number(Platform.Version) >= 26
281
+ ? yield* Effect.tryPromise({
282
+ try: () => Notifications.getNotificationChannelAsync("agent-alerts"),
283
+ catch: (cause) =>
284
+ new AgentAwarenessOperationError({
285
+ operation: "read-notification-permissions",
286
+ cause,
287
+ }),
288
+ }).pipe(
289
+ Effect.map((channel) => channel?.importance !== Notifications.AndroidImportance.NONE),
290
+ Effect.orElseSucceed(() => false),
291
+ )
292
+ : true);
293
if (observedPushToken) {
278
- return { notificationsEnabled: true, pushToken: observedPushToken };
294
+ return {
295
+ notificationsEnabled: alertsEnabled,
296
+ pushToken: observedPushToken,
297
+ notificationPermissionGranted: permissions.granted,
298
+ };
299
}
300
const token = yield* Effect.tryPromise({
301
try: () => Notifications.getDevicePushTokenAsync(),
@@ -296,7 +316,11 @@ const nativePushTokenRegistration = Effect.fn("remoteRegistration.nativePushToke
316
token?.type === Platform.OS && typeof token.data === "string" && token.data.trim().length > 0
317
? token.data.trim()
318
: null;
299
- return { notificationsEnabled: pushToken !== null, pushToken };
319
+ return {
320
+ notificationsEnabled: alertsEnabled && pushToken !== null,
321
+ pushToken,
322
+ notificationPermissionGranted: permissions.granted,
323
+ };
324
},
325
);
326
@@ -687,7 +711,11 @@ const registerDevice = Effect.fn("remoteRegistration.registerDevice")(function*
711
Constants.deviceName?.trim() ||
712
(Platform.OS === "android" ? "Android device" : "iOS device"),
713
...(Platform.OS === "android"
690
- ? { platform: "android" as const, androidApiLevel: Number(Platform.Version) }
714
+ ? {
715
+ platform: "android" as const,
716
+ androidApiLevel: Number(Platform.Version),
717
+ notificationPermissionGranted: pushTokenRegistration.notificationPermissionGranted,
718
+ }
719
: { platform: "ios" as const, iosMajorVersion: iosMajorVersion() }),
720
appVersion: Constants.expoConfig?.version,
721
...(bundleId ? { bundleId } : {}),
docs/user/mobile-notifications.md
+2
@@ -4,6 +4,8 @@ Sign in to T3 Connect, link your environments, and enable **Device Notifications
4
5
Enable **Live Activity Updates** on iOS, **Agent Live Updates** on Android 16 and newer, or **Ongoing Agent Activity** on older Android versions to follow work without opening the app. Finished results remain visible for up to 15 minutes. You can dismiss an Android activity card without disabling alerts; turn off the same switch to stop future cards.
6
7
+For activity without ordinary alerts on Android 8 or newer, leave **Ongoing agent activity** enabled and turn off **Agent alerts** in Android's notification settings for T3 Code. Activity updates continue, and the same card shows the finished result without a separate alert. On Android 16 and newer, the finished result remains a Live Update until dismissed or expired. Keep app-wide notification permission and **Live updates** enabled so Android can display it.
8
+
9
On iOS you can also add the **Agent Activity** widget to your Home Screen or Lock Screen. It shows the same agents as the Live Activity, using your T3 Connect sign-in. The widget refreshes when you open T3 and shows unfinished work as out of date after 10 minutes.
10
11
Ordinary alerts stay quiet while the mobile app is in the foreground. Ongoing activity continues to update. Viewing a thread on another device does not silence your phone's alerts.
infra/relay/src/agentActivity/FcmDeliveries.test.ts
+21
-15
@@ -508,25 +508,31 @@ describe("Android delivery routing", () => {
508
}).pipe(Effect.provide(h.layer));
509
});
510
511
- it.effect("honors disabled alert preferences while continuing ongoing activity", () => {
512
- const h = harness();
513
- h.current.state = { ...state, phase: "waiting_for_approval" };
514
- h.current.target.preferences_json = encodeJson({ ...preferences, notifyOnApproval: false });
515
- return Effect.gen(function* () {
516
- const delivery = yield* FcmDeliveries.FcmDeliveries;
517
- yield* delivery.process({ ...h.job, state: h.current.state });
518
- expect(h.sent[0]?.data.active).toBe("true");
519
- expect(h.sent[0]?.data.alert_id).toBeUndefined();
511
+ it.effect(
512
+ "continues ongoing activity when alerts are disabled, with or without a previous card",
513
+ () => {
514
+ const h = harness();
515
+ h.current.state = { ...state, phase: "waiting_for_approval" };
516
h.current.target.preferences_json = encodeJson({
517
...preferences,
518
notificationsEnabled: false,
519
});
524
- h.current.target.last_aggregate_json = encodeJson(aggregateFor([state]));
525
- yield* delivery.process({ ...h.job, state: h.current.state });
526
- expect(h.sent[1]?.data.active).toBe("false");
527
- expect(h.sent[1]?.data.alert_id).toBeUndefined();
528
- }).pipe(Effect.provide(h.layer));
529
- });
520
+ return Effect.gen(function* () {
521
+ const delivery = yield* FcmDeliveries.FcmDeliveries;
522
+ yield* delivery.process({ ...h.job, state: h.current.state });
523
+ expect(h.sent).toHaveLength(1);
524
+ expect(h.sent[0]?.data.active).toBe("true");
525
+ expect(h.sent[0]?.alert).toBe(false);
526
+ expect(h.sent[0]?.data.alert_id).toBeUndefined();
527
+ h.current.target.preferences_json = encodeJson({ ...preferences, notifyOnApproval: false });
528
+ h.current.target.last_aggregate_json = encodeJson(aggregateFor([state]));
529
+ yield* delivery.process({ ...h.job, state: h.current.state });
530
+ expect(h.sent[1]?.data.active).toBe("true");
531
+ expect(h.sent[1]?.data.alert_id).toBeUndefined();
532
+ expect(h.marked.at(-1)?.kind).toBe("live_activity_update");
533
+ }).pipe(Effect.provide(h.layer));
534
+ },
535
+ );
536
537
it.effect("replays an empty card to repair an orphan without a delivery baseline", () => {
538
const h = harness();
infra/relay/src/agentActivity/FcmDeliveries.ts
+1
-4
@@ -281,10 +281,7 @@ const make = Effect.gen(function* () {
281
alert = androidAlertForState(state, preferences.value, now.epochMilliseconds);
282
}
283
}
284
- const displayedAggregate =
285
- preferences.value.notificationsEnabled && preferences.value.liveActivitiesEnabled
286
- ? aggregate
287
- : null;
284
+ const displayedAggregate = preferences.value.liveActivitiesEnabled ? aggregate : null;
285
const active = (displayedAggregate?.activeCount ?? 0) > 0;
286
if (!displayedAggregate && !alert && !previousAggregate && job.state !== null) return;
287
const data: Record<string, string> = {