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