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, 14:30 UTC
fix(mobile): provider accounts fit each provider on one row (#25861)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Alex Southwell committed
Oct 28, 2026 at 00:06 UTC
0894156d9a38eeff8abfd9c266f3f57b8e524217
1 file changed
+283
-178
apps/mobile/src/features/settings/SettingsProviderAccountsRouteScreen.tsx
+283
-178
@@ -11,10 +11,15 @@ import {
11
} from "@t3tools/contracts";
12
import { useAtomValue } from "@effect/atom-react";
13
import { useRef, useState } from "react";
14
-import { Linking, Pressable, ScrollView, TextInput, View } from "react-native";
14
+import { Linking, Pressable, ScrollView, TextInput, useWindowDimensions, View } from "react-native";
15
import { useSafeAreaInsets } from "react-native-safe-area-context";
16
17
+import type { MenuAction } from "@react-native-menu/menu";
18
+
19
+import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
20
import { AppText as Text } from "../../components/ui/AppText";
21
+import { ControlPill } from "../../components/ui/ControlPill";
22
+import { Menu } from "../../components/ui/Menu";
23
import { ScreenScrollView } from "../../components/ui/ScreenScrollView";
24
import { environmentPresentations } from "../../state/presentation";
25
import { useEnvironmentQuery } from "../../state/query";
@@ -60,22 +65,17 @@ export function SettingsProviderAccountsRouteScreen() {
65
) : (
66
<>
67
{(providersByEnvironment.get(environment.environmentId) ?? [])
63
- .filter(
64
- (provider) =>
65
- provider.setup?.canAuthenticate ||
66
- (provider.driver === "acpRegistry" && provider.installed),
67
- )
68
- .map((provider) => (
68
+ .filter(canManageProvider)
69
+ .map((provider, index) => (
70
<ProviderAccount
71
key={provider.instanceId}
72
environment={environment}
73
provider={provider}
74
+ divider={index > 0}
75
/>
76
))}
77
{!(providersByEnvironment.get(environment.environmentId) ?? []).some(
76
- (provider) =>
77
- provider.setup?.canAuthenticate ||
78
- (provider.driver === "acpRegistry" && provider.installed),
78
+ canManageProvider,
79
) ? (
80
<Text className="p-4 text-foreground-muted">
81
Configure a provider with in-app sign-in in web or desktop Settings.
@@ -92,12 +92,20 @@ export function SettingsProviderAccountsRouteScreen() {
92
);
93
}
94
95
+function canManageProvider(provider: ServerProvider) {
96
+ return Boolean(
97
+ provider.setup?.canAuthenticate || (provider.driver === "acpRegistry" && provider.installed),
98
+ );
99
+}
100
+
101
function ProviderAccount({
102
environment,
103
provider,
104
+ divider,
105
}: {
106
readonly environment: SettingsTarget;
107
readonly provider: ServerProvider;
108
+ readonly divider: boolean;
109
}) {
110
const environmentId = environment.environmentId;
111
const instanceId = provider.instanceId;
@@ -109,8 +117,9 @@ function ProviderAccount({
117
const complete = useAtomCommand(serverEnvironment.completeProviderAuth, options);
118
const cancel = useAtomCommand(serverEnvironment.cancelProviderAuth, options);
119
const logout = useAtomCommand(serverEnvironment.logoutProviderAuth, options);
120
+ // Matches ListRowLayout: large text stacks the action below instead of squeezing the status.
121
+ const stacked = useWindowDimensions().fontScale >= 1.5;
122
const [pending, setPending] = useState(false);
113
- const [choosingMethod, setChoosingMethod] = useState(false);
123
const pendingRef = useRef(false);
124
const [error, setError] = useState<string | null>(null);
125
const [draft, setDraft] = useState({ id: "", values: {} as Record<string, string> });
@@ -180,120 +189,238 @@ function ProviderAccount({
189
/>
190
);
191
}
183
- function chooseMethod() {
184
- const methods = state?.methods ?? [];
185
- if (methods.length <= 1) {
186
- void run(() => start(target));
187
- return;
188
- }
189
- setChoosingMethod(true);
192
+ const name = provider.displayName ?? provider.driver;
193
+ const email = signedIn && !active && provider.enabled ? provider.auth.email?.trim() : undefined;
194
+ const methods = state?.methods ?? [];
195
+ // The status line says why a provider that is missing or turned off can't sign in.
196
+ const canSignIn =
197
+ !active &&
198
+ !needsExternalSetup &&
199
+ provider.setup?.canAuthenticate !== false &&
200
+ provider.enabled &&
201
+ provider.installed;
202
+ const signInDisabled = disabled || state === null;
203
+ const canSignOut =
204
+ !active && signedIn && (provider.auth.canLogout ?? provider.setup?.canAuthenticate);
205
+ const showCallback =
206
+ Boolean(url) && (interaction?.type === "browser" ? interaction.acceptsCallback : !interaction);
207
+ const status =
208
+ active || state?.phase === "failed" || state?.phase === "cancelled"
209
+ ? state.message
210
+ : !provider.enabled
211
+ ? "Turned off"
212
+ : signedIn
213
+ ? "Signed in"
214
+ : isDiscovering
215
+ ? "Discovering sign-in methods…"
216
+ : needsExternalSetup
217
+ ? "No in-app sign-in advertised. Follow the provider's docs to finish setup."
218
+ : !provider.installed
219
+ ? "Not installed"
220
+ : "Not signed in";
221
+ // A provider with several sign-in methods picks one from a menu on the same control.
222
+ const methodActions: MenuAction[] = methods.map((method) => ({
223
+ id: `method:${method.id}`,
224
+ title: method.name,
225
+ }));
226
+ function startSignIn(methodId?: string) {
227
+ void run(() => start(methodId ? { environmentId, input: { instanceId, methodId } } : target));
228
+ }
229
+ function signOut() {
230
+ Dialog.alert(
231
+ "Sign out?",
232
+ `Running threads sharing this sign-in on ${environment.label} will stop. Thread history is kept.`,
233
+ [
234
+ { text: "Cancel", style: "cancel" },
235
+ {
236
+ text: "Sign out",
237
+ style: "destructive",
238
+ onPress: () => {
239
+ void run(() => logout(target));
240
+ },
241
+ },
242
+ ],
243
+ );
244
}
245
+ function onMenuAction(id: string) {
246
+ if (id === "signOut") signOut();
247
+ // iOS keeps a disabled submenu's children selectable, so sign-in guards here too.
248
+ else if (signInDisabled) return;
249
+ else if (id.startsWith("method:")) startSignIn(id.slice("method:".length));
250
+ else if (id === "change") startSignIn();
251
+ }
252
+ const accountActions: MenuAction[] = [
253
+ ...(canSignIn
254
+ ? [
255
+ {
256
+ id: "change",
257
+ title: "Change account",
258
+ image: "person.crop.circle",
259
+ attributes: { disabled: signInDisabled },
260
+ ...(methodActions.length > 1
261
+ ? {
262
+ subactions: methodActions.map((action) => ({
263
+ ...action,
264
+ attributes: { disabled: signInDisabled },
265
+ })),
266
+ }
267
+ : {}),
268
+ },
269
+ ]
270
+ : []),
271
+ ...(canSignOut
272
+ ? [
273
+ {
274
+ id: "signOut",
275
+ title: "Sign out",
276
+ image: "rectangle.portrait.and.arrow.right",
277
+ attributes: { destructive: true, disabled: disabled || state === null },
278
+ },
279
+ ]
280
+ : []),
281
+ ];
282
+ const trailing = pending ? (
283
+ <View className="h-11 w-11 items-center justify-center">
284
+ <AppActivityIndicator colorClassName="accent-icon" />
285
+ </View>
286
+ ) : needsExternalSetup && provider.setup?.documentationUrl ? (
287
+ <ControlPill
288
+ variant="pill"
289
+ label="Docs"
290
+ onPress={() => {
291
+ void Linking.openURL(provider.setup!.documentationUrl!).catch(() =>
292
+ setError("Could not open the provider docs."),
293
+ );
294
+ }}
295
+ />
296
+ ) : active && state?.flowId ? (
297
+ <ControlPill
298
+ variant="pill"
299
+ label="Cancel"
300
+ accessibilityLabel={`Cancel ${name} sign-in`}
301
+ disabled={disabled}
302
+ onPress={() => {
303
+ void run(() => cancel({ environmentId, input: { instanceId, flowId: state.flowId! } }));
304
+ }}
305
+ />
306
+ ) : signedIn && !active && accountActions.length > 0 ? (
307
+ <Menu
308
+ accessible
309
+ accessibilityRole="button"
310
+ accessibilityLabel={`${name} account options`}
311
+ title={name}
312
+ actions={accountActions}
313
+ onPressAction={({ nativeEvent }) => onMenuAction(nativeEvent.event)}
314
+ >
315
+ <ControlPill icon="ellipsis" accessibilityLabel={`${name} account options`} />
316
+ </Menu>
317
+ ) : canSignIn && !signedIn && methodActions.length > 1 && !signInDisabled ? (
318
+ <Menu
319
+ accessible
320
+ accessibilityRole="button"
321
+ accessibilityLabel={`Sign in to ${name}`}
322
+ title="Sign in with"
323
+ actions={methodActions}
324
+ onPressAction={({ nativeEvent }) => onMenuAction(nativeEvent.event)}
325
+ >
326
+ <ControlPill variant="primary" label="Sign in" accessibilityLabel={`Sign in to ${name}`} />
327
+ </Menu>
328
+ ) : canSignIn && !signedIn ? (
329
+ <ControlPill
330
+ variant="primary"
331
+ label="Sign in"
332
+ accessibilityLabel={`Sign in to ${name}`}
333
+ disabled={signInDisabled}
334
+ onPress={() => startSignIn()}
335
+ />
336
+ ) : null;
337
return (
192
- <View className="border-b border-border-subtle">
193
- <View className="gap-2 p-4">
194
- <Text className="text-lg font-semibold text-foreground">
195
- {provider.displayName ?? provider.driver}
196
- </Text>
197
- <Text accessibilityLiveRegion="polite" className="text-sm text-foreground-muted">
198
- {active || state?.phase === "failed" || state?.phase === "cancelled"
199
- ? state.message
200
- : signedIn
201
- ? "Signed in."
202
- : isDiscovering
203
- ? "Discovering sign-in methods…"
204
- : needsExternalSetup
205
- ? "No in-app sign-in advertised. Follow the provider's docs to finish setup."
206
- : "Connect this provider."}
207
- </Text>
208
- {signedIn && !active && provider.auth.email?.trim() ? (
209
- <ProviderAccountEmail key={provider.auth.email} email={provider.auth.email} />
210
- ) : null}
211
- {interaction?.type === "deviceCode" ? (
212
- <Text selectable className="text-foreground">
213
- Enter code {interaction.userCode} on the sign-in page.
214
- </Text>
215
- ) : null}
216
- {interaction?.type === "terminal" ? (
217
- <>
218
- <ScrollView className="max-h-64" nestedScrollEnabled>
219
- <Text selectable className="font-mono text-sm text-foreground">
220
- {interaction.output.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "")}
221
- </Text>
222
- </ScrollView>
223
- {field("input", "Terminal response", true)}
224
- <SettingsActionRow
225
- icon="arrow.up"
226
- label="Send response"
227
- disabled={disabled}
228
- onPress={() => {
229
- void send({ type: "terminal", data: `${values.input ?? ""}\r` }).then((sent) => {
230
- if (sent) setDraft({ id: "", values: {} });
231
- });
232
- }}
233
- />
234
- </>
235
- ) : null}
236
- {interaction?.type === "credentials" ? (
237
- <>
238
- {interaction.fields.map((entry) => (
239
- <View key={entry.name}>{field(entry.name, entry.label, entry.secret)}</View>
240
- ))}
241
- <SettingsActionRow
242
- icon="person.crop.circle"
243
- label="Connect"
244
- disabled={disabled}
245
- onPress={() => {
246
- void send({ type: "credentials", values }).then((sent) => {
247
- if (sent) setDraft({ id: "", values: {} });
248
- });
249
- }}
250
- />
251
- </>
252
- ) : null}
253
- {url && (interaction?.type === "browser" ? interaction.acceptsCallback : !interaction) ? (
254
- <>
255
- {field("callback", "Final localhost URL", false)}
256
- <SettingsActionRow
257
- icon="arrow.right"
258
- label="Continue"
259
- disabled={disabled || !values.callback?.trim()}
260
- onPress={() => {
261
- if (!state?.flowId) return;
262
- void run(() =>
263
- complete({
264
- environmentId,
265
- input: { instanceId, flowId: state.flowId!, callbackUrl: values.callback! },
266
- }),
267
- ).then((sent) => {
268
- if (sent) setDraft({ id: "", values: {} });
269
- });
270
- }}
271
- />
272
- </>
273
- ) : null}
274
- {error || auth.error ? (
275
- <Text accessibilityRole="alert" className="text-danger-foreground">
276
- {error ?? auth.error}
277
- </Text>
278
- ) : null}
338
+ <View className={divider ? "border-t border-border-subtle" : undefined}>
339
+ <View
340
+ className={
341
+ stacked
342
+ ? "min-h-16 items-start gap-3 px-4 py-3"
343
+ : "min-h-16 flex-row items-center gap-3 px-4 py-3"
344
+ }
345
+ >
346
+ <ProviderAccountSummary key={email} name={name} status={status} email={email} />
347
+ {trailing}
348
</View>
280
- {choosingMethod && !active ? (
281
- <View>
282
- {state?.methods?.map((method) => (
283
- <SettingsActionRow
284
- key={method.id}
285
- icon="person.crop.circle"
286
- label={method.name}
287
- disabled={disabled}
288
- onPress={() => {
289
- setChoosingMethod(false);
290
- void run(() =>
291
- start({ environmentId, input: { instanceId, methodId: method.id } }),
292
- );
293
- }}
294
- />
295
- ))}
296
- <SettingsActionRow icon="xmark" label="Cancel" onPress={() => setChoosingMethod(false)} />
349
+ {interaction?.type === "deviceCode" ||
350
+ interaction?.type === "terminal" ||
351
+ interaction?.type === "credentials" ||
352
+ showCallback ||
353
+ error ||
354
+ auth.error ? (
355
+ <View className="gap-2 px-4 pb-3">
356
+ {interaction?.type === "deviceCode" ? (
357
+ <Text selectable className="text-foreground">
358
+ Enter code {interaction.userCode} on the sign-in page.
359
+ </Text>
360
+ ) : null}
361
+ {interaction?.type === "terminal" ? (
362
+ <>
363
+ <ScrollView className="max-h-64" nestedScrollEnabled>
364
+ <Text selectable className="font-mono text-sm text-foreground">
365
+ {interaction.output.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "")}
366
+ </Text>
367
+ </ScrollView>
368
+ {field("input", "Terminal response", true)}
369
+ <SettingsActionRow
370
+ icon="arrow.up"
371
+ label="Send response"
372
+ disabled={disabled}
373
+ onPress={() => {
374
+ void send({ type: "terminal", data: `${values.input ?? ""}\r` }).then((sent) => {
375
+ if (sent) setDraft({ id: "", values: {} });
376
+ });
377
+ }}
378
+ />
379
+ </>
380
+ ) : null}
381
+ {interaction?.type === "credentials" ? (
382
+ <>
383
+ {interaction.fields.map((entry) => (
384
+ <View key={entry.name}>{field(entry.name, entry.label, entry.secret)}</View>
385
+ ))}
386
+ <SettingsActionRow
387
+ icon="person.crop.circle"
388
+ label="Connect"
389
+ disabled={disabled}
390
+ onPress={() => {
391
+ void send({ type: "credentials", values }).then((sent) => {
392
+ if (sent) setDraft({ id: "", values: {} });
393
+ });
394
+ }}
395
+ />
396
+ </>
397
+ ) : null}
398
+ {showCallback ? (
399
+ <>
400
+ {field("callback", "Final localhost URL", false)}
401
+ <SettingsActionRow
402
+ icon="arrow.right"
403
+ label="Continue"
404
+ disabled={disabled || !values.callback?.trim()}
405
+ onPress={() => {
406
+ if (!state?.flowId) return;
407
+ void run(() =>
408
+ complete({
409
+ environmentId,
410
+ input: { instanceId, flowId: state.flowId!, callbackUrl: values.callback! },
411
+ }),
412
+ ).then((sent) => {
413
+ if (sent) setDraft({ id: "", values: {} });
414
+ });
415
+ }}
416
+ />
417
+ </>
418
+ ) : null}
419
+ {error || auth.error ? (
420
+ <Text accessibilityRole="alert" className="text-danger-foreground">
421
+ {error ?? auth.error}
422
+ </Text>
423
+ ) : null}
424
</View>
425
) : null}
426
{url ? (
@@ -314,72 +441,50 @@ function ProviderAccount({
441
}}
442
/>
443
) : null}
317
- {needsExternalSetup && provider.setup?.documentationUrl ? (
318
- <SettingsActionRow
319
- icon="globe"
320
- label="Open docs"
321
- onPress={() => {
322
- void Linking.openURL(provider.setup!.documentationUrl!).catch(() =>
323
- setError("Could not open the provider docs."),
324
- );
325
- }}
326
- />
327
- ) : active && state?.flowId ? (
328
- <SettingsActionRow
329
- icon="xmark"
330
- label="Cancel sign-in"
331
- disabled={disabled}
332
- onPress={() => {
333
- void run(() => cancel({ environmentId, input: { instanceId, flowId: state.flowId! } }));
334
- }}
335
- />
336
- ) : !active && !needsExternalSetup && provider.setup?.canAuthenticate !== false ? (
337
- <SettingsActionRow
338
- icon="person.crop.circle"
339
- label={signedIn ? "Change account" : "Sign in"}
340
- disabled={disabled || !provider.enabled || !provider.installed || state === null}
341
- loading={pending}
342
- onPress={chooseMethod}
343
- />
344
- ) : null}
345
- {!active && signedIn && (provider.auth.canLogout ?? provider.setup?.canAuthenticate) ? (
346
- <SettingsActionRow
347
- icon="person.crop.circle"
348
- label="Sign out"
349
- tone="danger"
350
- disabled={disabled || state === null}
351
- onPress={() =>
352
- Dialog.alert(
353
- "Sign out?",
354
- `Running threads sharing this sign-in on ${environment.label} will stop. Thread history is kept.`,
355
- [
356
- { text: "Cancel", style: "cancel" },
357
- {
358
- text: "Sign out",
359
- style: "destructive",
360
- onPress: () => {
361
- void run(() => logout(target));
362
- },
363
- },
364
- ],
365
- )
366
- }
367
- />
368
- ) : null}
444
</View>
445
);
446
}
447
373
-function ProviderAccountEmail({ email }: { readonly email: string }) {
448
+function ProviderAccountSummary({
449
+ name,
450
+ status,
451
+ email,
452
+}: {
453
+ readonly name: string;
454
+ readonly status: string | null | undefined;
455
+ readonly email: string | undefined;
456
+}) {
457
const [revealed, setRevealed] = useState(false);
458
+ const content = (
459
+ <>
460
+ <Text textRole="body" className="text-foreground" numberOfLines={1}>
461
+ {name}
462
+ </Text>
463
+ <Text accessibilityLiveRegion="polite" textRole="footnote" className="text-foreground-muted">
464
+ {email ? `${status} · ${revealed ? email : "••••••@••••••"}` : status}
465
+ </Text>
466
+ </>
467
+ );
468
+ if (!email) {
469
+ return (
470
+ <View
471
+ accessible
472
+ accessibilityLabel={[name, status].filter(Boolean).join(", ")}
473
+ className="min-w-0 shrink grow gap-0.5"
474
+ >
475
+ {content}
476
+ </View>
477
+ );
478
+ }
479
return (
480
<Pressable
481
accessibilityRole="button"
378
- accessibilityLabel={revealed ? "Hide account email" : "Reveal account email"}
482
+ accessibilityLabel={[name, status, revealed ? email : null].filter(Boolean).join(", ")}
483
+ accessibilityHint={revealed ? "Hides the account email" : "Reveals the account email"}
484
onPress={() => setRevealed((value) => !value)}
380
- className="min-h-[44px] justify-center"
485
+ className="min-w-0 shrink grow gap-0.5"
486
>
382
- <Text className="text-sm text-foreground-muted">{revealed ? email : "••••••@••••••"}</Text>
487
+ {content}
488
</Pressable>
489
);
490
}