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

ThreadComposer.tsx

1,193 lines48.5 KB

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