Open History to see the last commit
1import { useSidebarWorkspaceTabs } from "../workspace/useSystemWorkspaceTabBar";
2import { Button } from "../../components/ui/Button";
3import * as Dialog from "../../components/ui/Dialog";
4import type { ComposerTextPaste } from "../../native/T3ComposerEditor.types";
5import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
6import {
7 useAppearancePreferences,
8 useAndroidFloatingTabs,
9} from "../settings/appearance/AppearancePreferencesProvider";
10import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
11import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
12import { AsyncResult } from "effect/reactivity";
13import { useAtomValue } from "@effect/atom-react";
14import { clampFileAttachmentUploadBytes } from "@t3tools/client-runtime/state/attachments";
15import { pastedTextDisposition, replaceTextSelection } from "@t3tools/client-runtime/text-paste";
16import {
17 PROVIDER_SEND_TURN_MAX_ATTACHMENTS,
18 PROVIDER_SEND_TURN_MAX_INPUT_CHARS,
19 type ChatAttachment,
20 type EnvironmentId,
21 type MessageId,
22 type ModelSelection,
23 type ProviderInteractionMode,
24 type ServerConfig as T3ServerConfig,
25 type UsageLimitsReport,
26} from "@t3tools/contracts";
27import {
28 collectProviderUsageLimits,
29 hasProviderUsageLimits,
30 isUsageLimitsCommand,
31} from "@t3tools/shared/usageLimits";
32import { StackActions, useFocusEffect, useNavigation } from "@react-navigation/native";
33import type { ReactNode } from "react";
34import { useEffect, useEffectEvent, useRef, useState, type RefObject } from "react";
35import { Keyboard, Platform, View, type ViewStyle } from "react-native";
36import { composerImageGallery } from "../../lib/composerImageGallery";
37import { filePreviewGallery } from "../../lib/filePreviewGallery";
38import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
39import {
40 composerAttachmentUploadBlockReason,
41 composerAttachmentsStillUploading,
42 composerAttachmentUploadsAtom,
43} from "../../state/composer-attachment-uploads";
44import Animated, {
45 FadeIn,
46 FadeOut,
47 type LayoutAnimationFunction,
48 ReduceMotion,
49 useAnimatedStyle,
50 useDerivedValue,
51 useSharedValue,
52 withTiming,
53} from "react-native-reanimated";
54import { useUniwindTheme } from "../../lib/useUniwindTheme";
55import { themeColorWithAlpha } from "../../lib/mobileTheme";
56import { armAgentAwarenessLiveActivityForLocalWork } from "../agent-awareness/remoteRegistration";
57import { scopedThreadKey } from "../../lib/scopedEntities";
58import {
59 getComposerDraftSnapshot,
60 composerDraftsAtom,
61 setComposerDraftText,
62 composerContextImportsAtom,
63 countComposerDraftAttachmentsAfterSelection,
64 useComposerDraft,
65} from "../../state/use-composer-drafts";
66import { appAtomRegistry } from "../../state/atom-registry";
67import type { ComposerDocumentAttachment } from "../../lib/composerContext";
68import { useProject, useThreadShells } from "../../state/entities";
69import { scopeProjectRef } from "@t3tools/client-runtime/environment";
70
71import { AppText as Text } from "../../components/ui/AppText";
72import { ComposerAttachmentButton } from "./ComposerAttachmentButton";
73import {
74 ComposerAttachmentStrip,
75 ComposerAttachmentThumbnail,
76} from "../../components/ComposerAttachmentStrip";
77import { VideoPreviewModal, type VideoPreviewSource } from "../../components/VideoPreviewModal";
78import { GlassSurface } from "../../components/ui/GlassSurface";
79import { ComposerEditor, type ComposerEditorHandle } from "../../components/ComposerEditor";
80import { fileRoutePathSegments } from "../files/filePath";
81import { ComposerActionButton, ComposerToolbarRow } from "../../components/ComposerToolbar";
82import { ComposerModelControl } from "../../components/ComposerModelControl";
83import {
84 composerStripAttachments,
85 type DraftComposerFileAttachment,
86} from "../../lib/composerImages";
87import { buildModelOptions, isModelSelectionUnavailable } from "../../lib/modelOptions";
88import { useScaledTextRole, type ScaledTextRole } from "../settings/appearance/useScaledTextRole";
89import type { RemoteClientConnectionState } from "../../lib/connection";
90import { MOBILE_TYPOGRAPHY } from "../../lib/typography";
91import { Menu } from "../../components/ui/Menu";
92import type { ActiveTurnComposerAction } from "@t3tools/client-runtime/state/composer-dispatch";
93import type { FollowUpBehavior } from "../../lib/followUpBehavior";
94import {
95 resolveComposerSendPresentation,
96 type ComposerSendPresentation,
97} from "./composerSendPresentation";
98import { ComposerCommandPopover } from "./ComposerCommandPopover";
99import { ComposerPopoverAnchor } from "./ComposerPopoverAnchor";
100import { ComposerQueuedEditAttachments } from "./ComposerQueuedEdit";
101import { useComposerCommandMenu } from "./use-composer-command-menu";
102import {
103 ComposerDictationCancelAction,
104 ComposerDictationDraftContent,
105 ComposerDictationPrimaryAction,
106 ComposerDictationStartAction,
107 ComposerDictationStatus,
108 ComposerDictationToolbar,
109} from "../voice-input/ComposerDictationControl";
110import { useVoiceInputController } from "../voice-input/useVoiceInputController";
111import { resolveVoiceComposerPresentation } from "../voice-input/voiceInputPresentation";
112import type { ExistingThreadSettingsRouteParams } from "./ThreadSettingsSheet";
113import {
114 useThreadSettingsSheetPresentation,
115 type NavigationWithFinishTransitioning,
116} from "./use-thread-settings-sheet-presentation";
117
118export const COMPOSER_COLLAPSED_CHROME = 60;
119
120const COLLAPSED_EDITOR_DEFAULT_INSET = 6;
121// iOS puts line-height slack above glyphs. DM Sans's lowercase midline is
122// descender (0.31em) + half x-height (0.504em) above the line bottom.
123const LOWERCASE_MIDLINE_EM = 0.562;
124
125function lowercaseMidline(text: ScaledTextRole): number {
126 return text.lineHeight - LOWERCASE_MIDLINE_EM * text.fontSize;
127}
128
129function collapsedEditorInset(text: ScaledTextRole): number {
130 const shift = lowercaseMidline(text) - lowercaseMidline(MOBILE_TYPOGRAPHY.body);
131 return Math.max(0, Math.round(COLLAPSED_EDITOR_DEFAULT_INSET - shift));
132}
133
134export function useCompactComposerEditor(text: ScaledTextRole, value: string) {
135 const [contentSize, setContentSize] = useState({ width: 0, height: 0 });
136 const [compactWidth, setCompactWidth] = useState(0);
137 const contentHeight = contentSize.height;
138 const rowWidth = useSharedValue(0);
139 const editorX = useSharedValue(0);
140 const editorWidth = useSharedValue(0);
141 const inset =
142 Platform.OS === "android" ? COLLAPSED_EDITOR_DEFAULT_INSET : collapsedEditorInset(text);
143 const minimum = Math.max(INLINE_EDITOR_HEIGHT, Math.ceil(text.lineHeight) + 2 * inset);
144 const height = Math.max(
145 minimum,
146 Math.min(text.lineHeight * 4 + 2 * inset, contentHeight + 2 * inset),
147 );
148 // A line that fits the expanded editor may still overflow its compact slot.
149 // Compare its measured width too so widening cannot trigger a collapse loop.
150 const isExpanded =
151 value.length > 0 &&
152 (contentHeight > text.lineHeight * 1.5 ||
153 (compactWidth > 0 && contentSize.width > compactWidth));
154 const compactRowHeight = Math.max(44, minimum);
155 const editorStyle = useAnimatedStyle(() => ({
156 position: "absolute",
157 overflow: "hidden",
158 height,
159 left: isExpanded ? 14 : editorX.value + 4,
160 right: isExpanded ? 14 : rowWidth.value - editorX.value - editorWidth.value + 4,
161 // The full-width editor must move above the controls in the same frame it widens.
162 bottom: isExpanded ? 52 : (compactRowHeight - minimum) / 2,
163 }));
164 return {
165 isExpanded,
166 containerStyle: { height: isExpanded ? height + 52 : compactRowHeight },
167 editorStyle,
168 onRowLayout: (event: { nativeEvent: { layout: { width: number } } }) => {
169 rowWidth.set(event.nativeEvent.layout.width);
170 },
171 onEditorLayout: (event: { nativeEvent: { layout: { x: number; width: number } } }) => {
172 // The expanded toolbar gives this slot to the model control. Keep the
173 // compact geometry for the return transition, rather than recording zero.
174 if (!isExpanded) {
175 editorX.set(event.nativeEvent.layout.x);
176 editorWidth.set(event.nativeEvent.layout.width);
177 setCompactWidth(Math.max(0, event.nativeEvent.layout.width - 8));
178 }
179 },
180 editorProps: {
181 singleLineCentered: !isExpanded,
182 scrollEnabled: Platform.OS === "android" || contentHeight >= text.lineHeight * 4,
183 contentInsetVertical: inset,
184 onContentSizeChange: (size: { width: number; height: number }) => {
185 setContentSize(size);
186 },
187 style: { flex: 1 },
188 },
189 };
190}
191
192export interface ThreadComposerProps {
193 readonly isDraft?: boolean;
194 readonly canOperateThread: boolean;
195 readonly placeholder: string;
196 readonly contentMaxWidth?: number;
197 readonly draftControls?: ReactNode;
198 readonly bottomInset?: number;
199 readonly connectionState: RemoteClientConnectionState;
200 readonly environmentLabel: string | null;
201 readonly threadSyncPhase?: "loading" | "syncing" | null;
202 readonly selectedThread: EnvironmentThreadShell;
203 readonly reportedModelSelection?: ModelSelection | null;
204 readonly hasCompactableConversation: boolean;
205 readonly serverConfig: T3ServerConfig | null;
206 readonly queueCount: number;
207 readonly activeThreadBusy: boolean;
208 readonly canStopThread: boolean;
209 readonly environmentId: EnvironmentId;
210 readonly projectCwd: string | null;
211 readonly sendBlockedReason?: string | null;
212 readonly interactionLocked?: boolean;
213 readonly draftKey?: string;
214 readonly queuedEdit?: {
215 readonly existingAttachments: ReadonlyArray<ChatAttachment>;
216 readonly saving: boolean;
217 readonly onRemoveExistingAttachment: (attachmentId: string) => void;
218 } | null;
219 readonly followUpBehavior: FollowUpBehavior;
220 readonly canSteerActiveTurn: boolean;
221 readonly hidden: boolean;
222 readonly editorRef?: RefObject<ComposerEditorHandle | null>;
223 readonly onChangeDraftMessage: (value: string) => void;
224 readonly onPickDraftMedia: () => Promise<void>;
225 readonly onPickDraftFiles: () => Promise<void>;
226 readonly onNativePasteImages: (uris: ReadonlyArray<string>) => Promise<void>;
227 readonly onNativePasteText: (paste: ComposerTextPaste) => Promise<void>;
228 readonly onRemoveDraftImage: (imageId: string) => void;
229 readonly onStopThread: () => void;
230 /** Present while the thread's queue is held. */
231 readonly onResumeQueue: (() => Promise<void>) | null;
232 /** `stillSendable` reports whether the draft is unchanged after any wait before sending. */
233 readonly onSendMessage: (
234 followUp?: ActiveTurnComposerAction,
235 stillSendable?: () => boolean,
236 ) => Promise<MessageId | null>;
237 readonly onShowUsageLimits: (report: UsageLimitsReport | null) => void;
238 readonly canSwitchProvider: boolean;
239 readonly onUpdateInteractionMode?: (interactionMode: ProviderInteractionMode) => void;
240 readonly onHeightChange?: (height: number) => void;
241 readonly onEditorFocusChange?: (focused: boolean) => void;
242}
243
244// Android KeyboardStickyView tracks the IME; concurrent timed layout morphs cause jitter.
245export const COMPOSER_TRANSITION_DURATION_MS = 220;
246// Side panes animate dock width; nested horizontal transitions would make the surface trail the toolbar.
247const composerHeightTransition: LayoutAnimationFunction = (values) => {
248 "worklet";
249 const timing = {
250 duration: COMPOSER_TRANSITION_DURATION_MS,
251 reduceMotion: ReduceMotion.System,
252 };
253 return {
254 initialValues: {
255 originX: values.targetOriginX,
256 originY: values.currentOriginY,
257 width: values.targetWidth,
258 height: values.currentHeight,
259 },
260 animations: {
261 originX: values.targetOriginX,
262 originY: withTiming(values.targetOriginY, timing),
263 width: values.targetWidth,
264 height: withTiming(values.targetHeight, timing),
265 },
266 };
267};
268export const COMPOSER_LAYOUT_TRANSITION =
269 Platform.OS === "android" ? undefined : composerHeightTransition;
270// Share of the one-row composer the draft keeps; a long model name truncates first.
271const INLINE_EDITOR_MIN_WIDTH = "40%";
272const INLINE_EDITOR_HEIGHT = 36;
273
274const COMPOSER_ATTACHMENT_ENTERING =
275 Platform.OS === "android"
276 ? FadeIn.duration(160)
277 : FadeIn.delay(COMPOSER_TRANSITION_DURATION_MS).duration(160).reduceMotion(ReduceMotion.System);
278
279const AnimatedGlassSurface = Animated.createAnimatedComponent(GlassSurface);
280
281const FOLLOW_UP_ACTION_LABEL = {
282 queue: "Queue",
283 steer: "Steer now",
284 restart: "Restart turn",
285} as const;
286
287const FOLLOW_UP_ACTION_SUBTITLE = {
288 queue: "Run after the current turn",
289 steer: "Interrupt what the agent is doing",
290 restart: "Start the turn over with this message",
291} as const;
292
293function SendActionButton(props: {
294 readonly size?: "regular" | "large";
295 readonly accessibilityLabel: string;
296 readonly presentation: ComposerSendPresentation;
297 readonly disabled: boolean;
298 readonly onSend: (followUp?: ActiveTurnComposerAction) => void;
299}) {
300 const { presentation } = props;
301 const button = (
302 <ComposerActionButton
303 accessibilityLabel={props.accessibilityLabel}
304 size={props.size}
305 icon={presentation.icon}
306 variant="primary"
307 disabled={props.disabled}
308 onPress={() => props.onSend()}
309 />
310 );
311 if (!presentation.offersFollowUpChoice || presentation.action === null || props.disabled) {
312 return button;
313 }
314 const actions = [presentation.action, presentation.alternate].filter(
315 (action): action is ActiveTurnComposerAction => action !== null,
316 );
317 return (
318 <Menu
319 accessibilityLabel="Choose how to send this message"
320 shouldOpenOnLongPress
321 actions={actions.map((action) => ({
322 id: action,
323 title: FOLLOW_UP_ACTION_LABEL[action],
324 subtitle: FOLLOW_UP_ACTION_SUBTITLE[action],
325 state: action === presentation.action ? ("on" as const) : ("off" as const),
326 }))}
327 onPressAction={({ nativeEvent }) =>
328 props.onSend(nativeEvent.event as ActiveTurnComposerAction)
329 }
330 >
331 {button}
332 </Menu>
333 );
334}
335
336export function ComposerSurface(props: {
337 readonly children: ReactNode;
338 readonly style: ViewStyle;
339 readonly animateLayout?: boolean;
340}) {
341 const colors = useUniwindTheme();
342 const targetBorderRadius =
343 typeof props.style.borderRadius === "number" ? props.style.borderRadius : 0;
344 const shouldAnimate = props.animateLayout !== false && Platform.OS !== "android";
345 const animatedBorderRadius = useDerivedValue(() =>
346 shouldAnimate
347 ? withTiming(targetBorderRadius, {
348 duration: COMPOSER_TRANSITION_DURATION_MS,
349 reduceMotion: ReduceMotion.System,
350 })
351 : targetBorderRadius,
352 );
353 const borderCurve = props.style.borderCurve;
354 const animatedShapeStyle = useAnimatedStyle(() => ({
355 borderRadius: animatedBorderRadius.value,
356 ...(borderCurve ? { borderCurve } : {}),
357 }));
358 const layoutTransition = shouldAnimate ? COMPOSER_LAYOUT_TRANSITION : undefined;
359
360 // Animate every native frame or glass and content jump to final height inside the clip.
361 return (
362 <Animated.View
363 className={
364 Platform.OS === "android" ? undefined : "shadow-[0_6px_28px] shadow-adaptive-black-a15-a35"
365 }
366 layout={layoutTransition}
367 style={[
368 animatedShapeStyle,
369 {
370 overflow: "hidden",
371 },
372 ]}
373 >
374 <AnimatedGlassSurface
375 chrome="none"
376 fallbackColor={colors["--color-composer-surface"]}
377 fallbackClassName="border border-composer-border"
378 glassEffectStyle="regular"
379 pointerEvents="none"
380 tintColor="transparent"
381 layout={layoutTransition}
382 style={[{ position: "absolute", inset: 0 }, animatedShapeStyle]}
383 >
384 {null}
385 </AnimatedGlassSurface>
386 <Animated.View
387 collapsable={false}
388 layout={layoutTransition}
389 style={[props.style, animatedShapeStyle]}
390 >
391 {props.children}
392 </Animated.View>
393 </Animated.View>
394 );
395}
396
397/** Space below the composer pill, inside the bottom inset it is given. */
398export const THREAD_COMPOSER_BOTTOM_GUTTER = 6;
399
400export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps) {
401 const project = useProject(scopeProjectRef(props.environmentId, props.selectedThread.projectId));
402 const { themeVariables: materialTheme } = useAppearancePreferences();
403 const composerPanel = materialTheme["--color-composer-panel"];
404 const navigation = useNavigation();
405 const foregroundColor = useUniwindTheme()["--color-foreground"];
406 const bodyText = useScaledTextRole("body");
407 const fallbackInputRef = useRef<ComposerEditorHandle>(null);
408 const inputRef = props.editorRef ?? fallbackInputRef;
409 const [isFocused, setIsFocused] = useState(false);
410 const pendingPastedTextAttachmentCountRef = useRef(0);
411 const pendingNativeImagePasteCountRef = useRef(0);
412 const [pendingPastedTextAttachmentCount, setPendingPastedTextAttachmentCount] = useState(0);
413 const settingsRoutePresentedRef = useRef(false);
414 const settingsSheetPresentation = useThreadSettingsSheetPresentation({
415 editorRef: inputRef,
416 onPresent: () => {
417 if (settingsRoutePresentedRef.current) return;
418 settingsRoutePresentedRef.current = true;
419 // The draft composer edits the new-task flow, which owns its own settings route.
420 navigation.dispatch(
421 props.isDraft
422 ? StackActions.push("NewTaskThreadSettings")
423 : StackActions.push("ThreadSettingsSheet", {
424 environmentId: props.environmentId,
425 threadId: props.selectedThread.id,
426 draftKey: composerDraftKey,
427 } satisfies ExistingThreadSettingsRouteParams),
428 );
429 },
430 });
431 const disposeSettingsSheetPresentation = useEffectEvent(settingsSheetPresentation.dispose);
432 const wasExpandedBeforePreviewRef = useRef(false);
433 const inFlightThreadIdsRef = useRef(new Set<string>());
434
435 const [previewFile, setPreviewFile] = useState<FilePreviewSource | null>(null);
436 const [previewVideo, setPreviewVideo] = useState<VideoPreviewSource | null>(null);
437 const composerOwnerKey = scopedThreadKey(props.environmentId, props.selectedThread.id);
438 const composerDraftKey = props.draftKey ?? composerOwnerKey;
439 const { text: draftMessage, attachments: draftAttachments } = useComposerDraft(composerDraftKey);
440 const queuedEdit = props.queuedEdit ?? null;
441 const hasContent =
442 draftMessage.trim().length > 0 ||
443 draftAttachments.length > 0 ||
444 (queuedEdit?.existingAttachments.length ?? 0) > 0;
445 const stripAttachments = composerStripAttachments(draftAttachments);
446 const showStopAction = !hasContent && props.canStopThread && queuedEdit === null;
447 const onResumeQueue = props.onResumeQueue;
448 const [resumingQueue, setResumingQueue] = useState(false);
449 const showResumeAction =
450 !hasContent && !showStopAction && queuedEdit === null && onResumeQueue !== null;
451 const handleResumeQueue = async () => {
452 if (resumingQueue || onResumeQueue === null) return;
453 setResumingQueue(true);
454 await onResumeQueue();
455 setResumingQueue(false);
456 };
457
458 const uploadStates = useAtomValue(composerAttachmentUploadsAtom);
459 const attachmentsUploading =
460 props.connectionState === "connected" &&
461 composerAttachmentsStillUploading({
462 environmentId: props.environmentId,
463 attachments: draftAttachments,
464 serverConfig: props.serverConfig,
465 states: uploadStates,
466 });
467 const sendPresentation = resolveComposerSendPresentation({
468 editingQueuedMessage: queuedEdit !== null,
469 running: props.activeThreadBusy,
470 canSteer: props.canSteerActiveTurn,
471 followUpBehavior: props.followUpBehavior,
472 deliveryDeferred:
473 props.connectionState !== "connected" || props.queueCount > 0 || attachmentsUploading,
474 });
475 const sendLabel = sendPresentation.label;
476 const currentModelSelection = props.selectedThread.modelSelection;
477 const modelUnavailable =
478 props.connectionState === "connected" &&
479 isModelSelectionUnavailable(
480 props.serverConfig,
481 currentModelSelection,
482 props.selectedThread.projectId,
483 );
484 const selectedProviderStatus = (() => {
485 if (!props.serverConfig) return null;
486 return (
487 props.serverConfig.providers.find(
488 (p) => p.instanceId === props.selectedThread.modelSelection.instanceId,
489 ) ?? null
490 );
491 })();
492 const openDraftDocument = (attachment: ComposerDocumentAttachment) => {
493 Keyboard.dismiss();
494 navigation.navigate("ThreadAttachment", {
495 environmentId: String(props.environmentId),
496 threadId: String(props.selectedThread.id),
497 attachmentId: attachment.attachmentId,
498 name: attachment.name,
499 mimeType: attachment.mimeType,
500 sizeBytes: String(attachment.sizeBytes),
501 draftKey: composerDraftKey,
502 });
503 };
504 const { onSendMessage, onChangeDraftMessage, onShowUsageLimits } = props;
505 const usageLimitsOffered =
506 selectedProviderStatus !== null &&
507 hasProviderUsageLimits(
508 selectedProviderStatus.driver,
509 props.serverConfig?.providers ?? [],
510 props.serverConfig?.usageLimitSources ?? [],
511 );
512 const openUsageLimits = () => {
513 const report = collectProviderUsageLimits(
514 currentModelSelection.instanceId,
515 props.serverConfig?.providers ?? [],
516 props.serverConfig?.usageLimitSources ?? [],
517 Date.now(),
518 );
519 onShowUsageLimits(report);
520 if (!report) {
521 Dialog.alert("Usage limits unavailable", "This provider does not currently report limits.");
522 }
523 return report !== null;
524 };
525
526 const composerMenu = useComposerCommandMenu({
527 draftMessage: draftMessage,
528 ownerKey: composerDraftKey,
529 environmentId: props.environmentId,
530 threadShells: useThreadShells(),
531 currentThreadId: props.selectedThread.id,
532 projectCwd: props.projectCwd,
533 pullRequestProjectId: props.serverConfig?.environment.capabilities.pullRequests
534 ? (project?.id ?? null)
535 : null,
536 pullRequestRepository: project?.repositoryIdentity?.displayName ?? null,
537 threadPullRequests: props.selectedThread.pullRequests,
538 selectedProviderStatus,
539 hasThread: !props.isDraft,
540 hasCompactableConversation: props.hasCompactableConversation,
541 onChangeDraftMessage: props.onChangeDraftMessage,
542 onUpdateInteractionMode:
543 selectedProviderStatus?.showInteractionModeToggle === false
544 ? undefined
545 : props.onUpdateInteractionMode,
546 offersUsageLimits: usageLimitsOffered,
547 onUsageLimits:
548 usageLimitsOffered && draftAttachments.length === 0 ? openUsageLimits : undefined,
549 });
550 const voiceInput = useVoiceInputController({
551 ownerKey: composerDraftKey,
552 label: props.selectedThread.title || "Untitled thread",
553 readDraftMessage: () => getComposerDraftSnapshot(composerDraftKey).text,
554 subscribeToDraftChanges: (onChange) => appAtomRegistry.subscribe(composerDraftsAtom, onChange),
555 selection: composerMenu.selection,
556 onChangeDraftMessage: (text) => setComposerDraftText(composerDraftKey, text),
557 onChangeSelection: composerMenu.onSelectionChange,
558 });
559 const isSubmissionLocked =
560 props.interactionLocked === true || queuedEdit?.saving === true || voiceInput.blocksSubmission;
561 const voicePresentation = resolveVoiceComposerPresentation(
562 voiceInput.state,
563 voiceInput.elapsedSeconds,
564 );
565 const isVoiceInputPresented = voicePresentation.statusLabel !== null;
566 const isExpanded = isFocused || settingsSheetPresentation.keepsComposerExpanded;
567 const { layout, setComposerEditing } = useAdaptiveWorkspaceLayout();
568 const floatingSidebarComposer = useAndroidFloatingTabs() && layout.usesSplitView;
569 const usesLargeControls =
570 useSidebarWorkspaceTabs() === "picker" || (Platform.OS === "ios" && Platform.isPad);
571 const [compactRowWidth, setCompactRowWidth] = useState(0);
572 const compactAttachmentLimit = compactRowWidth >= 500 ? 3 : 1;
573 const compactEditor = useCompactComposerEditor(bodyText, draftMessage);
574 const showsCompactDictation = isVoiceInputPresented;
575 const isToolbarVisible = isVoiceInputPresented;
576 const hasEditingAttachments =
577 (queuedEdit !== null && queuedEdit.existingAttachments.length > 0) ||
578 stripAttachments.length > 0;
579 const attachmentBlockReason = composerAttachmentUploadBlockReason({
580 environmentId: props.environmentId,
581 attachments: draftAttachments,
582 connected: props.connectionState === "connected",
583 serverConfig: props.serverConfig,
584 states: uploadStates,
585 });
586 const contextImports = useAtomValue(composerContextImportsAtom);
587 const sendBlockedReason =
588 (queuedEdit?.saving === true ? "Saving…" : null) ??
589 props.sendBlockedReason ??
590 (pendingPastedTextAttachmentCount > 0 ? "Attaching pasted text" : null) ??
591 attachmentBlockReason;
592 const canSend =
593 (props.canOperateThread || props.connectionState !== "connected") &&
594 hasContent &&
595 !contextImports[composerDraftKey] &&
596 !isSubmissionLocked &&
597 sendBlockedReason === null &&
598 !modelUnavailable;
599
600 useEffect(() => () => setComposerEditing(false), [setComposerEditing]);
601 // A pending sheet presentation or focus restore has no composer left to act on.
602 useEffect(() => () => disposeSettingsSheetPresentation(), []);
603
604 const onPressPreview = (source: FilePreviewSource) => {
605 wasExpandedBeforePreviewRef.current = isFocused;
606 setPreviewVideo(null);
607 setPreviewFile(
608 (current) =>
609 current ?? {
610 ...source,
611 gallery: filePreviewGallery(source, composerImageGallery(draftAttachments)),
612 },
613 );
614 };
615
616 const closePreview = () => {
617 setPreviewFile(null);
618 setPreviewVideo(null);
619 if (wasExpandedBeforePreviewRef.current) {
620 setTimeout(() => {
621 if (navigation.isFocused()) inputRef.current?.focus();
622 }, 100);
623 }
624 };
625
626 const onPressVideo = (attachment: DraftComposerFileAttachment, sourceIdentifier: string) => {
627 wasExpandedBeforePreviewRef.current = isFocused;
628 setPreviewFile(null);
629 setPreviewVideo((current) => current ?? { type: "local", attachment, sourceIdentifier });
630 };
631
632 const onEditorFocusChange = props.onEditorFocusChange;
633 const handleFocus = () => {
634 setIsFocused(true);
635 settingsSheetPresentation.onEditorFocusChange(true);
636 onEditorFocusChange?.(true);
637 setComposerEditing(true);
638 };
639
640 const handleBlur = () => {
641 setIsFocused(false);
642 settingsSheetPresentation.onEditorFocusChange(false);
643 onEditorFocusChange?.(false);
644 setComposerEditing(false);
645 };
646 const handleSend = async (followUp?: ActiveTurnComposerAction) => {
647 if (
648 isSubmissionLocked ||
649 sendBlockedReason !== null ||
650 pendingPastedTextAttachmentCountRef.current > 0 ||
651 pendingNativeImagePasteCountRef.current > 0
652 )
653 return;
654 if (usageLimitsOffered && isUsageLimitsCommand(draftMessage) && draftAttachments.length === 0) {
655 if (openUsageLimits()) onChangeDraftMessage("");
656 return;
657 }
658 const threadKey = scopedThreadKey(props.environmentId, props.selectedThread.id);
659 if (inFlightThreadIdsRef.current.has(threadKey)) return;
660 inFlightThreadIdsRef.current.add(threadKey);
661 const draftAtSend = getComposerDraftSnapshot(composerDraftKey);
662 const stillSendable = () => {
663 const draft = getComposerDraftSnapshot(composerDraftKey);
664 return (
665 pendingPastedTextAttachmentCountRef.current === 0 &&
666 pendingNativeImagePasteCountRef.current === 0 &&
667 draft.text === draftAtSend.text &&
668 draft.attachments.length === draftAtSend.attachments.length &&
669 draft.attachments.every(
670 (attachment, index) => attachment.id === draftAtSend.attachments[index]?.id,
671 )
672 );
673 };
674 const sent = await settlePromise(() => onSendMessage(followUp, stillSendable));
675 inFlightThreadIdsRef.current.delete(threadKey);
676 if (AsyncResult.isFailure(sent)) {
677 console.error("[composer] send failed", squashAtomCommandFailure(sent));
678 return;
679 }
680 if (sent.value === null) return;
681 // Arm after send so preference reads and native Activity startup do not delay tap-frame feedback.
682 armAgentAwarenessLiveActivityForLocalWork({
683 environmentId: props.environmentId,
684 threadTitle: props.selectedThread.title,
685 projectTitle: props.environmentLabel ?? "T3 Code",
686 });
687 };
688
689 const lockedProviderInstanceId = props.canSwitchProvider
690 ? undefined
691 : currentModelSelection.instanceId;
692 const modelOptions = buildModelOptions(
693 props.serverConfig,
694 currentModelSelection,
695 lockedProviderInstanceId,
696 props.selectedThread.projectId,
697 );
698 const currentModelOption =
699 modelOptions.find(
700 (option) =>
701 option.selection.instanceId === currentModelSelection.instanceId &&
702 option.selection.model === currentModelSelection.model,
703 ) ?? null;
704 const openSettings = () => {
705 settingsSheetPresentation.open();
706 };
707
708 useFocusEffect(() => {
709 if (!settingsRoutePresentedRef.current) {
710 return;
711 }
712
713 settingsRoutePresentedRef.current = false;
714 settingsSheetPresentation.onDismissed();
715 });
716
717 useEffect(
718 () =>
719 // The native-stack patch exposes UIKit dismissal completion; restore the keyboard then.
720 (navigation as unknown as NavigationWithFinishTransitioning).addListener(
721 "finishTransitioning",
722 settingsSheetPresentation.onStackTransitionsFinished,
723 ),
724 [navigation, settingsSheetPresentation.onStackTransitionsFinished],
725 );
726
727 // Removable attachments: inside the card, or above the focused one-row composer.
728 const editingAttachments = hasEditingAttachments ? (
729 <>
730 {queuedEdit !== null && queuedEdit.existingAttachments.length > 0 ? (
731 <Animated.View
732 className="px-[14px] pb-2.5 pt-2"
733 entering={COMPOSER_ATTACHMENT_ENTERING}
734 exiting={FadeOut.duration(120)}
735 >
736 <ComposerQueuedEditAttachments
737 environmentId={props.environmentId}
738 attachments={queuedEdit.existingAttachments}
739 disabled={isSubmissionLocked}
740 onRemove={queuedEdit.onRemoveExistingAttachment}
741 />
742 </Animated.View>
743 ) : null}
744 {stripAttachments.length > 0 ? (
745 <Animated.View
746 className="px-[14px] pb-2.5 pt-2"
747 entering={COMPOSER_ATTACHMENT_ENTERING}
748 exiting={FadeOut.duration(120)}
749 >
750 <ComposerAttachmentStrip
751 environmentId={props.environmentId}
752 attachments={stripAttachments}
753 onRemove={isSubmissionLocked ? () => undefined : props.onRemoveDraftImage}
754 onPressPreview={isSubmissionLocked ? undefined : onPressPreview}
755 onPressVideo={isSubmissionLocked ? undefined : onPressVideo}
756 onPressDocument={
757 isSubmissionLocked
758 ? undefined
759 : (attachment) =>
760 openDraftDocument({
761 attachmentId: attachment.id,
762 name: attachment.name,
763 mimeType: attachment.mimeType,
764 sizeBytes: attachment.sizeBytes,
765 })
766 }
767 />
768 </Animated.View>
769 ) : null}
770 </>
771 ) : null;
772
773 const modelControl = (
774 <View className="min-w-0 shrink">
775 <ComposerModelControl
776 size={usesLargeControls ? "large" : "regular"}
777 modelOption={currentModelOption}
778 selection={currentModelSelection}
779 provider={selectedProviderStatus?.driver}
780 reportedSelection={props.reportedModelSelection}
781 prompt={draftMessage}
782 surfaceColor={composerPanel}
783 iconOnly={!compactEditor.isExpanded}
784 onPress={openSettings}
785 />
786 </View>
787 );
788
789 return (
790 <Animated.View
791 onLayout={(event) => props.onHeightChange?.(event.nativeEvent.layout.height)}
792 className="px-[12px]"
793 style={{
794 paddingTop: 6,
795 paddingBottom: (props.bottomInset ?? 0) + THREAD_COMPOSER_BOTTOM_GUTTER,
796 backgroundColor:
797 Platform.OS === "android" ? themeColorWithAlpha(composerPanel, 1) : undefined,
798 }}
799 >
800 {/* Use a plain View: Reanimated Animated.View drops experimental_backgroundImage on Android. */}
801 <View
802 className={
803 Platform.OS === "android"
804 ? "hidden"
805 : "absolute inset-0 bg-linear-to-b from-screen/0 via-screen/60 to-screen/90"
806 }
807 pointerEvents="none"
808 />
809 <Animated.View
810 className="relative w-full self-center"
811 style={{ maxWidth: props.contentMaxWidth }}
812 >
813 {props.draftControls}
814 {!isSubmissionLocked &&
815 composerMenu.trigger &&
816 (composerMenu.items.length > 0 || composerMenu.trigger.kind === "pull-request") ? (
817 <ComposerPopoverAnchor>
818 <ComposerCommandPopover
819 items={composerMenu.items}
820 triggerKind={composerMenu.trigger.kind}
821 isLoading={composerMenu.isLoading}
822 error={composerMenu.error}
823 onSelect={composerMenu.onSelect}
824 />
825 </ComposerPopoverAnchor>
826 ) : null}
827
828 {selectedProviderStatus?.compatibilityAdvisory?.message &&
829 (selectedProviderStatus.compatibilityAdvisory.status === "unsupported" ||
830 selectedProviderStatus.compatibilityAdvisory.status === "broken") ? (
831 <Text
832 accessibilityRole={
833 selectedProviderStatus.compatibilityAdvisory.status === "broken" ? "alert" : undefined
834 }
835 accessibilityLiveRegion={
836 selectedProviderStatus.compatibilityAdvisory.status === "broken"
837 ? "assertive"
838 : "polite"
839 }
840 className={
841 selectedProviderStatus.compatibilityAdvisory.status === "broken"
842 ? "bg-danger px-3 py-2 text-xs text-danger-foreground"
843 : "px-3 py-2 text-xs text-foreground"
844 }
845 >
846 {selectedProviderStatus.compatibilityAdvisory.message}
847 </Text>
848 ) : null}
849 {modelUnavailable ? (
850 <Button
851 label="Model unavailable. Open model settings."
852 tone="text"
853 onPress={openSettings}
854 />
855 ) : null}
856
857 <ComposerSurface
858 animateLayout={false}
859 style={{
860 borderRadius: usesLargeControls ? 31 : 27,
861 borderCurve: "circular",
862 overflow: "hidden",
863 paddingVertical: usesLargeControls ? 9 : floatingSidebarComposer ? 6 : 2,
864 }}
865 >
866 {isExpanded ? editingAttachments : null}
867 <View
868 onLayout={(event) => {
869 compactEditor.onRowLayout(event);
870 setCompactRowWidth(event.nativeEvent.layout.width);
871 }}
872 >
873 <ComposerDictationDraftContent
874 className="flex-row items-end"
875 compact
876 hidden={showsCompactDictation}
877 >
878 <ComposerAttachmentButton
879 size={usesLargeControls ? "large" : "regular"}
880 disabled={isSubmissionLocked}
881 supportsFiles={Boolean(
882 props.serverConfig?.environment.capabilities.fileAttachments,
883 )}
884 onPickMedia={props.onPickDraftMedia}
885 onPickFiles={props.onPickDraftFiles}
886 />
887 <Animated.View
888 className="min-w-0 flex-1"
889 onLayout={compactEditor.onEditorLayout}
890 style={[
891 {
892 minWidth:
893 compactEditor.isExpanded || stripAttachments.length > 0
894 ? 0
895 : INLINE_EDITOR_MIN_WIDTH,
896 },
897 compactEditor.containerStyle,
898 compactEditor.isExpanded ? { flex: 0, width: 0 } : undefined,
899 ]}
900 ></Animated.View>
901 {!isExpanded && stripAttachments.length > 0 ? (
902 <View className="h-[44px] shrink-0 flex-row items-center gap-1 pl-1">
903 {stripAttachments.slice(0, compactAttachmentLimit).map((attachment) => (
904 <ComposerAttachmentThumbnail
905 environmentId={props.environmentId}
906 key={attachment.id}
907 attachment={attachment}
908 size={30}
909 borderRadius={8}
910 compact
911 onPressPreview={isSubmissionLocked ? undefined : onPressPreview}
912 onPressVideo={isSubmissionLocked ? undefined : onPressVideo}
913 />
914 ))}
915 {stripAttachments.length > compactAttachmentLimit ? (
916 <View className="size-[30px] items-center justify-center rounded-lg bg-subtle-strong">
917 <Text className="text-foreground-muted text-2xs font-t3-bold">
918 +{stripAttachments.length - compactAttachmentLimit}
919 </Text>
920 </View>
921 ) : null}
922 </View>
923 ) : null}
924 <View
925 className="min-w-0 shrink flex-row items-center"
926 style={
927 compactEditor.isExpanded ? { flex: 1, justifyContent: "flex-end" } : undefined
928 }
929 >
930 {modelControl}
931 <ComposerDictationStartAction
932 size={usesLargeControls ? "large" : "regular"}
933 state={voiceInput.state}
934 isAvailable={voiceInput.isAvailable}
935 disabled={isSubmissionLocked}
936 onStart={voiceInput.start}
937 onCancel={voiceInput.cancel}
938 />
939 {showStopAction ? (
940 <ComposerActionButton
941 size={usesLargeControls ? "large" : "regular"}
942 accessibilityLabel="Stop agent"
943 icon="stop.fill"
944 variant="danger"
945 disabled={!props.canOperateThread}
946 onPress={props.onStopThread}
947 />
948 ) : showResumeAction ? (
949 <ComposerActionButton
950 size={usesLargeControls ? "large" : "regular"}
951 accessibilityLabel="Resume queue"
952 icon="play"
953 disabled={!props.canOperateThread || resumingQueue}
954 onPress={() => void handleResumeQueue()}
955 />
956 ) : (
957 <SendActionButton
958 size={usesLargeControls ? "large" : "regular"}
959 accessibilityLabel={sendBlockedReason ?? sendLabel}
960 presentation={sendPresentation}
961 disabled={!canSend}
962 onSend={handleSend}
963 />
964 )}
965 </View>
966 </ComposerDictationDraftContent>
967 <Animated.View
968 style={[
969 compactEditor.editorStyle,
970 showsCompactDictation ? { display: "none" } : undefined,
971 ]}
972 >
973 <ComposerEditor
974 hidden={props.hidden}
975 draftKey={composerDraftKey}
976 environmentId={props.environmentId}
977 onOpenMention={(path) => {
978 Keyboard.dismiss();
979 if (props.isDraft) {
980 navigation.navigate("NewTaskFile", {
981 environmentId: String(props.environmentId),
982 cwd: props.projectCwd ?? undefined,
983 path: fileRoutePathSegments(path),
984 });
985 } else {
986 navigation.navigate("ThreadFile", {
987 environmentId: String(props.environmentId),
988 threadId: String(props.selectedThread.id),
989 path: fileRoutePathSegments(path),
990 });
991 }
992 }}
993 onOpenAttachment={openDraftDocument}
994 chipsInert={!isExpanded}
995 onInertChipPress={() => inputRef.current?.focus()}
996 ref={inputRef}
997 multiline
998 value={draftMessage}
999 // The save uses a draft snapshot; further typing would be discarded on success.
1000 readOnly={isSubmissionLocked}
1001 skills={composerMenu.skills}
1002 selection={composerMenu.selection}
1003 onChangeText={(text) => {
1004 if (!isSubmissionLocked) props.onChangeDraftMessage(text);
1005 }}
1006 onSelectionChange={composerMenu.onSelectionChange}
1007 onPasteImages={(uris) => {
1008 if (isSubmissionLocked) return;
1009 pendingNativeImagePasteCountRef.current += 1;
1010 void props.onNativePasteImages(uris).finally(() => {
1011 pendingNativeImagePasteCountRef.current -= 1;
1012 });
1013 }}
1014 onPasteText={(paste) => {
1015 if (isSubmissionLocked) return;
1016 const insertPaste = () => {
1017 const insertion = replaceTextSelection({
1018 value: paste.value,
1019 selection: paste.selection,
1020 text: paste.text,
1021 });
1022 const selection = { start: insertion.cursor, end: insertion.cursor };
1023 props.onChangeDraftMessage(insertion.value);
1024 composerMenu.onSelectionChange(selection);
1025 };
1026 const capabilities = props.serverConfig?.environment.capabilities;
1027 const advertisedMax =
1028 capabilities?.attachmentUploads === true
1029 ? capabilities.fileAttachments?.maxUploadBytes
1030 : undefined;
1031 const maxBytes =
1032 advertisedMax === undefined
1033 ? null
1034 : clampFileAttachmentUploadBytes(advertisedMax);
1035 const wouldExceedInputLimit =
1036 paste.value.length -
1037 Math.max(0, paste.selection.end - paste.selection.start) +
1038 paste.text.length >
1039 PROVIDER_SEND_TURN_MAX_INPUT_CHARS;
1040 const canAttach =
1041 maxBytes !== null &&
1042 countComposerDraftAttachmentsAfterSelection(composerDraftKey, {
1043 text: paste.value,
1044 ...paste.selection,
1045 }) < PROVIDER_SEND_TURN_MAX_ATTACHMENTS &&
1046 new TextEncoder().encode(paste.text).byteLength <= maxBytes;
1047 if (
1048 pastedTextDisposition({
1049 text: paste.text,
1050 wouldExceedInputLimit,
1051 canAttach: true,
1052 }) === "attachment"
1053 ) {
1054 if (canAttach) {
1055 pendingPastedTextAttachmentCountRef.current += 1;
1056 setPendingPastedTextAttachmentCount(
1057 pendingPastedTextAttachmentCountRef.current,
1058 );
1059 const finishAttachment = () => {
1060 pendingPastedTextAttachmentCountRef.current = Math.max(
1061 0,
1062 pendingPastedTextAttachmentCountRef.current - 1,
1063 );
1064 setPendingPastedTextAttachmentCount(
1065 pendingPastedTextAttachmentCountRef.current,
1066 );
1067 };
1068 void props.onNativePasteText(paste).then(finishAttachment, finishAttachment);
1069 } else if (!wouldExceedInputLimit) {
1070 insertPaste();
1071 } else {
1072 Dialog.alert(
1073 wouldExceedInputLimit
1074 ? "Pasted text is too large for this message"
1075 : "Could not attach pasted text",
1076 wouldExceedInputLimit
1077 ? "Remove some text or an attachment, then paste again."
1078 : "Remove an attachment or use a smaller paste, then try again.",
1079 );
1080 }
1081 return;
1082 }
1083 insertPaste();
1084 }}
1085 placeholder={props.placeholder}
1086 onFocus={handleFocus}
1087 onBlur={handleBlur}
1088 onSubmit={(alternate) =>
1089 void handleSend(
1090 alternate && sendPresentation.alternate !== null
1091 ? sendPresentation.alternate
1092 : undefined,
1093 )
1094 }
1095 submitTitle={sendPresentation.label}
1096 alternateSubmitTitle={
1097 sendPresentation.alternate === null
1098 ? sendPresentation.label
1099 : FOLLOW_UP_ACTION_LABEL[sendPresentation.alternate]
1100 }
1101 {...compactEditor.editorProps}
1102 textStyle={{
1103 ...bodyText,
1104 color: foregroundColor,
1105 }}
1106 />
1107 </Animated.View>
1108 </View>
1109 <Animated.View
1110 accessibilityElementsHidden={!isToolbarVisible}
1111 collapsable={false}
1112 importantForAccessibility={isToolbarVisible ? "auto" : "no-hide-descendants"}
1113 pointerEvents={isToolbarVisible ? "auto" : "none"}
1114 style={{ position: "absolute", bottom: usesLargeControls ? 9 : 2, left: 0, right: 0 }}
1115 >
1116 <ComposerDictationToolbar
1117 showsDictation={isVoiceInputPresented}
1118 visible={isToolbarVisible}
1119 >
1120 <ComposerToolbarRow
1121 paddingBottom={0}
1122 paddingHorizontal={0}
1123 paddingTop={0}
1124 style={{ gap: 0 }}
1125 >
1126 <ComposerDictationCancelAction
1127 size={usesLargeControls ? "large" : "regular"}
1128 presentation={voicePresentation}
1129 onCancel={voiceInput.cancel}
1130 />
1131 {isVoiceInputPresented ? (
1132 <ComposerDictationStatus
1133 audioLevels={voiceInput.audioLevels}
1134 elapsedSeconds={voiceInput.elapsedSeconds}
1135 phase={voiceInput.state.phase}
1136 presentation={voicePresentation}
1137 onDismissError={voiceInput.cancel}
1138 />
1139 ) : (
1140 <View className="min-w-0 flex-1 flex-row items-center justify-between">
1141 <ComposerAttachmentButton
1142 size={usesLargeControls ? "large" : "regular"}
1143 disabled={isSubmissionLocked}
1144 supportsFiles={Boolean(
1145 props.serverConfig?.environment.capabilities.fileAttachments,
1146 )}
1147 onPickMedia={props.onPickDraftMedia}
1148 onPickFiles={props.onPickDraftFiles}
1149 />
1150 {modelControl}
1151 </View>
1152 )}
1153 <View className="shrink-0 flex-row items-center">
1154 <ComposerDictationPrimaryAction
1155 size={usesLargeControls ? "large" : "regular"}
1156 state={voiceInput.state}
1157 presentation={voicePresentation}
1158 isAvailable={voiceInput.isAvailable}
1159 disabled={isSubmissionLocked}
1160 onStart={voiceInput.start}
1161 onConfirm={voiceInput.stop}
1162 onCancel={voiceInput.cancel}
1163 />
1164 {showStopAction ? (
1165 <ComposerActionButton
1166 accessibilityLabel="Stop agent"
1167 icon="stop.fill"
1168 variant="danger"
1169 disabled={!props.canOperateThread}
1170 onPress={props.onStopThread}
1171 />
1172 ) : showResumeAction && voicePresentation.showsSend ? (
1173 <ComposerActionButton
1174 accessibilityLabel="Resume queue"
1175 icon="play"
1176 disabled={!props.canOperateThread || resumingQueue}
1177 onPress={() => void handleResumeQueue()}
1178 />
1179 ) : voicePresentation.showsSend ? (
1180 <SendActionButton
1181 accessibilityLabel={sendBlockedReason ?? sendLabel}
1182 presentation={sendPresentation}
1183 disabled={!canSend}
1184 onSend={handleSend}
1185 />
1186 ) : null}
1187 </View>
1188 </ComposerToolbarRow>
1189 </ComposerDictationToolbar>
1190 </Animated.View>
1191 </ComposerSurface>
1192
1193 {props.connectionState === "connected" && !props.canOperateThread ? (
1194 <Text className="pt-2 text-xs text-foreground-muted">
1195 This connection cannot control this task. You can still edit your draft.
1196 </Text>
1197 ) : null}
1198 </Animated.View>
1199
1200 <VideoPreviewModal source={previewVideo} onRequestClose={closePreview} />
1201 <FilePreviewModal source={previewFile} onRequestClose={closePreview} />
1202 </Animated.View>
1203 );
1204};