Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ThreadComposer.tsx

654 lines25.1 KB

1import type {
2 EnvironmentId,
3 MessageId,
4 ModelSelection,
5 OrchestrationThreadShell,
6 ProviderInteractionMode,
7 RuntimeMode,
8 ServerConfig as T3ServerConfig,
9} from "@t3tools/contracts";
10import { StackActions, useFocusEffect, useNavigation } from "@react-navigation/native";
11import type { ReactNode } from "react";
12import { memo, useCallback, useEffect, useMemo, useRef, useState, type RefObject } from "react";
13import { ActivityIndicator, Image, Platform, Pressable, View, type ViewStyle } from "react-native";
14import ImageViewing from "react-native-image-viewing";
15import Animated, {
16 FadeIn,
17 FadeInDown,
18 FadeOut,
19 FadeOutDown,
20 LinearTransition,
21} from "react-native-reanimated";
22import { useUniwindTheme } from "../../lib/useUniwindTheme";
23import { armAgentAwarenessLiveActivityForLocalWork } from "../agent-awareness/remoteRegistration";
24import { scopedThreadKey } from "../../lib/scopedEntities";
25​
26import { AppText as Text } from "../../components/AppText";
27import { ComposerAttachmentStrip } from "../../components/ComposerAttachmentStrip";
28import { GlassSurface } from "../../components/GlassSurface";
29import { ComposerEditor, type ComposerEditorHandle } from "../../components/ComposerEditor";
30import {
31 ComposerInlineControl,
32 ComposerToolbarButton,
33 ComposerToolbarRow,
34 ComposerToolbarScroller,
35} from "../../components/ComposerToolbar";
36import { ControlPill } from "../../components/ControlPill";
37import { ProviderIcon } from "../../components/ProviderIcon";
38import type { DraftComposerImageAttachment } from "../../lib/composerImages";
39import { buildModelOptions, groupByProvider } from "../../lib/modelOptions";
40import { useScaledTextRole } from "../settings/appearance/useScaledTextRole";
41import type { RemoteClientConnectionState } from "../../lib/connection";
42import { resolveProviderOptionDescriptors } from "../../lib/providerOptions";
43import { ComposerCommandPopover } from "./ComposerCommandPopover";
44import { useComposerCommandMenu } from "./use-composer-command-menu";
45import {
46 type ExistingThreadSettingsRouteSession,
47 useExistingThreadSettingsRoutePresentation,
48} from "./ThreadSettingsSheet";
49import {
50 useThreadSettingsSheetPresentation,
51 type NavigationWithFinishTransitioning,
52} from "./use-thread-settings-sheet-presentation";
53​
54/**
55 * Height of the collapsed composer (pill + vertical padding, excluding safe-area inset).
56 * Exported so the parent can compute feed overlap / content insets.
57 */
58export const COMPOSER_COLLAPSED_CHROME = 60;
59​
60/**
61 * Height of the expanded composer (card + toolbar + vertical padding, excluding safe-area inset).
62 * Used by the parent to compute the larger feed bottom inset when the composer is focused.
63 */
64export const COMPOSER_EXPANDED_CHROME = 156;
65​
66export interface ThreadComposerProps {
67 readonly draftMessage: string;
68 readonly draftAttachments: ReadonlyArray<DraftComposerImageAttachment>;
69 readonly placeholder: string;
70 readonly contentMaxWidth?: number;
71 readonly bottomInset?: number;
72 readonly connectionState: RemoteClientConnectionState;
73 readonly connectionError: string | null;
74 readonly environmentLabel: string | null;
75 /**
76 * Message sync phase for the selected thread (drives the status pill):
77 * "loading" = first fetch, nothing to show yet; "syncing" = cached messages
78 * are on screen while they reconcile with the server.
79 */
80 readonly threadSyncPhase?: "loading" | "syncing" | null;
81 readonly selectedThread: OrchestrationThreadShell;
82 readonly serverConfig: T3ServerConfig | null;
83 readonly queueCount: number;
84 readonly environmentId: EnvironmentId;
85 readonly projectCwd: string | null;
86 readonly editorRef?: RefObject<ComposerEditorHandle | null>;
87 readonly onChangeDraftMessage: (value: string) => void;
88 readonly onPickDraftImages: () => Promise<void>;
89 readonly onNativePasteImages: (uris: ReadonlyArray<string>) => Promise<void>;
90 readonly onRemoveDraftImage: (imageId: string) => void;
91 readonly onStopThread: () => void;
92 readonly onSendMessage: () => Promise<MessageId | null>;
93 readonly onUpdateModelSelection: (modelSelection: ModelSelection) => void;
94 readonly onUpdateRuntimeMode: (runtimeMode: RuntimeMode) => void;
95 readonly onUpdateInteractionMode: (interactionMode: ProviderInteractionMode) => void;
96 readonly onReconnectEnvironment: () => void;
97 readonly onExpandedChange?: (expanded: boolean) => void;
98 /** Fires on editor focus/blur; hosts use it to vet stale keyboard state. */
99 readonly onEditorFocusChange?: (focused: boolean) => void;
101​
102/**
103 * The pill / card container — renders with Expo's native GlassView on supported
104 * iOS 26+ devices and keeps the existing opaque fallback elsewhere.
105 * Exported so NewTaskDraftScreen can render the same composer chrome.
106 */
107// One timing for every piece of the expanded↔compact morph so the surface,
108// toolbar, and siblings move together instead of popping between layouts.
109// Android gets NO layout transition: the composer rides the keyboard via
110// KeyboardStickyView (frame-synced to the IME), and a time-based morph
111// running alongside that translate reads as jitter. Snapping the layout and
112// letting the keyboard-synced slide be the only motion looks native there.
113const COMPOSER_LAYOUT_TRANSITION =
114 Platform.OS === "android" ? undefined : LinearTransition.duration(220);
115​
116export function ComposerSurface(props: {
117 readonly children: ReactNode;
118 readonly style: ViewStyle;
119 /** Existing thread composers morph between pill and card layouts. */
120 readonly animateLayout?: boolean;
121}) {
122 // A box shadow follows the rounded surface even when the glass is transparent.
123 // Keep it outside the clipped content so the shadow can extend past the edge.
124 return (
125 <Animated.View
126 className="shadow-[0_6px_28px] shadow-adaptive-black-a15-a35"
127 layout={props.animateLayout === false ? undefined : COMPOSER_LAYOUT_TRANSITION}
128 style={{
129 borderRadius: props.style.borderRadius,
130 // Android versions before 9 do not support outset box shadows.
131 elevation: Platform.OS === "android" && Platform.Version < 28 ? 10 : undefined,
132 }}
133 >
134 <GlassSurface
135 chrome="none"
136 fallbackClassName="border border-border bg-card-translucent"
137 glassEffectStyle="regular"
138 // The composer is a passive material containing interactive controls.
139 // Expo GlassView defaults to non-interactive and both layouts share it.
140 tintColor="transparent"
141 style={props.style}
142 >
143 {props.children}
144 </GlassSurface>
145 </Animated.View>
146 );
148​
149type ComposerStatusPillState = {
150 readonly kind: "unavailable" | "reconnecting" | "syncing";
151 readonly label: string;
152};
153​
154function composerConnectionStatus(input: {
155 readonly connectionError: string | null;
156 readonly connectionState: RemoteClientConnectionState;
157 readonly environmentLabel: string | null;
158 readonly threadSyncPhase?: "loading" | "syncing" | null;
159}): ComposerStatusPillState | null {
160 const environmentLabel = input.environmentLabel ?? "Environment";
161​
162 switch (input.connectionState) {
163 case "connecting":
164 case "reconnecting":
165 return {
166 kind: "reconnecting",
167 label:
168 input.connectionError === null
169 ? `Reconnecting to ${environmentLabel}...`
170 : `Failed to connect. Retrying ${environmentLabel}...`,
171 };
172 case "offline":
173 return { kind: "unavailable", label: "You are offline" };
174 case "error":
175 return {
176 kind: "unavailable",
177 label: input.connectionError
178 ? `Failed to connect to ${environmentLabel}: ${input.connectionError}`
179 : `Failed to connect to ${environmentLabel}`,
180 };
181 case "available":
182 return { kind: "unavailable", label: `${environmentLabel} is not connected` };
183 case "connected":
184 break;
185 }
186​
187 // Connected: the pill is the single loading/sync indicator. One stable
188 // label per open — "Loading" when starting from scratch, "Syncing" when
189 // cached messages are already visible.
190 switch (input.threadSyncPhase) {
191 case "loading":
192 return { kind: "syncing", label: "Loading messages..." };
193 case "syncing":
194 return { kind: "syncing", label: "Syncing messages..." };
195 default:
196 return null;
197 }
199​
200const ComposerConnectionStatusPill = memo(function ComposerConnectionStatusPill(props: {
201 readonly onPress: () => void;
202 readonly status: ComposerStatusPillState;
203}) {
204 const isReconnecting = props.status.kind !== "unavailable";
205 return (
206 <Animated.View
207 className="absolute inset-x-0 bottom-full items-center pb-2"
208 entering={FadeInDown.duration(180)}
209 exiting={FadeOutDown.duration(140)}
210 pointerEvents="box-none"
211 >
212 <Pressable
213 accessibilityRole="button"
214 onPress={props.onPress}
215 className="max-w-full flex-row items-center gap-2 rounded-full bg-card px-3 py-2 shadow-sm active:opacity-70"
216 >
217 {isReconnecting ? (
218 <ActivityIndicator size="small" colorClassName={"accent-icon-muted"} />
219 ) : (
220 <View className="h-2 w-2 rounded-full bg-red-500" />
221 )}
222 <Text
223 className="max-w-[260px] text-sm font-t3-bold leading-snug text-foreground"
224 numberOfLines={1}
225 >
226 {props.status.label}
227 </Text>
228 </Pressable>
229 </Animated.View>
230 );
231});
232​
233export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposerProps) {
234 const navigation = useNavigation();
235 const foregroundColor = useUniwindTheme()["--color-foreground"];
236 const bodyText = useScaledTextRole("body");
237 const fallbackInputRef = useRef<ComposerEditorHandle>(null);
238 const inputRef = props.editorRef ?? fallbackInputRef;
239 const [isFocused, setIsFocused] = useState(false);
240 const settingsSheetPresentation = useThreadSettingsSheetPresentation({
241 editorRef: inputRef,
242 isEditorFocused: isFocused,
243 });
244 const settingsRoutePresentation = useExistingThreadSettingsRoutePresentation();
245 const settingsRoutePresentedRef = useRef(false);
246 const wasExpandedBeforePreviewRef = useRef(false);
247 const inFlightThreadIdsRef = useRef(new Set<string>());
248 const { onExpandedChange } = props;
249​
250 const [previewImageUri, setPreviewImageUri] = useState<string | null>(null);
251 const hasContent = props.draftMessage.trim().length > 0 || props.draftAttachments.length > 0;
252 // Opening and presentation count as active so the composer stays expanded
253 // while focus moves between its native editor and the settings picker.
254 const isExpanded = isFocused || settingsSheetPresentation.isActive;
255 const canSend = hasContent;
256​
257 // Notify the parent from the derived value, not focus events: the parent
258 // sizes the feed inset from this, and blur-during-sheet would otherwise
259 // report collapsed while the composer still renders expanded.
260 useEffect(() => {
261 onExpandedChange?.(isExpanded);
262 }, [isExpanded, onExpandedChange]);
263​
264 const onPressImage = useCallback(
265 (uri: string) => {
266 wasExpandedBeforePreviewRef.current = isFocused;
267 setPreviewImageUri(uri);
268 },
269 [isFocused],
270 );
271​
272 const closePreview = useCallback(() => {
273 setPreviewImageUri(null);
274 if (wasExpandedBeforePreviewRef.current) {
275 setTimeout(() => inputRef.current?.focus(), 100);
276 }
277 }, [inputRef]);
278​
279 const onEditorFocusChange = props.onEditorFocusChange;
280 const handleFocus = useCallback(() => {
281 setIsFocused(true);
282 onEditorFocusChange?.(true);
283 }, [onEditorFocusChange]);
284​
285 const handleBlur = useCallback(() => {
286 setIsFocused(false);
287 onEditorFocusChange?.(false);
288 }, [onEditorFocusChange]);
289 const showStopAction =
290 props.selectedThread.session?.status === "running" ||
291 props.selectedThread.session?.status === "starting";
292​
293 const sendLabel =
294 props.connectionState !== "connected" || props.queueCount > 0 ? "Queue" : "Send";
295 const currentModelSelection = props.selectedThread.modelSelection;
296 const currentRuntimeMode = props.selectedThread.runtimeMode;
297 const connectionStatus = composerConnectionStatus({
298 connectionError: props.connectionError,
299 connectionState: props.connectionState,
300 environmentLabel: props.environmentLabel,
301 threadSyncPhase: props.threadSyncPhase,
302 });
303 const selectedProviderStatus = useMemo(() => {
304 if (!props.serverConfig) return null;
305 return (
306 props.serverConfig.providers.find(
307 (p) => p.instanceId === props.selectedThread.modelSelection.instanceId,
308 ) ?? null
309 );
310 }, [props.serverConfig, props.selectedThread.modelSelection.instanceId]);
311​
312 const composerMenu = useComposerCommandMenu({
313 draftMessage: props.draftMessage,
314 environmentId: props.environmentId,
315 projectCwd: props.projectCwd,
316 selectedProviderStatus,
317 hasThread: true,
318 onChangeDraftMessage: props.onChangeDraftMessage,
319 onUpdateInteractionMode: props.onUpdateInteractionMode,
320 });
321 const { onSendMessage } = props;
322​
323 const handleSend = useCallback(async () => {
324 const threadKey = scopedThreadKey(props.environmentId, props.selectedThread.id);
325 if (inFlightThreadIdsRef.current.has(threadKey)) return;
326 inFlightThreadIdsRef.current.add(threadKey);
327 try {
328 const messageId = await onSendMessage();
329 if (messageId === null) {
330 return;
331 }
332 // Sending a prompt starts agent work: arm the lock-screen card while the
333 // app is foregrounded and the activity token can be registered. Armed
334 // after the send so its preference read and native Activity start don't
335 // contend with the queued-message feedback on the tap frame.
336 armAgentAwarenessLiveActivityForLocalWork({
337 environmentId: props.environmentId,
338 threadTitle: props.selectedThread.title,
339 projectTitle: props.environmentLabel ?? "T3 Code",
340 });
341 } finally {
342 inFlightThreadIdsRef.current.delete(threadKey);
343 }
344 }, [
345 onSendMessage,
346 props.environmentId,
347 props.environmentLabel,
348 props.selectedThread.id,
349 props.selectedThread.title,
350 ]);
351​
352 // ── Model menu ───────────────────────────────────────────
353 const modelOptions = useMemo(
354 () => buildModelOptions(props.serverConfig, currentModelSelection),
355 [props.serverConfig, currentModelSelection],
356 );
357 const providerGroups = useMemo(() => groupByProvider(modelOptions), [modelOptions]);
358 // An existing thread is bound to its harness: sessions can't move between
359 // provider instances, so the picker only offers the thread's own group.
360 const threadProviderGroups = useMemo(
361 () => providerGroups.filter((group) => group.providerKey === currentModelSelection.instanceId),
362 [providerGroups, currentModelSelection.instanceId],
363 );
364 const currentModelOption =
365 modelOptions.find(
366 (option) =>
367 option.selection.instanceId === currentModelSelection.instanceId &&
368 option.selection.model === currentModelSelection.model,
369 ) ?? null;
370 const providerOptionDescriptors = useMemo(
371 () =>
372 resolveProviderOptionDescriptors({
373 capabilities: currentModelOption?.capabilities,
374 selections: currentModelSelection.options,
375 }),
376 [currentModelOption?.capabilities, currentModelSelection.options],
377 );
378 const settingsOwnerId = scopedThreadKey(props.environmentId, props.selectedThread.id);
379 const settingsRouteSession = useMemo<ExistingThreadSettingsRouteSession>(
380 () => ({
381 ownerId: settingsOwnerId,
382 environmentId: props.environmentId,
383 providerGroups: threadProviderGroups,
384 selectedModel: currentModelSelection,
385 onSelectModel: (option) => props.onUpdateModelSelection(option.selection),
386 optionDescriptors: providerOptionDescriptors,
387 onUpdateOptionSelections: (options) =>
388 props.onUpdateModelSelection({ ...currentModelSelection, options }),
389 runtimeMode: currentRuntimeMode,
390 onUpdateRuntimeMode: props.onUpdateRuntimeMode,
391 }),
392 [
393 currentModelSelection,
394 currentRuntimeMode,
395 props.onUpdateModelSelection,
396 props.onUpdateRuntimeMode,
397 providerOptionDescriptors,
398 settingsOwnerId,
399 threadProviderGroups,
400 ],
401 );
402 const openSettings = useCallback(() => {
403 settingsRoutePresentation.present(settingsRouteSession);
404 settingsSheetPresentation.open();
405 }, [settingsRoutePresentation.present, settingsRouteSession, settingsSheetPresentation.open]);
406​
407 useEffect(() => {
408 if (settingsSheetPresentation.isActive) {
409 settingsRoutePresentation.present(settingsRouteSession);
410 }
411 }, [settingsRoutePresentation.present, settingsRouteSession, settingsSheetPresentation.isActive]);
412​
413 useEffect(() => {
414 if (!settingsSheetPresentation.isVisible || settingsRoutePresentedRef.current) {
415 return;
416 }
417​
418 settingsRoutePresentedRef.current = true;
419 navigation.dispatch(StackActions.push("ThreadSettingsSheet"));
420 }, [navigation, settingsSheetPresentation.isVisible]);
421​
422 useFocusEffect(
423 useCallback(() => {
424 if (!settingsRoutePresentedRef.current) {
425 return;
426 }
427​
428 settingsRoutePresentedRef.current = false;
429 settingsSheetPresentation.onDismissed();
430 settingsRoutePresentation.clear(settingsOwnerId);
431 }, [settingsOwnerId, settingsRoutePresentation.clear, settingsSheetPresentation.onDismissed]),
432 );
433​
434 useEffect(
435 () =>
436 // UIKit's completion callback for the sheet dismissal, surfaced by the
437 // native-stack patch. This is when the queued keyboard restore runs.
438 (navigation as unknown as NavigationWithFinishTransitioning).addListener(
439 "finishTransitioning",
440 settingsSheetPresentation.onStackTransitionsFinished,
441 ),
442 [navigation, settingsSheetPresentation.onStackTransitionsFinished],
443 );
444​
445 return (
446 <Animated.View
447 className="px-4"
448 layout={COMPOSER_LAYOUT_TRANSITION}
449 style={{
450 paddingTop: isExpanded ? 8 : 6,
451 paddingBottom: (props.bottomInset ?? 0) + (isExpanded ? 8 : 6),
452 }}
453 >
454 {/* The backdrop gradient lives on a plain View: Reanimated's Animated.View
455 silently drops experimental_backgroundImage on Android, which left this
456 strip fully transparent and the feed text legible through the composer. */}
457 <View
458 className="absolute inset-0 bg-linear-to-b from-screen/0 via-screen/60 to-screen/90"
459 pointerEvents="none"
460 />
461 <Animated.View
462 className="relative w-full self-center"
463 layout={COMPOSER_LAYOUT_TRANSITION}
464 style={{ maxWidth: props.contentMaxWidth }}
465 >
466 {composerMenu.trigger && composerMenu.items.length > 0 ? (
467 <View className="absolute inset-x-0 bottom-full z-10 mb-2">
468 <ComposerCommandPopover
469 items={composerMenu.items}
470 triggerKind={composerMenu.trigger.kind}
471 isLoading={composerMenu.isLoading}
472 onSelect={composerMenu.onSelect}
473 />
474 </View>
475 ) : null}
476​
477 {connectionStatus ? (
478 <ComposerConnectionStatusPill
479 status={connectionStatus}
480 onPress={props.onReconnectEnvironment}
481 />
482 ) : null}
483​
484 <ComposerSurface
485 style={
486 isExpanded
487 ? {
488 borderRadius: 26,
489 minHeight: 140,
490 overflow: "hidden" as const,
491 paddingBottom: 6,
492 paddingHorizontal: 14,
493 paddingTop: 14,
494 }
495 : {
496 borderRadius: 999,
497 overflow: "hidden" as const,
498 flexDirection: "row" as const,
499 alignItems: "center" as const,
500 paddingLeft: 18,
501 paddingRight: 5,
502 paddingVertical: 5,
503 }
504 }
505 >
506 {/* Attachment strip — inside the card, above the text input */}
507 {isExpanded ? (
508 <Animated.View
509 className={props.draftAttachments.length > 0 ? "pb-2.5" : undefined}
510 entering={FadeIn.duration(160)}
511 exiting={FadeOut.duration(120)}
512 >
513 <ComposerAttachmentStrip
514 attachments={props.draftAttachments}
515 onRemove={props.onRemoveDraftImage}
516 onPressImage={onPressImage}
517 />
518 </Animated.View>
519 ) : null}
520​
521 <View className={isExpanded ? undefined : "min-w-0 flex-1"}>
522 <ComposerEditor
523 ref={inputRef}
524 multiline
525 value={props.draftMessage}
526 skills={selectedProviderStatus?.skills ?? []}
527 selection={composerMenu.selection}
528 onChangeText={props.onChangeDraftMessage}
529 onSelectionChange={composerMenu.onSelectionChange}
530 onPasteImages={(uris) => void props.onNativePasteImages(uris)}
531 placeholder={props.placeholder}
532 onFocus={handleFocus}
533 onBlur={handleBlur}
534 onSubmit={handleSend}
535 scrollEnabled={isExpanded}
536 // Android: collapsed single line centers natively (gravity) in
537 // a pill-height box matching the send button; iOS keeps insets.
538 singleLineCentered={!isExpanded}
539 contentInsetVertical={isExpanded || Platform.OS === "android" ? 0 : 6}
540 style={
541 isExpanded
542 ? {
543 minHeight: 72,
544 maxHeight: 160,
545 paddingHorizontal: 4,
546 paddingVertical: 4,
547 }
548 : {
549 height: 36,
550 }
551 }
552 textStyle={{
553 ...bodyText,
554 color: foregroundColor,
555 }}
556 />
557 </View>
558 {!isExpanded && props.draftAttachments.length > 0 ? (
559 <View className="flex-row gap-1 pl-1">
560 {props.draftAttachments.slice(0, 3).map((image) => (
561 <Pressable key={image.id} onPress={() => onPressImage(image.previewUri)}>
562 <Image
563 source={{ uri: image.previewUri }}
564 className="size-[30px] rounded-lg bg-subtle"
565 resizeMode="cover"
566 />
567 </Pressable>
568 ))}
569 {props.draftAttachments.length > 3 ? (
570 <View className="size-[30px] items-center justify-center rounded-lg bg-subtle-strong">
571 <Text className="text-foreground-muted text-2xs font-t3-bold">
572 +{props.draftAttachments.length - 3}
573 </Text>
574 </View>
575 ) : null}
576 </View>
577 ) : null}
578 {!isExpanded ? (
579 <Animated.View entering={FadeIn.duration(180)} exiting={FadeOut.duration(100)}>
580 {showStopAction ? (
581 <ControlPill icon="stop.fill" variant="danger" onPress={props.onStopThread} />
582 ) : (
583 <ControlPill
584 icon="arrow.up"
585 variant="primary"
586 disabled={!canSend}
587 onPress={handleSend}
588 />
589 )}
590 </Animated.View>
591 ) : null}
592 {isExpanded ? (
593 <ComposerToolbarRow paddingBottom={0} paddingHorizontal={0} paddingTop={4}>
594 <ComposerToolbarScroller contentPaddingRight={8}>
595 <ComposerToolbarButton
596 accessibilityLabel="Add attachment"
597 icon="plus"
598 onPress={() => void props.onPickDraftImages()}
599 showChevron={false}
600 />
601 <ComposerInlineControl
602 accessibilityLabel="Model and reasoning settings"
603 emphasized
604 iconNode={
605 <ProviderIcon provider={currentModelOption?.providerDriver} size={16} />
606 }
607 label={currentModelOption?.label ?? currentModelSelection.model}
608 maxWidth={152}
609 onPress={openSettings}
610 />
611 {showStopAction ? (
612 <ComposerToolbarButton
613 accessibilityLabel="Stop"
614 icon="stop.fill"
615 variant="danger"
616 onPress={props.onStopThread}
617 showChevron={false}
618 />
619 ) : null}
620 </ComposerToolbarScroller>
621 <ComposerToolbarButton
622 accessibilityLabel={sendLabel}
623 icon="arrow.up"
624 variant="primary"
625 disabled={!canSend}
626 onPress={handleSend}
627 showChevron={false}
628 />
629 </ComposerToolbarRow>
630 ) : null}
631 </ComposerSurface>
632​
633 {/* Queue count */}
634 {props.queueCount > 0 ? (
635 <Animated.View entering={FadeIn.duration(180)} exiting={FadeOut.duration(120)}>
636 <Text className="pt-2 text-xs text-foreground-muted">
637 {props.queueCount} queued message{props.queueCount === 1 ? "" : "s"} will send
638 automatically.
639 </Text>
640 </Animated.View>
641 ) : null}
642 </Animated.View>
643​
644 <ImageViewing
645 images={previewImageUri ? [{ uri: previewImageUri }] : []}
646 imageIndex={0}
647 visible={previewImageUri !== null}
648 onRequestClose={closePreview}
649 swipeToCloseEnabled
650 doubleTapToZoomEnabled
651 />
652 </Animated.View>
653 );
654});