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

Stack.tsx

756 lines27.5 KB

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