@devries-cameron20 / t3code-1 / commits / 3a4d118a51
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

perf(mobile): device preview compiles with the React Compiler (#20971)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 17, 2026 at 20:12 UTC 3a4d118a518a025e44f11248fc4d2c87eb86aa00
3 files changed +21 -36
apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx
+16 -26
@@ -7,7 +7,7 @@ import {
7 import { useIsFocused, useNavigation, type StaticScreenProps } from "@react-navigation/native";
8 import { EnvironmentId, ThreadId } from "@t3tools/contracts";
9 import * as Cause from "effect/Cause";
10 -import { useCallback, useEffect, useMemo, useRef, useState, type RefObject } from "react";
10 +import { useEffect, useRef, useState, type RefObject } from "react";
11 import * as Haptics from "expo-haptics";
12 import { Accelerometer } from "expo-sensors";
13 import { AppState, BackHandler, Pressable, StatusBar, View } from "react-native";
@@ -47,7 +47,7 @@ type DevicePreviewRouteScreenProps = StaticScreenProps<{
47
48 export function DevicePreviewRouteScreen({ route }: DevicePreviewRouteScreenProps) {
49 const navigation = useNavigation();
50 - const onClose = useCallback(() => navigation.goBack(), [navigation]);
50 + const onClose = () => navigation.goBack();
51 const { environmentId, threadId } = route.params;
52 const isBlankLink = environmentId.trim().length === 0 || threadId.trim().length === 0;
53 useEffect(() => {
@@ -85,15 +85,12 @@ function DevicePreviewScreen({
85 const shutdown = useAtomCommand(deviceEnvironment.shutdown, { reportFailure: false });
86 const streamRef = useRef<DeviceStreamRef>(null);
87 const state = useEnvironmentQuery(deviceEnvironment.state({ environmentId, input: {} }));
88 - const previews = useMemo(
89 - () => threadDevicePreviews(state.data, threadId),
90 - [state.data, threadId],
91 - );
88 + const previews = threadDevicePreviews(state.data, threadId);
89 const preview = selectedThreadDevicePreview(previews, selectedKey);
93 - const onInputConnected = useCallback(async (connected: boolean) => {
90 + const onInputConnected = async (connected: boolean) => {
91 setInputConnected(connected);
92 if (connected) setControlsVisible(false);
96 - }, []);
93 + };
94 useEffect(() => {
95 const subscription = AppState.addEventListener("change", (state) =>
96 setForeground(state !== "background"),
@@ -126,20 +123,16 @@ function DevicePreviewScreen({
123 const shutDownDevice = async () => {
124 if (!preview || shuttingDown) return;
125 setShuttingDown(true);
129 - try {
130 - const result = await shutdown({
131 - environmentId,
132 - input: {
133 - hostId: preview.session.hostId,
134 - deviceId: preview.session.deviceId,
135 - platform: preview.session.platform,
136 - },
137 - });
138 - if (result._tag === "Failure") {
139 - Dialog.alert("Could not shut down device", String(Cause.squash(result.cause)));
140 - }
141 - } finally {
142 - setShuttingDown(false);
126 + const result = await shutdown({
127 + environmentId,
128 + input: {
129 + hostId: preview.session.hostId,
130 + deviceId: preview.session.deviceId,
131 + platform: preview.session.platform,
132 + },
133 + }).finally(() => setShuttingDown(false));
134 + if (result._tag === "Failure") {
135 + Dialog.alert("Could not shut down device", String(Cause.squash(result.cause)));
136 }
137 };
138
@@ -377,10 +370,7 @@ function OpenDevicePreview({
370 const { session } = preview;
371 const { themeVariables } = useAppearancePreferences();
372 const { access, error, refresh } = useDeviceHubAccess(environmentId, session.hostId);
380 - const onUnauthorized = useCallback(
381 - async () => refreshDeviceHubAccess(environmentId),
382 - [environmentId],
383 - );
373 + const onUnauthorized = async () => refreshDeviceHubAccess(environmentId);
374 useEffect(() => {
375 refreshDeviceHubAccess(environmentId);
376 return () => void onInputConnected(false);
apps/mobile/src/features/devices/DeviceStreamWebView.tsx
+5 -9
@@ -4,7 +4,6 @@ import {
4 useEffectEvent,
5 useImperativeHandle,
6 useLayoutEffect,
7 - useMemo,
7 useRef,
8 useState,
9 type Ref,
@@ -112,14 +111,11 @@ function DeviceStreamDocumentView({
111 const timer = setTimeout(bootstrapTimedOut, 15_000);
112 return () => clearTimeout(timer);
113 }, [started]);
115 - const source = useMemo(
116 - () => ({
117 - html: deviceStreamDocument(configuration, deviceStreamScript),
118 - // Android WebCodecs needs a secure document; streams still use the environment's URLs.
119 - baseUrl: Platform.OS === "android" ? "https://localhost/" : "file:///",
120 - }),
121 - [configuration],
122 - );
114 + const source = {
115 + html: deviceStreamDocument(configuration, deviceStreamScript),
116 + // Android WebCodecs needs a secure document; streams still use the environment's URLs.
117 + baseUrl: Platform.OS === "android" ? "https://localhost/" : "file:///",
118 + };
119 const command = (button: keyof DeviceStreamRef) => {
120 webView.current?.injectJavaScript(
121 `window.T3DeviceStream?.command(${JSON.stringify(button)}); true;`,
apps/mobile/src/reactCompilerCoverage.test.ts
-1
@@ -26,7 +26,6 @@ const KNOWN_BAILOUTS: Record<string, string> = {
26 "src/components/ui/Menu.tsx": "ref read during render",
27 "src/components/ui/OverlayPortal.tsx": "unsupported syntax",
28 "src/features/connection/ConnectionsNewRouteScreen.tsx": "try without catch",
29 - "src/features/devices/DevicePreviewRouteScreen.tsx": "try without catch",
29 "src/features/diffs/nativeReviewDiffSurface.ts": "ref read during render",
30 "src/features/files/AttachmentFileScreen.tsx": "manual memo not preserved",
31 "src/features/files/FileMarkdownPreview.tsx": "try without catch",