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

NewTaskDraftScreen.tsx

705 lines24.7 KB

1import { NativeStackScreenOptions } from "../../native/StackHeader";
2import { StackActions, useNavigation } from "@react-navigation/native";
3import { useCallback, useEffect, useMemo, useRef } from "react";
4import { Alert, InteractionManager, View, useColorScheme } from "react-native";
5import { KeyboardAvoidingView, useKeyboardState } from "react-native-keyboard-controller";
6import { useSafeAreaInsets } from "react-native-safe-area-context";
7import { useThemeColor } from "../../lib/useThemeColor";
8​
9import { EnvironmentId } from "@t3tools/contracts";
10import {
11 isAtomCommandInterrupted,
12 squashAtomCommandFailure,
13} from "@t3tools/client-runtime/state/runtime";
14​
15import { ComposerEditor, type ComposerEditorHandle } from "../../components/ComposerEditor";
16import {
17 ComposerToolbarButton,
18 ComposerToolbarRow,
19 ComposerToolbarScroller,
20 ComposerToolbarTrigger,
21} from "../../components/ComposerToolbarTrigger";
22import { ComposerAttachmentStrip } from "../../components/ComposerAttachmentStrip";
23import { ControlPillMenu } from "../../components/ControlPill";
24import { ProviderIcon } from "../../components/ProviderIcon";
25​
26import { makeTurnCommandMetadata } from "../../lib/commandMetadata";
27import { convertPastedImagesToAttachments, pickComposerImages } from "../../lib/composerImages";
28import {
29 applyProviderOptionMenuEvent,
30 buildProviderOptionMenuActions,
31 providerOptionsConfigurationLabel,
32 resolveProviderOptionDescriptors,
33} from "../../lib/providerOptions";
34import { useScaledTextRole } from "../settings/appearance/useScaledTextRole";
35import { getComposerDraftSnapshot } from "../../state/use-composer-drafts";
36import { useProjects } from "../../state/entities";
37import { enqueueThreadOutboxMessage, removeThreadOutboxMessage } from "../../state/thread-outbox";
38import { useRemoteConnectionStatus } from "../../state/use-remote-environment-registry";
39import { branchBadgeLabel, useNewTaskFlow } from "./new-task-flow-provider";
40import { useCreateProjectThread } from "./use-project-actions";
41​
42function formatWorkspaceLabel(input: {
43 readonly workspaceMode: string;
44 readonly currentBranchName: string | null;
45 readonly selectedBranchName: string | null;
46}): string {
47 const branchName = input.selectedBranchName ?? input.currentBranchName;
48 if (input.workspaceMode === "worktree") {
49 return branchName ? `New worktree · ${branchName}` : "New worktree";
50 }
51 return branchName ? `Current · ${branchName}` : "Current checkout";
53​
54export function NewTaskDraftScreen(props: {
55 readonly initialProjectRef?: {
56 readonly environmentId?: string;
57 readonly projectId?: string;
58 };
59 /** Queued outbox message id when editing an existing pending task. */
60 readonly pendingTaskId?: string;
61}) {
62 const projects = useProjects();
63 const createProjectThread = useCreateProjectThread();
64 const flow = useNewTaskFlow();
65 const navigation = useNavigation();
66 const insets = useSafeAreaInsets();
67 const colorScheme = useColorScheme();
68 const isKeyboardVisible = useKeyboardState((state) => state.isVisible);
69 const controlsBottomPadding = isKeyboardVisible ? 8 : Math.max(insets.bottom, 10);
70 const { logicalProjects, selectedProject, setProject } = flow;
71 const { connectedEnvironments } = useRemoteConnectionStatus();
72 const environmentConnected =
73 selectedProject !== null &&
74 connectedEnvironments.find(
75 (environment) => environment.environmentId === selectedProject.environmentId,
76 )?.connectionState === "connected";
77 const promptInputRef = useRef<ComposerEditorHandle>(null);
78 const loadedBranchesProjectKeyRef = useRef<string | null>(null);
79 const appliedInitialProjectKeyRef = useRef<string | null>(null);
80 useEffect(() => {
81 return () => {
82 appliedInitialProjectKeyRef.current = null;
83 };
84 }, []);
85​
86 const { beginEditingPendingTask, cancelEditingPendingTask, editingPendingTask } = flow;
87 const attemptedPendingTaskIdRef = useRef<string | null>(null);
88 useEffect(() => {
89 if (!props.pendingTaskId || editingPendingTask?.messageId === props.pendingTaskId) {
90 return;
91 }
92 // Attempt each pending task once: after it is delivered or deleted the
93 // editing session legitimately ends, and re-running must not navigate.
94 if (attemptedPendingTaskIdRef.current === props.pendingTaskId) {
95 return;
96 }
97 attemptedPendingTaskIdRef.current = props.pendingTaskId;
98 if (!beginEditingPendingTask(props.pendingTaskId)) {
99 // The queued task no longer exists (sent or deleted before opening).
100 navigation.dispatch(StackActions.replace("NewTask"));
101 }
102 }, [beginEditingPendingTask, editingPendingTask?.messageId, navigation, props.pendingTaskId]);
103​
104 useEffect(() => {
105 if (!props.pendingTaskId) return;
106 return () => {
107 // Allow a later navigation for the same pending task to re-hydrate it.
108 attemptedPendingTaskIdRef.current = null;
109 cancelEditingPendingTask();
110 };
111 }, [props.pendingTaskId, cancelEditingPendingTask]);
112​
113 const borderColor = useThemeColor("--color-border");
114 const headlineText = useScaledTextRole("headline");
115 const sheetFadeOpaque = colorScheme === "dark" ? "rgba(14,14,14,0.98)" : "rgba(242,242,247,0.98)";
116 const sheetFadeTransparent = colorScheme === "dark" ? "rgba(14,14,14,0)" : "rgba(242,242,247,0)";
117​
118 // A new navigation to this mounted screen delivers a fresh initialProjectRef
119 // reference — treat it as a new request and let it apply again.
120 const lastInitialProjectRefRef = useRef(props.initialProjectRef);
121​
122 useEffect(() => {
123 // Pending-task editing owns project selection (and must not fall through
124 // to the replace("NewTask") fallback while its hydration is in flight).
125 if (props.pendingTaskId) {
126 return;
127 }
128 if (lastInitialProjectRefRef.current !== props.initialProjectRef) {
129 lastInitialProjectRefRef.current = props.initialProjectRef;
130 appliedInitialProjectKeyRef.current = null;
131 }
132 const initialEnvironmentId = props.initialProjectRef?.environmentId;
133 const initialProjectId = props.initialProjectRef?.projectId;
134 if (initialEnvironmentId && initialProjectId) {
135 const directProject =
136 projects.find(
137 (project) =>
138 project.environmentId === initialEnvironmentId && project.id === initialProjectId,
139 ) ?? null;
140​
141 if (directProject) {
142 // Apply the route's project once. Re-applying on every change would
143 // instantly revert environment/project switches made in the picker.
144 const directProjectKey = `${directProject.environmentId}:${directProject.id}`;
145 if (appliedInitialProjectKeyRef.current === directProjectKey) {
146 return;
147 }
148 appliedInitialProjectKeyRef.current = directProjectKey;
149 if (
150 selectedProject?.environmentId === directProject.environmentId &&
151 selectedProject.id === directProject.id
152 ) {
153 return;
154 }
155 setProject(directProject);
156 return;
157 }
158 }
159​
160 if (selectedProject) {
161 return;
162 }
163​
164 if (logicalProjects.length === 1) {
165 setProject(logicalProjects[0]!.project);
166 return;
167 }
168​
169 navigation.dispatch(StackActions.replace("NewTask"));
170 }, [
171 logicalProjects,
172 projects,
173 props.initialProjectRef,
174 props.pendingTaskId,
175 navigation,
176 selectedProject,
177 setProject,
178 ]);
179​
180 useEffect(() => {
181 if (!selectedProject) {
182 loadedBranchesProjectKeyRef.current = null;
183 return;
184 }
185 const projectKey = `${selectedProject.environmentId}:${selectedProject.id}`;
186 if (loadedBranchesProjectKeyRef.current === projectKey) {
187 return;
188 }
189 loadedBranchesProjectKeyRef.current = projectKey;
190 void flow.loadBranches();
191 }, [flow.loadBranches, selectedProject]);
192​
193 useEffect(() => {
194 if (!selectedProject) {
195 return;
196 }
197​
198 let focusFrame: ReturnType<typeof requestAnimationFrame> | null = null;
199 const interaction = InteractionManager.runAfterInteractions(() => {
200 focusFrame = requestAnimationFrame(() => promptInputRef.current?.focus());
201 });
202​
203 return () => {
204 interaction.cancel();
205 if (focusFrame !== null) {
206 cancelAnimationFrame(focusFrame);
207 }
208 };
209 }, [selectedProject]);
210​
211 const environmentMenuActions = useMemo(
212 () =>
213 flow.environments.map((environment) => ({
214 id: `environment:${environment.environmentId}`,
215 title: environment.environmentLabel,
216 state:
217 flow.selectedEnvironmentId === environment.environmentId ? ("on" as const) : undefined,
218 })),
219 [flow.environments, flow.selectedEnvironmentId],
220 );
221​
222 const modelMenuActions = useMemo(
223 () =>
224 flow.providerGroups.map((group) => ({
225 id: `provider:${group.providerKey}`,
226 title: group.providerLabel,
227 subtitle: group.models.find(
228 (model) =>
229 flow.selectedModel &&
230 model.selection.instanceId === flow.selectedModel.instanceId &&
231 model.selection.model === flow.selectedModel.model,
232 )?.label,
233 subactions: group.models.map((option) => ({
234 id: `model:${option.key}`,
235 title: option.label,
236 state:
237 flow.selectedModel &&
238 option.selection.instanceId === flow.selectedModel.instanceId &&
239 option.selection.model === flow.selectedModel.model
240 ? ("on" as const)
241 : undefined,
242 })),
243 })),
244 [flow.providerGroups, flow.selectedModel],
245 );
246 const providerOptionDescriptors = useMemo(
247 () =>
248 resolveProviderOptionDescriptors({
249 capabilities: flow.selectedModelOption?.capabilities,
250 selections: flow.selectedModel?.options,
251 }),
252 [flow.selectedModel?.options, flow.selectedModelOption?.capabilities],
253 );
254​
255 const optionsMenuActions = useMemo(
256 () => [
257 ...buildProviderOptionMenuActions(providerOptionDescriptors),
258 {
259 id: "options-runtime",
260 title: "Runtime",
261 subtitle:
262 flow.runtimeMode === "approval-required"
263 ? "Approve actions"
264 : flow.runtimeMode === "auto-accept-edits"
265 ? "Auto-accept edits"
266 : "Full access",
267 subactions: [
268 { id: "options:runtime:approval-required", title: "Approve actions" },
269 { id: "options:runtime:auto-accept-edits", title: "Auto-accept edits" },
270 { id: "options:runtime:full-access", title: "Full access" },
271 ].map((option) => {
272 const value = option.id.replace("options:runtime:", "");
273 return {
274 id: option.id,
275 title: option.title,
276 state: flow.runtimeMode === value ? ("on" as const) : undefined,
277 };
278 }),
279 },
280 {
281 id: "options-interaction",
282 title: "Interaction",
283 subtitle: flow.interactionMode === "plan" ? "Plan" : "Default",
284 subactions: [
285 { id: "options:interaction:default", title: "Default" },
286 { id: "options:interaction:plan", title: "Plan" },
287 ].map((option) => {
288 const value = option.id.replace("options:interaction:", "");
289 return {
290 id: option.id,
291 title: option.title,
292 state: flow.interactionMode === value ? ("on" as const) : undefined,
293 };
294 }),
295 },
296 ],
297 [flow.interactionMode, flow.runtimeMode, providerOptionDescriptors],
298 );
299​
300 const workspaceMenuActions = useMemo(() => {
301 const branchActions =
302 flow.availableBranches.length === 0
303 ? [
304 {
305 id: "workspace:branch:none",
306 title: flow.branchesLoading ? "Loading branches…" : "No branches available",
307 attributes: { disabled: true },
308 },
309 ]
310 : flow.availableBranches.slice(0, 12).map((branch) => {
311 const badge = branchBadgeLabel({
312 branch,
313 project: flow.selectedProject,
314 });
315​
316 return {
317 id: `workspace:branch:${branch.name}`,
318 title: branch.name,
319 subtitle: badge ? badge.toUpperCase() : undefined,
320 state: flow.selectedBranchName === branch.name ? ("on" as const) : undefined,
321 };
322 });
323​
324 return [
325 {
326 id: "workspace:mode",
327 title: "Mode",
328 subtitle: flow.workspaceMode === "local" ? "Current checkout" : "New worktree",
329 subactions: (["local", "worktree"] as const).map((value) => ({
330 id: `workspace:mode:${value}`,
331 title: value === "local" ? "Current checkout" : "New worktree",
332 state: flow.workspaceMode === value ? ("on" as const) : undefined,
333 })),
334 },
335 {
336 id: "workspace:branch",
337 title: "Branch",
338 subtitle: flow.selectedBranchName ?? "Choose branch",
339 subactions: branchActions,
340 },
341 ...(flow.workspaceMode === "worktree"
342 ? [
343 {
344 id: "workspace:start-from-origin",
345 title: "Start from origin",
346 subtitle: "Base the worktree on the latest origin branch",
347 image: "arrow.triangle.pull",
348 state: flow.startFromOrigin ? ("on" as const) : undefined,
349 },
350 ]
351 : []),
352 ];
353 }, [
354 flow.availableBranches,
355 flow.branchesLoading,
356 flow.selectedBranchName,
357 flow.selectedProject,
358 flow.startFromOrigin,
359 flow.workspaceMode,
360 ]);
361​
362 const selectedEnvironmentLabel =
363 flow.environments.find(
364 (environment) => environment.environmentId === flow.selectedEnvironmentId,
365 )?.environmentLabel ?? "Environment";
366 const currentBranchName =
367 flow.availableBranches.find((branch) => branch.current)?.name ??
368 flow.availableBranches.find((branch) => branch.isDefault)?.name ??
369 null;
370 const configurationLabel = useMemo(
371 () => providerOptionsConfigurationLabel(providerOptionDescriptors),
372 [providerOptionDescriptors],
373 );
374 const workspaceLabel = useMemo(
375 () =>
376 formatWorkspaceLabel({
377 currentBranchName,
378 selectedBranchName: flow.selectedBranchName,
379 workspaceMode: flow.workspaceMode,
380 }),
381 [currentBranchName, flow.selectedBranchName, flow.workspaceMode],
382 );
383 function handleModelMenuAction(event: string) {
384 if (!event.startsWith("model:")) {
385 return;
386 }
387 flow.setSelectedModelKey(event.slice("model:".length));
388 }
389​
390 function handleEnvironmentMenuAction(event: string) {
391 if (!event.startsWith("environment:")) {
392 return;
393 }
394 flow.selectEnvironment(EnvironmentId.make(event.slice("environment:".length)));
395 }
396​
397 function handleOptionsMenuAction(event: string) {
398 const providerOptions = applyProviderOptionMenuEvent(providerOptionDescriptors, event);
399 if (providerOptions) {
400 flow.setSelectedModelOptions(providerOptions);
401 return;
402 }
403 if (event.startsWith("options:runtime:")) {
404 flow.setRuntimeMode(
405 event.slice("options:runtime:".length) as Parameters<typeof flow.setRuntimeMode>[0],
406 );
407 return;
408 }
409 if (event.startsWith("options:interaction:")) {
410 flow.setInteractionMode(
411 event.slice("options:interaction:".length) as Parameters<typeof flow.setInteractionMode>[0],
412 );
413 }
414 }
415​
416 function handleWorkspaceMenuAction(event: string) {
417 if (event.startsWith("workspace:mode:")) {
418 flow.setWorkspaceMode(
419 event.slice("workspace:mode:".length) as Parameters<typeof flow.setWorkspaceMode>[0],
420 );
421 return;
422 }
423 if (event === "workspace:start-from-origin") {
424 flow.setStartFromOrigin(!flow.startFromOrigin);
425 return;
426 }
427 if (event.startsWith("workspace:branch:")) {
428 const branchName = event.slice("workspace:branch:".length);
429 const branch = flow.availableBranches.find((candidate) => candidate.name === branchName);
430 if (branch) {
431 flow.selectBranch(branch);
432 }
433 }
434 }
435​
436 async function handlePickImages(): Promise<void> {
437 const result = await pickComposerImages({ existingCount: flow.attachments.length });
438 if (result.images.length > 0) {
439 flow.appendAttachments(result.images);
440 }
441 }
442​
443 const handleNativePasteImages = useCallback(
444 async (uris: ReadonlyArray<string>) => {
445 try {
446 const images = await convertPastedImagesToAttachments({
447 uris,
448 existingCount: flow.attachments.length,
449 });
450 if (images.length > 0) {
451 flow.appendAttachments(images);
452 }
453 } catch (error) {
454 console.error("[native paste] error converting images", error);
455 }
456 },
457 [flow],
458 );
459​
460 async function handleStart(): Promise<void> {
461 const selectedProject = flow.selectedProject;
462 const draftKey = flow.draftKey;
463 if (!selectedProject || !draftKey) {
464 return;
465 }
466 const draft = getComposerDraftSnapshot(draftKey);
467 const modelSelection = draft.modelSelection ?? flow.selectedModel;
468 const workspaceMode = draft.workspaceSelection?.mode ?? flow.workspaceMode;
469 const selectedBranchName = draft.workspaceSelection?.branch ?? flow.selectedBranchName;
470 const selectedWorktreePath =
471 draft.workspaceSelection?.worktreePath ?? flow.selectedWorktreePath;
472 const startFromOrigin = draft.workspaceSelection?.startFromOrigin ?? flow.startFromOrigin;
473 const runtimeMode = draft.runtimeMode ?? flow.runtimeMode;
474 const interactionMode = draft.interactionMode ?? flow.interactionMode;
475 const initialMessageText = draft.text.trim();
476​
477 if (
478 !modelSelection ||
479 initialMessageText.length === 0 ||
480 flow.submitting ||
481 (workspaceMode === "worktree" && !selectedBranchName)
482 ) {
483 return;
484 }
485​
486 const editingPendingTask = flow.editingPendingTask;
487​
488 if (!environmentConnected) {
489 // Offline: park the task in the outbox; the drain sends it when the
490 // environment reconnects. Editing an existing pending task re-queues it
491 // under its original identifiers.
492 const metadata = editingPendingTask
493 ? {
494 threadId: editingPendingTask.threadId,
495 commandId: editingPendingTask.commandId,
496 messageId: editingPendingTask.messageId,
497 createdAt: editingPendingTask.createdAt,
498 }
499 : makeTurnCommandMetadata();
500 const message = flow.buildPendingTaskMessage(metadata);
501 if (!message) {
502 return;
503 }
504 flow.setSubmitting(true);
505 try {
506 await enqueueThreadOutboxMessage(message);
507 } catch (error) {
508 Alert.alert(
509 "Could not queue task",
510 error instanceof Error ? error.message : "The task could not be saved to the outbox.",
511 );
512 return;
513 } finally {
514 flow.setSubmitting(false);
515 }
516 if (editingPendingTask) {
517 flow.finishEditingPendingTask();
518 } else {
519 flow.setPrompt("");
520 flow.clearAttachments();
521 }
522 navigation.getParent()?.goBack();
523 return;
524 }
525​
526 flow.setSubmitting(true);
527 const result = await createProjectThread({
528 project: selectedProject,
529 modelSelection,
530 envMode: workspaceMode,
531 branch: selectedBranchName,
532 worktreePath: workspaceMode === "worktree" ? null : selectedWorktreePath,
533 startFromOrigin,
534 runtimeMode,
535 interactionMode,
536 initialMessageText,
537 initialAttachments: draft.attachments,
538 ...(editingPendingTask
539 ? {
540 turnMetadata: {
541 threadId: editingPendingTask.threadId,
542 commandId: editingPendingTask.commandId,
543 messageId: editingPendingTask.messageId,
544 createdAt: editingPendingTask.createdAt,
545 },
546 }
547 : {}),
548 });
549 flow.setSubmitting(false);
550​
551 if (result._tag === "Failure") {
552 if (!isAtomCommandInterrupted(result)) {
553 const error = squashAtomCommandFailure(result);
554 Alert.alert(
555 "Could not start task",
556 error instanceof Error ? error.message : "The task could not be started.",
557 );
558 }
559 return;
560 }
561​
562 if (editingPendingTask) {
563 try {
564 await removeThreadOutboxMessage(editingPendingTask);
565 } catch (error) {
566 console.warn("[new-task] failed to remove delivered pending task", error);
567 }
568 flow.finishEditingPendingTask();
569 } else {
570 flow.setPrompt("");
571 flow.clearAttachments();
572 }
573 navigation.dispatch(
574 StackActions.replace("Thread", {
575 environmentId: String(result.value.environmentId),
576 threadId: String(result.value.threadId),
577 }),
578 );
579 }
580​
581 if (!selectedProject) {
582 return (
583 <View className="flex-1 bg-sheet">
584 <NativeStackScreenOptions options={{ title: "Loading task" }} />
585 </View>
586 );
587 }
588​
589 return (
590 <View className="flex-1 bg-sheet">
591 <NativeStackScreenOptions options={{ title: selectedProject.title }} />
592​
593 <KeyboardAvoidingView automaticOffset behavior="padding" style={{ flex: 1 }}>
594 <View style={{ flex: 1, minHeight: 0, paddingHorizontal: 20, paddingTop: 8 }}>
595 <ComposerEditor
596 ref={promptInputRef}
597 autoFocus
598 multiline
599 scrollEnabled
600 value={flow.prompt}
601 skills={flow.selectedProviderSkills}
602 onChangeText={flow.setPrompt}
603 onPasteImages={(uris) => void handleNativePasteImages(uris)}
604 placeholder={`Describe a coding task in ${selectedProject.title}`}
605 style={{ flex: 1, minHeight: 0 }}
606 textStyle={headlineText}
607 />
608 </View>
609​
610 <View
611 style={{
612 borderTopWidth: 1,
613 borderTopColor: borderColor,
614 paddingBottom: controlsBottomPadding,
615 }}
616 >
617 {flow.attachments.length > 0 ? (
618 <View style={{ paddingHorizontal: 16, paddingTop: 12 }}>
619 <ComposerAttachmentStrip
620 attachments={flow.attachments}
621 onRemove={flow.removeAttachment}
622 imageSize={88}
623 imageBorderRadius={20}
624 />
625 </View>
626 ) : null}
627 <ComposerToolbarRow paddingBottom={controlsBottomPadding} paddingHorizontal={6}>
628 <ComposerToolbarScroller
629 fadeOpaque={sheetFadeOpaque}
630 fadeTransparent={sheetFadeTransparent}
631 >
632 <ComposerToolbarButton
633 icon="plus"
634 onPress={() => void handlePickImages()}
635 showChevron={false}
636 />
637 <ControlPillMenu
638 actions={modelMenuActions}
639 onPressAction={({ nativeEvent }) => handleModelMenuAction(nativeEvent.event)}
640 >
641 <ComposerToolbarTrigger
642 accessibilityLabel="Model"
643 iconNode={
644 <ProviderIcon provider={flow.selectedModelOption?.providerDriver} size={16} />
645 }
646 label={flow.selectedModelOption?.label ?? "Model"}
647 />
648 </ControlPillMenu>
649 <ControlPillMenu
650 actions={optionsMenuActions}
651 onPressAction={({ nativeEvent }) => handleOptionsMenuAction(nativeEvent.event)}
652 >
653 <ComposerToolbarTrigger
654 accessibilityLabel="Configuration"
655 icon="slider.horizontal.3"
656 label={configurationLabel}
657 />
658 </ControlPillMenu>
659 <ControlPillMenu
660 actions={environmentMenuActions}
661 onPressAction={({ nativeEvent }) => handleEnvironmentMenuAction(nativeEvent.event)}
662 >
663 <ComposerToolbarTrigger
664 accessibilityLabel="Environment"
665 icon="desktopcomputer"
666 label={selectedEnvironmentLabel}
667 />
668 </ControlPillMenu>
669 <ControlPillMenu
670 actions={workspaceMenuActions}
671 onPressAction={({ nativeEvent }) => handleWorkspaceMenuAction(nativeEvent.event)}
672 >
673 <ComposerToolbarTrigger
674 accessibilityLabel="Workspace"
675 icon="point.topleft.down.curvedto.point.bottomright.up"
676 label={workspaceLabel}
677 />
678 </ControlPillMenu>
679 </ComposerToolbarScroller>
680 <ComposerToolbarButton
681 accessibilityLabel={
682 flow.submitting
683 ? "Starting task"
684 : environmentConnected
685 ? "Start task"
686 : "Queue task"
687 }
688 icon={environmentConnected ? "arrow.up" : "tray.and.arrow.up"}
689 onPress={() => void handleStart()}
690 variant="primary"
691 showChevron={false}
692 disabled={
693 !flow.selectedProject ||
694 !flow.selectedModel ||
695 flow.prompt.trim().length === 0 ||
696 flow.submitting ||
697 (flow.workspaceMode === "worktree" && !flow.selectedBranchName)
698 }
699 />
700 </ComposerToolbarRow>
701 </View>
702 </KeyboardAvoidingView>
703 </View>
704 );