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 23, 03:00 UTC
perf(mobile): settings screens compile with the React Compiler (#21119)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 18, 2026 at 14:33 UTC
93fbedb50c3fc935158add75077888c7a40bb1ee
7 files changed
+158
-211
apps/mobile/src/features/settings/SettingsAboutRouteScreen.tsx
+12
-11
@@ -1,7 +1,8 @@
1
import * as Dialog from "../../components/ui/Dialog";
2
import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
3
import Constants from "expo-constants";
4
-import { useCallback, useEffect, useRef, useState } from "react";
4
+import { settlePromise } from "@t3tools/client-runtime/state/runtime";
5
+import { useEffect, useRef, useState } from "react";
6
import { Pressable, View } from "react-native";
7
import { useSafeAreaInsets } from "react-native-safe-area-context";
8
@@ -56,30 +57,30 @@ function AppSettingsSection() {
57
return () => clearTimeout(timer);
58
}, [updateState]);
59
59
- const checkForUpdate = useCallback(async () => {
60
+ async function checkForUpdate() {
61
// `disabled={busy}` only takes effect on the next render, so two taps in the
62
// same frame would both get through. The ref closes that window.
63
if (updateInFlight.current) return;
64
updateInFlight.current = true;
64
- try {
65
- await runAppUpdateCheck({
65
+ // Failures arrive through onFailure; the settled result only matters for unlocking.
66
+ await settlePromise(() =>
67
+ runAppUpdateCheck({
68
applyMode: "immediate",
69
onFailure: (message) => Dialog.alert("Update failed", message),
70
onStateChange: setUpdateState,
69
- });
70
- } finally {
71
- updateInFlight.current = false;
72
- }
73
- }, []);
71
+ }),
72
+ );
73
+ updateInFlight.current = false;
74
+ }
75
75
- const handleVersionPress = useCallback(() => {
76
+ function handleVersionPress() {
77
if (!updateCheckAvailable || updateInFlight.current) return;
78
const tap = registerHiddenUpdateTap(hiddenUpdateTapCount.current);
79
hiddenUpdateTapCount.current = tap.nextCount;
80
if (tap.shouldCheck) {
81
void checkForUpdate();
82
}
82
- }, [checkForUpdate, updateCheckAvailable]);
83
+ }
84
85
const statusLabel =
86
updateState === "checking"
apps/mobile/src/features/settings/SettingsEnvironmentDetailRouteScreen.tsx
+15
-20
@@ -7,7 +7,7 @@ import {
7
type EnvironmentId,
8
type ServerProvider,
9
} from "@t3tools/contracts";
10
-import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
10
+import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
11
import { AsyncResult } from "effect/reactivity";
12
import { useEffect, useRef, useState } from "react";
13
import { View } from "react-native";
@@ -96,15 +96,14 @@ function EnvironmentDetail({ environmentId }: { readonly environmentId: Environm
96
setPending(label);
97
setError(null);
98
setNotice(null);
99
- try {
100
- await action();
101
- } catch (cause) {
99
+ const result = await settlePromise(action);
100
+ pendingRef.current = false;
101
+ setPending(null);
102
+ if (AsyncResult.isFailure(result)) {
103
+ const cause = squashAtomCommandFailure(result);
104
setError(
105
cause instanceof Error ? cause.message : "The action could not be completed. Try again.",
106
);
105
- } finally {
106
- pendingRef.current = false;
107
- setPending(null);
107
}
108
}
109
@@ -268,19 +267,15 @@ function EnvironmentDetail({ environmentId }: { readonly environmentId: Environm
267
const controller = new AbortController();
268
checkController.current = controller;
269
const timeout = setTimeout(() => controller.abort(), 20_000);
271
- try {
272
- const targetVersion = await findEnvironmentUpdate(
273
- config.environment.serverVersion,
274
- controller.signal,
275
- );
276
- setRelease({
277
- fromVersion: config.environment.serverVersion,
278
- targetVersion,
279
- });
280
- } finally {
281
- clearTimeout(timeout);
282
- checkController.current = null;
283
- }
270
+ const fromVersion = config.environment.serverVersion;
271
+ const result = await settlePromise(() =>
272
+ findEnvironmentUpdate(fromVersion, controller.signal),
273
+ );
274
+ clearTimeout(timeout);
275
+ checkController.current = null;
276
+ // `run` owns the error message, so a failed lookup rethrows to it.
277
+ if (AsyncResult.isFailure(result)) throw squashAtomCommandFailure(result);
278
+ setRelease({ fromVersion, targetVersion: result.value });
279
});
280
}}
281
/>
apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx
+33
-42
@@ -3,7 +3,7 @@ import { useNavigation } from "@react-navigation/native";
3
import { useAtomValue } from "@effect/atom-react";
4
import { managedRelaySessionAtom } from "@t3tools/client-runtime/relay";
5
import type { EnvironmentId } from "@t3tools/contracts";
6
-import { useCallback, useRef, useState } from "react";
6
+import { useRef, useState } from "react";
7
import { Platform, RefreshControl } from "react-native";
8
import { useSafeAreaInsets } from "react-native-safe-area-context";
9
@@ -59,49 +59,40 @@ export function SettingsEnvironmentsRouteScreen() {
59
if (!relaySession || cloudRefreshPendingRef.current) return;
60
cloudRefreshPendingRef.current = true;
61
setIsRefreshingCloud(true);
62
- try {
63
- await refreshRelayEnvironments();
64
- } finally {
65
- cloudRefreshPendingRef.current = false;
66
- setIsRefreshingCloud(false);
67
- }
62
+ await refreshRelayEnvironments();
63
+ cloudRefreshPendingRef.current = false;
64
+ setIsRefreshingCloud(false);
65
}
66
70
- const openEnvironment = useCallback(
71
- (environmentId: EnvironmentId) => {
72
- navigation.navigate("SettingsSheet", {
73
- screen: "SettingsContent",
74
- params: { screen: "SettingsEnvironmentDetail", params: { environmentId } },
75
- });
76
- },
77
- [navigation],
78
- );
79
- const handleUpdateEnvironment = useCallback(
80
- (
81
- environmentId: EnvironmentId,
82
- updates: { readonly label: string; readonly displayUrl: string },
83
- ) => {
84
- if (!SHOWCASE_ENABLED) return onUpdateEnvironment(environmentId, updates);
85
- const actualEnvironment = environmentSections.localEnvironments.find(
86
- (environment) => environment.environmentId === environmentId,
87
- );
88
- const presentedEnvironment = localEnvironments.find(
89
- (environment) => environment.environmentId === environmentId,
90
- );
91
- return onUpdateEnvironment(environmentId, {
92
- ...updates,
93
- displayUrl:
94
- actualEnvironment && presentedEnvironment
95
- ? resolveShowcaseEnvironmentUpdateDisplayUrl({
96
- actualDisplayUrl: actualEnvironment.displayUrl,
97
- presentedDisplayUrl: presentedEnvironment.displayUrl,
98
- submittedDisplayUrl: updates.displayUrl,
99
- })
100
- : updates.displayUrl,
101
- });
102
- },
103
- [environmentSections.localEnvironments, localEnvironments, onUpdateEnvironment],
104
- );
67
+ const openEnvironment = (environmentId: EnvironmentId) => {
68
+ navigation.navigate("SettingsSheet", {
69
+ screen: "SettingsContent",
70
+ params: { screen: "SettingsEnvironmentDetail", params: { environmentId } },
71
+ });
72
+ };
73
+ const handleUpdateEnvironment = (
74
+ environmentId: EnvironmentId,
75
+ updates: { readonly label: string; readonly displayUrl: string },
76
+ ) => {
77
+ if (!SHOWCASE_ENABLED) return onUpdateEnvironment(environmentId, updates);
78
+ const actualEnvironment = environmentSections.localEnvironments.find(
79
+ (environment) => environment.environmentId === environmentId,
80
+ );
81
+ const presentedEnvironment = localEnvironments.find(
82
+ (environment) => environment.environmentId === environmentId,
83
+ );
84
+ return onUpdateEnvironment(environmentId, {
85
+ ...updates,
86
+ displayUrl:
87
+ actualEnvironment && presentedEnvironment
88
+ ? resolveShowcaseEnvironmentUpdateDisplayUrl({
89
+ actualDisplayUrl: actualEnvironment.displayUrl,
90
+ presentedDisplayUrl: presentedEnvironment.displayUrl,
91
+ submittedDisplayUrl: updates.displayUrl,
92
+ })
93
+ : updates.displayUrl,
94
+ });
95
+ };
96
97
return (
98
<SettingsScreen
apps/mobile/src/features/settings/SettingsNotificationsRouteScreen.tsx
+81
-106
@@ -8,7 +8,7 @@ import * as Notifications from "expo-notifications";
8
import { useNavigation } from "@react-navigation/native";
9
import * as Effect from "effect/Effect";
10
import { AsyncResult } from "effect/reactivity";
11
-import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
11
+import { useEffect, useRef, useState, useSyncExternalStore } from "react";
12
import { AppState, Linking, Platform } from "react-native";
13
import { useSafeAreaInsets } from "react-native-safe-area-context";
14
@@ -98,10 +98,10 @@ function ConfiguredSettingsNotificationsRouteScreen() {
98
AsyncResult.isSuccess(preferencesResult) &&
99
preferencesResult.value.liveActivitiesEnabled !== false;
100
101
- const connections = useMemo(() => Object.values(savedConnectionsById), [savedConnectionsById]);
101
+ const connections = Object.values(savedConnectionsById);
102
const environmentCount = connections.length;
103
104
- const refreshNotifications = useCallback(async () => {
104
+ const refreshNotifications = async () => {
105
if (Platform.OS !== "ios" && Platform.OS !== "android") {
106
setNotificationStatus("unsupported");
107
return;
@@ -113,7 +113,7 @@ function ConfiguredSettingsNotificationsRouteScreen() {
113
return;
114
}
115
setNotificationStatus(result.value.granted ? "enabled" : "disabled");
116
- }, []);
116
+ };
117
118
useEffect(() => {
119
void refreshNotifications();
@@ -146,7 +146,7 @@ function ConfiguredSettingsNotificationsRouteScreen() {
146
);
147
}, [isLoaded, isSignedIn, preferencesResult]);
148
149
- const requestNotifications = useCallback(async () => {
149
+ const requestNotifications = async () => {
150
const result = await settleAsyncResult(() =>
151
runtime.runPromiseExit(
152
requestAgentNotificationPermission.pipe(
@@ -199,9 +199,9 @@ function ConfiguredSettingsNotificationsRouteScreen() {
199
{ text: "Open Settings", onPress: () => void Linking.openSettings() },
200
],
201
);
202
- }, []);
202
+ };
203
204
- const promptSignIn = useCallback(() => {
204
+ const promptSignIn = () => {
205
Dialog.alert(
206
"Sign in to T3 Connect",
207
"Live Activity updates require T3 Connect so relay can deliver updates to this device.",
@@ -213,9 +213,9 @@ function ConfiguredSettingsNotificationsRouteScreen() {
213
},
214
],
215
);
216
- }, [navigation]);
216
+ };
217
218
- const linkEnvironments = useCallback(async () => {
218
+ const linkEnvironments = async () => {
219
if (!isSignedIn) {
220
promptSignIn();
221
return;
@@ -310,111 +310,86 @@ function ConfiguredSettingsNotificationsRouteScreen() {
310
"This device could not be registered with T3 Connect, so activity updates won't appear yet. They'll start once registration succeeds.",
311
);
312
}
313
- }, [
314
- connections,
315
- environmentCount,
316
- getToken,
317
- isSignedIn,
318
- liveActivitiesPreferenceEnabled,
319
- promptSignIn,
320
- savePreferences,
321
- ]);
313
+ };
314
323
- const handleDeviceNotificationsChange = useCallback(
324
- (enabled: boolean) => {
325
- if (enabled) {
326
- if (!isSignedIn) {
327
- promptSignIn();
328
- return;
329
- }
330
- void requestNotifications();
315
+ const handleDeviceNotificationsChange = (enabled: boolean) => {
316
+ if (enabled) {
317
+ if (!isSignedIn) {
318
+ promptSignIn();
319
return;
320
}
321
+ void requestNotifications();
322
+ return;
323
+ }
324
334
- Dialog.alert(
335
- "Disable notifications",
336
- "Open system Settings to disable notifications for T3 Code.",
337
- [
338
- { text: "Cancel", style: "cancel" },
339
- { text: "Open Settings", onPress: () => void Linking.openSettings() },
340
- ],
341
- );
342
- },
343
- [isSignedIn, promptSignIn, requestNotifications],
344
- );
345
-
346
- const handleLiveActivitiesChange = useCallback(
347
- (enabled: boolean) => {
348
- if (liveActivityWriteInFlight.current) return;
349
- if (!enabled) {
350
- liveActivityWriteInFlight.current = true;
351
- setLiveActivityStatus("linking");
352
- void (async () => {
353
- try {
354
- let token: string | null = null;
355
- if (isSignedIn) {
356
- const tokenResult = await settlePromise(() =>
357
- getToken(resolveRelayClerkTokenOptions()),
358
- );
359
- if (tokenResult._tag === "Failure") {
360
- setLiveActivityStatus("enabled");
361
- reportAtomCommandResult(tokenResult, {
362
- label: "live activity disable token lookup",
363
- });
364
- return;
365
- }
366
- token = tokenResult.value;
367
- }
325
+ Dialog.alert(
326
+ "Disable notifications",
327
+ "Open system Settings to disable notifications for T3 Code.",
328
+ [
329
+ { text: "Cancel", style: "cancel" },
330
+ { text: "Open Settings", onPress: () => void Linking.openSettings() },
331
+ ],
332
+ );
333
+ };
334
369
- const updateResult = await settleAsyncResult(() =>
370
- runtime.runPromiseExit(
371
- setLiveActivityUpdatesEnabled({
372
- canConfigureEnvironment: (environmentId) =>
373
- readEnvironmentScope(environmentId, AuthRelayWriteScope),
374
- enabled: false,
375
- previousEnabled: liveActivitiesPreferenceEnabled,
376
- clerkToken: token,
377
- connections,
378
- }),
379
- ),
380
- );
381
- if (updateResult._tag === "Failure") {
382
- setLiveActivityStatus(isSignedIn ? "enabled" : "signed-out");
383
- reportAtomCommandResult(updateResult, {
384
- label: "live activity disable",
385
- });
386
- return;
387
- }
388
- savePreferences({ liveActivitiesEnabled: false });
389
- refreshManagedRelayEnvironments();
390
- setLiveActivityStatus("disabled");
391
- } finally {
392
- liveActivityWriteInFlight.current = false;
393
- }
394
- })();
335
+ async function disableLiveActivities() {
336
+ let token: string | null = null;
337
+ if (isSignedIn) {
338
+ const tokenResult = await settlePromise(() => getToken(resolveRelayClerkTokenOptions()));
339
+ if (tokenResult._tag === "Failure") {
340
+ setLiveActivityStatus("enabled");
341
+ reportAtomCommandResult(tokenResult, {
342
+ label: "live activity disable token lookup",
343
+ });
344
return;
345
}
346
+ token = tokenResult.value;
347
+ }
348
398
- if (!isSignedIn) {
399
- promptSignIn();
400
- return;
401
- }
349
+ const updateResult = await settleAsyncResult(() =>
350
+ runtime.runPromiseExit(
351
+ setLiveActivityUpdatesEnabled({
352
+ canConfigureEnvironment: (environmentId) =>
353
+ readEnvironmentScope(environmentId, AuthRelayWriteScope),
354
+ enabled: false,
355
+ previousEnabled: liveActivitiesPreferenceEnabled,
356
+ clerkToken: token,
357
+ connections,
358
+ }),
359
+ ),
360
+ );
361
+ if (updateResult._tag === "Failure") {
362
+ setLiveActivityStatus(isSignedIn ? "enabled" : "signed-out");
363
+ reportAtomCommandResult(updateResult, {
364
+ label: "live activity disable",
365
+ });
366
+ return;
367
+ }
368
+ savePreferences({ liveActivitiesEnabled: false });
369
+ refreshManagedRelayEnvironments();
370
+ setLiveActivityStatus("disabled");
371
+ }
372
373
+ // Both writers settle their own failures, so awaiting them never throws.
374
+ const handleLiveActivitiesChange = async (enabled: boolean) => {
375
+ if (liveActivityWriteInFlight.current) return;
376
+ if (!enabled) {
377
liveActivityWriteInFlight.current = true;
404
- void linkEnvironments().finally(() => {
405
- liveActivityWriteInFlight.current = false;
406
- });
407
- },
408
- [
409
- connections,
410
- getToken,
411
- isSignedIn,
412
- linkEnvironments,
413
- liveActivitiesPreferenceEnabled,
414
- promptSignIn,
415
- savePreferences,
416
- ],
417
- );
378
+ setLiveActivityStatus("linking");
379
+ await disableLiveActivities();
380
+ liveActivityWriteInFlight.current = false;
381
+ return;
382
+ }
383
+
384
+ if (!isSignedIn) {
385
+ promptSignIn();
386
+ return;
387
+ }
388
+
389
+ liveActivityWriteInFlight.current = true;
390
+ await linkEnvironments();
391
+ liveActivityWriteInFlight.current = false;
392
+ };
393
394
return (
395
<SettingsScreen title="Notifications">
@@ -465,13 +440,13 @@ function ConfiguredSettingsNotificationsRouteScreen() {
440
(liveActivityStatus === "enabled" || liveActivityStatus === "linking") &&
441
deviceRegistered
442
}
468
- onValueChange={handleLiveActivitiesChange}
443
+ onValueChange={(enabled) => void handleLiveActivitiesChange(enabled)}
444
/>
445
{liveActivityStatus === "signed-out" && canClearLiveActivitiesPreference ? (
446
<SettingsRow
447
icon="bolt.circle"
448
label="Turn off Live Activity preference"
474
- onPress={() => handleLiveActivitiesChange(false)}
449
+ onPress={() => void handleLiveActivitiesChange(false)}
450
/>
451
) : null}
452
{supportsAndroidLiveUpdateSettings() ? (
apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx
+10
-13
@@ -75,19 +75,16 @@ function ProjectOverviewContent(props: {
75
if (!canSave) return;
76
setIsSaving(true);
77
void (async () => {
78
- try {
79
- const results = await Promise.all(
80
- props.members.map((member) =>
81
- updateProject({
82
- environmentId: member.environmentId,
83
- input: { projectId: member.id, title: nextName },
84
- }),
85
- ),
86
- );
87
- if (results.every((result) => result._tag !== "Failure")) setDraftName(null);
88
- } finally {
89
- setIsSaving(false);
90
- }
78
+ const results = await Promise.all(
79
+ props.members.map((member) =>
80
+ updateProject({
81
+ environmentId: member.environmentId,
82
+ input: { projectId: member.id, title: nextName },
83
+ }),
84
+ ),
85
+ );
86
+ setIsSaving(false);
87
+ if (results.every((result) => result._tag !== "Failure")) setDraftName(null);
88
})();
89
};
90
apps/mobile/src/features/settings/SettingsProviderAccountsRouteScreen.tsx
+7
-12
@@ -127,20 +127,15 @@ function ProviderAccount({
127
pendingRef.current = true;
128
setPending(true);
129
setError(null);
130
- let succeeded = false;
131
- try {
132
- const result = await command();
133
- if (result._tag === "Success") succeeded = true;
134
- else if (!isAtomCommandInterrupted(result)) {
135
- const failure = squashAtomCommandFailure(result);
136
- setError(failure instanceof Error ? failure.message : "Could not update provider sign-in.");
137
- }
138
- } catch {
139
- setError("Could not update provider sign-in.");
140
- }
130
+ const result = await command();
131
pendingRef.current = false;
132
setPending(false);
143
- return succeeded;
133
+ if (result._tag === "Success") return true;
134
+ if (!isAtomCommandInterrupted(result)) {
135
+ const failure = squashAtomCommandFailure(result);
136
+ setError(failure instanceof Error ? failure.message : "Could not update provider sign-in.");
137
+ }
138
+ return false;
139
}
140
function send(response: ProviderAuthResponse) {
141
if (!state?.flowId || !interaction) return Promise.resolve(false);
apps/mobile/src/reactCompilerCoverage.test.ts
-7
@@ -58,14 +58,7 @@ const KNOWN_BAILOUTS: Record<string, string> = {
58
"src/features/review/ReviewSheet.tsx": "try without catch",
59
"src/features/review/reviewDiffRendering.tsx": "mutates a frozen value",
60
"src/features/review/useNativeReviewDiffHighlighting.ts": "conditional inside try",
61
- "src/features/settings/SettingsAboutRouteScreen.tsx": "try without catch",
61
"src/features/settings/SettingsAuthRouteScreen.tsx": "ref read during render",
63
- "src/features/settings/SettingsEnvironmentDetailRouteScreen.tsx":
64
- "try without catch, try/finally",
65
- "src/features/settings/SettingsEnvironmentsRouteScreen.tsx": "try without catch",
66
- "src/features/settings/SettingsNotificationsRouteScreen.tsx": "try without catch",
67
- "src/features/settings/SettingsProjectOverviewRouteScreen.tsx": "try without catch",
68
- "src/features/settings/SettingsProviderAccountsRouteScreen.tsx": "conditional inside try",
62
"src/features/settings/SettingsScheduledTasksRouteScreen.tsx": "unsupported syntax",
63
"src/features/settings/components/SettingsDragHandle.tsx": "ref read during render",
64
"src/features/terminal/ThreadTerminalRouteScreen.tsx": "ref read during render",