Open History to see the last commit
1import {
2 createPathConfigForStaticNavigation,
3 getPathFromState,
4 NavigationState,
5 StackActions,
6 useNavigation,
7} from "@react-navigation/native";
8import {
9 createNativeStackNavigator,
10 createNativeStackScreen,
11 type NativeStackNavigationOptions,
12} from "@react-navigation/native-stack";
13import { useEffect, useRef } from "react";
14import { Platform, Pressable, ScrollView, StyleSheet, View } from "react-native";
15import { useResolveClassNames } from "uniwind";
16
17import { AppText as Text } from "./components/AppText";
18import { getCompactBrandHeaderOptions } from "./components/CompactBrandTitle";
19import { ArchivedThreadsRouteScreen } from "./features/archive/ArchivedThreadsRouteScreen";
20import { useAgentNotificationNavigation } from "./features/agent-awareness/notificationNavigation";
21import { ConnectOnboardingRouteScreen } from "./features/cloud/ConnectOnboardingRouteScreen";
22import { useConnectOnboardingNavigation } from "./features/cloud/connectOnboardingNavigation";
23import { AttachmentFileScreen } from "./features/files/AttachmentFileScreen";
24import { ThreadFilesTreeScreen, ThreadFileScreen } from "./features/files/ThreadFilesRouteScreen";
25import { AdaptiveWorkspaceLayout } from "./features/layout/AdaptiveWorkspaceLayout";
26import {
27 HardwareKeyboardCommandOverlay,
28 HardwareKeyboardCommandProvider,
29} from "./features/keyboard/HardwareKeyboardCommandProvider";
30import { ReviewCommentComposerSheet } from "./features/review/ReviewCommentComposerSheet";
31import { ReviewSheet } from "./features/review/ReviewSheet";
32import { ThreadTerminalRouteScreen } from "./features/terminal/ThreadTerminalRouteScreen";
33import { GitBranchesSheet } from "./features/threads/git/GitBranchesSheet";
34import { GitCommitSheet } from "./features/threads/git/GitCommitSheet";
35import { GitConfirmSheet } from "./features/threads/git/GitConfirmSheet";
36import { GitOverviewSheet } from "./features/threads/git/GitOverviewSheet";
37import { ThreadRouteScreen } from "./features/threads/ThreadRouteScreen";
38import { ConnectionsRouteScreen } from "./features/connection/ConnectionsRouteScreen";
39import { ConnectionsNewRouteScreen } from "./features/connection/ConnectionsNewRouteScreen";
40import { HomeRouteScreen } from "./features/home/HomeRouteScreen";
41import { AddProjectDestinationRoute } from "./features/projects/AddProjectDestinationRoute";
42import { AddProjectLocalRoute } from "./features/projects/AddProjectLocalRoute";
43import { AddProjectRepositoryRoute } from "./features/projects/AddProjectRepositoryRoute";
44import { AddProjectSourceRoute } from "./features/projects/AddProjectSourceRoute";
45import { NewTaskDraftRouteScreen } from "./features/threads/NewTaskDraftRouteScreen";
46import {
47 NewTaskBranchPickerRouteScreen,
48 NewTaskEnvironmentPickerRouteScreen,
49} from "./features/threads/NewTaskContextPickerScreens";
50import {
51 ExistingThreadSettingsRouteProvider,
52 ExistingThreadSettingsRouteScreen,
53 NewTaskThreadSettingsRouteScreen,
54} from "./features/threads/ThreadSettingsSheet";
55import { NewTaskFlowProvider } from "./features/threads/new-task-flow-provider";
56import { NewTaskRouteScreen } from "./features/threads/NewTaskRouteScreen";
57import { SettingsAppearanceRouteScreen } from "./features/settings/SettingsAppearanceRouteScreen";
58import { SettingsClientStorageRouteScreen } from "./features/settings/SettingsClientStorageRouteScreen";
59import { SettingsDiagnosticsRouteScreen } from "./features/diagnostics/SettingsDiagnosticsRouteScreen";
60import { SettingsAuthRouteScreen } from "./features/settings/SettingsAuthRouteScreen";
61import { SettingsEnvironmentsRouteScreen } from "./features/settings/SettingsEnvironmentsRouteScreen";
62import { SettingsKeyboardRouteScreen } from "./features/settings/SettingsKeyboardRouteScreen";
63import { SettingsLegalRouteScreen } from "./features/settings/SettingsLegalRouteScreen";
64import {
65 SettingsOpenSourceLicenseRouteScreen,
66 SettingsOpenSourceLicensesRouteScreen,
67} from "./features/settings/SettingsOpenSourceLicensesRouteScreen";
68import { SettingsProjectGroupingRouteScreen } from "./features/settings/SettingsProjectGroupingRouteScreen";
69import { UsageLimitAccountScreen } from "./features/usage/UsageLimitsPooled";
70import { UsageRouteScreen } from "./features/usage/UsageRouteScreen";
71import { SettingsRouteScreen } from "./features/settings/SettingsRouteScreen";
72import { ShowcaseCaptureCoordinator } from "./features/showcase/ShowcaseCaptureCoordinator";
73import {
74 SettingsLegalDocumentCloseHeaderButton,
75 SettingsLegalDocumentExternalHeaderButton,
76} from "./features/settings/components/SettingsLegalDocumentRouteScreen";
77import { useAppShortcuts } from "./features/shortcuts/useAppShortcuts";
78import { useIncomingShare } from "./features/sharing/IncomingShareProvider";
79import {
80 EMPTY_INCOMING_SHARE_PRESENTATION_STATE,
81 transitionIncomingSharePresentation,
82} from "./features/sharing/incoming-share-presentation";
83import { NATIVE_LIQUID_GLASS_SUPPORTED } from "./native/native-glass";
84import { nativeHeaderScrollEdgeEffects } from "./native/StackHeader";
85import { FORM_SHEET_PRESENTATION_OPTIONS } from "./native/sheet-surface";
86import { useThreadOutboxDrain } from "./state/use-thread-outbox-drain";
87import { useComposerAttachmentUploadWorker } from "./state/composer-attachment-uploads";
88
89const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
90
91type AppScreenOptions = NativeStackNavigationOptions & {
92 readonly unstable_navigationItemStyle?: "editor";
93};
94
95// Shared header presets. Screens only override genuinely dynamic values (titles,
96// subtitles, toolbar items, search callbacks) via NativeStackScreenOptions.
97//
98// GLASS: transparent header over the screen's primary scroll view on supported
99// iOS versions. Pre-glass iOS gets the same solid material as internal-scroll
100// surfaces so content is laid out below the bar instead of underlapping it.
101const GLASS_HEADER_OPTIONS: AppScreenOptions = {
102 headerBackButtonDisplayMode: "minimal",
103 headerBackTitle: "",
104 headerLargeTitle: false,
105 headerShadowVisible: false,
106 headerShown: true,
107 headerStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? { backgroundColor: "transparent" } : undefined,
108 headerTitleStyle: { fontSize: 18, fontWeight: "800" },
109 headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,
110 scrollEdgeEffects: NATIVE_LIQUID_GLASS_SUPPORTED ? HEADER_SCROLL_EDGE_EFFECTS : undefined,
111 unstable_navigationItemStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? "editor" : undefined,
112};
113
114// SOLID: opaque sheet-colored header for surfaces whose content scrolls internally
115// (file viewer, terminal, review) — there is nothing for glass to sample there.
116const SOLID_HEADER_OPTIONS: AppScreenOptions = {
117 headerBackButtonDisplayMode: "minimal",
118 headerBackTitle: "",
119 headerLargeTitle: false,
120 headerShadowVisible: false,
121 headerShown: true,
122 headerTitleStyle: { fontSize: 18, fontWeight: "800" },
123 headerTransparent: false,
124 unstable_navigationItemStyle: Platform.OS === "ios" ? "editor" : undefined,
125};
126
127// Solid header variant for screens inside sheets (centered title, no editor style).
128const SHEET_SOLID_HEADER_OPTIONS: AppScreenOptions = {
129 ...SOLID_HEADER_OPTIONS,
130 unstable_navigationItemStyle: undefined,
131};
132
133// A native glass header for a sheet screen whose primary child is a scroll
134// view. The centered sheet title stays stable while UIKit supplies scroll-edge
135// fading from that child.
136const SHEET_GLASS_HEADER_OPTIONS: AppScreenOptions = {
137 ...GLASS_HEADER_OPTIONS,
138 unstable_navigationItemStyle: undefined,
139};
140
141const LEGAL_DOCUMENT_HEADER_OPTIONS: AppScreenOptions = {
142 ...SHEET_SOLID_HEADER_OPTIONS,
143 headerBackVisible: false,
144 headerLeft: SettingsLegalDocumentCloseHeaderButton,
145 headerRight: () => <SettingsLegalDocumentExternalHeaderButton />,
146 presentation: "fullScreenModal",
147};
148
149const SettingsContentStack = createNativeStackNavigator({
150 initialRouteName: "Settings",
151 screenOptions: {
152 ...GLASS_HEADER_OPTIONS,
153 // Sheets read better with the iOS-default centered title (no editor style).
154 unstable_navigationItemStyle: undefined,
155 },
156 screens: {
157 Settings: createNativeStackScreen({
158 screen: SettingsRouteScreen,
159 linking: "",
160 options: {
161 title: "Settings",
162 },
163 }),
164 SettingsEnvironments: createNativeStackScreen({
165 screen: SettingsEnvironmentsRouteScreen,
166 linking: "environments",
167 options: {
168 title: "Environments",
169 },
170 }),
171 SettingsEnvironmentNew: createNativeStackScreen({
172 screen: ConnectionsNewRouteScreen,
173 linking: "environment-new",
174 options: {
175 title: "Add Environment",
176 },
177 }),
178 SettingsArchive: createNativeStackScreen({
179 screen: ArchivedThreadsRouteScreen,
180 linking: "archive",
181 options: {
182 title: "Archived Threads",
183 },
184 }),
185 SettingsAppearance: createNativeStackScreen({
186 screen: SettingsAppearanceRouteScreen,
187 linking: "appearance",
188 options: {
189 title: "Appearance",
190 },
191 }),
192 SettingsProjectGrouping: createNativeStackScreen({
193 screen: SettingsProjectGroupingRouteScreen,
194 linking: "project-grouping",
195 options: {
196 title: "Project Grouping",
197 },
198 }),
199 SettingsKeyboard: createNativeStackScreen({
200 screen: SettingsKeyboardRouteScreen,
201 linking: "keyboard",
202 options: {
203 title: "Keyboard",
204 },
205 }),
206 SettingsClientStorage: createNativeStackScreen({
207 screen: SettingsClientStorageRouteScreen,
208 linking: "client-storage",
209 options: {
210 title: "Client Storage",
211 },
212 }),
213 SettingsDiagnostics: createNativeStackScreen({
214 screen: SettingsDiagnosticsRouteScreen,
215 linking: "diagnostics",
216 options: {
217 title: "Diagnostics",
218 },
219 }),
220 SettingsUsageAccount: createNativeStackScreen({
221 screen: UsageLimitAccountScreen,
222 options: { title: "Account" },
223 }),
224 SettingsOpenSourceLicenses: createNativeStackScreen({
225 screen: SettingsOpenSourceLicensesRouteScreen,
226 linking: "open-source-licenses",
227 options: {
228 title: "Open source licenses",
229 },
230 }),
231 SettingsOpenSourceLicense: createNativeStackScreen({
232 screen: SettingsOpenSourceLicenseRouteScreen,
233 linking: "open-source-licenses/:entryKey",
234 options: {
235 title: "License notice",
236 },
237 }),
238 SettingsUsage: createNativeStackScreen({
239 screen: UsageRouteScreen,
240 linking: "usage",
241 options: {
242 title: "Usage",
243 },
244 }),
245 },
246});
247
248// The outer stack never owns visible chrome. Settings routes render inside a
249// nested stack whose native header remains mounted, while Clerk owns auth chrome.
250// Keeping bar visibility invariant avoids iOS 26's headerless-to-headered jump.
251const SettingsSheetStack = createNativeStackNavigator({
252 initialRouteName: "SettingsContent",
253 screenOptions: {
254 headerShown: false,
255 },
256 screens: {
257 SettingsContent: createNativeStackScreen({
258 screen: SettingsContentStack,
259 linking: "",
260 }),
261 SettingsAuth: createNativeStackScreen({
262 screen: SettingsAuthRouteScreen,
263 linking: "auth",
264 }),
265 SettingsWaitlist: createNativeStackScreen({
266 // Keep the old deep link working after the Connect GA launch.
267 screen: SettingsAuthRouteScreen,
268 linking: "waitlist",
269 }),
270 },
271});
272
273// Thread routes live FLAT in the root stack (not in a nested navigator). A nested
274// stack means a second UINavigationController with its own UINavigationBar, which
275// breaks iOS 26's shared-header morphing between Home and Thread (each pair inside
276// one bar morphs; across two bars the whole screen slides). Flat linking paths keep
277// the same deep-link URLs the nested config produced.
278const THREAD_LINKING_PREFIX = "threads/:environmentId/:threadId";
279
280// New-task / add-project flow: nested navigator inside the formSheet (Settings-sheet
281// pattern — a plain formSheet screen cannot render a stack header; the header and
282// in-sheet pushes come from this nested stack).
283const NewTaskSheetStack = createNativeStackNavigator({
284 initialRouteName: "NewTask",
285 screenOptions: {
286 ...SHEET_GLASS_HEADER_OPTIONS,
287 // The form-sheet host owns the one opaque adaptive surface. Child screens
288 // and the navigation bar stay transparent over it, avoiding visible color
289 // slabs as view controllers move horizontally.
290 contentStyle: Platform.OS === "ios" ? { backgroundColor: "transparent" } : undefined,
291 // UIKit's default push adds a dimming shadow and independently transitions
292 // the navigation bar. Both read as mismatched sheet backgrounds here.
293 // simple_push retains native push/pop gestures without either artifact.
294 animation: Platform.OS === "ios" ? "simple_push" : undefined,
295 animationDuration: Platform.OS === "ios" ? 350 : undefined,
296 },
297 screens: {
298 NewTask: createNativeStackScreen({
299 screen: NewTaskRouteScreen,
300 linking: "",
301 options: {
302 title: "Choose project",
303 },
304 }),
305 NewTaskDraft: createNativeStackScreen({
306 screen: NewTaskDraftRouteScreen,
307 linking: "draft",
308 options: {
309 headerBackVisible: false,
310 title: "",
311 },
312 }),
313 NewTaskEnvironment: createNativeStackScreen({
314 screen: NewTaskEnvironmentPickerRouteScreen,
315 linking: "draft/environment",
316 options: {
317 title: "Environment",
318 },
319 }),
320 NewTaskBranch: createNativeStackScreen({
321 screen: NewTaskBranchPickerRouteScreen,
322 linking: "draft/branch",
323 options: {
324 title: "Branch",
325 },
326 }),
327 // The same file view the thread composer pushes. A draft has no thread, so it names its
328 // own workspace through route params instead of resolving one from a selected thread.
329 NewTaskFile: createNativeStackScreen({
330 screen: ThreadFileScreen,
331 linking: "draft/files/:path*",
332 options: SOLID_HEADER_OPTIONS,
333 }),
334 NewTaskAttachment: createNativeStackScreen({
335 screen: AttachmentFileScreen,
336 linking: "draft/attachments/:attachmentId",
337 options: SOLID_HEADER_OPTIONS,
338 }),
339 ThreadSettings: createNativeStackScreen({
340 screen: NewTaskThreadSettingsRouteScreen,
341 linking: "draft/settings",
342 options: {
343 gestureEnabled: true,
344 headerShown: false,
345 ...(Platform.OS === "android"
346 ? { presentation: "card" as const }
347 : {
348 ...FORM_SHEET_PRESENTATION_OPTIONS,
349 sheetAllowedDetents: [1],
350 sheetGrabberVisible: true,
351 }),
352 },
353 }),
354 AddProject: createNativeStackScreen({
355 screen: AddProjectSourceRoute,
356 linking: "add-project",
357 options: {
358 title: "Add Project",
359 },
360 }),
361 AddProjectRepository: createNativeStackScreen({
362 screen: AddProjectRepositoryRoute,
363 linking: "add-project/repository",
364 }),
365 AddProjectDestination: createNativeStackScreen({
366 screen: AddProjectDestinationRoute,
367 linking: "add-project/destination",
368 }),
369 AddProjectLocal: createNativeStackScreen({
370 screen: AddProjectLocalRoute,
371 linking: "add-project/local",
372 }),
373 },
374});
375
376// Routes presented as sheets/overlays ON TOP of the workspace. They must not
377// influence the adaptive workspace layout: opening Settings over Home should
378// not flip the sidebar in or change the active thread.
379const WORKSPACE_OVERLAY_ROUTES = new Set([
380 "ConnectOnboarding",
381 "Connections",
382 "ConnectionsNew",
383 "GitBranches",
384 "GitCommit",
385 "GitConfirm",
386 "GitOverview",
387 "NewTaskSheet",
388 "SettingsLegal",
389 "SettingsSheet",
390 "ThreadReviewComment",
391 "ThreadSettingsSheet",
392]);
393
394/**
395 * Location of the topmost non-overlay route, including its key so thread
396 * selection can dismiss sheets without replacing the wrong destination.
397 */
398function workspaceLocationFromState(state: NavigationState) {
399 const routes = state.routes.filter((route) => !WORKSPACE_OVERLAY_ROUTES.has(route.name));
400 const effectiveState =
401 routes.length > 0 && routes.length !== state.routes.length
402 ? ({ ...state, routes, index: routes.length - 1 } as NavigationState)
403 : state;
404 const path = getPathFromState(effectiveState, navigationPathConfig);
405 return {
406 pathname: path.startsWith("/") ? path : `/${path}`,
407 routeKey: effectiveState.routes[effectiveState.index]?.key,
408 };
409}
410
411// The drain hook subscribes to the outbox, all thread shells, projects, and
412// connection statuses. Hosting it in a null-rendering leaf keeps those
413// updates from re-rendering RootStackLayout (and with it every screen) on
414// each enqueue, shell change, or reconnect.
415function ThreadOutboxDrainWorker() {
416 useThreadOutboxDrain();
417 useComposerAttachmentUploadWorker();
418 return null;
419}
420
421function RootStackLayout(props: {
422 readonly children: React.ReactNode;
423 readonly state: NavigationState;
424}) {
425 const navigation = useNavigation();
426 const { pendingShare } = useIncomingShare();
427 const sharePresentationRef = useRef(EMPTY_INCOMING_SHARE_PRESENTATION_STATE);
428 useAgentNotificationNavigation();
429 // Presents the T3 Connect onboarding sheet after an in-session sign-in.
430 useConnectOnboardingNavigation();
431 // Launcher app shortcuts: routes shortcut taps and tracks opened threads.
432 useAppShortcuts(props.state);
433 useEffect(() => {
434 const topRouteName = props.state.routes[props.state.index]?.name;
435 const transition = transitionIncomingSharePresentation(sharePresentationRef.current, {
436 isShareSheetPresented: topRouteName === "NewTaskSheet",
437 pendingShareId: pendingShare?.id ?? null,
438 });
439 sharePresentationRef.current = transition.state;
440 if (!transition.shareIdToPresent) {
441 return;
442 }
443 navigation.navigate("NewTaskSheet", {
444 screen: "NewTask",
445 params: { incomingShareId: transition.shareIdToPresent },
446 });
447 }, [navigation, pendingShare, props.state]);
448 // Full pathname (sheets included) for keyboard-command scoping; the
449 // workspace layout only reacts to the underlying non-overlay route.
450 const path = getPathFromState(props.state, navigationPathConfig);
451 const pathname = path.startsWith("/") ? path : `/${path}`;
452 const workspaceLocation = workspaceLocationFromState(props.state);
453
454 return (
455 <HardwareKeyboardCommandProvider pathname={pathname}>
456 <ThreadOutboxDrainWorker />
457 <ShowcaseCaptureCoordinator pathname={pathname} />
458 <ExistingThreadSettingsRouteProvider>
459 <AdaptiveWorkspaceLayout
460 pathname={workspaceLocation.pathname}
461 workspaceRouteKey={workspaceLocation.routeKey}
462 >
463 {props.children}
464 <HardwareKeyboardCommandOverlay />
465 </AdaptiveWorkspaceLayout>
466 </ExistingThreadSettingsRouteProvider>
467 </HardwareKeyboardCommandProvider>
468 );
469}
470
471function NotFoundScreen() {
472 const navigation = useNavigation();
473 const screenBgStyle = StyleSheet.flatten(useResolveClassNames("bg-screen"));
474 const primaryBgStyle = StyleSheet.flatten(useResolveClassNames("bg-primary"));
475 const returnHomeButtonStyle = StyleSheet.flatten([
476 {
477 borderRadius: 999,
478 paddingHorizontal: 20,
479 paddingVertical: 14,
480 },
481 primaryBgStyle,
482 ]);
483
484 return (
485 <ScrollView
486 contentInsetAdjustmentBehavior="automatic"
487 contentContainerStyle={{
488 flexGrow: 1,
489 alignItems: "center",
490 justifyContent: "center",
491 gap: 16,
492 paddingHorizontal: 24,
493 paddingVertical: 32,
494 }}
495 style={[{ flex: 1 }, screenBgStyle]}
496 >
497 <Text className="text-3xl font-t3-bold text-foreground" selectable>
498 Route not found
499 </Text>
500 <Pressable
501 style={returnHomeButtonStyle}
502 onPress={() => navigation.dispatch(StackActions.replace("Home"))}
503 >
504 <Text className="text-base font-t3-bold text-primary-foreground">Return home</Text>
505 </Pressable>
506 </ScrollView>
507 );
508}
509
510export const RootStack = createNativeStackNavigator({
511 initialRouteName: "Home",
512 layout: RootStackLayout,
513 screenOptions: {
514 headerShown: false,
515 },
516 screens: {
517 Home: createNativeStackScreen({
518 screen: HomeRouteScreen,
519 linking: "",
520 options: {
521 ...GLASS_HEADER_OPTIONS,
522 contentStyle: { backgroundColor: "transparent" },
523 headerBackVisible: false,
524 ...getCompactBrandHeaderOptions(),
525 },
526 }),
527 Thread: createNativeStackScreen({
528 screen: ThreadRouteScreen,
529 linking: THREAD_LINKING_PREFIX,
530 options: GLASS_HEADER_OPTIONS,
531 }),
532 ThreadTerminal: createNativeStackScreen({
533 screen: ThreadTerminalRouteScreen,
534 linking: `${THREAD_LINKING_PREFIX}/terminal`,
535 options: SOLID_HEADER_OPTIONS,
536 }),
537 ThreadReview: createNativeStackScreen({
538 screen: ReviewSheet,
539 linking: `${THREAD_LINKING_PREFIX}/review`,
540 options: SOLID_HEADER_OPTIONS,
541 }),
542 ThreadReviewComment: createNativeStackScreen({
543 screen: ReviewCommentComposerSheet,
544 linking: `${THREAD_LINKING_PREFIX}/review-comment`,
545 options: {
546 // Android cannot host the keyboard-driven comment composer inside a
547 // formSheet; use a full-screen modal there instead.
548 ...(Platform.OS === "android"
549 ? { presentation: "fullScreenModal" as const }
550 : FORM_SHEET_PRESENTATION_OPTIONS),
551 sheetAllowedDetents: Platform.OS === "android" ? undefined : [0.55, 0.92],
552 sheetGrabberVisible: Platform.OS !== "android",
553 },
554 }),
555 ThreadFiles: createNativeStackScreen({
556 screen: ThreadFilesTreeScreen,
557 linking: `${THREAD_LINKING_PREFIX}/files`,
558 options: {
559 ...GLASS_HEADER_OPTIONS,
560 title: "Files",
561 },
562 }),
563 ThreadFile: createNativeStackScreen({
564 screen: ThreadFileScreen,
565 linking: `${THREAD_LINKING_PREFIX}/files/:path*`,
566 options: SOLID_HEADER_OPTIONS,
567 }),
568 ThreadAttachment: createNativeStackScreen({
569 screen: AttachmentFileScreen,
570 linking: `${THREAD_LINKING_PREFIX}/attachments/:attachmentId`,
571 options: SOLID_HEADER_OPTIONS,
572 }),
573 ThreadSettingsSheet: createNativeStackScreen({
574 screen: ExistingThreadSettingsRouteScreen,
575 options: {
576 gestureEnabled: true,
577 headerShown: false,
578 ...(Platform.OS === "android"
579 ? { presentation: "card" as const }
580 : {
581 ...FORM_SHEET_PRESENTATION_OPTIONS,
582 sheetAllowedDetents: [1],
583 sheetGrabberVisible: true,
584 }),
585 },
586 }),
587 GitOverview: createNativeStackScreen({
588 screen: GitOverviewSheet,
589 linking: `${THREAD_LINKING_PREFIX}/git`,
590 options: {
591 ...FORM_SHEET_PRESENTATION_OPTIONS,
592 sheetAllowedDetents: [0.55, 0.92],
593 sheetGrabberVisible: true,
594 },
595 }),
596 GitCommit: createNativeStackScreen({
597 screen: GitCommitSheet,
598 linking: `${THREAD_LINKING_PREFIX}/git/commit`,
599 options: {
600 ...FORM_SHEET_PRESENTATION_OPTIONS,
601 sheetAllowedDetents: [0.55, 0.92],
602 sheetGrabberVisible: true,
603 },
604 }),
605 GitBranches: createNativeStackScreen({
606 screen: GitBranchesSheet,
607 linking: `${THREAD_LINKING_PREFIX}/git/branches`,
608 options: {
609 ...FORM_SHEET_PRESENTATION_OPTIONS,
610 sheetAllowedDetents: [0.55, 0.92],
611 sheetGrabberVisible: true,
612 },
613 }),
614 GitConfirm: createNativeStackScreen({
615 screen: GitConfirmSheet,
616 linking: `${THREAD_LINKING_PREFIX}/git-confirm`,
617 options: {
618 ...FORM_SHEET_PRESENTATION_OPTIONS,
619 sheetAllowedDetents: [0.45, 0.7],
620 sheetGrabberVisible: true,
621 },
622 }),
623 SettingsSheet: createNativeStackScreen({
624 screen: SettingsSheetStack,
625 linking: "settings",
626 options: {
627 gestureEnabled: true,
628 headerShown: false,
629 // Android pushes settings as a regular full page with an in-screen
630 // back header; iOS keeps the detented form sheet.
631 ...(Platform.OS === "android"
632 ? { presentation: "card" as const }
633 : {
634 ...FORM_SHEET_PRESENTATION_OPTIONS,
635 sheetAllowedDetents: [0.7, 0.92],
636 sheetGrabberVisible: true,
637 }),
638 },
639 }),
640 SettingsLegal: createNativeStackScreen({
641 screen: SettingsLegalRouteScreen,
642 linking: "settings/legal",
643 options: {
644 ...LEGAL_DOCUMENT_HEADER_OPTIONS,
645 title: "Legal",
646 },
647 }),
648 ConnectOnboarding: createNativeStackScreen({
649 screen: ConnectOnboardingRouteScreen,
650 linking: "connect-onboarding",
651 options: {
652 // A root-level Android formSheet does not host the native stack bar;
653 // the route renders an embedded AndroidSheetHeader instead.
654 ...(Platform.OS === "android" ? { headerShown: false } : SHEET_SOLID_HEADER_OPTIONS),
655 title: "Set up T3 Connect",
656 gestureEnabled: true,
657 ...FORM_SHEET_PRESENTATION_OPTIONS,
658 sheetAllowedDetents: [0.6, 0.95],
659 sheetGrabberVisible: true,
660 },
661 }),
662 Connections: createNativeStackScreen({
663 screen: ConnectionsRouteScreen,
664 linking: "connections",
665 options: {
666 title: "Environments",
667 // Android: full page; the screen renders its own AndroidScreenHeader,
668 // so the native bar stays hidden. iOS keeps the sheet.
669 ...(Platform.OS === "android"
670 ? { presentation: "card" as const, headerShown: false }
671 : {
672 ...FORM_SHEET_PRESENTATION_OPTIONS,
673 sheetAllowedDetents: [0.55, 0.7],
674 sheetGrabberVisible: true,
675 }),
676 },
677 }),
678 ConnectionsNew: createNativeStackScreen({
679 screen: ConnectionsNewRouteScreen,
680 linking: "connections/new",
681 options: {
682 ...FORM_SHEET_PRESENTATION_OPTIONS,
683 sheetAllowedDetents: [0.55, 0.7],
684 sheetGrabberVisible: true,
685 },
686 }),
687 NewTaskSheet: createNativeStackScreen({
688 screen: NewTaskSheetStack,
689 linking: "new",
690 // The whole new-task flow (choose project → draft → add project) shares
691 // draft state via NewTaskFlowProvider. The expo-router era mounted it in
692 // app/new/_layout.tsx; this layout wrapper is the native-stack equivalent.
693 layout: ({ children }) => (
694 <NewTaskFlowProvider>
695 <View className="flex-1 bg-sheet-solid">{children}</View>
696 </NewTaskFlowProvider>
697 ),
698 options: {
699 gestureEnabled: true,
700 headerShown: false,
701 // Android pushes the flow as a regular full page — the draft should
702 // read like a thread that just doesn't exist yet; iOS keeps the sheet.
703 ...(Platform.OS === "android"
704 ? { presentation: "card" as const }
705 : {
706 ...FORM_SHEET_PRESENTATION_OPTIONS,
707 sheetAllowedDetents: [0.92],
708 sheetGrabberVisible: true,
709 }),
710 },
711 }),
712 NotFound: createNativeStackScreen({
713 screen: NotFoundScreen,
714 linking: "*",
715 }),
716 },
717});
718type RootStackType = typeof RootStack;
719
720const navigationPathConfig = {
721 screens: createPathConfigForStaticNavigation(RootStack) ?? {},
722};
723
724declare module "@react-navigation/native" {
725 interface RootNavigator extends RootStackType {}
726}