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