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, 09:15 UTC
refactor(mobile): finish shared alert adoption (#20000)
Julius Marminge committed
Oct 15, 2026 at 15:51 UTC
3b43e3f1f09e0d0cb51d1f9df2629af8c7ae0662
33 files changed
+134
-118
apps/mobile/src/components/ComposerContextAttachment.tsx
+3
-2
@@ -1,5 +1,6 @@
1
+import * as Dialog from "./Dialog";
2
import type { ComposerContextRecord, EnvironmentId } from "@t3tools/contracts";
2
-import { Alert, Pressable, View } from "react-native";
3
+import { Pressable, View } from "react-native";
4
import { Image } from "expo-image";
5
import { useEffect, useId, useMemo, useState } from "react";
6
import type { DraftComposerAttachment } from "../lib/composerImages";
@@ -82,7 +83,7 @@ export function ComposerContextAttachment(props: {
83
});
84
}
85
} catch (cause) {
85
- Alert.alert(
86
+ Dialog.alert(
87
"Could not open attachment",
88
cause instanceof Error ? cause.message : "Try again.",
89
);
apps/mobile/src/components/ComposerContextSheet.tsx
+3
-2
@@ -1,3 +1,4 @@
1
+import * as Dialog from "./Dialog";
2
import { useOpenPullRequest } from "../native/useOpenPullRequest";
3
import { SourceFileSurface } from "../features/files/SourceFileSurface";
4
import { filePreviewKind } from "@t3tools/shared/filePreview";
@@ -10,7 +11,7 @@ import type {
11
} from "@t3tools/contracts";
12
import { formatAttachmentSize } from "@t3tools/client-runtime/state/attachments";
13
import { videoMimeType } from "@t3tools/shared/video";
13
-import { Alert, Platform, Pressable, ScrollView, View } from "react-native";
14
+import { Platform, Pressable, ScrollView, View } from "react-native";
15
import { useSafeAreaInsets } from "react-native-safe-area-context";
16
import { REVIEW_MONO_FONT_FAMILY } from "../features/review/reviewDiffRendering";
17
import { ReviewCommentCard, useReviewCommentColors } from "../features/review/ReviewCommentCard";
@@ -354,7 +355,7 @@ export function ComposerContextSheet(props: {
355
onPress={() => {
356
props.onClose();
357
void openPullRequest(pullRequestUrl).catch(() =>
357
- Alert.alert("Could not open pull request", "Try again when connected."),
358
+ Dialog.alert("Could not open pull request", "Try again when connected."),
359
);
360
}}
361
className="rounded-xl bg-subtle p-4"
apps/mobile/src/components/ComposerEditor.tsx
+4
-4
@@ -1,9 +1,9 @@
1
+import * as Dialog from "./Dialog";
2
import { ComposerContextId } from "@t3tools/contracts";
3
import { useAtomValue } from "@effect/atom-react";
4
import { AsyncResult } from "effect/reactivity";
5
import { useNavigation } from "@react-navigation/native";
6
import { useEffect, useMemo, useRef, useState } from "react";
6
-import { Alert } from "react-native";
7
import type { EnvironmentId } from "@t3tools/contracts";
8
import { encodeComposerContextFragment } from "@t3tools/shared/composerContextClipboard";
9
import { collectComposerContextReferences } from "@t3tools/shared/composerContextReferences";
@@ -107,20 +107,20 @@ export function ComposerEditor({
107
return;
108
}
109
if (!insertComposerDraftContext(draftKey, result, insertion)) {
110
- Alert.alert(
110
+ Dialog.alert(
111
"Could not paste context",
112
"Remove some attachments or context items from the draft, then paste again.",
113
);
114
return;
115
}
116
if (result.failures.length > 0)
117
- Alert.alert(
117
+ Dialog.alert(
118
"Some attachments could not be copied",
119
"Reconnect to the source environment and copy them again. References without their files are marked unavailable.",
120
);
121
} catch (error) {
122
if (!controller.signal.aborted)
123
- Alert.alert(
123
+ Dialog.alert(
124
"Could not paste context",
125
error instanceof Error ? error.message : "Try copying again.",
126
);
apps/mobile/src/components/CopyTextButton.tsx
+4
-3
@@ -1,6 +1,7 @@
1
+import * as Dialog from "./Dialog";
2
import { SymbolView } from "../components/AppSymbol";
3
import { memo, useEffect, useRef, useState } from "react";
3
-import { Alert, Pressable, type ColorValue } from "react-native";
4
+import { Pressable, type ColorValue } from "react-native";
5
6
import { tryCopyTextWithHaptic } from "../lib/copyTextWithHaptic";
7
@@ -43,11 +44,11 @@ export const CopyTextButton = memo(function CopyTextButton(props: {
44
if (props.onCopy) await props.onCopy();
45
else if (!(await tryCopyTextWithHaptic(props.text))) {
46
// A refused clipboard write is the common failure, and silence reads as success.
46
- Alert.alert("Could not copy", "Try again.");
47
+ Dialog.alert("Could not copy", "Try again.");
48
return;
49
}
50
} catch {
50
- Alert.alert("Could not copy", "Try again.");
51
+ Dialog.alert("Could not copy", "Try again.");
52
return;
53
}
54
setCopied(true);
apps/mobile/src/components/FilePreview.ios.tsx
+2
-2
@@ -1,6 +1,6 @@
1
+import * as Dialog from "./Dialog";
2
import { requireNativeModule } from "expo";
3
import { useEffect, useEffectEvent, useId } from "react";
3
-import { Alert } from "react-native";
4
5
import type { ResolvedFilePreviewSource } from "./FilePreviewModal.types";
6
@@ -30,7 +30,7 @@ function NativeFilePreview(props: {
30
const onRequestClose = useEffectEvent(props.onRequestClose);
31
const onOpenError = useEffectEvent((error: unknown) => {
32
if (props.onOpenError) props.onOpenError(error);
33
- else Alert.alert("Could not open preview", "The file could not be loaded. Please try again.");
33
+ else Dialog.alert("Could not open preview", "The file could not be loaded. Please try again.");
34
});
35
36
useEffect(() => {
apps/mobile/src/components/FilePreview.tsx
+3
-2
@@ -1,5 +1,6 @@
1
+import * as Dialog from "./Dialog";
2
import { useEffect, useEffectEvent } from "react";
2
-import { Alert, Modal, Pressable, View } from "react-native";
3
+import { Modal, Pressable, View } from "react-native";
4
import ImageViewing from "react-native-image-viewing";
5
6
import { openAttachmentInViewer } from "../lib/attachmentDownload";
@@ -17,7 +18,7 @@ function DocumentPreview(props: {
18
const onOpenError = useEffectEvent((error: unknown) => {
19
if (props.onOpenError) props.onOpenError(error);
20
else
20
- Alert.alert(
21
+ Dialog.alert(
22
"Could not open document",
23
"A compatible viewer must be installed. Check your connection and try again.",
24
);
apps/mobile/src/components/FilePreviewModal.tsx
+3
-2
@@ -1,3 +1,4 @@
1
+import * as Dialog from "./Dialog";
2
import { useNavigation } from "@react-navigation/native";
3
import {
4
useCallback,
@@ -8,7 +9,7 @@ import {
9
useSyncExternalStore,
10
useMemo,
11
} from "react";
11
-import { Alert, Keyboard } from "react-native";
12
+import { Keyboard } from "react-native";
13
14
import { loadLocalAttachmentPreview } from "../lib/localAttachmentPreview";
15
import { useRefreshAssetUrl } from "../state/assets";
@@ -44,7 +45,7 @@ function PreviewItemResolver(props: {
45
const onRequestClose = useEffectEvent(props.onRequestClose);
46
const onResolutionError = useEffectEvent((error: unknown, fallbackMessage: string) => {
47
if (props.onOpenError) props.onOpenError(error);
47
- else Alert.alert("Could not open preview", fallbackMessage);
48
+ else Dialog.alert("Could not open preview", fallbackMessage);
49
onRequestClose();
50
});
51
useEffect(() => Keyboard.dismiss(), []);
apps/mobile/src/components/PermissionUpdateNotice.tsx
+2
-2
@@ -1,9 +1,9 @@
1
+import * as Dialog from "./Dialog";
2
import { useAtomValue } from "@effect/atom-react";
3
import { sessionHasLegacyPermissions } from "@t3tools/contracts";
4
import { Atom } from "effect/reactivity";
5
import * as SecureStore from "expo-secure-store";
6
import { useEffect, useMemo, useRef, useState } from "react";
6
-import { Alert } from "react-native";
7
8
import { useEnvironments } from "../state/environments";
9
import { environmentSession } from "../state/session";
@@ -73,7 +73,7 @@ export function PermissionUpdateNotice() {
73
// Remember for this launch even if persistent storage is unavailable.
74
});
75
};
76
- Alert.alert(
76
+ Dialog.alert(
77
`Permissions have changed for ${environment.label}`,
78
"This connection still uses the old permissions, so some actions may no longer be available. Pair again using a new link with the permissions you need.",
79
[{ text: "Got it", onPress: dismiss }],
apps/mobile/src/components/VideoPreviewModal.ios.tsx
+4
-3
@@ -1,7 +1,8 @@
1
+import * as Dialog from "./Dialog";
2
import { useIsFocused } from "@react-navigation/native";
3
import { requireNativeModule } from "expo";
4
import { useEffect, useEffectEvent, useId, useState } from "react";
4
-import { Alert, Keyboard } from "react-native";
5
+import { Keyboard } from "react-native";
6
7
import { loadLocalAttachmentPreview } from "../lib/localAttachmentPreview";
8
import { fullscreenVideoClosed, fullscreenVideoOpened } from "../lib/videoAudioSession";
@@ -61,7 +62,7 @@ function NativeVideoPreview(props: {
62
}, [playbackUrl, resolvedUrl]);
63
useEffect(() => {
64
if (!loadError) return;
64
- Alert.alert("Could not open video", loadError);
65
+ Dialog.alert("Could not open video", loadError);
66
onRequestClose();
67
}, [loadError]);
68
@@ -93,7 +94,7 @@ function NativeVideoPreview(props: {
94
if (controller.signal.aborted) return;
95
// AVKit gives no retry, so re-mint now; the cached URL may simply have expired.
96
if (ready) void refreshAssetUrl();
96
- Alert.alert(
97
+ Dialog.alert(
98
"Could not open video",
99
ready
100
? "This video couldn't be loaded or played. Check the connection, or touch and hold the video to save or share the original."
apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx
+4
-3
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../../components/Dialog";
2
import {
3
deviceToolVersionLabels,
4
deviceToolUpdateOwnership,
@@ -9,7 +10,7 @@ import * as Cause from "effect/Cause";
10
import { useCallback, useEffect, useMemo, useRef, useState, type RefObject } from "react";
11
import * as Haptics from "expo-haptics";
12
import { Accelerometer } from "expo-sensors";
12
-import { Alert, AppState, BackHandler, Pressable, StatusBar, View } from "react-native";
13
+import { AppState, BackHandler, Pressable, StatusBar, View } from "react-native";
14
import Animated, { FadeIn, FadeOut, ReduceMotion } from "react-native-reanimated";
15
import { useSafeAreaInsets } from "react-native-safe-area-context";
16
@@ -139,7 +140,7 @@ function DevicePreviewScreen({
140
},
141
});
142
if (result._tag === "Failure") {
142
- Alert.alert("Could not shut down device", String(Cause.squash(result.cause)));
143
+ Dialog.alert("Could not shut down device", String(Cause.squash(result.cause)));
144
}
145
} finally {
146
setShuttingDown(false);
@@ -177,7 +178,7 @@ function DevicePreviewScreen({
178
title: "Device tool versions",
179
icon: "info.circle",
180
onPress: () =>
180
- Alert.alert(
181
+ Dialog.alert(
182
"Device tool versions",
183
deviceToolUpdateOwnership +
184
"\n\n" +
apps/mobile/src/features/home/usePendingTaskListActions.ts
+4
-4
@@ -1,6 +1,6 @@
1
+import * as Dialog from "../../components/Dialog";
2
import { useNavigation } from "@react-navigation/native";
3
import { useCallback } from "react";
3
-import { Alert } from "react-native";
4
5
import { removeThreadOutboxMessage } from "../../state/thread-outbox-removal";
6
import { clearComposerDraftContent } from "../../state/use-composer-drafts";
@@ -31,7 +31,7 @@ export function usePendingTaskListActions(): {
31
32
const confirmDeletePendingTask = useCallback((pendingTask: PendingNewTask) => {
33
if (pendingTask.kind === "draft") {
34
- Alert.alert("Discard draft?", `“${pendingTask.title}” will be removed.`, [
34
+ Dialog.alert("Discard draft?", `“${pendingTask.title}” will be removed.`, [
35
{ text: "Cancel", style: "cancel" },
36
{
37
text: "Discard",
@@ -48,7 +48,7 @@ export function usePendingTaskListActions(): {
48
]);
49
return;
50
}
51
- Alert.alert(
51
+ Dialog.alert(
52
"Delete pending task?",
53
`“${pendingTask.title}” has not been sent yet and will be removed from the outbox.`,
54
[
@@ -63,7 +63,7 @@ export function usePendingTaskListActions(): {
63
void removeThreadOutboxMessage(pendingTask.message)
64
.then(() => releaseEditingQueuedMessage(pendingTask.message.messageId))
65
.catch((error) => {
66
- Alert.alert(
66
+ Dialog.alert(
67
"Could not delete pending task",
68
error instanceof Error ? error.message : "The pending task could not be removed.",
69
);
apps/mobile/src/features/home/useThreadListActions.test.ts
+2
@@ -44,6 +44,8 @@ vi.mock("expo-haptics", () => ({
44
ImpactFeedbackStyle: { Light: "light" },
45
}));
46
vi.mock("../../components/Dialog", () => ({
47
+ alert: (title: string, _message: string, buttons?: { text: string; onPress?: () => void }[]) =>
48
+ state.alerts.push({ title, buttons }),
49
confirm: (dialog: { onConfirm: () => void }) => state.dialogs.push(dialog),
50
}));
51
vi.mock("../archive/useArchivedThreadSnapshots", () => ({
apps/mobile/src/features/home/useThreadListActions.ts
+22
-23
@@ -5,7 +5,6 @@ import { AuthOrchestrationOperateScope } from "@t3tools/contracts";
5
import * as Cause from "effect/Cause";
6
import * as Haptics from "expo-haptics";
7
import { useCallback, useRef } from "react";
8
-import { Alert } from "react-native";
8
9
import { withThreadDismissal } from "./thread-dismissal";
10
import * as Dialog from "../../components/Dialog";
@@ -112,7 +111,7 @@ function actionFailureTitle(action: ThreadListAction): string {
111
112
function checkThreadOperationPermission(thread: EnvironmentThreadShell, title: string): boolean {
113
if (readEnvironmentScope(thread.environmentId, AuthOrchestrationOperateScope)) return true;
115
- Alert.alert(title, "This connection cannot change threads.");
114
+ Dialog.alert(title, "This connection cannot change threads.");
115
return false;
116
}
117
@@ -142,7 +141,7 @@ function useThreadActionExecutor(
141
(action === "settle" || action === "unsettle") &&
142
!environmentSupportsSettlement(thread.environmentId)
143
) {
145
- Alert.alert(
144
+ Dialog.alert(
145
actionFailureTitle(action),
146
"This environment's server does not support settling yet. Update the server to use Settle.",
147
);
@@ -151,7 +150,7 @@ function useThreadActionExecutor(
150
// Archive keeps its original, narrower guard: never interrupt a
151
// thread mid-turn.
152
if (action === "archive" && !threadCanArchive(thread.runtime)) {
154
- Alert.alert(
153
+ Dialog.alert(
154
actionFailureTitle(action),
155
"This thread is working. Interrupt it first, then try again.",
156
);
@@ -182,7 +181,7 @@ function useThreadActionExecutor(
181
(result) => result._tag === "Success",
182
);
183
if (result._tag === "Failure") {
185
- Alert.alert(actionFailureTitle(action), actionFailureMessage(action, result.cause));
184
+ Dialog.alert(actionFailureTitle(action), actionFailureMessage(action, result.cause));
185
return false;
186
}
187
// Settled threads stay in the live shell stream; only the archive
@@ -286,14 +285,14 @@ export function useThreadListActions(): {
285
snoozeInFlightThreadKeys.current.add(key);
286
try {
287
if (!environmentSupportsSnooze(thread.environmentId)) {
289
- Alert.alert(
288
+ Dialog.alert(
289
"Could not snooze thread",
290
"This environment's server does not support snoozing yet. Update the server to use Snooze.",
291
);
292
return false;
293
}
294
if (!canSnooze(thread, { now: new Date().toISOString() })) {
296
- Alert.alert(
295
+ Dialog.alert(
296
"Could not snooze thread",
297
thread.hasPendingApprovals ||
298
thread.hasPendingUserInput ||
@@ -319,7 +318,7 @@ export function useThreadListActions(): {
318
);
319
if (result._tag === "Failure") {
320
const error = Cause.squash(result.cause);
322
- Alert.alert(
321
+ Dialog.alert(
322
"Could not snooze thread",
323
error instanceof Error && error.message.trim().length > 0
324
? error.message
@@ -344,7 +343,7 @@ export function useThreadListActions(): {
343
snoozeInFlightThreadKeys.current.add(key);
344
try {
345
if (!environmentSupportsSnooze(thread.environmentId)) {
347
- Alert.alert(
346
+ Dialog.alert(
347
"Could not wake thread",
348
"This environment's server does not support snoozing yet. Update the server to wake this thread.",
349
);
@@ -363,7 +362,7 @@ export function useThreadListActions(): {
362
);
363
if (result._tag === "Failure") {
364
const error = Cause.squash(result.cause);
366
- Alert.alert(
365
+ Dialog.alert(
366
"Could not wake thread",
367
error instanceof Error && error.message.trim().length > 0
368
? error.message
@@ -386,7 +385,7 @@ export function useThreadListActions(): {
385
async (thread: EnvironmentThreadShell) => {
386
if (!checkThreadOperationPermission(thread, "Could not pin thread")) return false;
387
if (!environmentSupportsPinning(thread.environmentId)) {
389
- Alert.alert(
388
+ Dialog.alert(
389
"Could not pin thread",
390
"This environment's server does not support pinning yet. Update the server to use Pin.",
391
);
@@ -411,7 +410,7 @@ export function useThreadListActions(): {
410
});
411
if (result._tag === "Failure") {
412
const error = Cause.squash(result.cause);
414
- Alert.alert(
413
+ Dialog.alert(
414
"Could not pin thread",
415
error instanceof Error && error.message.trim().length > 0
416
? error.message
@@ -427,7 +426,7 @@ export function useThreadListActions(): {
426
async (thread: EnvironmentThreadShell) => {
427
if (!checkThreadOperationPermission(thread, "Could not unpin thread")) return false;
428
if (!environmentSupportsPinning(thread.environmentId)) {
430
- Alert.alert(
429
+ Dialog.alert(
430
"Could not unpin thread",
431
"This environment's server does not support pinning yet. Update the server to use Pin.",
432
);
@@ -440,7 +439,7 @@ export function useThreadListActions(): {
439
});
440
if (result._tag === "Failure") {
441
const error = Cause.squash(result.cause);
443
- Alert.alert(
442
+ Dialog.alert(
443
"Could not unpin thread",
444
error instanceof Error && error.message.trim().length > 0
445
? error.message
@@ -455,7 +454,7 @@ export function useThreadListActions(): {
454
const setThreadAutoSettle = useCallback(
455
async (thread: EnvironmentThreadShell, enabled: boolean) => {
456
if (!environmentSupportsAutoSettleOptOut(thread.environmentId)) {
458
- Alert.alert(
457
+ Dialog.alert(
458
"Could not update auto-settle",
459
"This environment's server does not support turning auto-settle off per thread yet. Update the server to use it.",
460
);
@@ -468,7 +467,7 @@ export function useThreadListActions(): {
467
});
468
if (result._tag === "Failure") {
469
const error = Cause.squash(result.cause);
471
- Alert.alert(
470
+ Dialog.alert(
471
"Could not update auto-settle",
472
error instanceof Error && error.message.trim().length > 0
473
? error.message
@@ -491,7 +490,7 @@ export function useThreadListActions(): {
490
return false;
491
}
492
if (!environmentSupportsTitleRegeneration(thread.environmentId)) {
494
- Alert.alert(
493
+ Dialog.alert(
494
"Could not regenerate title",
495
"This environment's server does not support title regeneration yet. Update the server to regenerate thread titles.",
496
);
@@ -507,7 +506,7 @@ export function useThreadListActions(): {
506
});
507
if (result._tag === "Failure") {
508
const error = Cause.squash(result.cause);
510
- Alert.alert(
509
+ Dialog.alert(
510
"Could not regenerate title",
511
error instanceof Error && error.message.trim().length > 0
512
? error.message
@@ -527,7 +526,7 @@ export function useThreadListActions(): {
526
const commit = (title: string) => {
527
const resolution = resolveThreadTitleRename({ title, originalTitle: thread.title });
528
if (resolution.action === "reject-empty") {
530
- Alert.alert("Could not rename thread", "Thread title cannot be empty.");
529
+ Dialog.alert("Could not rename thread", "Thread title cannot be empty.");
530
return;
531
}
532
if (resolution.action === "noop") return;
@@ -538,7 +537,7 @@ export function useThreadListActions(): {
537
}).then((result) => {
538
if (result._tag === "Success") return;
539
const error = Cause.squash(result.cause);
541
- Alert.alert(
540
+ Dialog.alert(
541
"Could not rename thread",
542
error instanceof Error && error.message.trim().length > 0
543
? error.message
@@ -597,7 +596,7 @@ export function useThreadListActions(): {
596
: capabilities?.threadActiveReorder === true;
597
};
598
if (!supportsReorder(thread.environmentId)) {
600
- Alert.alert(
599
+ Dialog.alert(
600
"Could not move thread",
601
"This environment's server does not support reordering these threads. Update the server to arrange them.",
602
);
@@ -674,7 +673,7 @@ export function useThreadListActions(): {
673
input: { threadId: thread.id, ...(orderKey === undefined ? {} : { orderKey }) },
674
});
675
if (result._tag === "Failure") {
677
- Alert.alert("Could not pin thread", String(Cause.squash(result.cause)));
676
+ Dialog.alert("Could not pin thread", String(Cause.squash(result.cause)));
677
return false;
678
}
679
} else {
@@ -701,7 +700,7 @@ export function useThreadListActions(): {
700
});
701
if (result._tag === "Failure") {
702
const error = Cause.squash(result.cause);
704
- Alert.alert(
703
+ Dialog.alert(
704
"Could not move thread",
705
error instanceof Error && error.message.trim().length > 0
706
? error.message
apps/mobile/src/features/projects/AddProjectScreen.tsx
+6
-5
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../../components/Dialog";
2
import { AppActivityIndicator } from "../../components/AppActivityIndicator";
3
import { NavigationRow } from "../../components/NavigationRow";
4
import { SettingsScreen } from "../settings/components/SettingsScreen";
@@ -56,7 +57,7 @@ import {
57
import { CommonActions, StackActions, useNavigation } from "@react-navigation/native";
58
import { SymbolView } from "../../components/AppSymbol";
59
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
59
-import { Platform, Alert, Pressable, View } from "react-native";
60
+import { Platform, Pressable, View } from "react-native";
61
import { useSafeAreaInsets } from "react-native-safe-area-context";
62
import * as Arr from "effect/Array";
63
import * as Cause from "effect/Cause";
@@ -718,7 +719,7 @@ function useCreateProject(environment: EnvironmentOption | null) {
719
!canCreateProjectInEnvironment(environment.connectionState) ||
720
!readEnvironmentScope(environment.environmentId, AuthOrchestrationOperateScope)
721
) {
721
- Alert.alert(
722
+ Dialog.alert(
723
"Project not added",
724
`This connection cannot add projects right now. Any existing files remain at ${workspaceRoot}.`,
725
);
@@ -731,7 +732,7 @@ function useCreateProject(environment: EnvironmentOption | null) {
732
path: workspaceRoot,
733
});
734
if (existing) {
734
- Alert.alert("Project already exists", existing.title);
735
+ Dialog.alert("Project already exists", existing.title);
736
navigation.dispatch(
737
CommonActions.reset({
738
index: 0,
@@ -1092,7 +1093,7 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
1093
}
1094
const { projectId, workspaceRoot, commitError } = result.value;
1095
if (commitError !== undefined) {
1095
- Alert.alert("Created without a first commit", commitError);
1096
+ Dialog.alert("Created without a first commit", commitError);
1097
}
1098
if (publishes && publishTarget !== null) {
1099
void publishRepository({
@@ -1105,7 +1106,7 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
1106
},
1107
}).then((publishResult) => {
1108
if (AsyncResult.isFailure(publishResult)) {
1108
- Alert.alert(
1109
+ Dialog.alert(
1110
`Could not create the ${publishTarget.definition.label} repository`,
1111
errorMessage(Cause.squash(publishResult.cause)),
1112
);
apps/mobile/src/features/prompt-links/prompt-link-actions.ts
+5
-5
@@ -1,5 +1,5 @@
1
+import * as Dialog from "../../components/Dialog";
2
import { buildNewThreadLink, type LinkedPrompt } from "@t3tools/shared/promptLinks";
2
-import { Alert } from "react-native";
3
4
import { tryCopyTextWithHaptic } from "../../lib/copyTextWithHaptic";
5
import {
@@ -11,7 +11,7 @@ import { linkedThreadDraftAction } from "./prompt-link-model";
11
12
/** Shows the one notice a prompt link owes the user, built with `promptLinkNotice`. */
13
export function showPromptLinkNotice(notice: string): void {
14
- Alert.alert("Prompt from a link", notice);
14
+ Dialog.alert("Prompt from a link", notice);
15
}
16
17
/**
@@ -27,7 +27,7 @@ export async function applyLinkedPromptToThreadDraft(
27
try {
28
await waitForComposerDraftsLoaded();
29
} catch {
30
- Alert.alert("Could not open link", "Drafts could not be loaded, so the prompt was not added.");
30
+ Dialog.alert("Could not open link", "Drafts could not be loaded, so the prompt was not added.");
31
return;
32
}
33
const action = linkedThreadDraftAction(getComposerDraftSnapshot(draftKey).text, prompt.text);
@@ -36,7 +36,7 @@ export async function applyLinkedPromptToThreadDraft(
36
showPromptLinkNotice(notice);
37
return;
38
}
39
- Alert.alert("Linked prompt ready. Replace draft?", notice, [
39
+ Dialog.alert("Linked prompt ready. Replace draft?", notice, [
40
{ text: "Keep mine", style: "cancel" },
41
{ text: "Replace", onPress: () => setComposerDraftText(draftKey, prompt.text) },
42
]);
@@ -45,6 +45,6 @@ export async function applyLinkedPromptToThreadDraft(
45
/** Copies a shareable link that opens a new task with this prompt. Used by sent user messages. */
46
export async function copyPromptLink(prompt: string): Promise<void> {
47
if (!(await tryCopyTextWithHaptic(buildNewThreadLink({ prompt }), { target: "prompt link" }))) {
48
- Alert.alert("Could not copy", "Try again.");
48
+ Dialog.alert("Could not copy", "Try again.");
49
}
50
}
apps/mobile/src/features/prompt-links/usePromptLinkResolver.ts
+7
-7
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../../components/Dialog";
2
import { StackActions, useNavigation } from "@react-navigation/native";
3
import { availableScratchWorkspaceRoot } from "@t3tools/client-runtime/operations/projects";
4
import {
@@ -18,7 +19,6 @@ import {
19
type PromptLinkRepository,
20
} from "@t3tools/shared/promptLinks";
21
import { useEffect, useEffectEvent, useRef } from "react";
21
-import { Alert } from "react-native";
22
23
import { scopedThreadKey } from "../../lib/scopedEntities";
24
import { useServerConfigs, useThreadShells } from "../../state/entities";
@@ -103,7 +103,7 @@ export function usePromptLinkResolver(params: Readonly<Record<string, unknown>>
103
try {
104
await waitForComposerDraftsLoaded();
105
} catch {
106
- Alert.alert(
106
+ Dialog.alert(
107
"Could not open link",
108
"Drafts could not be loaded, so the prompt was not added.",
109
);
@@ -171,7 +171,7 @@ export function usePromptLinkResolver(params: Readonly<Record<string, unknown>>
171
.map((environment) => environment.environmentId),
172
);
173
if (environmentId === null) {
174
- Alert.alert(
174
+ Dialog.alert(
175
"Could not start without a project",
176
"No connected environment offers threads without a project.",
177
);
@@ -181,7 +181,7 @@ export function usePromptLinkResolver(params: Readonly<Record<string, unknown>>
181
if (result._tag === "Failure") {
182
if (!isAtomCommandInterrupted(result)) {
183
const error = squashAtomCommandFailure(result);
184
- Alert.alert(
184
+ Dialog.alert(
185
"Could not start without a project",
186
error instanceof Error
187
? error.message
@@ -200,7 +200,7 @@ export function usePromptLinkResolver(params: Readonly<Record<string, unknown>>
200
const environmentId =
201
flow.selectedEnvironmentId ?? connectedEnvironments[0]?.environmentId ?? null;
202
if (environmentId === null) {
203
- Alert.alert("Could not clone", "Connect an environment first.");
203
+ Dialog.alert("Could not clone", "Connect an environment first.");
204
return;
205
}
206
// Only a tracked clone opens a draft the prompt can ride into; older servers do not.
@@ -236,7 +236,7 @@ export function usePromptLinkResolver(params: Readonly<Record<string, unknown>>
236
const resolveLink = useEffectEvent((linkSearch: string) => {
237
const parsed = parseNewThreadLink(linkSearch);
238
if (!parsed.ok) {
239
- Alert.alert("Could not open link", parsed.error);
239
+ Dialog.alert("Could not open link", parsed.error);
240
return;
241
}
242
const link = parsed.value;
@@ -289,7 +289,7 @@ export function usePromptLinkResolver(params: Readonly<Record<string, unknown>>
289
void openProjectDraft(project, request);
290
return;
291
}
292
- Alert.alert(`You don't have ${promptLinkRepositoryName(repository)}`, undefined, [
292
+ Dialog.alert(`You don't have ${promptLinkRepositoryName(repository)}`, undefined, [
293
{ text: "Cancel", style: "cancel" },
294
...(request.prompt
295
? [{ text: "Use without project", onPress: () => void openScratchDraft(request) }]
apps/mobile/src/features/prompt-links/useThreadPromptLink.ts
+2
-2
@@ -1,7 +1,7 @@
1
+import * as Dialog from "../../components/Dialog";
2
import { useNavigation } from "@react-navigation/native";
3
import { parseThreadLinkPrompt } from "@t3tools/shared/promptLinks";
4
import { useEffect, useRef } from "react";
4
-import { Alert } from "react-native";
5
6
import { applyLinkedPromptToThreadDraft } from "./prompt-link-actions";
7
import {
@@ -33,7 +33,7 @@ export function useThreadPromptLink(
33
navigation.setParams(clearedPromptLinkParams(THREAD_LINK_KEYS));
34
const parsed = parseThreadLinkPrompt(search);
35
if (!parsed.ok) {
36
- Alert.alert("Could not open link", parsed.error);
36
+ Dialog.alert("Could not open link", parsed.error);
37
return;
38
}
39
if (parsed.value === null) return;
apps/mobile/src/features/pull-requests/usePullRequestAction.ts
+3
-3
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../../components/Dialog";
2
import { useAtomRefresh } from "@effect/atom-react";
3
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
4
import type {
@@ -6,7 +7,6 @@ import type {
7
PullRequestUpdateMethod,
8
} from "@t3tools/contracts";
9
import { useRef, useState } from "react";
9
-import { Alert } from "react-native";
10
import { composerPullRequests } from "../../state/pull-requests";
11
import { useAtomCommand } from "../../state/use-atom-command";
12
import { canPerformPullRequestAction } from "./pullRequestActions";
@@ -37,7 +37,7 @@ export function usePullRequestAction(params: PullRequestParams, pr: PullRequestD
37
refreshDetail();
38
refreshActivity();
39
} catch (cause) {
40
- Alert.alert(
40
+ Dialog.alert(
41
"Couldn't update this pull request",
42
cause instanceof Error ? cause.message : "Try again.",
43
);
@@ -47,7 +47,7 @@ export function usePullRequestAction(params: PullRequestParams, pr: PullRequestD
47
}
48
};
49
const confirm = (action: PullRequestAction, title: string, message: string) =>
50
- Alert.alert(title, message, [
50
+ Dialog.alert(title, message, [
51
{ text: "Cancel", style: "cancel" },
52
{
53
text: title,
apps/mobile/src/features/pull-requests/usePullRequestListActions.ts
+4
-3
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../../components/Dialog";
2
import { RegistryContext, useAtomValue } from "@effect/atom-react";
3
import { useNavigation } from "@react-navigation/native";
4
import { executeAtomQuery, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
@@ -5,7 +6,7 @@ import type { EnvironmentId, PullRequestAction } from "@t3tools/contracts";
6
import * as Clipboard from "expo-clipboard";
7
import { Atom } from "effect/reactivity";
8
import { use, useCallback, useMemo, useRef, useState } from "react";
8
-import { Alert, Linking, Platform, Share } from "react-native";
9
+import { Linking, Platform, Share } from "react-native";
10
import type { MenuProps } from "../../components/Menu.types";
11
import { composerPullRequests } from "../../state/pull-requests";
12
import { useAtomCommand } from "../../state/use-atom-command";
@@ -97,7 +98,7 @@ export function usePullRequestListActions(
98
: { isDraft: action === "draft" },
99
);
100
} catch (cause) {
100
- Alert.alert(
101
+ Dialog.alert(
102
"Couldn't update this pull request",
103
cause instanceof Error ? cause.message : "Try again.",
104
);
@@ -140,7 +141,7 @@ export function usePullRequestListActions(
141
(value) => value === action,
142
);
143
if (!supported) return;
143
- Alert.alert(`${PR_ACTION_LABELS[supported]}?`, `#${entry.number} · ${entry.title}`, [
144
+ Dialog.alert(`${PR_ACTION_LABELS[supported]}?`, `#${entry.number} · ${entry.title}`, [
145
{ text: "Cancel", style: "cancel" },
146
{
147
text: PR_ACTION_LABELS[supported],
apps/mobile/src/features/pull-requests/usePullRequestThreads.ts
+3
-2
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../../components/Dialog";
2
import { useNavigation, useNavigationState, useRoute } from "@react-navigation/native";
3
import { threadPullRequestLinkMode } from "@t3tools/client-runtime/thread-pull-request-compatibility";
4
import {
@@ -11,7 +12,7 @@ import { formatComposerContextReference } from "@t3tools/shared/composerContextR
12
import { parseChangeRequestUrl } from "@t3tools/shared/changeRequestUrl";
13
import { normalizeThreadPullRequestKey } from "@t3tools/shared/threadPullRequests";
14
import { useRef, useState } from "react";
14
-import { Alert, Platform } from "react-native";
15
+import { Platform } from "react-native";
16
import { useAndroidWorkspaceSelection } from "../workspace/useAndroidWorkspaceSelection";
17
import { pullRequestComposerContext } from "../../lib/composerContext";
18
import { scopedThreadKey } from "../../lib/scopedEntities";
@@ -150,7 +151,7 @@ export function usePullRequestThreads(
151
params: { draftId: draftKey, title: `Ask about #${pr.number}` },
152
});
153
} catch (cause) {
153
- Alert.alert("Couldn't open a thread", cause instanceof Error ? cause.message : "Try again.");
154
+ Dialog.alert("Couldn't open a thread", cause instanceof Error ? cause.message : "Try again.");
155
} finally {
156
pending.current = false;
157
setBusy(false);
apps/mobile/src/features/sharing/IncomingShareProvider.tsx
+3
-2
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../../components/Dialog";
2
import Constants from "expo-constants";
3
import * as Crypto from "expo-crypto";
4
import { PROVIDER_SEND_TURN_MAX_FILE_BYTES } from "@t3tools/contracts";
@@ -9,7 +10,7 @@ import {
10
type SharePayload,
11
} from "expo-sharing";
12
import React, { useCallback, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
12
-import { Alert, AppState, Platform } from "react-native";
13
+import { AppState, Platform } from "react-native";
14
15
import {
16
buildIncomingShareDraft,
@@ -278,7 +279,7 @@ export function IncomingShareProvider(props: React.PropsWithChildren) {
279
if (!error) {
280
return;
281
}
281
- Alert.alert("Could not import shared content", error.message, [
282
+ Dialog.alert("Could not import shared content", error.message, [
283
{ text: "Dismiss", style: "cancel", onPress: () => setError(null) },
284
{
285
text: "Retry",
apps/mobile/src/features/terminal/TerminalContextSheet.tsx
+3
-2
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../../components/Dialog";
2
import {
3
ComposerContextId,
4
COMPOSER_CONTEXT_TERMINAL_TEXT_MAX_CHARS,
@@ -6,7 +7,7 @@ import {
7
} from "@t3tools/contracts";
8
import { formatComposerContextReference } from "@t3tools/shared/composerContextReferences";
9
import { useState } from "react";
9
-import { Alert, Platform, Pressable, ScrollView, View } from "react-native";
10
+import { Platform, Pressable, ScrollView, View } from "react-native";
11
import { useSafeAreaInsets } from "react-native-safe-area-context";
12
import { REVIEW_MONO_FONT_FAMILY } from "../review/reviewDiffRendering";
13
import { AppText as Text } from "../../components/AppText";
@@ -50,7 +51,7 @@ export function TerminalContextSheet(props: {
51
context: { version: 1, records: [record] },
52
})
53
) {
53
- Alert.alert("Too many context items", "Remove some context from the draft and try again.");
54
+ Dialog.alert("Too many context items", "Remove some context from the draft and try again.");
55
return;
56
}
57
props.onAttach();
apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx
+4
-2
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../../components/Dialog";
2
import {
3
AuthTerminalReadScope,
4
AuthTerminalOperateScope,
@@ -12,7 +13,7 @@ import { AppBar } from "../../components/AppBar";
13
import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
14
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
15
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
15
-import { Alert, Platform, Pressable, View } from "react-native";
16
+import { Platform, Pressable, View } from "react-native";
17
import { useSafeAreaInsets } from "react-native-safe-area-context";
18
import { AppText as Text } from "../../components/AppText";
19
import { TerminalContextSheet } from "./TerminalContextSheet";
@@ -1283,7 +1284,8 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
1284
captureRequest={captureRequest}
1285
onCapture={(text) => {
1286
if (text.trim()) setCapturedOutput(text);
1286
- else Alert.alert("No terminal output", "There is no visible output to attach.");
1287
+ else
1288
+ Dialog.alert("No terminal output", "There is no visible output to attach.");
1289
}}
1290
onInput={handleInput}
1291
onResize={handleResize}
apps/mobile/src/features/threads/use-composer-command-menu.ts
+3
-3
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../../components/Dialog";
2
import type {
3
EnvironmentId,
4
ProjectId,
@@ -14,7 +15,6 @@ import {
15
COMPOSER_CONTEXT_MAX_RECORDS,
16
PROVIDER_WORKSPACE_SNAPSHOT_TTL_MS,
17
} from "@t3tools/contracts";
17
-import { Alert } from "react-native";
18
import { formatComposerContextReference } from "@t3tools/shared/composerContextReferences";
19
import { pullRequestComposerContext, threadComposerContext } from "../../lib/composerContext";
20
import { uuidv4 } from "../../lib/uuid";
@@ -564,7 +564,7 @@ export function useComposerCommandMenu({
564
const existing = getComposerDraftSnapshot(ownerKey).context?.records ?? [];
565
const alreadyAttached = existing.some((entry) => entry.contextId === record.contextId);
566
if (!alreadyAttached && existing.length >= COMPOSER_CONTEXT_MAX_RECORDS) {
567
- Alert.alert(
567
+ Dialog.alert(
568
"Too many context items",
569
"Remove some context from the draft and try again.",
570
);
@@ -599,7 +599,7 @@ export function useComposerCommandMenu({
599
(getComposerDraftSnapshot(ownerKey).context?.records.length ?? 0) >=
600
COMPOSER_CONTEXT_MAX_RECORDS
601
) {
602
- Alert.alert(
602
+ Dialog.alert(
603
"Too many context items",
604
"Remove some context from the draft and try again.",
605
);
apps/mobile/src/features/threads/useFileChipShare.ts
+2
-2
@@ -1,8 +1,8 @@
1
+import * as Dialog from "../../components/Dialog";
2
import { resolveAssetUrl } from "@t3tools/client-runtime/state/assets";
3
import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
4
import * as Option from "effect/Option";
5
import { useCallback, useEffect, useLayoutEffect, useRef } from "react";
5
-import { Alert } from "react-native";
6
7
import { downloadAndShareAttachment } from "../../lib/attachmentDownload";
8
import { assetEnvironment } from "../../state/assets";
@@ -52,7 +52,7 @@ export function useFileChipShare(
52
})()
53
.catch((error: unknown) => {
54
if (!request.signal.aborted) {
55
- Alert.alert(
55
+ Dialog.alert(
56
"Could not share file",
57
error instanceof Error ? error.message : "Try again.",
58
);
apps/mobile/src/features/updates/app-updates.ts
+2
-2
@@ -446,9 +446,9 @@ async function applyDeferredAppUpdateInstall(
446
}
447
448
async function defaultConfirmInstallNow(): Promise<boolean> {
449
- const { Alert } = await import("react-native");
449
+ const Dialog = await import("../../components/Dialog");
450
return new Promise<boolean>((resolve) => {
451
- Alert.alert(
451
+ Dialog.alert(
452
"Update ready",
453
"A new version has been downloaded and installs automatically the next time you leave the app. Install it now instead?",
454
[
apps/mobile/src/features/usage/UsageLimitsSection.tsx
+3
-2
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../../components/Dialog";
2
import { useAtomValue } from "@effect/atom-react";
3
import {
4
AuthProvidersManageScope,
@@ -19,7 +20,7 @@ import {
20
} from "@t3tools/shared/usageLimits";
21
import { type ReactNode, useEffect, useEffectEvent, useRef, useState } from "react";
22
import { refreshUsageLimits } from "@t3tools/client-runtime/state/usage";
22
-import { Alert, Linking, Pressable, View } from "react-native";
23
+import { Linking, Pressable, View } from "react-native";
24
25
import { AppText as Text } from "../../components/AppText";
26
import { ProviderIcon } from "../../components/ProviderIcon";
@@ -246,7 +247,7 @@ export function ResetCredits(props: {
247
248
const confirm = () => {
249
if (!readEnvironmentScope(environmentId, AuthProvidersManageScope)) return;
249
- Alert.alert(
250
+ Dialog.alert(
251
"Use a reset credit?",
252
"This redeems one credit on your account and clears the current rate-limit windows. It cannot be undone.",
253
[
apps/mobile/src/lib/attachmentDocument.ts
+2
-2
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../components/Dialog";
2
import { filePreviewDelimiter, parseDelimitedPreview } from "@t3tools/shared/delimitedPreview";
3
import type { EnvironmentId } from "@t3tools/contracts";
4
import { readFilePreviewResponse } from "@t3tools/client-runtime/file-preview";
@@ -5,7 +6,6 @@ import { filePreviewKind, FILE_TEXT_PREVIEW_MAX_BYTES } from "@t3tools/shared/fi
6
import { fetch } from "expo/fetch";
7
import { File } from "expo-file-system";
8
import { useEffect, useMemo, useRef, useState } from "react";
8
-import { Alert } from "react-native";
9
10
import type { FileBackedComposerAttachment } from "./composerImages";
11
import { loadLocalAttachmentPreview } from "./localAttachmentPreview";
@@ -179,7 +179,7 @@ export function useAttachmentDocument(input: {
179
else await downloadAndShareAttachment({ ...request, url: (await refresh()) ?? uri });
180
} catch (cause) {
181
if (controller.signal.aborted) return;
182
- Alert.alert(
182
+ Dialog.alert(
183
"Could not share file",
184
cause instanceof Error ? cause.message : "Please try again.",
185
);
apps/mobile/src/state/mediaActions.ts
+2
-2
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../components/Dialog";
2
import type { MediaActionsSource } from "../lib/mediaActionsSource";
3
import { useNavigation } from "@react-navigation/native";
4
import type { MediaActionId } from "@t3tools/client-runtime/media-actions";
@@ -11,7 +12,6 @@ import { normalizeNativeMarkdownUrl } from "../lib/markdownLinks";
12
import * as Option from "effect/Option";
13
import { AsyncResult } from "effect/reactivity";
14
import { useEffect, useRef, useState } from "react";
14
-import { Alert } from "react-native";
15
16
import { useRefreshAssetUrl } from "./assets";
17
import { appAtomRegistry } from "./atom-registry";
@@ -83,7 +83,7 @@ export function useMediaActions(source: MediaActionsSource | undefined, onOpenFi
83
})()
84
.catch((error: unknown) => {
85
if (!request.signal.aborted) {
86
- Alert.alert(
86
+ Dialog.alert(
87
"Could not share file",
88
error instanceof Error ? error.message : "Try again.",
89
);
apps/mobile/src/state/use-remote-environment-registry.ts
+4
-4
@@ -1,10 +1,10 @@
1
+import * as Dialog from "../components/Dialog";
2
import { useAtomValue } from "@effect/atom-react";
3
import { useNavigation } from "@react-navigation/native";
4
import type { EnvironmentId } from "@t3tools/contracts";
5
import * as Cause from "effect/Cause";
6
import { AsyncResult, Atom } from "effect/reactivity";
7
import { useCallback } from "react";
7
-import { Alert } from "react-native";
8
9
import { useConnectionController } from "../features/connection/useConnectionController";
10
import { environmentPresentations } from "./presentation";
@@ -124,7 +124,7 @@ export function useRemoteConnections() {
124
"reason" in error &&
125
error.reason === "unsupported"
126
) {
127
- Alert.alert("Client not supported", message);
127
+ Dialog.alert("Client not supported", message);
128
} else {
129
setPendingConnectionError(message);
130
}
@@ -171,7 +171,7 @@ export function useRemoteConnections() {
171
// Removing a T3 Connect environment here leaves its account registration
172
// and host space, so point to where it can be deregistered.
173
if (environment.isRelayManaged) {
174
- Alert.alert(
174
+ Dialog.alert(
175
"Remove from this device?",
176
`Forget ${environment.environmentLabel} and its cached threads on this device.\n\nIt stays on your T3 Connect account and keeps its host space. Deregister it under T3 Account → T3 Connect to free it.`,
177
[
@@ -185,7 +185,7 @@ export function useRemoteConnections() {
185
);
186
return;
187
}
188
- Alert.alert(
188
+ Dialog.alert(
189
"Remove from this device?",
190
`Forget ${environment.environmentLabel} and its cached threads on this device. Switch it off instead to keep it saved.`,
191
[{ text: "Cancel", style: "cancel" }, remove],
apps/mobile/src/state/use-selected-thread-requests.ts
+2
-2
@@ -1,5 +1,5 @@
1
+import * as Dialog from "../components/Dialog";
2
import { useServerConfigs } from "./entities";
2
-import { Alert } from "react-native";
3
import {
4
questionAttachmentDraftKey,
5
questionAttachmentDraftPrefix,
@@ -294,7 +294,7 @@ export function useSelectedThreadRequests() {
294
attachment.uploadEnvironmentId !== selectedThreadShell.environmentId,
295
)
296
) {
297
- Alert.alert(
297
+ Dialog.alert(
298
"Attachments are not ready",
299
"Wait for uploads to finish, or retry failed uploads.",
300
);
apps/mobile/src/state/use-thread-composer-state.ts
+12
-12
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../components/Dialog";
2
import { AuthOrchestrationOperateScope } from "@t3tools/contracts";
3
import { readEnvironmentScope } from "./session";
4
import type { ComposerTextPaste } from "../native/T3ComposerEditor.types";
@@ -12,7 +13,6 @@ import {
13
threadRuntimeHasInterruptibleRun,
14
} from "@t3tools/client-runtime/state/thread-execution";
15
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
15
-import { Alert } from "react-native";
16
17
import {
18
CommandId,
@@ -131,7 +131,7 @@ export function appendReviewCommentToDraft(input: {
131
reidentifyComposerContext(upgraded.text, upgraded.records, uuidv4),
132
)
133
) {
134
- Alert.alert("Too many context items", "Remove some context from the draft and try again.");
134
+ Dialog.alert("Too many context items", "Remove some context from the draft and try again.");
135
return;
136
}
137
if (input.attachments && input.attachments.length > 0) {
@@ -502,14 +502,14 @@ export function useThreadComposerState() {
502
const text = draft.text.trim();
503
if (text.length === 0) {
504
// The server rejects an empty queued message, attachments or not.
505
- Alert.alert("Add a message", "A queued message cannot be left empty.");
505
+ Dialog.alert("Add a message", "A queued message cannot be left empty.");
506
return;
507
}
508
if (
509
edit.existingAttachments.length + draft.attachments.length >
510
PROVIDER_SEND_TURN_MAX_ATTACHMENTS
511
) {
512
- Alert.alert(
512
+ Dialog.alert(
513
"Too many attachments",
514
`Remove attachments until there are at most ${PROVIDER_SEND_TURN_MAX_ATTACHMENTS}.`,
515
);
@@ -545,7 +545,7 @@ export function useThreadComposerState() {
545
},
546
});
547
if (result._tag !== "Success") {
548
- Alert.alert(
548
+ Dialog.alert(
549
"Could not save the queued message",
550
"It may have already started. Your edit is still in the composer.",
551
);
@@ -610,7 +610,7 @@ export function useThreadComposerState() {
610
// would enqueue a message that outbox recovery rejects forever, so block
611
// here until the user removes attachments.
612
if (attachments.length > PROVIDER_SEND_TURN_MAX_ATTACHMENTS) {
613
- Alert.alert(
613
+ Dialog.alert(
614
"Too many attachments",
615
`Remove attachments until there are at most ${PROVIDER_SEND_TURN_MAX_ATTACHMENTS}.`,
616
);
@@ -619,7 +619,7 @@ export function useThreadComposerState() {
619
620
const contextBlockReason = composerContextSendBlockReason(draft.context);
621
if (contextBlockReason) {
622
- Alert.alert("Too much context", contextBlockReason);
622
+ Dialog.alert("Too much context", contextBlockReason);
623
return null;
624
}
625
@@ -634,7 +634,7 @@ export function useThreadComposerState() {
634
modelSelection,
635
thread.projectId,
636
);
637
- Alert.alert(title, detail);
637
+ Dialog.alert(title, detail);
638
return null;
639
}
640
const provider = serverConfig?.providers.find(
@@ -648,7 +648,7 @@ export function useThreadComposerState() {
648
if (!readEnvironmentScope(selectedThreadShell.environmentId, AuthOrchestrationOperateScope))
649
return null;
650
if (thread.activeProviderThreadId === null) {
651
- Alert.alert("Start a Codex thread first", "Send a message before you submit feedback.");
651
+ Dialog.alert("Start a Codex thread first", "Send a message before you submit feedback.");
652
return null;
653
}
654
const metadata = makeQueuedMessageMetadata();
@@ -806,7 +806,7 @@ export function useThreadComposerState() {
806
: []),
807
];
808
if (problems.length > 0) {
809
- Alert.alert("Could not attach photo or video", problems.join("\n\n"));
809
+ Dialog.alert("Could not attach photo or video", problems.join("\n\n"));
810
}
811
}, [composerDrafts, selectedEnvironmentRuntime?.serverConfig, selectedThreadShell]);
812
@@ -818,7 +818,7 @@ export function useThreadComposerState() {
818
selectedEnvironmentRuntime?.serverConfig?.environment.capabilities.fileAttachments
819
?.maxUploadBytes;
820
if (maxBytes === undefined) {
821
- Alert.alert("Could not attach file", "This server does not support file attachments.");
821
+ Dialog.alert("Could not attach file", "This server does not support file attachments.");
822
return;
823
}
824
@@ -842,7 +842,7 @@ export function useThreadComposerState() {
842
: []),
843
];
844
if (problems.length > 0) {
845
- Alert.alert("Could not attach file", problems.join("\n\n"));
845
+ Dialog.alert("Could not attach file", problems.join("\n\n"));
846
}
847
}, [composerDrafts, selectedEnvironmentRuntime?.serverConfig, selectedThreadShell]);
848
apps/mobile/src/state/use-thread-outbox-drain.ts
+2
-2
@@ -1,3 +1,4 @@
1
+import * as Dialog from "../components/Dialog";
2
import { useAtomValue } from "@effect/atom-react";
3
import {
4
threadRuntimeIsActive,
@@ -18,7 +19,6 @@ import { buildTemporaryWorktreeBranchName } from "@t3tools/shared/git";
19
import * as Cause from "effect/Cause";
20
import { AsyncResult } from "effect/reactivity";
21
import { useCallback, useEffect, useRef, useState } from "react";
21
-import { Alert } from "react-native";
22
23
import { createDebugLogger } from "../lib/debugLog";
24
import { scopedThreadKey } from "../lib/scopedEntities";
@@ -758,7 +758,7 @@ export function useThreadOutboxDrain(): void {
758
let mounted = true;
759
const load = async () => {
760
if ((await threadOutboxManager.load()) || !mounted) return;
761
- Alert.alert(
761
+ Dialog.alert(
762
"Some queued messages could not be loaded",
763
"Unreadable records and attachment files are still saved. Other messages can still be sent.",
764
[