Open History to see the last commit
1import { MaterialListRow } from "../../components/MaterialListRow";
2import { SettingsScreen } from "../settings/components/SettingsScreen";
3import { ScreenScrollView as ScrollView } from "../../components/ScreenScrollView";
4import { MaterialButton } from "../../components/MaterialButton";
5import {
6 addProjectRemoteSourceLabel,
7 addProjectRemoteSourcePathHint,
8 addProjectRemoteSourceProvider,
9 buildAddProjectRemoteSourceReadiness,
10 buildProjectCreateCommand,
11 canCreateProjectInEnvironment,
12 findExistingAddProject,
13 getAddProjectInitialQuery,
14 getCloneDestinationBrowsePath,
15 getCloneDestinationPath,
16 getCloneDirectoryName,
17 getDefaultCloneUrl,
18 getNewProjectGitHubRepository,
19 getNewProjectGitHubTarget,
20 getNewProjectPathPreview,
21 normalizePastedCloneUrl,
22 resolveAddProjectPath,
23 sortAddProjectProviderSources,
24 type AddProjectRemoteSource,
25} from "@t3tools/client-runtime/operations/projects";
26import {
27 connectionStatusText,
28 type EnvironmentConnectionPhase,
29} from "@t3tools/client-runtime/connection";
30import {
31 canPreloadBrowsePath,
32 createBrowseNavigationCoordinator,
33 filterFilesystemBrowseEntries,
34 getFilesystemBrowsePath,
35 resolveFilesystemReadAccess,
36} from "@t3tools/client-runtime/state/filesystem";
37import {
38 appendBrowsePathSegment,
39 inferProjectTitleFromPath,
40 isWindowsPlatform,
41} from "@t3tools/client-runtime/state/projects";
42import {
43 AuthOrchestrationOperateScope,
44 AuthSourceControlWriteScope,
45 AuthFilesystemReadScope,
46 CommandId,
47 type EnvironmentId,
48 type EnvironmentMachineKind,
49 ProjectId,
50 resolveEnvironmentMachineKind,
51} from "@t3tools/contracts";
52import { CommonActions, StackActions, useNavigation } from "@react-navigation/native";
53import { SymbolView } from "../../components/AppSymbol";
54import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
55import { Platform, ActivityIndicator, Alert, Pressable, View } from "react-native";
56import { useSafeAreaInsets } from "react-native-safe-area-context";
57import * as Arr from "effect/Array";
58import * as Cause from "effect/Cause";
59import * as Order from "effect/Order";
60import { AsyncResult } from "effect/reactivity";
61import { cn } from "../../lib/cn";
62import { useProjects, useServerConfigs, waitForProject } from "../../state/entities";
63import { filesystemEnvironment } from "../../state/filesystem";
64import { projectEnvironment } from "../../state/projects";
65import { useEnvironmentQuery } from "../../state/query";
66import { environmentSession, useEnvironmentScope, readEnvironmentScope } from "../../state/session";
67import { useEnvironmentPresentation } from "../../state/presentation";
68import { sourceControlEnvironment } from "../../state/sourceControl";
69import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
70import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
71import { ErrorBanner } from "../../components/ErrorBanner";
72import { SourceControlIcon } from "../../components/SourceControlIcon";
73import { ThemedSwitch } from "../../components/ThemedSwitch";
74import { uuidv4 } from "../../lib/uuid";
75import { useAtomCommand } from "../../state/use-atom-command";
76import { useAtomQueryRunner } from "../../state/use-atom-query-runner";
77import {
78 useRemoteConnectionStatus,
79 useRemoteEnvironmentRuntime,
80 useSavedRemoteConnections,
81} from "../../state/use-remote-environment-registry";
82import { resolveAddProjectEnvironment } from "./AddProjectScreen.logic";
83
84interface EnvironmentOption {
85 readonly environmentId: EnvironmentId;
86 readonly label: string;
87 readonly platform: string;
88 readonly machine: EnvironmentMachineKind;
89 readonly baseDirectory: string | null;
90 /** Folder for projects started from just a name; null on servers without it. */
91 readonly newProjectsRoot: string | null;
92 readonly connectionState: EnvironmentConnectionPhase;
93 readonly connectionError: string | null;
94 readonly connectionErrorTraceId: string | null;
95 /** Server runs clones in the background and streams progress; older servers block. */
96 readonly supportsCloneTracking: boolean;
97}
98
99const environmentOptionOrder = Order.mapInput(
100 Order.Struct({
101 label: Order.String,
102 }),
103 (environment: EnvironmentOption) => ({ label: environment.label }),
104);
105
106function platformFromOs(os: string | null | undefined): string {
107 if (os === "windows") return "Win32";
108 if (os === "darwin") return "MacIntel";
109 if (os === "linux") return "Linux";
110 return "";
111}
112
113function errorMessage(error: unknown): string {
114 return error instanceof Error && error.message.trim().length > 0
115 ? error.message
116 : "An error occurred.";
117}
118
119function stringParam(value: string | string[] | undefined): string | null {
120 if (Array.isArray(value)) return value[0] ?? null;
121 return value ?? null;
122}
123
124function sourceFromParam(value: string | string[] | undefined): AddProjectRemoteSource {
125 const source = stringParam(value);
126 if (
127 source === "url" ||
128 source === "github" ||
129 source === "gitlab" ||
130 source === "forgejo" ||
131 source === "bitbucket" ||
132 source === "azure-devops"
133 ) {
134 return source;
135 }
136 return "url";
137}
138
139function SectionTitle(props: { readonly children: string }) {
140 return (
141 <Text
142 className={
143 Platform.OS === "android"
144 ? "px-4 text-sm font-t3-medium text-primary-text"
145 : "px-1 text-2xs font-t3-bold tracking-[0.7px] uppercase text-foreground-muted"
146 }
147 >
148 {props.children}
149 </Text>
150 );
151}
152
153function AddProjectShell(props: { readonly children: ReactNode; readonly title: string }) {
154 const insets = useSafeAreaInsets();
155
156 return (
157 // collapsable={false} is load-bearing: if this wrapper is flattened, the
158 // ScrollView lands directly under RNSSafeAreaView and RNS's formSheet
159 // scroll-view frame correction mistakes this full-height wrapper for a
160 // "header" sibling, coercing the ScrollView to zero height (blank sheet
161 // as soon as the sheet re-lays-out, e.g. when the keyboard opens).
162 <SettingsScreen title={props.title}>
163 <ScrollView
164 keyboardShouldPersistTaps="handled"
165 contentInsetAdjustmentBehavior="automatic"
166 contentContainerStyle={{
167 paddingHorizontal: Platform.OS === "android" ? 16 : 20,
168 paddingTop: 16,
169 paddingBottom: Math.max(insets.bottom, 18) + 18,
170 gap: Platform.OS === "android" ? 16 : 10,
171 }}
172 >
173 {props.children}
174 </ScrollView>
175 </SettingsScreen>
176 );
177}
178
179function ListSection(props: { readonly children: ReactNode }) {
180 return (
181 <View
182 className={
183 Platform.OS === "android"
184 ? "overflow-hidden rounded-[28px] bg-grouped-card"
185 : "overflow-hidden rounded-[24px] bg-grouped-card"
186 }
187 >
188 {props.children}
189 </View>
190 );
191}
192
193function ListRow(props: {
194 readonly title: string;
195 readonly subtitle?: string | null;
196 readonly icon: ReactNode;
197 readonly disabled?: boolean;
198 readonly selected?: boolean;
199 readonly isFirst?: boolean;
200 readonly right?: ReactNode;
201 readonly onPress?: () => void;
202}) {
203 if (Platform.OS === "android") {
204 return (
205 <MaterialListRow
206 className="bg-grouped-card"
207 title={props.title}
208 subtitle={props.subtitle}
209 leading={props.icon}
210 trailing={props.right}
211 disabled={props.disabled}
212 onPress={props.onPress}
213 accessibilityRole={props.selected !== undefined ? "radio" : "button"}
214 accessibilityState={props.selected !== undefined ? { checked: props.selected } : undefined}
215 />
216 );
217 }
218 return (
219 <Pressable
220 disabled={props.disabled}
221 onPress={props.onPress}
222 className={cn(
223 "bg-grouped-card px-3.5 py-2.5 active:opacity-70",
224 !props.isFirst && "border-t border-border-subtle",
225 props.disabled && "opacity-[0.45]",
226 )}
227 >
228 <View className="flex-row items-center gap-3">
229 <View
230 className={
231 props.selected
232 ? "h-7 w-7 items-center justify-center rounded-full bg-primary"
233 : "h-7 w-7 items-center justify-center"
234 }
235 >
236 {props.icon}
237 </View>
238 <View className="flex-1 gap-0.5">
239 <Text className="text-base leading-snug font-t3-bold">{props.title}</Text>
240 {props.subtitle ? (
241 <Text className="text-sm leading-snug text-foreground-muted" numberOfLines={2}>
242 {props.subtitle}
243 </Text>
244 ) : null}
245 </View>
246 {"right" in props ? (
247 props.right
248 ) : !props.disabled ? (
249 <SymbolView
250 name="chevron.right"
251 size={13}
252 tintColorClassName="accent-chevron"
253 type="monochrome"
254 />
255 ) : null}
256 </View>
257 </Pressable>
258 );
259}
260
261function PrimaryActionButton(props: {
262 readonly label: string;
263 readonly disabled?: boolean;
264 readonly loading?: boolean;
265 readonly onPress: () => void;
266}) {
267 if (Platform.OS === "android") return <MaterialButton {...props} tone="primary" fullWidth />;
268 return (
269 <Pressable
270 disabled={props.disabled}
271 onPress={props.onPress}
272 className="h-12 items-center justify-center rounded-full bg-primary active:opacity-70 disabled:opacity-45"
273 >
274 {props.loading ? (
275 <ActivityIndicator colorClassName={String("accent-primary-foreground")} />
276 ) : (
277 <Text className="text-base font-t3-bold text-primary-foreground">{props.label}</Text>
278 )}
279 </Pressable>
280 );
281}
282
283function ProjectPathInput(props: {
284 readonly value: string;
285 readonly onChangeText: (value: string) => void;
286 readonly onSubmit: () => void;
287}) {
288 return (
289 <TextInput
290 className="h-12 min-h-12 rounded-[24px] px-4 py-0 text-base leading-snug"
291 value={props.value}
292 onChangeText={props.onChangeText}
293 autoCapitalize="none"
294 autoCorrect={false}
295 placeholder="~/projects/my-app"
296 returnKeyType="done"
297 onSubmitEditing={props.onSubmit}
298 />
299 );
300}
301
302// `pinnedDirectoryName` is the repository folder the clone destination keeps
303// appended to whatever folder the user browses to. The plain add-project flow
304// passes nothing, so it keeps proposing the browsed folder itself.
305function useBrowsePathInput(environment: EnvironmentOption | null, pinnedDirectoryName = "") {
306 const environmentId = environment?.environmentId ?? null;
307 const environmentBaseDirectory = environment?.baseDirectory ?? null;
308 const clonePathCaseSensitive = !isWindowsPlatform(environment?.platform ?? "");
309 const [pathInput, commitPathInput] = useState(() =>
310 getCloneDestinationPath(
311 getAddProjectInitialQuery(environmentBaseDirectory),
312 pinnedDirectoryName,
313 ),
314 );
315 const previousEnvironmentIdRef = useRef(environmentId);
316 const environmentRuntime = useRemoteEnvironmentRuntime(environmentId);
317 const loadBrowsePath = useAtomQueryRunner(filesystemEnvironment.browse, {
318 reportFailure: false,
319 reportDefect: false,
320 });
321 const [browseNavigation] = useState(createBrowseNavigationCoordinator);
322 const [isBrowseNavigating, setIsBrowseNavigating] = useState(false);
323 const setPathInput = useCallback(
324 (path: string) => {
325 browseNavigation.invalidate();
326 setIsBrowseNavigating(false);
327 commitPathInput(path);
328 },
329 [browseNavigation],
330 );
331 const navigateToBrowsePath = useCallback(
332 async (input: {
333 readonly browseDirectoryPath: string;
334 readonly selectedDirectoryName?: string;
335 }) => {
336 const selectedDirectoryPath = input.selectedDirectoryName
337 ? appendBrowsePathSegment(input.browseDirectoryPath, input.selectedDirectoryName)
338 : input.browseDirectoryPath;
339 const nextPathInput =
340 pinnedDirectoryName && input.selectedDirectoryName
341 ? getCloneDestinationBrowsePath({
342 browseDirectoryPath: input.browseDirectoryPath,
343 selectedDirectoryName: input.selectedDirectoryName,
344 cloneDirectoryName: pinnedDirectoryName,
345 caseSensitive: clonePathCaseSensitive,
346 })
347 : getCloneDestinationPath(selectedDirectoryPath, pinnedDirectoryName);
348 setIsBrowseNavigating(true);
349 const committed = await browseNavigation.run(
350 async () => {
351 if (
352 environment &&
353 readEnvironmentScope(environment.environmentId, AuthFilesystemReadScope) &&
354 canPreloadBrowsePath(environmentRuntime?.connectionState)
355 ) {
356 await loadBrowsePath({
357 environmentId: environment.environmentId,
358 input: { partialPath: selectedDirectoryPath },
359 });
360 }
361 },
362 () => commitPathInput(nextPathInput),
363 );
364 if (committed) {
365 setIsBrowseNavigating(false);
366 }
367 return committed;
368 },
369 [
370 browseNavigation,
371 clonePathCaseSensitive,
372 environment,
373 environmentRuntime?.connectionState,
374 loadBrowsePath,
375 pinnedDirectoryName,
376 ],
377 );
378
379 useEffect(() => {
380 if (environmentId !== null && environmentId !== previousEnvironmentIdRef.current) {
381 previousEnvironmentIdRef.current = environmentId;
382 setPathInput(
383 getCloneDestinationPath(
384 getAddProjectInitialQuery(environmentBaseDirectory),
385 pinnedDirectoryName,
386 ),
387 );
388 }
389 }, [environmentBaseDirectory, environmentId, pinnedDirectoryName, setPathInput]);
390
391 useEffect(
392 () => () => {
393 browseNavigation.invalidate();
394 },
395 [browseNavigation],
396 );
397
398 return { isBrowseNavigating, pathInput, setPathInput, navigateToBrowsePath };
399}
400
401function useEnvironmentOptions(): ReadonlyArray<EnvironmentOption> {
402 const serverConfigByEnvironmentId = useServerConfigs();
403 const { savedConnectionsById } = useSavedRemoteConnections();
404 const { connectedEnvironments } = useRemoteConnectionStatus();
405
406 return useMemo<ReadonlyArray<EnvironmentOption>>(() => {
407 const runtimeByEnvironmentId = new Map(
408 connectedEnvironments.map((environment) => [environment.environmentId, environment] as const),
409 );
410 const options = Object.values(savedConnectionsById).map((connection) => {
411 const config = serverConfigByEnvironmentId.get(connection.environmentId);
412 const runtime = runtimeByEnvironmentId.get(connection.environmentId);
413 return {
414 environmentId: connection.environmentId,
415 label: connection.environmentLabel,
416 platform: platformFromOs(config?.environment.platform.os ?? null),
417 machine: resolveEnvironmentMachineKind(config ?? null),
418 baseDirectory: config?.settings.addProjectBaseDirectory ?? null,
419 newProjectsRoot: config?.newProjectsRoot ?? null,
420 connectionState: runtime?.connectionState ?? "available",
421 connectionError: runtime?.connectionError ?? null,
422 connectionErrorTraceId: runtime?.connectionErrorTraceId ?? null,
423 supportsCloneTracking: config?.environment.capabilities.projectCloneTracking === true,
424 };
425 });
426 return Arr.sort(
427 options.filter((environment) => canCreateProjectInEnvironment(environment.connectionState)),
428 environmentOptionOrder,
429 );
430 }, [connectedEnvironments, savedConnectionsById, serverConfigByEnvironmentId]);
431}
432
433function useSelectedEnvironment(): {
434 readonly environmentOptions: ReadonlyArray<EnvironmentOption>;
435 readonly selectedEnvironment: EnvironmentOption | null;
436 readonly setSelectedEnvironmentId: (environmentId: EnvironmentId) => void;
437} {
438 const [selectedEnvironmentId, setSelectedEnvironmentId] = useState<EnvironmentId | null>(null);
439 const environmentOptions = useEnvironmentOptions();
440 const selectedEnvironment =
441 environmentOptions.find(
442 (environment) =>
443 environment.environmentId === selectedEnvironmentId &&
444 canCreateProjectInEnvironment(environment.connectionState),
445 ) ??
446 environmentOptions.find((environment) =>
447 canCreateProjectInEnvironment(environment.connectionState),
448 ) ??
449 null;
450
451 return {
452 environmentOptions,
453 selectedEnvironment,
454 setSelectedEnvironmentId,
455 };
456}
457
458function EmptyEnvironmentState() {
459 const navigation = useNavigation();
460
461 return (
462 <View className="items-center gap-3 rounded-2xl bg-grouped-card px-5 py-8">
463 <Text className="text-center text-lg font-t3-bold">Environment unavailable</Text>
464 <Text className="text-center text-sm leading-normal text-foreground-muted">
465 Start or reconnect an environment before adding a project.
466 </Text>
467 <Pressable
468 onPress={() => navigation.dispatch(StackActions.replace("ConnectionsNew"))}
469 className="mt-1 rounded-full bg-primary px-4 py-2.5 active:opacity-70"
470 >
471 <Text className="text-sm font-t3-bold text-primary-foreground">Add environment</Text>
472 </Pressable>
473 </View>
474 );
475}
476
477function SourceControlRow(props: {
478 readonly source: AddProjectRemoteSource;
479 readonly selectedEnvironmentId: EnvironmentId;
480 readonly ready: boolean;
481 readonly hint: string;
482 readonly isFirst: boolean;
483}) {
484 const navigation = useNavigation();
485 const title =
486 props.source === "url" ? "Git URL" : `${addProjectRemoteSourceLabel(props.source)} repository`;
487 const subtitle =
488 props.source === "url"
489 ? "Clone from a remote URL"
490 : `Clone ${addProjectRemoteSourceLabel(props.source)} ${props.hint}`;
491 const icon =
492 props.source === "url" ? (
493 <SymbolView
494 name="link"
495 size={Platform.OS === "android" ? 24 : 17}
496 tintColorClassName="accent-icon"
497 type="monochrome"
498 />
499 ) : (
500 <SourceControlIcon
501 kind={props.source}
502 size={Platform.OS === "android" ? 24 : 18}
503 colorClassName="accent-icon"
504 />
505 );
506
507 if (!props.ready) {
508 return (
509 <ListRow title={title} subtitle={props.hint} icon={icon} disabled isFirst={props.isFirst} />
510 );
511 }
512
513 return (
514 <ListRow
515 title={title}
516 subtitle={subtitle}
517 icon={icon}
518 isFirst={props.isFirst}
519 onPress={() =>
520 navigation.dispatch(
521 StackActions.push("AddProjectRepository", {
522 environmentId: props.selectedEnvironmentId,
523 source: props.source,
524 }),
525 )
526 }
527 />
528 );
529}
530
531export function AddProjectSourceScreen() {
532 const navigation = useNavigation();
533 const { environmentOptions, selectedEnvironment, setSelectedEnvironmentId } =
534 useSelectedEnvironment();
535 const canWriteSourceControl = useEnvironmentScope(
536 selectedEnvironment?.environmentId ?? null,
537 AuthSourceControlWriteScope,
538 );
539 const canCreateProject = useEnvironmentScope(
540 selectedEnvironment?.environmentId ?? null,
541 AuthOrchestrationOperateScope,
542 );
543 const canCloneProject = canWriteSourceControl && canCreateProject;
544 const discoveryState = useEnvironmentQuery(
545 selectedEnvironment === null
546 ? null
547 : sourceControlEnvironment.discovery({
548 environmentId: selectedEnvironment.environmentId,
549 input: {},
550 }),
551 );
552 const readiness = useMemo(
553 () => buildAddProjectRemoteSourceReadiness(discoveryState.data),
554 [discoveryState.data],
555 );
556
557 return (
558 <AddProjectShell title="Add project">
559 {selectedEnvironment === null ? <EmptyEnvironmentState /> : null}
560
561 {environmentOptions.length > 1 ? (
562 <>
563 <SectionTitle>Environments</SectionTitle>
564 <ListSection>
565 {environmentOptions.map((environment, index) => (
566 <ListRow
567 key={environment.environmentId}
568 title={environment.label}
569 subtitle={
570 canCreateProjectInEnvironment(environment.connectionState)
571 ? undefined
572 : connectionStatusText({
573 phase: environment.connectionState,
574 error: environment.connectionError,
575 traceId: environment.connectionErrorTraceId,
576 })
577 }
578 icon={
579 <EnvironmentMachineSymbol
580 kind={environment.machine}
581 size={Platform.OS === "android" ? 24 : 17}
582 tintColorClassName="accent-icon"
583 />
584 }
585 selected={environment.environmentId === selectedEnvironment?.environmentId}
586 disabled={!canCreateProjectInEnvironment(environment.connectionState)}
587 isFirst={index === 0}
588 right={
589 environment.environmentId === selectedEnvironment?.environmentId ? (
590 <SymbolView
591 name="checkmark"
592 size={Platform.OS === "android" ? 20 : 14}
593 tintColorClassName="accent-icon"
594 type="monochrome"
595 />
596 ) : null
597 }
598 onPress={() => setSelectedEnvironmentId(environment.environmentId)}
599 />
600 ))}
601 </ListSection>
602 </>
603 ) : null}
604
605 {selectedEnvironment ? (
606 <>
607 <ListSection>
608 {selectedEnvironment.newProjectsRoot !== null ? (
609 <ListRow
610 title="New project"
611 subtitle="Start a new Git repository from a name"
612 icon={
613 <SymbolView
614 name="plus"
615 size={Platform.OS === "android" ? 24 : 17}
616 tintColorClassName="accent-icon"
617 type="monochrome"
618 />
619 }
620 isFirst
621 onPress={() =>
622 navigation.dispatch(
623 StackActions.push("AddProjectNew", {
624 environmentId: selectedEnvironment.environmentId,
625 }),
626 )
627 }
628 />
629 ) : null}
630 <ListRow
631 title="Local folder"
632 subtitle={
633 canCreateProject
634 ? "Browse a folder on disk"
635 : "This connection cannot add projects."
636 }
637 icon={
638 <SymbolView
639 name="folder.badge.plus"
640 size={Platform.OS === "android" ? 24 : 17}
641 tintColorClassName="accent-icon"
642 type="monochrome"
643 />
644 }
645 isFirst={selectedEnvironment.newProjectsRoot === null}
646 disabled={!canCreateProject}
647 onPress={() =>
648 navigation.dispatch(
649 StackActions.push("AddProjectLocal", {
650 environmentId: selectedEnvironment.environmentId,
651 }),
652 )
653 }
654 />
655 {(["url", ...sortAddProjectProviderSources(readiness)] as AddProjectRemoteSource[]).map(
656 (candidate) => (
657 <SourceControlRow
658 key={candidate}
659 source={candidate}
660 selectedEnvironmentId={selectedEnvironment.environmentId}
661 ready={canCloneProject && readiness[candidate].ready}
662 hint={
663 !canCloneProject
664 ? "This connection cannot clone projects."
665 : readiness[candidate].ready
666 ? addProjectRemoteSourcePathHint(candidate)
667 : (readiness[candidate].hint ?? "")
668 }
669 isFirst={false}
670 />
671 ),
672 )}
673 </ListSection>
674 {discoveryState.isPending ? (
675 <ActivityIndicator colorClassName="accent-icon-muted" />
676 ) : null}
677 </>
678 ) : null}
679 </AddProjectShell>
680 );
681}
682
683function openNewTaskDraft(
684 navigation: { dispatch: (action: ReturnType<typeof CommonActions.reset>) => void },
685 params: { environmentId: EnvironmentId; projectId: ProjectId; title: string; cloning?: "1" },
686) {
687 navigation.dispatch(
688 CommonActions.reset({ index: 0, routes: [{ name: "NewTaskDraft", params }] }),
689 );
690}
691
692function useCreateProject(environment: EnvironmentOption | null) {
693 const navigation = useNavigation();
694 const createProject = useAtomCommand(projectEnvironment.create, { reportFailure: false });
695 const projects = useProjects();
696
697 return useCallback(
698 async (workspaceRoot: string) => {
699 if (
700 !environment ||
701 !canCreateProjectInEnvironment(environment.connectionState) ||
702 !readEnvironmentScope(environment.environmentId, AuthOrchestrationOperateScope)
703 ) {
704 Alert.alert(
705 "Project not added",
706 `This connection cannot add projects right now. Any existing files remain at ${workspaceRoot}.`,
707 );
708 return;
709 }
710
711 const existing = findExistingAddProject({
712 projects,
713 environmentId: environment.environmentId,
714 path: workspaceRoot,
715 });
716 if (existing) {
717 Alert.alert("Project already exists", existing.title);
718 navigation.dispatch(
719 CommonActions.reset({
720 index: 0,
721 routes: [
722 {
723 name: "NewTaskDraft",
724 params: {
725 environmentId: existing.environmentId,
726 projectId: existing.id,
727 title: existing.title,
728 },
729 },
730 ],
731 }),
732 );
733 return;
734 }
735
736 const projectId = ProjectId.make(uuidv4());
737 const command = buildProjectCreateCommand({
738 commandId: CommandId.make(uuidv4()),
739 projectId,
740 workspaceRoot,
741 });
742 const result = await createProject({
743 environmentId: environment.environmentId,
744 input: command,
745 });
746 if (AsyncResult.isFailure(result)) {
747 return result;
748 }
749 navigation.dispatch(
750 CommonActions.reset({
751 index: 0,
752 routes: [
753 {
754 name: "NewTaskDraft",
755 params: {
756 environmentId: environment.environmentId,
757 projectId,
758 title: inferProjectTitleFromPath(workspaceRoot),
759 },
760 },
761 ],
762 }),
763 );
764 return result;
765 },
766 [createProject, environment, projects, navigation],
767 );
768}
769
770function useEnvironmentFromParam(
771 environmentIdParam: string | string[] | undefined,
772): EnvironmentOption | null {
773 const environmentOptions = useEnvironmentOptions();
774 const environmentId = stringParam(environmentIdParam) as EnvironmentId | null;
775 return resolveAddProjectEnvironment(environmentOptions, environmentId);
776}
777
778export function AddProjectRepositoryScreen(props: {
779 readonly environmentId?: string | string[];
780 readonly source?: string | string[];
781}) {
782 const lookupRepositoryQuery = useAtomQueryRunner(sourceControlEnvironment.repository, {
783 reportFailure: false,
784 });
785 const navigation = useNavigation();
786 const environment = useEnvironmentFromParam(props.environmentId);
787 const source = sourceFromParam(props.source);
788 const [repositoryInput, setRepositoryInput] = useState("");
789 const [isSubmitting, setIsSubmitting] = useState(false);
790 const [error, setError] = useState<string | null>(null);
791
792 const lookupRepository = useCallback(async () => {
793 if (!environment || repositoryInput.trim().length === 0 || isSubmitting) return;
794 setError(null);
795 setIsSubmitting(true);
796 const provider = addProjectRemoteSourceProvider(source);
797 if (!provider) {
798 const remoteUrl = normalizePastedCloneUrl(repositoryInput);
799 navigation.dispatch(
800 StackActions.push("AddProjectDestination", {
801 environmentId: environment.environmentId,
802 source,
803 remoteUrl,
804 repositoryTitle: remoteUrl,
805 repositoryName: getCloneDirectoryName(remoteUrl),
806 }),
807 );
808 setIsSubmitting(false);
809 return;
810 }
811
812 const result = await lookupRepositoryQuery({
813 environmentId: environment.environmentId,
814 input: {
815 provider,
816 repository: repositoryInput.trim(),
817 },
818 });
819 if (AsyncResult.isFailure(result)) {
820 setError(errorMessage(Cause.squash(result.cause)));
821 } else {
822 const repository = result.value;
823 navigation.dispatch(
824 StackActions.push("AddProjectDestination", {
825 environmentId: environment.environmentId,
826 source,
827 remoteUrl: getDefaultCloneUrl(repository),
828 repositoryTitle: repository.nameWithOwner,
829 repositoryName: getCloneDirectoryName(repository.nameWithOwner),
830 }),
831 );
832 }
833 setIsSubmitting(false);
834 }, [environment, isSubmitting, lookupRepositoryQuery, repositoryInput, navigation, source]);
835
836 return (
837 <AddProjectShell title={source === "url" ? "Git URL" : addProjectRemoteSourceLabel(source)}>
838 {error ? <ErrorBanner message={error} /> : null}
839 {environment ? (
840 <>
841 <TextInput
842 className="h-12 min-h-12 rounded-[24px] px-4 py-0 text-base leading-snug"
843 value={repositoryInput}
844 onChangeText={setRepositoryInput}
845 autoCapitalize="none"
846 autoCorrect={false}
847 placeholder={
848 source === "url"
849 ? "https://github.com/org/repo.git"
850 : addProjectRemoteSourcePathHint(source)
851 }
852 returnKeyType="next"
853 onSubmitEditing={() => void lookupRepository()}
854 />
855 <PrimaryActionButton
856 label={source === "url" ? "Continue" : "Lookup repository"}
857 disabled={isSubmitting || repositoryInput.trim().length === 0}
858 onPress={() => void lookupRepository()}
859 loading={isSubmitting}
860 />
861 </>
862 ) : (
863 <EmptyEnvironmentState />
864 )}
865 </AddProjectShell>
866 );
867}
868
869function FolderBrowser(props: {
870 readonly environment: EnvironmentOption;
871 readonly pathInput: string;
872 readonly setPathInput: (path: string) => void;
873 readonly navigateToBrowsePath: (input: {
874 readonly browseDirectoryPath: string;
875 readonly selectedDirectoryName?: string;
876 }) => Promise<boolean>;
877 readonly pinnedDirectoryName?: string;
878}) {
879 const browsePath = useMemo(
880 () => getFilesystemBrowsePath(props.pathInput, props.environment.platform),
881 [props.environment.platform, props.pathInput],
882 );
883 const browseInput = useMemo(
884 () => (browsePath.directoryPath.length > 0 ? { partialPath: browsePath.directoryPath } : null),
885 [browsePath.directoryPath],
886 );
887 const fileAccessSession = useEnvironmentQuery(
888 environmentSession.sessionStateAtom(props.environment.environmentId),
889 );
890 const fileEnvironment = useEnvironmentPresentation(props.environment.environmentId);
891 const fileAccess = resolveFilesystemReadAccess({
892 isCatalogReady: fileEnvironment.isReady,
893 connection: fileEnvironment.presentation?.connection ?? null,
894 session: fileAccessSession.data,
895 sessionError: fileAccessSession.error,
896 });
897 const { canReadFiles } = fileAccess;
898 const browseState = useEnvironmentQuery(
899 !canReadFiles || browseInput === null
900 ? null
901 : filesystemEnvironment.browse({
902 environmentId: props.environment.environmentId,
903 input: browseInput,
904 }),
905 );
906 // A pinned repository folder does not exist yet, so filtering the listing by
907 // it would empty the folder picker. Anything the user typed still filters.
908 const pinnedDirectoryName = props.pinnedDirectoryName ?? "";
909 const pinnedDirectoryMatches = isWindowsPlatform(props.environment.platform)
910 ? browsePath.filterQuery.toLowerCase() === pinnedDirectoryName.toLowerCase()
911 : browsePath.filterQuery === pinnedDirectoryName;
912 const browseFilterQuery = pinnedDirectoryMatches ? "" : browsePath.filterQuery;
913 const { visibleEntries: visibleBrowseEntries } = useMemo(
914 () => filterFilesystemBrowseEntries(browseState.data?.entries ?? [], browseFilterQuery),
915 [browseFilterQuery, browseState.data?.entries],
916 );
917
918 return (
919 <>
920 <SectionTitle>Browse folders</SectionTitle>
921 {!canReadFiles && !fileAccess.isPending ? (
922 <ErrorBanner message={fileAccess.error ?? "This connection cannot browse host folders."} />
923 ) : null}
924 {browseState.error ? <ErrorBanner message={browseState.error} /> : null}
925 <ListSection>
926 {fileAccess.isPending || (browseState.isPending && browseState.data === null) ? (
927 <View className="items-center py-5">
928 <ActivityIndicator colorClassName="accent-icon-muted" />
929 </View>
930 ) : null}
931 {browsePath.canBrowseUp ? (
932 <ListRow
933 title=".."
934 icon={
935 <SymbolView
936 name="arrow.turn.left.up"
937 size={Platform.OS === "android" ? 24 : 17}
938 tintColorClassName="accent-icon-muted"
939 type="monochrome"
940 />
941 }
942 isFirst
943 right={null}
944 onPress={() => {
945 if (browsePath.parentPath) {
946 void props.navigateToBrowsePath({
947 browseDirectoryPath: browsePath.parentPath,
948 });
949 }
950 }}
951 />
952 ) : null}
953 {visibleBrowseEntries.map((entry, index) => (
954 <ListRow
955 key={entry.fullPath}
956 title={entry.name}
957 icon={
958 <SymbolView
959 name="folder"
960 size={Platform.OS === "android" ? 24 : 17}
961 tintColorClassName="accent-icon-muted"
962 type="monochrome"
963 />
964 }
965 isFirst={index === 0 && !browsePath.canBrowseUp}
966 right={null}
967 onPress={() => {
968 void props.navigateToBrowsePath({
969 browseDirectoryPath: browsePath.directoryPath,
970 selectedDirectoryName: entry.name,
971 });
972 }}
973 />
974 ))}
975 </ListSection>
976 </>
977 );
978}
979
980/**
981 * New project: a name, then the server makes the folder, README, icon, and
982 * first commit. Optionally publishes it to GitHub as a private repository.
983 */
984export function AddProjectNewScreen(props: { readonly environmentId?: string | string[] }) {
985 const navigation = useNavigation();
986 // Starts on the machine picked in Add project; the rows below switch it.
987 const environmentOptions = useEnvironmentOptions().filter(
988 (option) => option.newProjectsRoot !== null,
989 );
990 const [selectedEnvironmentId, setSelectedEnvironmentId] = useState(
991 () => stringParam(props.environmentId) as EnvironmentId | null,
992 );
993 const environment = resolveAddProjectEnvironment(environmentOptions, selectedEnvironmentId);
994 const createNew = useAtomCommand(projectEnvironment.createNew, { reportFailure: false });
995 const publishRepository = useAtomCommand(sourceControlEnvironment.publishRepository, {
996 reportFailure: false,
997 });
998 const discoveryState = useEnvironmentQuery(
999 environment === null
1000 ? null
1001 : sourceControlEnvironment.discovery({
1002 environmentId: environment.environmentId,
1003 input: {},
1004 }),
1005 );
1006 const githubTarget = getNewProjectGitHubTarget(discoveryState.data);
1007 const [name, setName] = useState("");
1008 const [publishesToGitHub, setPublishesToGitHub] = useState(false);
1009 const [isSubmitting, setIsSubmitting] = useState(false);
1010 const [error, setError] = useState<string | null>(null);
1011 const trimmedName = name.trim();
1012 const pathPreview =
1013 environment?.newProjectsRoot != null
1014 ? getNewProjectPathPreview(environment.newProjectsRoot, trimmedName)
1015 : null;
1016
1017 // Shown when there is a choice, or when the selected machine went away and
1018 // another one can take over.
1019 const showMachines =
1020 environmentOptions.length > 1 || (environment === null && environmentOptions.length > 0);
1021 const machineRows = showMachines ? (
1022 <ListSection>
1023 {environmentOptions.map((option, index) => {
1024 const selected = option.environmentId === environment?.environmentId;
1025 return (
1026 <ListRow
1027 key={option.environmentId}
1028 title={option.label}
1029 icon={
1030 <EnvironmentMachineSymbol
1031 kind={option.machine}
1032 size={Platform.OS === "android" ? 24 : 17}
1033 tintColorClassName="accent-icon"
1034 />
1035 }
1036 selected={selected}
1037 // The create in flight keeps the machine it started on.
1038 disabled={isSubmitting}
1039 isFirst={index === 0}
1040 right={
1041 selected ? (
1042 <SymbolView
1043 name="checkmark"
1044 size={Platform.OS === "android" ? 20 : 14}
1045 tintColorClassName="accent-icon"
1046 type="monochrome"
1047 />
1048 ) : null
1049 }
1050 onPress={() => setSelectedEnvironmentId(option.environmentId)}
1051 />
1052 );
1053 })}
1054 </ListSection>
1055 ) : null;
1056
1057 // State lags a render behind, so a double tap could start a second create.
1058 const submittingRef = useRef(false);
1059 const submit = async () => {
1060 if (!environment || trimmedName.length === 0 || submittingRef.current) return;
1061 submittingRef.current = true;
1062 setError(null);
1063 setIsSubmitting(true);
1064 try {
1065 const result = await createNew({
1066 environmentId: environment.environmentId,
1067 input: { name: trimmedName },
1068 });
1069 if (AsyncResult.isFailure(result)) {
1070 setError(errorMessage(Cause.squash(result.cause)));
1071 return;
1072 }
1073 const { projectId, workspaceRoot, commitError } = result.value;
1074 if (commitError !== undefined) {
1075 Alert.alert("Created without a first commit", commitError);
1076 }
1077 if (publishesToGitHub && githubTarget !== null) {
1078 void publishRepository({
1079 environmentId: environment.environmentId,
1080 input: {
1081 cwd: workspaceRoot,
1082 provider: "github",
1083 repository: getNewProjectGitHubRepository(githubTarget, workspaceRoot),
1084 visibility: "private",
1085 },
1086 }).then((publishResult) => {
1087 if (AsyncResult.isFailure(publishResult)) {
1088 Alert.alert(
1089 "Could not create the GitHub repository",
1090 errorMessage(Cause.squash(publishResult.cause)),
1091 );
1092 }
1093 });
1094 }
1095 // The draft screen resolves its project from the client store, so it
1096 // must not open before the create event has arrived.
1097 const project = await waitForProject(
1098 { environmentId: environment.environmentId, projectId },
1099 15_000,
1100 );
1101 if (project === null) {
1102 // The project exists, so clearing the name keeps Create from making a `-2` copy.
1103 setName("");
1104 setError(
1105 "The project was created but has not reached this device yet. It will appear in the project list once the connection catches up.",
1106 );
1107 return;
1108 }
1109 openNewTaskDraft(navigation, {
1110 environmentId: environment.environmentId,
1111 projectId,
1112 title: trimmedName,
1113 });
1114 } finally {
1115 submittingRef.current = false;
1116 setIsSubmitting(false);
1117 }
1118 };
1119
1120 return (
1121 <AddProjectShell title="New project">
1122 {error ? <ErrorBanner message={error} /> : null}
1123 {environment ? (
1124 <>
1125 <TextInput
1126 className="h-12 min-h-12 rounded-[24px] px-4 py-0 text-base leading-snug"
1127 value={name}
1128 onChangeText={setName}
1129 autoCorrect={false}
1130 autoFocus
1131 placeholder="Project name"
1132 returnKeyType="done"
1133 onSubmitEditing={() => void submit()}
1134 />
1135 {pathPreview !== null ? (
1136 <Text className="px-1 text-sm leading-snug text-foreground-muted" numberOfLines={2}>
1137 {trimmedName.length > 0
1138 ? `Creates ${pathPreview}`
1139 : `Goes in ${environment.newProjectsRoot}`}
1140 {showMachines ? ` on ${environment.label}` : null}
1141 </Text>
1142 ) : null}
1143 {machineRows}
1144 {githubTarget !== null ? (
1145 <ListSection>
1146 <ListRow
1147 title="Create private repository on GitHub"
1148 subtitle={
1149 trimmedName.length > 0 && pathPreview !== null
1150 ? getNewProjectGitHubRepository(githubTarget, pathPreview)
1151 : githubTarget.account
1152 }
1153 icon={
1154 <SourceControlIcon
1155 kind="github"
1156 size={Platform.OS === "android" ? 24 : 18}
1157 colorClassName="accent-icon"
1158 />
1159 }
1160 isFirst
1161 right={
1162 <ThemedSwitch
1163 accessibilityLabel="Create private repository on GitHub"
1164 value={publishesToGitHub}
1165 onValueChange={setPublishesToGitHub}
1166 />
1167 }
1168 onPress={() => setPublishesToGitHub((publishes) => !publishes)}
1169 />
1170 </ListSection>
1171 ) : null}
1172 <PrimaryActionButton
1173 label="Create project"
1174 disabled={isSubmitting || trimmedName.length === 0}
1175 onPress={() => void submit()}
1176 loading={isSubmitting}
1177 />
1178 <ListSection>
1179 <ListRow
1180 title="Add existing project"
1181 subtitle="Open a folder or clone a repository"
1182 icon={
1183 <SymbolView
1184 name="folder.badge.plus"
1185 size={Platform.OS === "android" ? 24 : 17}
1186 tintColorClassName="accent-icon"
1187 type="monochrome"
1188 />
1189 }
1190 isFirst
1191 // New project opens from Add project, so going back shows the
1192 // other sources. A deep link has nothing behind it.
1193 onPress={() =>
1194 navigation.canGoBack()
1195 ? navigation.goBack()
1196 : navigation.dispatch(StackActions.replace("AddProject"))
1197 }
1198 />
1199 </ListSection>
1200 </>
1201 ) : environmentOptions.length > 0 ? (
1202 machineRows
1203 ) : (
1204 <EmptyEnvironmentState />
1205 )}
1206 </AddProjectShell>
1207 );
1208}
1209
1210export function AddProjectLocalFolderScreen(props: { readonly environmentId?: string | string[] }) {
1211 const environment = useEnvironmentFromParam(props.environmentId);
1212 const canCreateProject = useEnvironmentScope(
1213 environment?.environmentId ?? null,
1214 AuthOrchestrationOperateScope,
1215 );
1216 const createProject = useCreateProject(environment);
1217 const { isBrowseNavigating, navigateToBrowsePath, pathInput, setPathInput } =
1218 useBrowsePathInput(environment);
1219 const [isSubmitting, setIsSubmitting] = useState(false);
1220 const [error, setError] = useState<string | null>(null);
1221
1222 const submitPath = useCallback(async () => {
1223 if (!environment || isBrowseNavigating || isSubmitting) return;
1224 setError(null);
1225 const resolved = resolveAddProjectPath({
1226 rawPath: pathInput,
1227 currentProjectCwd: null,
1228 platform: environment.platform,
1229 });
1230 if (!resolved.ok) {
1231 setError(resolved.error);
1232 return;
1233 }
1234
1235 setIsSubmitting(true);
1236 const result = await createProject(resolved.path);
1237 if (result && AsyncResult.isFailure(result)) {
1238 setError(errorMessage(Cause.squash(result.cause)));
1239 }
1240 setIsSubmitting(false);
1241 }, [createProject, environment, isBrowseNavigating, isSubmitting, pathInput]);
1242
1243 return (
1244 <AddProjectShell title="Local folder">
1245 {error ? <ErrorBanner message={error} /> : null}
1246 {environment ? (
1247 <>
1248 {!canCreateProject ? (
1249 <ErrorBanner message="This connection cannot add projects." />
1250 ) : null}
1251 <ProjectPathInput value={pathInput} onChangeText={setPathInput} onSubmit={submitPath} />
1252 <PrimaryActionButton
1253 label="Add project"
1254 disabled={!canCreateProject || isBrowseNavigating || isSubmitting}
1255 onPress={submitPath}
1256 loading={isSubmitting}
1257 />
1258 <FolderBrowser
1259 environment={environment}
1260 navigateToBrowsePath={navigateToBrowsePath}
1261 pathInput={pathInput}
1262 setPathInput={setPathInput}
1263 />
1264 </>
1265 ) : (
1266 <EmptyEnvironmentState />
1267 )}
1268 </AddProjectShell>
1269 );
1270}
1271
1272export function AddProjectDestinationScreen(props: {
1273 readonly environmentId?: string | string[];
1274 readonly remoteUrl?: string | string[];
1275 readonly repositoryTitle?: string | string[];
1276 readonly repositoryName?: string | string[];
1277}) {
1278 const cloneRepository = useAtomCommand(sourceControlEnvironment.cloneRepository, {
1279 reportFailure: false,
1280 });
1281 const startProjectClone = useAtomCommand(sourceControlEnvironment.startProjectClone, {
1282 reportFailure: false,
1283 });
1284 const navigation = useNavigation();
1285 const environment = useEnvironmentFromParam(props.environmentId);
1286 const canWriteSourceControl = useEnvironmentScope(
1287 environment?.environmentId ?? null,
1288 AuthSourceControlWriteScope,
1289 );
1290 const canCreateProject = useEnvironmentScope(
1291 environment?.environmentId ?? null,
1292 AuthOrchestrationOperateScope,
1293 );
1294 const canCloneProject = canWriteSourceControl && canCreateProject;
1295 const createProject = useCreateProject(environment);
1296 const remoteUrl = stringParam(props.remoteUrl);
1297 const repositoryTitle = stringParam(props.repositoryTitle);
1298 // A lookup derives this from "owner/repo", a pasted clone URL from its own
1299 // last segment. Older links without the param keep the browsed folder.
1300 // Trim once here: the path input and the folder-list filter must compare the
1301 // same value, or a deep link with a padded param empties the folder picker.
1302 const repositoryName = stringParam(props.repositoryName)?.trim() ?? "";
1303 const { isBrowseNavigating, navigateToBrowsePath, pathInput, setPathInput } = useBrowsePathInput(
1304 environment,
1305 repositoryName,
1306 );
1307 const [isSubmitting, setIsSubmitting] = useState(false);
1308 const [error, setError] = useState<string | null>(null);
1309
1310 const submitPath = useCallback(async () => {
1311 if (
1312 !environment ||
1313 !readEnvironmentScope(environment.environmentId, AuthSourceControlWriteScope) ||
1314 !readEnvironmentScope(environment.environmentId, AuthOrchestrationOperateScope) ||
1315 !remoteUrl ||
1316 isBrowseNavigating ||
1317 isSubmitting
1318 ) {
1319 return;
1320 }
1321 setError(null);
1322 const resolved = resolveAddProjectPath({
1323 rawPath: pathInput,
1324 currentProjectCwd: null,
1325 platform: environment.platform,
1326 });
1327 if (!resolved.ok) {
1328 setError(resolved.error);
1329 return;
1330 }
1331
1332 setIsSubmitting(true);
1333 if (environment.supportsCloneTracking) {
1334 // The server creates the project and clones in the background; the
1335 // draft screen shows progress and holds Start until the files land.
1336 const projectId = ProjectId.make(uuidv4());
1337 const title = inferProjectTitleFromPath(resolved.path);
1338 const startResult = await startProjectClone({
1339 environmentId: environment.environmentId,
1340 input: {
1341 projectId,
1342 title,
1343 createdAt: new Date().toISOString(),
1344 remoteUrl,
1345 destinationPath: resolved.path,
1346 },
1347 });
1348 if (AsyncResult.isFailure(startResult)) {
1349 setError(errorMessage(Cause.squash(startResult.cause)));
1350 } else {
1351 // The draft screen resolves its project from the client store, so it
1352 // must not open before the create event has arrived (it would fall
1353 // back to the project picker and lose the clone controls). Stay in
1354 // the submitting state until then; the clone keeps running either way.
1355 const project = await waitForProject(
1356 { environmentId: environment.environmentId, projectId },
1357 15_000,
1358 );
1359 if (project === null) {
1360 setError(
1361 "The project was created but has not reached this device yet. It will appear in the project list once the connection catches up.",
1362 );
1363 } else {
1364 openNewTaskDraft(navigation, {
1365 environmentId: environment.environmentId,
1366 projectId,
1367 title,
1368 cloning: "1",
1369 });
1370 }
1371 }
1372 setIsSubmitting(false);
1373 return;
1374 }
1375 const cloneResult = await cloneRepository({
1376 environmentId: environment.environmentId,
1377 input: {
1378 remoteUrl,
1379 destinationPath: resolved.path,
1380 },
1381 });
1382 if (AsyncResult.isFailure(cloneResult)) {
1383 setError(errorMessage(Cause.squash(cloneResult.cause)));
1384 } else {
1385 const createResult = await createProject(cloneResult.value.cwd);
1386 if (createResult && AsyncResult.isFailure(createResult)) {
1387 setError(errorMessage(Cause.squash(createResult.cause)));
1388 }
1389 }
1390 setIsSubmitting(false);
1391 }, [
1392 cloneRepository,
1393 createProject,
1394 environment,
1395 isBrowseNavigating,
1396 isSubmitting,
1397 navigation,
1398 pathInput,
1399 remoteUrl,
1400 startProjectClone,
1401 ]);
1402
1403 return (
1404 <AddProjectShell title="Clone destination">
1405 {error ? <ErrorBanner message={error} /> : null}
1406 {repositoryTitle ? (
1407 <View className="rounded-[24px] bg-grouped-card px-4 py-3">
1408 <Text className="text-base font-t3-bold">{repositoryTitle}</Text>
1409 <Text className="mt-0.5 text-xs text-foreground-muted" numberOfLines={2}>
1410 {remoteUrl}
1411 </Text>
1412 </View>
1413 ) : null}
1414 {environment ? (
1415 <>
1416 <ProjectPathInput value={pathInput} onChangeText={setPathInput} onSubmit={submitPath} />
1417 <PrimaryActionButton
1418 label="Clone project"
1419 disabled={!canCloneProject || isBrowseNavigating || isSubmitting || !remoteUrl}
1420 onPress={submitPath}
1421 loading={isSubmitting}
1422 />
1423 {!canCloneProject ? (
1424 <Text className="text-sm text-foreground-muted">
1425 This connection cannot clone projects.
1426 </Text>
1427 ) : null}
1428 <FolderBrowser
1429 environment={environment}
1430 navigateToBrowsePath={navigateToBrowsePath}
1431 pathInput={pathInput}
1432 setPathInput={setPathInput}
1433 pinnedDirectoryName={repositoryName}
1434 />
1435 </>
1436 ) : (
1437 <EmptyEnvironmentState />
1438 )}
1439 </AddProjectShell>
1440 );
1441}