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

ThreadComposer.tsx

1,215 lines49.4 KB

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