TypeScript
feat(mobile): capture Live Activities and agent notifications in showcase screenshots (#13316)
Julius Marminge11e91f126405
diff --git a/.github/workflows/mobile-showcase-screenshots.yml b/.github/workflows/mobile-showcase-screenshots.ymlindex c64bccacdca..fc75c447c6d 100644--- a/.github/workflows/mobile-showcase-screenshots.yml+++ b/.github/workflows/mobile-showcase-screenshots.yml@@ -76,6 +76,17 @@ jobs:echo "$vp_pnpm_bin" >> "$GITHUB_PATH""$vp_pnpm_bin/pnpm" --version+ - name: Install AXe+ # Locks the simulator and answers the notification prompt for the+ # agent-activity scene.+ # Homebrew refuses third-party tap formulae until they are trusted;+ # older releases have no trust command and install them as is.+ run: |+ brew tap cameroncooke/axe+ if brew commands | grep -qx trust; then brew trust --formula cameroncooke/axe/axe; fi+ brew install cameroncooke/axe/axe+ axe --version+- name: Capture iOS showcaserun: pnpm screenshots:mobile --platform ios --appearance "${{ inputs.appearance }}" --theme "${{ inputs.theme }}"diff --git a/apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/AgentNotifications.kt b/apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/AgentNotifications.ktindex 35086bbd75f..00af98ac4b2 100644--- a/apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/AgentNotifications.kt+++ b/apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/AgentNotifications.kt@@ -138,17 +138,7 @@ object AgentNotifications {// Match iOS foreground presentation. Consume suppressed alerts as well,// so a delivery retry cannot surface them after the app backgrounds.if (!ProcessLifecycleOwner.get().lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) {- val title = data["alert_title"].orEmpty().take(120)- // Grouped alerts list up to five 120-character thread titles.- val body = data["alert_body"].orEmpty().take(608)- val id = alertId.hashCode()- val notification = base(context, ALERT_CHANNEL)- .setContentTitle(title).setContentText(body)- .setStyle(NotificationCompat.BigTextStyle().bigText(body))- .setAutoCancel(true)- .setContentIntent(contentIntent(context, scheme, data["alert_path"], id))- .build()- manager(context).notify(ALERT_TAG, id, notification)+ postAlert(context, scheme, data, alertId)}prefs.edit().remove("seenAlerts").putString("seenAlertsOrdered",@@ -157,6 +147,36 @@ object AgentNotifications {}}+ private fun postAlert(+ context: Context,+ scheme: String,+ data: Map<String, String>,+ alertId: String+ ) {+ val title = data["alert_title"].orEmpty().take(120)+ // Grouped alerts list up to five 120-character thread titles.+ val body = data["alert_body"].orEmpty().take(608)+ val id = alertId.hashCode()+ val notification = base(context, ALERT_CHANNEL)+ .setContentTitle(title).setContentText(body)+ .setStyle(NotificationCompat.BigTextStyle().bigText(body))+ .setAutoCancel(true)+ .setContentIntent(contentIntent(context, scheme, data["alert_path"], id))+ .build()+ manager(context).notify(ALERT_TAG, id, notification)+ }++ /**+ * Renders a relay-shaped payload without the registration, freshness and+ * foreground checks, for the showcase capture's staged notifications.+ */+ @Synchronized+ fun showcase(context: Context, scheme: String, data: Map<String, String>) {+ channels(context)+ data["alert_id"]?.let { postAlert(context, scheme, data, it) }+ showActivity(context, scheme, data, data["active"] == "true", RUNNING_LIFETIME_MS)+ }+private fun updateActivity(context: Context,prefs: SharedPreferences,diff --git a/apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/T3AgentNotificationsModule.kt b/apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/T3AgentNotificationsModule.ktindex 246db274a19..0a2d2b30589 100644--- a/apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/T3AgentNotificationsModule.kt+++ b/apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/T3AgentNotificationsModule.kt@@ -26,6 +26,10 @@ class T3AgentNotificationsModule : Module() {appContext.reactContext?.let { AgentNotifications.clear(it) }}+ Function("showShowcaseActivity") { scheme: String, data: Map<String, String> ->+ appContext.reactContext?.let { AgentNotifications.showcase(it, scheme, data) }+ }+Function("openLiveUpdateSettings") {val context = appContext.reactContextif (context == null || Build.VERSION.SDK_INT < 36) {diff --git a/apps/mobile/src/features/agent-awareness/androidNotifications.ts b/apps/mobile/src/features/agent-awareness/androidNotifications.tsindex 9ffe586ecb8..a2a0945faaf 100644--- a/apps/mobile/src/features/agent-awareness/androidNotifications.ts+++ b/apps/mobile/src/features/agent-awareness/androidNotifications.ts@@ -6,6 +6,7 @@ interface AndroidAgentNotifications {configure(deviceId: string, userId: string, scheme: string, ongoingEnabled: boolean): void;clear(): void;openLiveUpdateSettings?(): boolean;+ showShowcaseActivity?(scheme: string, data: Record<string, string>): void;}const native =@@ -17,18 +18,24 @@ export function supportsAndroidAgentNotifications(): boolean {return typeof native?.configure === "function" && typeof native?.clear === "function";}+function appScheme(): string {+ const scheme = Constants.expoConfig?.scheme;+ return (Array.isArray(scheme) ? scheme[0] : scheme) ?? "t3code";+}+export function configureAndroidAgentNotifications(deviceId: string,userId: string,ongoingEnabled: boolean,): void {- const scheme = Constants.expoConfig?.scheme;- native?.configure?.(- deviceId,- userId,- (Array.isArray(scheme) ? scheme[0] : scheme) ?? "t3code",- ongoingEnabled,- );+ native?.configure?.(deviceId, userId, appScheme(), ongoingEnabled);+}++/** Posts a staged relay payload for the showcase capture; false when unsupported. */+export function showAndroidShowcaseAgentActivity(data: Record<string, string>): boolean {+ if (!native?.showShowcaseActivity) return false;+ native.showShowcaseActivity(appScheme(), data);+ return true;}export function clearAndroidAgentNotifications(): void {diff --git a/apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx b/apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsxindex 557c3b19035..716f4edd416 100644--- a/apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx+++ b/apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx@@ -29,6 +29,7 @@ import {buildShowcasePendingTasks,SHOWCASE_PENDING_TASK_DEFINITIONS,} from "./showcasePendingTasks";+import { buildShowcaseAgentActivity } from "./showcaseAgentActivity";import { retryShowcaseOperation } from "./showcaseRetry";import {clearShowcaseRenderSignal,@@ -36,6 +37,7 @@ import {isShowcaseNativeContentReady,subscribeToShowcaseRenderSignal,} from "./showcaseRenderSignal";+import { stageShowcaseAgentActivity } from "./stageShowcaseAgentActivity";const SHOWCASE_ENABLED = process.env.EXPO_PUBLIC_SHOWCASE === "1";const SHOWCASE_THREAD_ID = "remote-command-center";@@ -75,7 +77,14 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })const [themeRequestSettled, setThemeRequestSettled] = useState(false);const [readyScene, setReadyScene] = useState<ShowcaseScene | null>(null);const [orientationSettled, setOrientationSettled] = useState(false);+ const [agentActivityStaged, setAgentActivityStaged] = useState(false);const requestedSceneRef = useRef<ShowcaseScene | null>(null);+ // Staging reads the latest entities without restarting on every shell+ // update, which would re-enter a permission prompt that is still open.+ const entitiesRef = useRef({ threads, projects });+ useEffect(() => {+ entitiesRef.current = { threads, projects };+ }, [projects, threads]);const renderSignal = useSyncExternalStore(subscribeToShowcaseRenderSignal,getShowcaseRenderSignal,@@ -109,6 +118,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })}let cancelled = false;+ let lastOutcome: string | null = null;void retryShowcaseOperation(async () => applyNativeShowcaseOrientation(orientation), {isCancelled: () => cancelled,}).then((applied) => {@@ -129,6 +139,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })// A native draw belongs only to the scene request that produced it. In// particular, revisiting review must wait for its newly mounted surface.clearShowcaseRenderSignal();+ setAgentActivityStaged(false);setRequestedScene(value);};readRequestedScene();@@ -176,7 +187,11 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })};}, [connectPairingUrl, pairingUrls]);- const scene = sceneFromPathname(props.pathname);+ const routeScene = sceneFromPathname(props.pathname);+ // Agent activity is captured over the thread list: the runner locks the+ // simulator or opens the notification shade on top of it.+ const scene =+ requestedScene === "agent-activity" && routeScene === "threads" ? "agent-activity" : routeScene;const hasServerFixture =workspace.state.hasReadyEnvironment &&workspace.environments.length >= 3 &&@@ -228,6 +243,11 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })navigation.dispatch(StackActions.popToTop());return;}+ // Follows the environments scene, whose settings sheet popToTop leaves open.+ if (requestedScene === "agent-activity") {+ navigation.dispatch(CommonActions.reset({ index: 0, routes: [{ name: "Home" }] }));+ return;+ }const routes: ShowcaseResetRoute[] = [{ name: "Home" }];if (requestedScene === "environments") {routes.push({@@ -264,6 +284,39 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string }));}, [hasFixture, navigation, requestedScene, scene, showcaseThread]);+ useEffect(() => {+ if (!SHOWCASE_ENABLED || scene !== "agent-activity" || !hasFixture || agentActivityStaged) {+ return;+ }+ let cancelled = false;+ let lastOutcome: string | null = null;+ void retryShowcaseOperation(+ async () => {+ const now = Date.now();+ const { threads: latestThreads, projects: latestProjects } = entitiesRef.current;+ const activity = buildShowcaseAgentActivity(latestThreads, latestProjects, now);+ const outcome =+ activity === null+ ? "fixture threads not loaded"+ : await stageShowcaseAgentActivity(activity, now);+ if (outcome === true) return true;+ // Surfaces in the runner's Metro output when the scene never turns ready.+ if (outcome !== lastOutcome)+ console.warn(`[showcase] agent activity not staged: ${outcome}`);+ lastOutcome = outcome;+ return false;+ },+ // The first attempt waits on the notification permission prompt until+ // the runner answers it.+ { isCancelled: () => cancelled, attemptTimeoutMs: 60_000 },+ ).then((staged) => {+ if (!cancelled && staged) setAgentActivityStaged(true);+ });+ return () => {+ cancelled = true;+ };+ }, [agentActivityStaged, hasFixture, scene]);+useEffect(() => {if (!SHOWCASE_ENABLED ||@@ -276,6 +329,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })!orientationSettled ||// Likewise for the palette: an early screenshot shows the default theme.!themeApplied ||+ (scene === "agent-activity" && !agentActivityStaged) ||!isShowcaseNativeContentReady({ scene, themeId, renderSignal })) {setReadyScene(null);@@ -298,7 +352,16 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })if (renderFrame !== null) cancelAnimationFrame(renderFrame);if (readyFrame !== null) cancelAnimationFrame(readyFrame);};- }, [hasFixture, orientationSettled, renderSignal, requestedScene, scene, themeApplied, themeId]);+ }, [+ agentActivityStaged,+ hasFixture,+ orientationSettled,+ renderSignal,+ requestedScene,+ scene,+ themeApplied,+ themeId,+ ]);if (!SHOWCASE_ENABLED || readyScene === null) return null;diff --git a/apps/mobile/src/features/showcase/nativeShowcaseScene.ts b/apps/mobile/src/features/showcase/nativeShowcaseScene.tsindex 11618291932..33839b2fe47 100644--- a/apps/mobile/src/features/showcase/nativeShowcaseScene.ts+++ b/apps/mobile/src/features/showcase/nativeShowcaseScene.ts@@ -2,7 +2,14 @@ import { requireOptionalNativeModule } from "expo";import { MOBILE_THEME_IDS, type MobileThemeId } from "../../lib/mobileTheme";-export const SHOWCASE_SCENES = ["threads", "thread", "terminal", "review", "environments"] as const;+export const SHOWCASE_SCENES = [+ "threads",+ "thread",+ "terminal",+ "review",+ "environments",+ "agent-activity",+] as const;export type ShowcaseScene = (typeof SHOWCASE_SCENES)[number];export type ShowcaseOrientation = "portrait" | "landscape";diff --git a/apps/mobile/src/features/showcase/showcaseAgentActivity.test.ts b/apps/mobile/src/features/showcase/showcaseAgentActivity.test.tsnew file mode 100644index 00000000000..94aaa2fc5e9--- /dev/null+++ b/apps/mobile/src/features/showcase/showcaseAgentActivity.test.ts@@ -0,0 +1,93 @@+import type {+ EnvironmentProject,+ EnvironmentThreadShell,+} from "@t3tools/client-runtime/state/shell";+import { EnvironmentId, ProjectId, ThreadId } from "@t3tools/contracts";+import { assert, it } from "@effect/vitest";++import {+ buildShowcaseAgentActivity,+ SHOWCASE_AGENT_ACTIVITY_ROWS,+ showcaseAndroidActivityData,+} from "./showcaseAgentActivity";++const NOW = Date.parse("2026-07-16T09:00:00.000Z");++const project = (environmentId: string, id: string, title: string) =>+ ({+ environmentId: EnvironmentId.make(environmentId),+ id: ProjectId.make(id),+ title,+ }) as EnvironmentProject;++const thread = (environmentId: string, id: string, projectId: string, title: string) =>+ ({+ environmentId: EnvironmentId.make(environmentId),+ id: ThreadId.make(id),+ projectId: ProjectId.make(projectId),+ title,+ }) as EnvironmentThreadShell;++const projects = [+ project("moonbase-terminal", "t3code", "T3 Code"),+ project("suspense-station", "react", "React"),+ project("kernel-cabin", "linux", "Linux"),+];++const threads = [+ thread("moonbase-terminal", "remote-command-center", "t3code", "Make remote coding feel local"),+ thread(+ "moonbase-terminal",+ "pocket-command-center",+ "t3code",+ "Put the command center in your pocket",+ ),+ thread("suspense-station", "buttery-suspense", "react", "Make Suspense transitions buttery"),+ thread("kernel-cabin", "beautiful-boot", "linux", "Make boot logs oddly beautiful"),+];++it("waits until every staged thread and its project have loaded", () => {+ assert.isNull(buildShowcaseAgentActivity(threads.slice(1), projects, NOW));+ assert.isNull(buildShowcaseAgentActivity(threads, projects.slice(0, 2), NOW));+});++it("stages relay-shaped rows against the seeded threads", () => {+ const activity = buildShowcaseAgentActivity(threads, projects, NOW);+ assert.isNotNull(activity);+ if (!activity) return;++ assert.strictEqual(activity.activeCount, 3);+ assert.deepStrictEqual(+ activity.activities.map((row) => [row.threadId, row.status, row.projectTitle, row.updatedAt]),+ [+ ["pocket-command-center", "Approval", "T3 Code", "2026-07-16T08:59:00.000Z"],+ ["beautiful-boot", "Input", "Linux", "2026-07-16T08:56:00.000Z"],+ ["buttery-suspense", "Working", "React", "2026-07-16T08:58:00.000Z"],+ ["remote-command-center", "Done", "T3 Code", "2026-07-16T08:57:00.000Z"],+ ],+ );+ assert.strictEqual(+ activity.activities[0]?.deepLink,+ "/threads/moonbase-terminal/pocket-command-center",+ );+ assert.strictEqual(activity.activities.length, SHOWCASE_AGENT_ACTIVITY_ROWS.length);+});++it("encodes the Android Live Update and its alert like a relay push", () => {+ const activity = buildShowcaseAgentActivity(threads, projects, NOW);+ assert.isNotNull(activity);+ if (!activity) return;+ const data = showcaseAndroidActivityData(activity, NOW);++ assert.strictEqual(data.active, "true");+ assert.strictEqual(data.activity_chip, "Review");+ assert.strictEqual(data.activity_title, "3 active agents · 2 need attention");+ assert.strictEqual(+ data.activity_line_0,+ "Approval\tPut the command center in your pocket\tT3 Code",+ );+ assert.strictEqual(data.activity_line_3, "Done\tMake remote coding feel local\tT3 Code");+ assert.strictEqual(data.alert_title, "Put the command center in your pocket");+ assert.strictEqual(data.alert_body, "Approval: T3 Code");+ assert.strictEqual(data.alert_path, "/threads/moonbase-terminal/pocket-command-center");+});diff --git a/apps/mobile/src/features/showcase/showcaseAgentActivity.ts b/apps/mobile/src/features/showcase/showcaseAgentActivity.tsnew file mode 100644index 00000000000..736c672dff0--- /dev/null+++ b/apps/mobile/src/features/showcase/showcaseAgentActivity.ts@@ -0,0 +1,138 @@+import type {+ EnvironmentProject,+ EnvironmentThreadShell,+} from "@t3tools/client-runtime/state/shell";++import type {+ AgentActivityPhase,+ AgentActivityProps,+ AgentActivityRowProps,+} from "../../widgets/AgentActivity";++/**+ * Agent work shown by the agent-activity scene. The rows point at+ * seeded showcase threads so the copy matches the thread list, but the phases+ * are staged: the relay that normally derives them is not part of the capture.+ * Rows follow the relay's order: attention first, then running, then finished.+ */+export const SHOWCASE_AGENT_ACTIVITY_ROWS = [+ { threadId: "pocket-command-center", phase: "waiting_for_approval", minutesAgo: 1 },+ { threadId: "beautiful-boot", phase: "waiting_for_input", minutesAgo: 4 },+ { threadId: "buttery-suspense", phase: "running", minutesAgo: 2 },+ { threadId: "remote-command-center", phase: "completed", minutesAgo: 3 },+] as const satisfies ReadonlyArray<{+ readonly threadId: string;+ readonly phase: AgentActivityPhase;+ readonly minutesAgo: number;+}>;++// Matches the relay's row wording (AgentActivityPublisher.statusForPhase).+const STATUS_BY_PHASE: Record<AgentActivityPhase, string> = {+ starting: "Connecting",+ running: "Working",+ waiting_for_approval: "Approval",+ waiting_for_input: "Input",+ stale: "Waiting",+ completed: "Done",+ failed: "Failed",+};++const ACTIVE_PHASES: ReadonlySet<AgentActivityPhase> = new Set([+ "starting",+ "running",+ "waiting_for_approval",+ "waiting_for_input",+]);++/** Returns null until every staged thread and its project have loaded. */+export function buildShowcaseAgentActivity(+ threads: ReadonlyArray<EnvironmentThreadShell>,+ projects: ReadonlyArray<EnvironmentProject>,+ now: number,+): AgentActivityProps | null {+ const rows: AgentActivityRowProps[] = [];+ for (const definition of SHOWCASE_AGENT_ACTIVITY_ROWS) {+ const thread = threads.find((candidate) => String(candidate.id) === definition.threadId);+ const project = thread+ ? projects.find(+ (candidate) =>+ candidate.environmentId === thread.environmentId && candidate.id === thread.projectId,+ )+ : undefined;+ if (!thread || !project) return null;+ const environmentId = String(thread.environmentId);+ rows.push({+ environmentId,+ threadId: definition.threadId,+ projectTitle: project.title,+ threadTitle: thread.title,+ modelTitle: "",+ phase: definition.phase,+ status: STATUS_BY_PHASE[definition.phase],+ updatedAt: new Date(now - definition.minutesAgo * 60_000).toISOString(),+ deepLink: `/threads/${encodeURIComponent(environmentId)}/${encodeURIComponent(definition.threadId)}`,+ });+ }+ return {+ title: "T3 Code",+ subtitle: "Agent work in progress",+ activeCount: rows.filter((row) => ACTIVE_PHASES.has(row.phase)).length,+ updatedAt: new Date(now).toISOString(),+ activities: rows,+ };+}++/** The alert the relay sends when the hero row starts waiting on the user. */+export function showcaseAgentAlert(activity: AgentActivityProps) {+ const row = activity.activities[0];+ if (!row) return null;+ return {+ title: row.threadTitle,+ body: `${row.status}: ${row.projectTitle}`,+ path: row.deepLink,+ environmentId: row.environmentId,+ threadId: row.threadId,+ };+}++/**+ * The FCM data map Android's native receiver renders, mirroring the relay's+ * androidActivityData so the shade shows exactly what a real push produces.+ */+export function showcaseAndroidActivityData(+ activity: AgentActivityProps,+ now: number,+): Record<string, string> {+ const attentionCount = activity.activities.filter(+ (row) => row.phase === "waiting_for_approval" || row.phase === "waiting_for_input",+ ).length;+ const hero = activity.activities[0];+ const alert = showcaseAgentAlert(activity);+ return {+ t3_kind: "agent_activity",+ updated_at: String(now),+ active: String(activity.activeCount > 0),+ activity_chip: attentionCount > 0 ? "Review" : "Active",+ activity_title: `${activity.activeCount} active agents · ${attentionCount} need attention`,+ activity_phase: hero?.phase ?? "",+ activity_active_count: String(activity.activeCount),+ activity_attention_count: String(attentionCount),+ activity_body: hero ? `${hero.status}: ${hero.threadTitle} · ${hero.projectTitle}` : "",+ ...Object.fromEntries(+ activity.activities.map((row, index) => [+ `activity_line_${index}`,+ [row.status, row.threadTitle, row.projectTitle].join("\t"),+ ]),+ ),+ activity_path: hero?.deepLink ?? "/",+ activity_expires_at: String(now + 2 * 60 * 60_000),+ ...(alert+ ? {+ alert_id: "showcase-alert",+ alert_title: alert.title,+ alert_body: alert.body,+ alert_path: alert.path,+ }+ : {}),+ };+}diff --git a/apps/mobile/src/features/showcase/stageShowcaseAgentActivity.ts b/apps/mobile/src/features/showcase/stageShowcaseAgentActivity.tsnew file mode 100644index 00000000000..6b1f61815b3--- /dev/null+++ b/apps/mobile/src/features/showcase/stageShowcaseAgentActivity.ts@@ -0,0 +1,42 @@+import * as Notifications from "expo-notifications";+import { Platform } from "react-native";++import type { AgentActivityProps } from "../../widgets/AgentActivity";+import {+ getAgentLiveActivities,+ startAgentLiveActivity,+} from "../agent-awareness/agentLiveActivity";+import { showAndroidShowcaseAgentActivity } from "../agent-awareness/androidNotifications";+import { showcaseAndroidActivityData } from "./showcaseAgentActivity";++/**+ * Puts the staged agent activity on screen for the capture runner, which then+ * locks the simulator (iOS) or opens the notification shade (Android).+ * Resolves true once shown, otherwise the reason it could not be, so the+ * caller can retry and report.+ */+export async function stageShowcaseAgentActivity(+ activity: AgentActivityProps,+ now: number,+): Promise<true | string> {+ // The runner answers the iOS prompt and pre-grants Android's, so this only+ // settles the permission the runner's alert delivery depends on.+ const permission = await Notifications.requestPermissionsAsync({+ ios: { allowAlert: true, allowBadge: true, allowSound: true },+ });+ if (!permission.granted) return `notification permission ${permission.status}`;++ if (Platform.OS === "android") {+ return (+ showAndroidShowcaseAgentActivity(showcaseAndroidActivityData(activity, now)) ||+ "native showShowcaseActivity missing"+ );+ }+ if (Platform.OS !== "ios") return `unsupported platform ${Platform.OS}`;++ // A retried or revisited scene must not stack a second card.+ await Promise.all(getAgentLiveActivities().map((existing) => existing.end("immediate")));+ // ActivityKit only starts activities while the app is foreground, which+ // holds here: the runner locks the device after the scene reports ready.+ return startAgentLiveActivity(activity) !== null || "Live Activity did not start";+}diff --git a/docs/operations/mobile-app-store-screenshots.md b/docs/operations/mobile-app-store-screenshots.mdindex 0e3c1784429..5d6fff05155 100644--- a/docs/operations/mobile-app-store-screenshots.md+++ b/docs/operations/mobile-app-store-screenshots.md@@ -52,8 +52,8 @@ verify process ownership. Concurrent screenshot harnesses in different worktreescollide or attach to the wrong Metro process.Every configured device defaults to dark appearance and the `t3-code` palette, so plain-`pnpm screenshots:mobile` produces 30 dark PNGs. Pass `--appearance light`, `--appearance dark`, or-`--appearance both` to override the configured appearance; `both` produces 60 PNGs.+`pnpm screenshots:mobile` produces 35 dark PNGs. Pass `--appearance light`, `--appearance dark`, or+`--appearance both` to override the configured appearance; `both` produces 70 PNGs.Pass `--theme <id>` (repeatable) or `--theme all` to capture the app's other palettes: `t3-code`,`t3-chat`, `grove`, `ocean`, `ember`, and `iris`. The runner hands the palette to the app as a launch@@ -72,23 +72,32 @@ The default matrix is:| `google-play/tablet-7/dark/t3-code/` | Pixel AVD at 600dp width | 1080×1920 | Google Play 7-inch tablet, portrait 9:16 || `google-play/tablet-10/dark/t3-code/` | Pixel AVD at 800dp width | 1440×2560 | Google Play 10-inch tablet, portrait 9:16 |-Each target captures thread, terminal, review, thread list, and environments. Each palette folder's-five screenshots satisfy the configured Apple limit of 1–10, Google+Each target captures thread, terminal, review, thread list, and environments, and every target but+the iPad also captures agent activity. Each palette folder's five or six screenshots satisfy the configured Apple limit of 1–10, Googlephone requirement of 2–8, and Google tablet recommendation/slot minimum of 4 with a maximum of 8.Every palette gets its own leaf folder so one upload slot never mixes themes and each folder keeps astore-legal screenshot count.+The agent-activity scene shows what a user sees away from the app. The app stages the same Live+Activity (iOS) or ongoing Live Update (Android) the relay would publish for four seeded threads. On+iOS the runner then locks the simulator and pushes the matching approval alert with `simctl push`;+on Android the staged update carries the alert and the runner opens the notification shade. Locking+the simulator and answering the notification permission prompt use+[AXe](https://github.com/cameroncooke/AXe), so install it (`brew tap cameroncooke/axe && brew+install axe`) or set `AXE_PATH` before capturing iOS. The iPad skips the scene because the lock+screen does not follow the app's landscape self-rotation.+The generated tree is deliberately aligned with the store upload fields:artifacts/app-store/screenshots/├── apple/- │ ├── iphone-6.9/dark/t3-code/{thread,terminal,review,threads,environments}.png- │ ├── iphone-6.5/dark/t3-code/{thread,terminal,review,threads,environments}.png+ │ ├── iphone-6.9/dark/t3-code/{thread,terminal,review,threads,environments,agent-activity}.png+ │ ├── iphone-6.5/dark/t3-code/{thread,terminal,review,threads,environments,agent-activity}.png│ └── ipad-13/dark/t3-code/{thread,terminal,review,threads,environments}.png└── google-play/- ├── phone/dark/t3-code/{thread,terminal,review,threads,environments}.png- ├── tablet-7/dark/t3-code/{thread,terminal,review,threads,environments}.png- └── tablet-10/dark/t3-code/{thread,terminal,review,threads,environments}.png+ ├── phone/dark/t3-code/{thread,terminal,review,threads,environments,agent-activity}.png+ ├── tablet-7/dark/t3-code/{thread,terminal,review,threads,environments,agent-activity}.png+ └── tablet-10/dark/t3-code/{thread,terminal,review,threads,environments,agent-activity}.pngA light-only run writes the same tree under `light/`; `--appearance both` writes both appearancefolders, and each requested theme adds a sibling folder next to `t3-code/`.diff --git a/scripts/mobile-showcase-environment.ts b/scripts/mobile-showcase-environment.tsindex 93738b61325..209df77bf80 100644--- a/scripts/mobile-showcase-environment.ts+++ b/scripts/mobile-showcase-environment.ts@@ -11,7 +11,14 @@ export const SHOWCASE_PROJECT_ID = "t3code";export const SHOWCASE_THREAD_ID = "remote-command-center";export const SHOWCASE_TERMINAL_ID = "term-1";-export const SHOWCASE_SCENES = ["threads", "thread", "terminal", "review", "environments"] as const;+export const SHOWCASE_SCENES = [+ "threads",+ "thread",+ "terminal",+ "review",+ "environments",+ "agent-activity",+] as const;export type ShowcaseScene = (typeof SHOWCASE_SCENES)[number];const PROJECTOR_NAMES = [diff --git a/scripts/mobile-showcase.config.ts b/scripts/mobile-showcase.config.tsindex 45a9f474fa8..c52d1f1dd11 100644--- a/scripts/mobile-showcase.config.ts+++ b/scripts/mobile-showcase.config.ts@@ -108,7 +108,7 @@ const config: ShowcaseConfig = {simulatorDeviceType: "com.apple.CoreSimulator.SimDeviceType.iPhone-17-Pro-Max",appearance: "dark",theme: DEFAULT_SHOWCASE_THEME,- scenes: ["thread", "terminal", "review", "threads", "environments"],+ scenes: ["thread", "terminal", "review", "threads", "environments", "agent-activity"],storeAsset: {store: "apple",directory: "apple/iphone-6.9",@@ -125,7 +125,7 @@ const config: ShowcaseConfig = {simulatorDeviceType: "com.apple.CoreSimulator.SimDeviceType.iPhone-14-Plus",appearance: "dark",theme: DEFAULT_SHOWCASE_THEME,- scenes: ["thread", "terminal", "review", "threads", "environments"],+ scenes: ["thread", "terminal", "review", "threads", "environments", "agent-activity"],storeAsset: {store: "apple",directory: "apple/iphone-6.5",@@ -143,6 +143,8 @@ const config: ShowcaseConfig = {appearance: "dark",theme: DEFAULT_SHOWCASE_THEME,orientation: "landscape",+ // The lock screen does not follow the app's self-rotation, so a+ // headless landscape capture of it would come out sideways.scenes: ["thread", "terminal", "review", "threads", "environments"],storeAsset: {store: "apple",@@ -167,7 +169,7 @@ const config: ShowcaseConfig = {height: 1920,density: 420,},- scenes: ["thread", "terminal", "review", "threads", "environments"],+ scenes: ["thread", "terminal", "review", "threads", "environments", "agent-activity"],storeAsset: {store: "google-play",directory: "google-play/phone",@@ -190,7 +192,7 @@ const config: ShowcaseConfig = {height: 1920,density: 288,},- scenes: ["thread", "terminal", "review", "threads", "environments"],+ scenes: ["thread", "terminal", "review", "threads", "environments", "agent-activity"],storeAsset: {store: "google-play",directory: "google-play/tablet-7",@@ -213,7 +215,7 @@ const config: ShowcaseConfig = {height: 2560,density: 288,},- scenes: ["thread", "terminal", "review", "threads", "environments"],+ scenes: ["thread", "terminal", "review", "threads", "environments", "agent-activity"],storeAsset: {store: "google-play",directory: "google-play/tablet-10",diff --git a/scripts/mobile-showcase.ts b/scripts/mobile-showcase.tsindex ccce919a744..1fa8e3009f4 100644--- a/scripts/mobile-showcase.ts+++ b/scripts/mobile-showcase.ts@@ -26,6 +26,7 @@ import showcaseConfig, {import {SHOWCASE_ENVIRONMENTS,SHOWCASE_PROJECTS,+ SHOWCASE_THREADS,seedShowcaseEnvironment,} from "./mobile-showcase-environment.ts";@@ -934,6 +935,133 @@ async function waitForIosShowcaseScene(throw new Error(`iOS showcase scene '${scene}' did not render within ${timeoutMs}ms.`);}+function iosAxe(): string {+ return NodeProcess.env.AXE_PATH ?? "axe";+}++async function runAxe(udid: string, args: ReadonlyArray<string>): Promise<void> {+ // HID events sent right after the simulator settles are dropped without it.+ await runCommand(iosAxe(), [...args, "--udid", udid], {+ env: { ...NodeProcess.env, AXE_HID_STABILIZATION_MS: "3000" },+ }).catch((error: unknown) => {+ if ((error as NodeJS.ErrnoException).code === "ENOENT") {+ throw new Error(+ "The agent-activity scene drives the simulator with AXe. Install it with `brew tap cameroncooke/axe && brew install axe`, or set AXE_PATH.",+ );+ }+ throw error;+ });+}++async function iosSimulatorLocked(udid: string): Promise<boolean> {+ const state = await commandOutput("xcrun", [+ "simctl",+ "spawn",+ udid,+ "notifyutil",+ "-g",+ "com.apple.springboard.lockstate",+ ]).catch(() => "");+ return state.trim().endsWith(" 1");+}++/**+ * The staging app asks for notification permission; simctl has no privacy+ * service for it, so answer the prompt until the scene reports ready.+ */+async function allowIosNotificationsUntilReady(udid: string, ready: Promise<void>): Promise<void> {+ const state = { settled: false };+ const tapping = (async () => {+ while (!state.settled) {+ await runAxe(udid, ["tap", "--label", "Allow"]).catch(() => undefined);+ if (!state.settled) await delay(1_000);+ }+ })();+ try {+ await ready;+ } finally {+ state.settled = true;+ await tapping;+ }+}++/**+ * Locks the simulator over the staged Live Activity and delivers the alert a+ * relay push would, so the lock screen shows both.+ */+async function presentIosLockScreen(udid: string): Promise<void> {+ await runAxe(udid, ["button", "lock"]);+ const deadline = Date.now() + 15_000;+ while (!(await iosSimulatorLocked(udid))) {+ if (Date.now() > deadline) throw new Error(`Simulator ${udid} did not lock.`);+ await delay(500);+ }+ const alert = showcaseAgentAlert();+ await new Promise<void>((resolve, reject) => {+ const child = NodeChildProcess.execFile(+ "xcrun",+ ["simctl", "push", udid, ANDROID_PACKAGE, "-"],+ { cwd: REPO_ROOT },+ (error) => (error ? reject(error) : resolve()),+ );+ child.stdin?.end(+ JSON.stringify({+ aps: { alert: { title: alert.title, body: alert.body }, sound: "default" },+ }),+ );+ });+ await wakeIosLockScreen(udid);+ // The first Live Activity on the lock screen asks to keep allowing them.+ await delay(2_000);+ await runAxe(udid, ["tap", "--label", "Allow"]).catch(() => undefined);+}++/**+ * The alert usually wakes the display, but not always. A home press on a dark+ * display only wakes it, so press only after a screenshot proves it is dark;+ * pressing on a lit lock screen would unlock the device instead.+ */+async function wakeIosLockScreen(udid: string): Promise<void> {+ const probe = NodePath.join(NodeOS.tmpdir(), `t3-showcase-wake-${udid}.png`);+ try {+ for (let attempt = 0; attempt < 5; attempt += 1) {+ await delay(2_000);+ await runCommand("xcrun", ["simctl", "io", udid, "screenshot", probe]);+ if (!pngIsBlack(await NodeFSP.readFile(probe))) return;+ await runAxe(udid, ["button", "home"]);+ }+ throw new Error(`Simulator ${udid} lock screen stayed dark.`);+ } finally {+ await NodeFSP.rm(probe, { force: true });+ }+}++function pngIsBlack(bytes: Uint8Array): boolean {+ const { data } = PNG.sync.read(Buffer.from(bytes));+ // Sample a sparse grid; a sleeping display is uniformly black.+ for (let offset = 0; offset < data.length; offset += 4 * 997) {+ if ((data[offset] ?? 0) > 8 || (data[offset + 1] ?? 0) > 8 || (data[offset + 2] ?? 0) > 8) {+ return false;+ }+ }+ return true;+}++async function unlockIosSimulator(udid: string): Promise<void> {+ // The first press wakes the display, the second dismisses the lock screen.+ await runAxe(udid, ["button", "home"]);+ await delay(2_000);+ await runAxe(udid, ["button", "home"]);+}++/** Mirrors the app's staged hero row (showcaseAgentActivity.ts). */+function showcaseAgentAlert(): { readonly title: string; readonly body: string } {+ const thread = SHOWCASE_THREADS.find((candidate) => candidate.id === "pocket-command-center");+ const project = SHOWCASE_PROJECTS.find((candidate) => candidate.id === thread?.projectId);+ if (!thread || !project) throw new Error("The showcase fixture lost its agent-activity thread.");+ return { title: thread.title, body: `Approval: ${project.title}` };+}+async function captureIos(capture: ShowcaseCapture & { readonly device: ShowcaseIosDevice },appPath: string | null,@@ -1021,6 +1149,12 @@ async function captureIos(for (const [sceneIndex, scene] of capture.scenes.entries()) {if (sceneIndex > 0) await NodeFSP.rm(readyPath, { force: true });await NodeFSP.writeFile(scenePath, scene);+ const waitForScene = (timeoutMs?: number) => {+ const ready = waitForIosShowcaseScene(simulator.udid, scene, timeoutMs);+ return scene === "agent-activity"+ ? allowIosNotificationsUntilReady(simulator.udid, ready)+ : ready;+ };if (sceneIndex === 0) {for (let attempt = 0; attempt < 2; attempt += 1) {const isLastAttempt = attempt === 1;@@ -1028,7 +1162,7 @@ async function captureIos(// A freshly installed Expo development build can spend well over 30s// applying an already-bundled update after it reaches 100%. Killing it// at that point sends the next capture back to the dev launcher.- await waitForIosShowcaseScene(simulator.udid, scene, 120_000);+ await waitForScene(120_000);break;} catch (error) {if (isLastAttempt) throw error;@@ -1036,8 +1170,9 @@ async function captureIos(}}} else {- await waitForIosShowcaseScene(simulator.udid, scene);+ await waitForScene();}+ if (scene === "agent-activity") await presentIosLockScreen(simulator.udid);await delay(scene === "review" ? Math.max(config.settleDelayMs, 8_000) : config.settleDelayMs);const destination = NodePath.join(showcaseCaptureDirectory(outputDirectory, capture),@@ -1053,6 +1188,7 @@ async function captureIos(await runCommand("sips", ["--rotate", "270", destination]);}}+ if (scene === "agent-activity") await unlockIosSimulator(simulator.udid);await finalizeCapture(destination, capture.device);}}@@ -1069,6 +1205,22 @@ async function runAdb(serial: string, args: ReadonlyArray<string>): Promise<voidawait runCommand(androidSdkTool("platform-tools/adb"), ["-s", serial, ...args]);}+/**+ * Emulator images post their own ongoing notices (keyboard configured, serial+ * console enabled) that would share the shade with the app's. Snoozing hides+ * them for the capture; they come back on their own an hour later.+ */+async function snoozeAndroidSystemNotifications(serial: string): Promise<void> {+ const keys = (await adbOutput(serial, ["shell", "cmd", "notification", "list"]))+ .split("\n")+ .map((line) => line.trim())+ .filter((key) => key.includes("|") && !key.includes(`|${ANDROID_PACKAGE}|`));+ for (const key of keys) {+ // adb joins shell args with spaces, so the key needs quoting for the pipes.+ await runAdb(serial, ["shell", `cmd notification snooze --for 3600000 '${key}'`]);+ }+}+async function runningAndroidAvds(): Promise<ReadonlyMap<string, string>> {const adb = androidSdkTool("platform-tools/adb");const devices = (await commandOutput(adb, ["devices"]))@@ -1248,6 +1400,15 @@ async function captureAndroid(await runAdb(serial, ["install", "-r", apkPath]);}await runAdb(serial, ["shell", "pm", "clear", ANDROID_PACKAGE]);+ // The agent-activity scene posts notifications; granting up front keeps the+ // runtime prompt off every capture.+ await runAdb(serial, [+ "shell",+ "pm",+ "grant",+ ANDROID_PACKAGE,+ "android.permission.POST_NOTIFICATIONS",+ ]);await prepareAndroidShowcaseApp(serial);await runAdb(serial, ["reverse", `tcp:${config.metroPort}`, `tcp:${config.metroPort}`]);const metroUrl = encodeURIComponent(`http://127.0.0.1:${config.metroPort}?disableOnboarding=1`);@@ -1275,6 +1436,10 @@ async function captureAndroid(for (const [sceneIndex, scene] of capture.scenes.entries()) {if (sceneIndex > 0) await writeAndroidShowcaseScene(serial, scene);await waitForAndroidShowcaseScene(serial, scene);+ if (scene === "agent-activity") {+ await snoozeAndroidSystemNotifications(serial);+ await runAdb(serial, ["shell", "cmd", "statusbar", "expand-notifications"]);+ }await delay(Math.max(config.settleDelayMs, scene === "review" ? 8_000 : 5_000));const destination = NodePath.join(showcaseCaptureDirectory(outputDirectory, capture),@@ -1292,6 +1457,9 @@ async function captureAndroid();});await NodeFSP.writeFile(destination, png);+ if (scene === "agent-activity") {+ await runAdb(serial, ["shell", "cmd", "statusbar", "collapse"]);+ }await finalizeCapture(destination, capture.device);}}