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