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