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

ThreadComposer.tsx

1,215 lines49.6 KB

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