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

ThreadComposer.tsx

1,231 lines49.5 KB

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