Skip to content

Commit 11e91f1

Browse files
feat(mobile): capture Live Activities and agent notifications in showcase screenshots (#13316)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent f5ef0dd commit 11e91f1

13 files changed

Lines changed: 609 additions & 38 deletions

File tree

‎.github/workflows/mobile-showcase-screenshots.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ jobs:
7676
echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
7777
"$vp_pnpm_bin/pnpm" --version
7878
79+
- name: Install AXe
80+
# Locks the simulator and answers the notification prompt for the
81+
# agent-activity scene.
82+
# Homebrew refuses third-party tap formulae until they are trusted;
83+
# older releases have no trust command and install them as is.
84+
run: |
85+
brew tap cameroncooke/axe
86+
if brew commands | grep -qx trust; then brew trust --formula cameroncooke/axe/axe; fi
87+
brew install cameroncooke/axe/axe
88+
axe --version
89+
7990
- name: Capture iOS showcase
8091
run: pnpm screenshots:mobile --platform ios --appearance "${{ inputs.appearance }}" --theme "${{ inputs.theme }}"
8192

‎apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/AgentNotifications.kt‎

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,7 @@ object AgentNotifications {
138138
// Match iOS foreground presentation. Consume suppressed alerts as well,
139139
// so a delivery retry cannot surface them after the app backgrounds.
140140
if (!ProcessLifecycleOwner.get().lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) {
141-
val title = data["alert_title"].orEmpty().take(120)
142-
// Grouped alerts list up to five 120-character thread titles.
143-
val body = data["alert_body"].orEmpty().take(608)
144-
val id = alertId.hashCode()
145-
val notification = base(context, ALERT_CHANNEL)
146-
.setContentTitle(title).setContentText(body)
147-
.setStyle(NotificationCompat.BigTextStyle().bigText(body))
148-
.setAutoCancel(true)
149-
.setContentIntent(contentIntent(context, scheme, data["alert_path"], id))
150-
.build()
151-
manager(context).notify(ALERT_TAG, id, notification)
141+
postAlert(context, scheme, data, alertId)
152142
}
153143
prefs.edit().remove("seenAlerts").putString(
154144
"seenAlertsOrdered",
@@ -157,6 +147,36 @@ object AgentNotifications {
157147
}
158148
}
159149

150+
private fun postAlert(
151+
context: Context,
152+
scheme: String,
153+
data: Map<String, String>,
154+
alertId: String
155+
) {
156+
val title = data["alert_title"].orEmpty().take(120)
157+
// Grouped alerts list up to five 120-character thread titles.
158+
val body = data["alert_body"].orEmpty().take(608)
159+
val id = alertId.hashCode()
160+
val notification = base(context, ALERT_CHANNEL)
161+
.setContentTitle(title).setContentText(body)
162+
.setStyle(NotificationCompat.BigTextStyle().bigText(body))
163+
.setAutoCancel(true)
164+
.setContentIntent(contentIntent(context, scheme, data["alert_path"], id))
165+
.build()
166+
manager(context).notify(ALERT_TAG, id, notification)
167+
}
168+
169+
/**
170+
* Renders a relay-shaped payload without the registration, freshness and
171+
* foreground checks, for the showcase capture's staged notifications.
172+
*/
173+
@Synchronized
174+
fun showcase(context: Context, scheme: String, data: Map<String, String>) {
175+
channels(context)
176+
data["alert_id"]?.let { postAlert(context, scheme, data, it) }
177+
showActivity(context, scheme, data, data["active"] == "true", RUNNING_LIFETIME_MS)
178+
}
179+
160180
private fun updateActivity(
161181
context: Context,
162182
prefs: SharedPreferences,

‎apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/T3AgentNotificationsModule.kt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class T3AgentNotificationsModule : Module() {
2626
appContext.reactContext?.let { AgentNotifications.clear(it) }
2727
}
2828

29+
Function("showShowcaseActivity") { scheme: String, data: Map<String, String> ->
30+
appContext.reactContext?.let { AgentNotifications.showcase(it, scheme, data) }
31+
}
32+
2933
Function("openLiveUpdateSettings") {
3034
val context = appContext.reactContext
3135
if (context == null || Build.VERSION.SDK_INT < 36) {

‎apps/mobile/src/features/agent-awareness/androidNotifications.ts‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ interface AndroidAgentNotifications {
66
configure(deviceId: string, userId: string, scheme: string, ongoingEnabled: boolean): void;
77
clear(): void;
88
openLiveUpdateSettings?(): boolean;
9+
showShowcaseActivity?(scheme: string, data: Record<string, string>): void;
910
}
1011

1112
const native =
@@ -17,18 +18,24 @@ export function supportsAndroidAgentNotifications(): boolean {
1718
return typeof native?.configure === "function" && typeof native?.clear === "function";
1819
}
1920

21+
function appScheme(): string {
22+
const scheme = Constants.expoConfig?.scheme;
23+
return (Array.isArray(scheme) ? scheme[0] : scheme) ?? "t3code";
24+
}
25+
2026
export function configureAndroidAgentNotifications(
2127
deviceId: string,
2228
userId: string,
2329
ongoingEnabled: boolean,
2430
): void {
25-
const scheme = Constants.expoConfig?.scheme;
26-
native?.configure?.(
27-
deviceId,
28-
userId,
29-
(Array.isArray(scheme) ? scheme[0] : scheme) ?? "t3code",
30-
ongoingEnabled,
31-
);
31+
native?.configure?.(deviceId, userId, appScheme(), ongoingEnabled);
32+
}
33+
34+
/** Posts a staged relay payload for the showcase capture; false when unsupported. */
35+
export function showAndroidShowcaseAgentActivity(data: Record<string, string>): boolean {
36+
if (!native?.showShowcaseActivity) return false;
37+
native.showShowcaseActivity(appScheme(), data);
38+
return true;
3239
}
3340

3441
export function clearAndroidAgentNotifications(): void {

‎apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx‎

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ import {
2929
buildShowcasePendingTasks,
3030
SHOWCASE_PENDING_TASK_DEFINITIONS,
3131
} from "./showcasePendingTasks";
32+
import { buildShowcaseAgentActivity } from "./showcaseAgentActivity";
3233
import { retryShowcaseOperation } from "./showcaseRetry";
3334
import {
3435
clearShowcaseRenderSignal,
3536
getShowcaseRenderSignal,
3637
isShowcaseNativeContentReady,
3738
subscribeToShowcaseRenderSignal,
3839
} from "./showcaseRenderSignal";
40+
import { stageShowcaseAgentActivity } from "./stageShowcaseAgentActivity";
3941

4042
const SHOWCASE_ENABLED = process.env.EXPO_PUBLIC_SHOWCASE === "1";
4143
const SHOWCASE_THREAD_ID = "remote-command-center";
@@ -75,7 +77,14 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
7577
const [themeRequestSettled, setThemeRequestSettled] = useState(false);
7678
const [readyScene, setReadyScene] = useState<ShowcaseScene | null>(null);
7779
const [orientationSettled, setOrientationSettled] = useState(false);
80+
const [agentActivityStaged, setAgentActivityStaged] = useState(false);
7881
const requestedSceneRef = useRef<ShowcaseScene | null>(null);
82+
// Staging reads the latest entities without restarting on every shell
83+
// update, which would re-enter a permission prompt that is still open.
84+
const entitiesRef = useRef({ threads, projects });
85+
useEffect(() => {
86+
entitiesRef.current = { threads, projects };
87+
}, [projects, threads]);
7988
const renderSignal = useSyncExternalStore(
8089
subscribeToShowcaseRenderSignal,
8190
getShowcaseRenderSignal,
@@ -109,6 +118,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
109118
}
110119

111120
let cancelled = false;
121+
let lastOutcome: string | null = null;
112122
void retryShowcaseOperation(async () => applyNativeShowcaseOrientation(orientation), {
113123
isCancelled: () => cancelled,
114124
}).then((applied) => {
@@ -129,6 +139,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
129139
// A native draw belongs only to the scene request that produced it. In
130140
// particular, revisiting review must wait for its newly mounted surface.
131141
clearShowcaseRenderSignal();
142+
setAgentActivityStaged(false);
132143
setRequestedScene(value);
133144
};
134145
readRequestedScene();
@@ -176,7 +187,11 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
176187
};
177188
}, [connectPairingUrl, pairingUrls]);
178189

179-
const scene = sceneFromPathname(props.pathname);
190+
const routeScene = sceneFromPathname(props.pathname);
191+
// Agent activity is captured over the thread list: the runner locks the
192+
// simulator or opens the notification shade on top of it.
193+
const scene =
194+
requestedScene === "agent-activity" && routeScene === "threads" ? "agent-activity" : routeScene;
180195
const hasServerFixture =
181196
workspace.state.hasReadyEnvironment &&
182197
workspace.environments.length >= 3 &&
@@ -228,6 +243,11 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
228243
navigation.dispatch(StackActions.popToTop());
229244
return;
230245
}
246+
// Follows the environments scene, whose settings sheet popToTop leaves open.
247+
if (requestedScene === "agent-activity") {
248+
navigation.dispatch(CommonActions.reset({ index: 0, routes: [{ name: "Home" }] }));
249+
return;
250+
}
231251
const routes: ShowcaseResetRoute[] = [{ name: "Home" }];
232252
if (requestedScene === "environments") {
233253
routes.push({
@@ -264,6 +284,39 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
264284
);
265285
}, [hasFixture, navigation, requestedScene, scene, showcaseThread]);
266286

287+
useEffect(() => {
288+
if (!SHOWCASE_ENABLED || scene !== "agent-activity" || !hasFixture || agentActivityStaged) {
289+
return;
290+
}
291+
let cancelled = false;
292+
let lastOutcome: string | null = null;
293+
void retryShowcaseOperation(
294+
async () => {
295+
const now = Date.now();
296+
const { threads: latestThreads, projects: latestProjects } = entitiesRef.current;
297+
const activity = buildShowcaseAgentActivity(latestThreads, latestProjects, now);
298+
const outcome =
299+
activity === null
300+
? "fixture threads not loaded"
301+
: await stageShowcaseAgentActivity(activity, now);
302+
if (outcome === true) return true;
303+
// Surfaces in the runner's Metro output when the scene never turns ready.
304+
if (outcome !== lastOutcome)
305+
console.warn(`[showcase] agent activity not staged: ${outcome}`);
306+
lastOutcome = outcome;
307+
return false;
308+
},
309+
// The first attempt waits on the notification permission prompt until
310+
// the runner answers it.
311+
{ isCancelled: () => cancelled, attemptTimeoutMs: 60_000 },
312+
).then((staged) => {
313+
if (!cancelled && staged) setAgentActivityStaged(true);
314+
});
315+
return () => {
316+
cancelled = true;
317+
};
318+
}, [agentActivityStaged, hasFixture, scene]);
319+
267320
useEffect(() => {
268321
if (
269322
!SHOWCASE_ENABLED ||
@@ -276,6 +329,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
276329
!orientationSettled ||
277330
// Likewise for the palette: an early screenshot shows the default theme.
278331
!themeApplied ||
332+
(scene === "agent-activity" && !agentActivityStaged) ||
279333
!isShowcaseNativeContentReady({ scene, themeId, renderSignal })
280334
) {
281335
setReadyScene(null);
@@ -298,7 +352,16 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
298352
if (renderFrame !== null) cancelAnimationFrame(renderFrame);
299353
if (readyFrame !== null) cancelAnimationFrame(readyFrame);
300354
};
301-
}, [hasFixture, orientationSettled, renderSignal, requestedScene, scene, themeApplied, themeId]);
355+
}, [
356+
agentActivityStaged,
357+
hasFixture,
358+
orientationSettled,
359+
renderSignal,
360+
requestedScene,
361+
scene,
362+
themeApplied,
363+
themeId,
364+
]);
302365

303366
if (!SHOWCASE_ENABLED || readyScene === null) return null;
304367

‎apps/mobile/src/features/showcase/nativeShowcaseScene.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import { requireOptionalNativeModule } from "expo";
22

33
import { MOBILE_THEME_IDS, type MobileThemeId } from "../../lib/mobileTheme";
44

5-
export const SHOWCASE_SCENES = ["threads", "thread", "terminal", "review", "environments"] as const;
5+
export const SHOWCASE_SCENES = [
6+
"threads",
7+
"thread",
8+
"terminal",
9+
"review",
10+
"environments",
11+
"agent-activity",
12+
] as const;
613
export type ShowcaseScene = (typeof SHOWCASE_SCENES)[number];
714

815
export type ShowcaseOrientation = "portrait" | "landscape";
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import type {
2+
EnvironmentProject,
3+
EnvironmentThreadShell,
4+
} from "@t3tools/client-runtime/state/shell";
5+
import { EnvironmentId, ProjectId, ThreadId } from "@t3tools/contracts";
6+
import { assert, it } from "@effect/vitest";
7+
8+
import {
9+
buildShowcaseAgentActivity,
10+
SHOWCASE_AGENT_ACTIVITY_ROWS,
11+
showcaseAndroidActivityData,
12+
} from "./showcaseAgentActivity";
13+
14+
const NOW = Date.parse("2026-07-16T09:00:00.000Z");
15+
16+
const project = (environmentId: string, id: string, title: string) =>
17+
({
18+
environmentId: EnvironmentId.make(environmentId),
19+
id: ProjectId.make(id),
20+
title,
21+
}) as EnvironmentProject;
22+
23+
const thread = (environmentId: string, id: string, projectId: string, title: string) =>
24+
({
25+
environmentId: EnvironmentId.make(environmentId),
26+
id: ThreadId.make(id),
27+
projectId: ProjectId.make(projectId),
28+
title,
29+
}) as EnvironmentThreadShell;
30+
31+
const projects = [
32+
project("moonbase-terminal", "t3code", "T3 Code"),
33+
project("suspense-station", "react", "React"),
34+
project("kernel-cabin", "linux", "Linux"),
35+
];
36+
37+
const threads = [
38+
thread("moonbase-terminal", "remote-command-center", "t3code", "Make remote coding feel local"),
39+
thread(
40+
"moonbase-terminal",
41+
"pocket-command-center",
42+
"t3code",
43+
"Put the command center in your pocket",
44+
),
45+
thread("suspense-station", "buttery-suspense", "react", "Make Suspense transitions buttery"),
46+
thread("kernel-cabin", "beautiful-boot", "linux", "Make boot logs oddly beautiful"),
47+
];
48+
49+
it("waits until every staged thread and its project have loaded", () => {
50+
assert.isNull(buildShowcaseAgentActivity(threads.slice(1), projects, NOW));
51+
assert.isNull(buildShowcaseAgentActivity(threads, projects.slice(0, 2), NOW));
52+
});
53+
54+
it("stages relay-shaped rows against the seeded threads", () => {
55+
const activity = buildShowcaseAgentActivity(threads, projects, NOW);
56+
assert.isNotNull(activity);
57+
if (!activity) return;
58+
59+
assert.strictEqual(activity.activeCount, 3);
60+
assert.deepStrictEqual(
61+
activity.activities.map((row) => [row.threadId, row.status, row.projectTitle, row.updatedAt]),
62+
[
63+
["pocket-command-center", "Approval", "T3 Code", "2026-07-16T08:59:00.000Z"],
64+
["beautiful-boot", "Input", "Linux", "2026-07-16T08:56:00.000Z"],
65+
["buttery-suspense", "Working", "React", "2026-07-16T08:58:00.000Z"],
66+
["remote-command-center", "Done", "T3 Code", "2026-07-16T08:57:00.000Z"],
67+
],
68+
);
69+
assert.strictEqual(
70+
activity.activities[0]?.deepLink,
71+
"/threads/moonbase-terminal/pocket-command-center",
72+
);
73+
assert.strictEqual(activity.activities.length, SHOWCASE_AGENT_ACTIVITY_ROWS.length);
74+
});
75+
76+
it("encodes the Android Live Update and its alert like a relay push", () => {
77+
const activity = buildShowcaseAgentActivity(threads, projects, NOW);
78+
assert.isNotNull(activity);
79+
if (!activity) return;
80+
const data = showcaseAndroidActivityData(activity, NOW);
81+
82+
assert.strictEqual(data.active, "true");
83+
assert.strictEqual(data.activity_chip, "Review");
84+
assert.strictEqual(data.activity_title, "3 active agents · 2 need attention");
85+
assert.strictEqual(
86+
data.activity_line_0,
87+
"Approval\tPut the command center in your pocket\tT3 Code",
88+
);
89+
assert.strictEqual(data.activity_line_3, "Done\tMake remote coding feel local\tT3 Code");
90+
assert.strictEqual(data.alert_title, "Put the command center in your pocket");
91+
assert.strictEqual(data.alert_body, "Approval: T3 Code");
92+
assert.strictEqual(data.alert_path, "/threads/moonbase-terminal/pocket-command-center");
93+
});

0 commit comments

Comments
 (0)