From ee203ed5182ad05afed96f64d913e9ae528d0c44 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 30 Jun 2026 16:12:14 -0700 Subject: [PATCH] Structure mobile navigation around native stack --- apps/mobile/src/App.tsx | 510 +----------------- .../agent-awareness/notificationNavigation.ts | 4 +- .../archive/ArchivedThreadsRouteScreen.tsx | 2 +- .../archive/ArchivedThreadsScreen.tsx | 53 +- .../features/files/ThreadFilesRouteScreen.tsx | 51 +- apps/mobile/src/features/home/HomeHeader.tsx | 89 +-- .../HardwareKeyboardCommandProvider.tsx | 6 +- .../layout/AdaptiveWorkspaceLayout.tsx | 14 +- .../layout/native-glass-header-items.ts | 2 +- .../layout/native-mail-search-toolbar.ts | 3 +- .../layout/workspace-sidebar-toolbar.tsx | 8 +- .../features/projects/AddProjectScreen.tsx | 34 +- .../review/ReviewCommentComposerSheet.tsx | 6 +- .../src/features/review/ReviewSheet.tsx | 65 +-- .../useReviewCommentSelectionController.ts | 6 +- .../terminal/ThreadTerminalRouteScreen.tsx | 61 ++- .../features/threads/NewTaskDraftScreen.tsx | 8 +- .../src/features/threads/ThreadFeed.tsx | 4 +- .../features/threads/ThreadGitControls.tsx | 90 ++-- .../threads/ThreadNavigationSidebar.tsx | 4 +- .../features/threads/ThreadRouteScreen.tsx | 21 +- .../features/threads/git/GitBranchesSheet.tsx | 4 +- .../features/threads/git/GitCommitSheet.tsx | 4 +- .../features/threads/git/GitConfirmSheet.tsx | 6 +- .../features/threads/git/GitOverviewSheet.tsx | 12 +- apps/mobile/src/lib/routes.test.ts | 4 +- apps/mobile/src/lib/routes.ts | 20 +- apps/mobile/src/navigation/RootNavigator.tsx | 405 ++++++++++++++ apps/mobile/src/navigation/app-navigation.tsx | 176 ++++++ apps/mobile/src/navigation/linking.ts | 39 ++ .../{router.tsx => native-stack-header.tsx} | 261 +++------ apps/mobile/src/navigation/route-model.ts | 4 + apps/mobile/src/screens/+not-found.tsx | 6 +- apps/mobile/src/screens/connections/index.tsx | 16 +- apps/mobile/src/screens/connections/new.tsx | 19 +- apps/mobile/src/screens/debug/rns-glass.tsx | 6 +- apps/mobile/src/screens/index.tsx | 12 +- .../screens/new/add-project/repository.tsx | 6 +- apps/mobile/src/screens/new/draft.tsx | 6 +- apps/mobile/src/screens/new/index.tsx | 25 +- apps/mobile/src/screens/settings/archive.tsx | 3 - apps/mobile/src/screens/settings/auth.tsx | 6 +- .../src/screens/settings/environment-new.tsx | 1 - .../src/screens/settings/environments.tsx | 16 +- apps/mobile/src/screens/settings/index.tsx | 25 +- apps/mobile/src/screens/settings/waitlist.tsx | 13 +- .../[threadId]/files/[...path].tsx | 5 - .../[threadId]/files/index.tsx | 5 - .../[threadId]/git-confirm.tsx | 5 - .../[threadId]/git/branches.tsx | 5 - .../[environmentId]/[threadId]/git/commit.tsx | 5 - .../[environmentId]/[threadId]/git/index.tsx | 5 - .../[environmentId]/[threadId]/index.tsx | 5 - .../[threadId]/review-comment.tsx | 5 - .../[environmentId]/[threadId]/review.tsx | 10 - .../[environmentId]/[threadId]/terminal.tsx | 5 - apps/mobile/src/state/use-thread-selection.ts | 4 +- 57 files changed, 1090 insertions(+), 1105 deletions(-) create mode 100644 apps/mobile/src/navigation/RootNavigator.tsx create mode 100644 apps/mobile/src/navigation/app-navigation.tsx create mode 100644 apps/mobile/src/navigation/linking.ts rename apps/mobile/src/navigation/{router.tsx => native-stack-header.tsx} (59%) delete mode 100644 apps/mobile/src/screens/settings/archive.tsx delete mode 100644 apps/mobile/src/screens/settings/environment-new.tsx delete mode 100644 apps/mobile/src/screens/threads/[environmentId]/[threadId]/files/[...path].tsx delete mode 100644 apps/mobile/src/screens/threads/[environmentId]/[threadId]/files/index.tsx delete mode 100644 apps/mobile/src/screens/threads/[environmentId]/[threadId]/git-confirm.tsx delete mode 100644 apps/mobile/src/screens/threads/[environmentId]/[threadId]/git/branches.tsx delete mode 100644 apps/mobile/src/screens/threads/[environmentId]/[threadId]/git/commit.tsx delete mode 100644 apps/mobile/src/screens/threads/[environmentId]/[threadId]/git/index.tsx delete mode 100644 apps/mobile/src/screens/threads/[environmentId]/[threadId]/index.tsx delete mode 100644 apps/mobile/src/screens/threads/[environmentId]/[threadId]/review-comment.tsx delete mode 100644 apps/mobile/src/screens/threads/[environmentId]/[threadId]/review.tsx delete mode 100644 apps/mobile/src/screens/threads/[environmentId]/[threadId]/terminal.tsx diff --git a/apps/mobile/src/App.tsx b/apps/mobile/src/App.tsx index 543a9f64e8..dc221fc05b 100644 --- a/apps/mobile/src/App.tsx +++ b/apps/mobile/src/App.tsx @@ -4,513 +4,19 @@ import { DMSans_700Bold, useFonts, } from "@expo-google-fonts/dm-sans"; -import { NavigationContainer, type NavigationContainerRef } from "@react-navigation/native"; -import { createNativeStackNavigator } from "@react-navigation/native-stack"; -import * as Linking from "expo-linking"; -import { use, useCallback, useMemo, useRef, useState, type ReactNode } from "react"; -import { StatusBar, useColorScheme, useWindowDimensions } from "react-native"; import { GestureHandlerRootView } from "react-native-gesture-handler"; import { KeyboardProvider } from "react-native-keyboard-controller"; import { SafeAreaProvider } from "react-native-safe-area-context"; -import { useResolveClassNames } from "uniwind"; import { RegistryContext } from "@effect/atom-react"; import { LoadingScreen } from "./components/LoadingScreen"; -import { ArchivedThreadsRouteScreen } from "./features/archive/ArchivedThreadsRouteScreen"; -import { useAgentNotificationNavigation } from "./features/agent-awareness/notificationNavigation"; import { CloudAuthProvider } from "./features/cloud/CloudAuthProvider"; -import { - ClerkSettingsSheetDetentProvider, - useClerkSettingsSheetDetent, -} from "./features/cloud/ClerkSettingsSheetDetent"; -import { - AdaptiveWorkspaceLayout, - useAdaptiveWorkspaceLayout, -} from "./features/layout/AdaptiveWorkspaceLayout"; -import { deriveStableFormSheetDetent } from "./lib/layout"; -import { useThemeColor } from "./lib/useThemeColor"; +import { AppNavigationProvider } from "./navigation/app-navigation"; +import { RootNavigator } from "./navigation/RootNavigator"; import { appAtomRegistry } from "./state/atom-registry"; -import { ThreadSelectionProvider } from "./state/use-thread-selection"; -import { useThreadOutboxDrain } from "./state/use-thread-outbox-drain"; -import HomeRouteScreen from "./screens/index"; -import SettingsRouteScreen from "./screens/settings/index"; -import SettingsEnvironmentsRouteScreen from "./screens/settings/environments"; -import SettingsAuthRouteScreen from "./screens/settings/auth"; -import SettingsWaitlistRouteScreen from "./screens/settings/waitlist"; -import ConnectionsRouteScreen from "./screens/connections/index"; -import ConnectionsNewRouteScreen from "./screens/connections/new"; -import NewTaskRoute from "./screens/new/index"; -import AddProjectRoute from "./screens/new/add-project/index"; -import AddProjectRepositoryRoute from "./screens/new/add-project/repository"; -import AddProjectDestinationRoute from "./screens/new/add-project/destination"; -import AddProjectLocalRoute from "./screens/new/add-project/local"; -import NewTaskDraftRoute from "./screens/new/draft"; -import RnsGlassDebugRoute from "./screens/debug/rns-glass"; -import NotFoundRoute from "./screens/+not-found"; -import { ThreadFilesTreeScreen, ThreadFileScreen } from "./features/files/ThreadFilesRouteScreen"; -import { ReviewHighlighterProvider } from "./features/review/ReviewHighlighterProvider"; -import { ReviewCommentComposerSheet } from "./features/review/ReviewCommentComposerSheet"; -import { ReviewSheet } from "./features/review/ReviewSheet"; -import { ThreadTerminalRouteScreen } from "./features/terminal/ThreadTerminalRouteScreen"; -import { ThreadRouteScreen } from "./features/threads/ThreadRouteScreen"; -import { GitBranchesSheet } from "./features/threads/git/GitBranchesSheet"; -import { GitCommitSheet } from "./features/threads/git/GitCommitSheet"; -import { GitConfirmSheet } from "./features/threads/git/GitConfirmSheet"; -import { GitOverviewSheet } from "./features/threads/git/GitOverviewSheet"; -import { HardwareKeyboardCommandProvider } from "./features/keyboard/HardwareKeyboardCommandProvider"; -import { - AppNavigationContext, - createRouter, - pathAndParamsFromCurrentRoute, -} from "./navigation/router"; -import { - getFocusedRoute, - type AppStackParamList, - type RouteParams, -} from "./navigation/route-model"; import "../global.css"; -const RootStack = createNativeStackNavigator(); - -const linking = { - prefixes: [Linking.createURL("/"), "t3code://", "t3code-dev://", "t3code-preview://"], - config: { - screens: { - Home: "", - DebugRnsGlass: "debug/rns-glass", - Settings: "settings", - SettingsEnvironments: "settings/environments", - SettingsEnvironmentNew: "settings/environment-new", - SettingsArchive: "settings/archive", - SettingsAuth: "settings/auth", - SettingsWaitlist: "settings/waitlist", - Connections: "connections", - ConnectionsNew: "connections/new", - NewTask: "new", - AddProject: "new/add-project", - AddProjectRepository: "new/add-project/repository", - AddProjectDestination: "new/add-project/destination", - AddProjectLocal: "new/add-project/local", - NewTaskDraft: "new/draft", - Thread: "threads/:environmentId/:threadId", - ThreadTerminal: "threads/:environmentId/:threadId/terminal", - ThreadReview: "threads/:environmentId/:threadId/review", - ThreadReviewComment: "threads/:environmentId/:threadId/review-comment", - ThreadFiles: "threads/:environmentId/:threadId/files", - ThreadFile: "threads/:environmentId/:threadId/files/:path*", - GitOverview: "threads/:environmentId/:threadId/git", - GitCommit: "threads/:environmentId/:threadId/git/commit", - GitBranches: "threads/:environmentId/:threadId/git/branches", - GitConfirm: "threads/:environmentId/:threadId/git-confirm", - NotFound: "*", - }, - }, -}; - -function ThreadSelectionRoute(props: { readonly children: ReactNode }) { - return {props.children}; -} - -function ThreadRoute() { - return ( - - - - ); -} - -function ThreadTerminalRoute() { - return ( - - - - ); -} - -function ThreadFilesRoute() { - return ( - - - - ); -} - -function ThreadFileRoute() { - return ( - - - - ); -} - -function ThreadReviewRoute() { - return ( - - - - - - ); -} - -function ThreadReviewCommentRoute() { - return ( - - - - ); -} - -function GitOverviewRoute() { - return ( - - - - ); -} - -function GitCommitRoute() { - return ( - - - - ); -} - -function GitBranchesRoute() { - return ( - - - - ); -} - -function GitConfirmRoute() { - return ( - - - - ); -} - -function AppNavigationProvider(props: { readonly children: ReactNode }) { - const navigationRef = useRef>(null); - const [pathname, setPathname] = useState("/"); - const [params, setParams] = useState({}); - const router = useMemo(() => createRouter(navigationRef), []); - const contextValue = useMemo( - () => ({ - navigationRef, - pathname, - params, - router, - }), - [params, pathname, router], - ); - const syncState = useCallback(() => { - const route = getFocusedRoute(navigationRef.current?.getRootState()); - if (!route) { - setPathname("/"); - setParams({}); - return; - } - - const current = pathAndParamsFromCurrentRoute(route); - setPathname(current.pathname); - setParams(current.params); - }, []); - - return ( - - - {props.children} - - - ); -} - -function AppNavigator() { - const pathname = usePathnameFromContext(); - const expandedSettingsRouteIsActive = - pathname === "/settings/archive" || pathname === "/settings/auth"; - - return ( - - - - ); -} - -function usePathnameFromContext() { - const context = use(AppNavigationContext); - if (context === null) { - return "/"; - } - return context.pathname; -} - -function AppNavigatorContent() { - const pathname = usePathnameFromContext(); - const isDebugRoute = pathname.startsWith("/debug/"); - - if (isDebugRoute) { - return ; - } - - return ; -} - -function DebugNavigatorHost() { - return ( - <> - - - - - - - - ); -} - -function WorkspaceNavigatorHost() { - const colorScheme = useColorScheme(); - const statusBarBg = useThemeColor("--color-status-bar"); - useAgentNotificationNavigation(); - useThreadOutboxDrain(); - - return ( - <> - - - - - - ); -} - -function WorkspaceNavigator() { - const { collapse, isExpanded } = useClerkSettingsSheetDetent(); - const { layout } = useAdaptiveWorkspaceLayout(); - const { height } = useWindowDimensions(); - const sheetStyle = useResolveClassNames("bg-sheet"); - - const handleSettingsTransitionEnd = useCallback( - (event: { data: { closing: boolean } }) => { - if (event.data.closing) { - collapse(); - } - }, - [collapse], - ); - - const connectionSheetScreenOptions = { - contentStyle: sheetStyle, - gestureEnabled: true, - headerShown: false, - presentation: "formSheet" as const, - sheetAllowedDetents: [0.55, 0.7], - sheetGrabberVisible: true, - }; - const settingsScreenOptions = layout.usesSplitView - ? { - animation: "none" as const, - contentStyle: sheetStyle, - gestureEnabled: false, - headerShown: false, - presentation: "card" as const, - } - : { - ...connectionSheetScreenOptions, - sheetAllowedDetents: isExpanded ? [0.92] : [0.7], - }; - const newTaskScreenOptions = { - contentStyle: sheetStyle, - gestureEnabled: true, - headerShown: false, - presentation: "formSheet" as const, - sheetAllowedDetents: [layout.usesSplitView ? deriveStableFormSheetDetent(height) : 0.92], - sheetGrabberVisible: !layout.usesSplitView, - }; - - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ); -} - export default function App() { const [fontsLoaded] = useFonts({ DMSans_400Regular, @@ -525,13 +31,11 @@ export default function App() { - - {fontsLoaded ? ( - - ) : ( - - )} - + {fontsLoaded ? ( + + ) : ( + + )} diff --git a/apps/mobile/src/features/agent-awareness/notificationNavigation.ts b/apps/mobile/src/features/agent-awareness/notificationNavigation.ts index 03aacf2ca3..2662566e28 100644 --- a/apps/mobile/src/features/agent-awareness/notificationNavigation.ts +++ b/apps/mobile/src/features/agent-awareness/notificationNavigation.ts @@ -1,12 +1,12 @@ import { useEffect, useRef } from "react"; import * as Notifications from "expo-notifications"; -import { useRouter } from "../../navigation/router"; +import { useAppNavigation } from "../../navigation/native-stack-header"; import { routeAgentNotificationResponseOnce } from "./notificationPayload"; import { consumeLastAgentNotificationResponse } from "./notificationResponseConsumer"; export function useAgentNotificationNavigation(): void { - const router = useRouter(); + const router = useAppNavigation(); const handledResponseIds = useRef(new Set()); useEffect(() => { diff --git a/apps/mobile/src/features/archive/ArchivedThreadsRouteScreen.tsx b/apps/mobile/src/features/archive/ArchivedThreadsRouteScreen.tsx index 8253481bf2..8c56962b10 100644 --- a/apps/mobile/src/features/archive/ArchivedThreadsRouteScreen.tsx +++ b/apps/mobile/src/features/archive/ArchivedThreadsRouteScreen.tsx @@ -1,7 +1,7 @@ import type { EnvironmentId } from "@t3tools/contracts"; import * as Arr from "effect/Array"; import * as Order from "effect/Order"; -import { useFocusEffect } from "../../navigation/router"; +import { useFocusEffect } from "../../navigation/native-stack-header"; import { useCallback, useMemo, useState } from "react"; import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry"; diff --git a/apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx b/apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx index 354da26494..f8e50eb4db 100644 --- a/apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx +++ b/apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx @@ -4,7 +4,10 @@ import type { } from "@t3tools/client-runtime/state/shell"; import type { EnvironmentId } from "@t3tools/contracts"; import type { MenuAction } from "@react-native-menu/menu"; -import { Stack } from "../../navigation/router"; +import { + NativeHeaderToolbar, + NativeStackScreenOptions, +} from "../../navigation/native-stack-header"; import { SymbolView } from "expo-symbols"; import { useCallback, useMemo, useRef, type ComponentProps } from "react"; import { @@ -111,7 +114,7 @@ function ArchivedThreadsHeader(props: { return ( <> - {usesCompactMailToolbar ? null : ( - + {usesNativeChrome ? ( - ) : null} - - - Environment - + Environment + props.onEnvironmentChange(null)} > - All environments - + All environments + {props.environments.map((environment) => ( - props.onEnvironmentChange(environment.environmentId)} > - {environment.label} - + {environment.label} + ))} - + - - Sort by archived date - + Sort by archived date + props.onSortOrderChange("newest")} > - Newest first - - Newest first + + props.onSortOrderChange("oldest")} > - Oldest first - - - - + Oldest first + + + + )} ); diff --git a/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx b/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx index 083ba56d7a..b6bf434b6b 100644 --- a/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx +++ b/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx @@ -1,6 +1,9 @@ -import Stack from "../../navigation/router"; +import { + NativeHeaderToolbar, + NativeStackScreenOptions, +} from "../../navigation/native-stack-header"; import { SymbolView } from "expo-symbols"; -import { useLocalSearchParams, useRouter } from "../../navigation/router"; +import { useRouteParams, useAppNavigation } from "../../navigation/native-stack-header"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { ActivityIndicator, @@ -355,7 +358,7 @@ function FileContent(props: { } function useThreadFilesWorkspace() { - const params = useLocalSearchParams<{ + const params = useRouteParams<{ environmentId?: string | string[]; threadId?: string | string[]; }>(); @@ -385,7 +388,7 @@ function useThreadFilesWorkspace() { function FilesUnavailable() { return ( - + - {layout.usesSplitView ? ( - - + - + ) : null} {!usesCompactMailToolbar ? ( - - + - + ) : null} {usesCompactMailToolbar ? null : ( - - - + + + )} (); @@ -744,7 +747,7 @@ export function ThreadFileScreen() { if (relativePath === null) { return ( - + ); @@ -753,7 +756,7 @@ export function ThreadFileScreen() { return ( - {fileInspector.supported ? ( - { @@ -776,9 +779,9 @@ export function ThreadFileScreen() { /> ) : null} - + {fileInspector.supported ? ( - ) : null} - { @@ -798,7 +801,7 @@ export function ThreadFileScreen() { fileQuery.refresh(); }} /> - + renderInspector(0) : undefined} > diff --git a/apps/mobile/src/features/home/HomeHeader.tsx b/apps/mobile/src/features/home/HomeHeader.tsx index 287c40c85b..043c4c3d07 100644 --- a/apps/mobile/src/features/home/HomeHeader.tsx +++ b/apps/mobile/src/features/home/HomeHeader.tsx @@ -3,7 +3,10 @@ import type { SidebarProjectGroupingMode, SidebarThreadSortOrder, } from "@t3tools/contracts"; -import { Stack } from "../../navigation/router"; +import { + NativeHeaderToolbar, + NativeStackScreenOptions, +} from "../../navigation/native-stack-header"; import { useCallback, useRef } from "react"; import { Platform } from "react-native"; import type { SearchBarCommands } from "react-native-screens"; @@ -54,7 +57,7 @@ export function HomeHeader(props: { return ( <> - {Platform.OS === "ios" ? null : ( - - + - + )} {Platform.OS === "ios" ? null : ( - - + - - Settings - + + Settings + - - Environment - + Environment + props.onEnvironmentChange(null)} subtitle="Show threads from every environment" > - All environments - + All environments + {props.environments.map((environment) => ( - props.onEnvironmentChange(environment.environmentId)} > - {environment.label} - + {environment.label} + ))} - + - - Sort projects + + Sort projects {PROJECT_SORT_OPTIONS.map((option) => ( - props.onProjectSortOrderChange(option.value)} > - {option.label} - + {option.label} + ))} - + - - Sort threads + + Sort threads {THREAD_SORT_OPTIONS.map((option) => ( - props.onThreadSortOrderChange(option.value)} > - {option.label} - + {option.label} + ))} - + - - Group projects + + Group projects {PROJECT_GROUPING_OPTIONS.map((option) => ( - props.onProjectGroupingModeChange(option.value)} subtitle={option.subtitle} > - {option.label} - + {option.label} + ))} - - - - - - + + + + + - + )} ); diff --git a/apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx b/apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx index b026e8c646..ddf79b8cc2 100644 --- a/apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx +++ b/apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx @@ -1,4 +1,4 @@ -import { usePathname, useRouter } from "../../navigation/router"; +import { useCurrentPathname, useAppNavigation } from "../../navigation/native-stack-header"; import { useCallback, useMemo, useSyncExternalStore, type PropsWithChildren } from "react"; import { @@ -18,8 +18,8 @@ import { } from "./hardwareKeyboardCommands"; export function HardwareKeyboardCommandProvider({ children }: PropsWithChildren) { - const pathname = usePathname(); - const router = useRouter(); + const pathname = useCurrentPathname(); + const router = useAppNavigation(); const registrationVersion = useSyncExternalStore( subscribeToHardwareKeyboardCommandRegistrations, getHardwareKeyboardCommandRegistrationVersion, diff --git a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx index bcb69a0c93..a575926d7d 100644 --- a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx +++ b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx @@ -2,10 +2,10 @@ import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell import { EnvironmentId, ThreadId } from "@t3tools/contracts"; import { useFocusEffect, - useGlobalSearchParams, - usePathname, - useRouter, -} from "../../navigation/router"; + useCurrentRouteParams, + useCurrentPathname, + useAppNavigation, +} from "../../navigation/native-stack-header"; import { createContext, use, @@ -99,8 +99,8 @@ export function useAdaptiveWorkspacePaneRole(role: WorkspaceAuxiliaryPaneRole) { export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) { const { width, height } = useWindowDimensions(); - const pathname = usePathname(); - const router = useRouter(); + const pathname = useCurrentPathname(); + const router = useAppNavigation(); const activeRoleOwner = useRef(null); const [primarySidebarPreferredVisible, setPrimarySidebarPreferredVisible] = useState(true); const [supplementaryPanePreferredVisible, setSupplementaryPanePreferredVisible] = useState(true); @@ -114,7 +114,7 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) const [primarySidebarSearchQuery, setPrimarySidebarSearchQuery] = useState(""); const [focusedAuxiliaryPaneRole, setFocusedAuxiliaryPaneRole] = useState(null); - const params = useGlobalSearchParams<{ + const params = useCurrentRouteParams<{ environmentId?: string | string[]; threadId?: string | string[]; }>(); diff --git a/apps/mobile/src/features/layout/native-glass-header-items.ts b/apps/mobile/src/features/layout/native-glass-header-items.ts index 997f3bc101..ec88051eaa 100644 --- a/apps/mobile/src/features/layout/native-glass-header-items.ts +++ b/apps/mobile/src/features/layout/native-glass-header-items.ts @@ -9,7 +9,7 @@ type NativeGlassHeaderItem = { /** * iOS 26/27 Mail-style header controls need the native glass button * configuration when they are not part of a larger toolbar. Keep this - * centralized so Expo Router screens and plain react-native-screens demos + * centralized so native-stack screens and plain react-native-screens demos * don't drift apart. */ export function withNativeGlassHeaderItem( diff --git a/apps/mobile/src/features/layout/native-mail-search-toolbar.ts b/apps/mobile/src/features/layout/native-mail-search-toolbar.ts index 5cc12957c5..820e122224 100644 --- a/apps/mobile/src/features/layout/native-mail-search-toolbar.ts +++ b/apps/mobile/src/features/layout/native-mail-search-toolbar.ts @@ -10,7 +10,8 @@ type NativeMailSearchToolbarInput = Omit< * * Keeping this behind an app-level helper makes the iOS-only RNS patch an * explicit layout primitive instead of a per-screen object literal. Android can - * keep using Expo Router toolbar primitives without depending on this helper. + * keep using platform-specific header/search primitives without depending on + * this helper. */ export function createNativeMailSearchToolbarItem( input: NativeMailSearchToolbarInput, diff --git a/apps/mobile/src/features/layout/workspace-sidebar-toolbar.tsx b/apps/mobile/src/features/layout/workspace-sidebar-toolbar.tsx index 3db7c343cc..b25f59f5b4 100644 --- a/apps/mobile/src/features/layout/workspace-sidebar-toolbar.tsx +++ b/apps/mobile/src/features/layout/workspace-sidebar-toolbar.tsx @@ -1,4 +1,4 @@ -import { Stack } from "../../navigation/router"; +import { NativeHeaderToolbar } from "../../navigation/native-stack-header"; import type { ReactNode } from "react"; import { useAdaptiveWorkspaceLayout } from "./AdaptiveWorkspaceLayout"; @@ -16,9 +16,9 @@ export function WorkspaceSidebarToolbar( } return ( - + {props.children} - {props.afterSidebarButton} - + ); } diff --git a/apps/mobile/src/features/projects/AddProjectScreen.tsx b/apps/mobile/src/features/projects/AddProjectScreen.tsx index db00a9d202..a1aaf7df93 100644 --- a/apps/mobile/src/features/projects/AddProjectScreen.tsx +++ b/apps/mobile/src/features/projects/AddProjectScreen.tsx @@ -22,7 +22,7 @@ import { isFilesystemBrowseQuery, } from "@t3tools/client-runtime/state/projects"; import { CommandId, type EnvironmentId, ProjectId } from "@t3tools/contracts"; -import { useLocalSearchParams, useRouter } from "../../navigation/router"; +import { useRouteParams, useAppNavigation } from "../../navigation/native-stack-header"; import { SymbolView } from "expo-symbols"; import { useCallback, useEffect, useMemo, useState, type ReactNode } from "react"; import { ActivityIndicator, Alert, Pressable, ScrollView, View } from "react-native"; @@ -250,8 +250,8 @@ function useSelectedEnvironment(): { readonly selectedEnvironment: EnvironmentOption | null; readonly setSelectedEnvironmentId: (environmentId: EnvironmentId) => void; } { - const router = useRouter(); - const params = useLocalSearchParams<{ environmentId?: string }>(); + const router = useAppNavigation(); + const params = useRouteParams<{ environmentId?: string }>(); const environmentOptions = useEnvironmentOptions(); const requestedEnvironmentId = stringParam(params.environmentId) as EnvironmentId | null; const selectedEnvironment = @@ -269,7 +269,7 @@ function useSelectedEnvironment(): { } function EmptyEnvironmentState() { - const router = useRouter(); + const router = useAppNavigation(); return ( @@ -294,7 +294,7 @@ function SourceControlRow(props: { readonly hint: string; readonly isFirst: boolean; }) { - const router = useRouter(); + const router = useAppNavigation(); const iconColor = useThemeColor("--color-icon"); const title = props.source === "url" ? "Git URL" : `${addProjectRemoteSourceLabel(props.source)} repository`; @@ -323,7 +323,7 @@ function SourceControlRow(props: { isFirst={props.isFirst} onPress={() => router.push({ - pathname: "/new/add-project/repository", + name: "AddProjectRepository", params: { environmentId: props.selectedEnvironmentId, source: props.source, @@ -335,7 +335,7 @@ function SourceControlRow(props: { } export function AddProjectSourceScreen() { - const router = useRouter(); + const router = useAppNavigation(); const accentColor = useThemeColor("--color-icon-muted"); const iconColor = useThemeColor("--color-icon"); const { environmentOptions, selectedEnvironment, setSelectedEnvironmentId } = @@ -410,7 +410,7 @@ export function AddProjectSourceScreen() { isFirst onPress={() => router.push({ - pathname: "/new/add-project/local", + name: "AddProjectLocal", params: { environmentId: selectedEnvironment.environmentId }, }) } @@ -440,7 +440,7 @@ export function AddProjectSourceScreen() { } function useCreateProject(environment: EnvironmentOption | null) { - const router = useRouter(); + const router = useAppNavigation(); const createProject = useAtomCommand(projectEnvironment.create, { reportFailure: false }); const projects = useProjects(); @@ -456,7 +456,7 @@ function useCreateProject(environment: EnvironmentOption | null) { if (existing) { Alert.alert("Project already exists", existing.title); router.replace({ - pathname: "/new/draft", + name: "NewTaskDraft", params: { environmentId: existing.environmentId, projectId: existing.id, @@ -481,7 +481,7 @@ function useCreateProject(environment: EnvironmentOption | null) { return result; } router.replace({ - pathname: "/new/draft", + name: "NewTaskDraft", params: { environmentId: environment.environmentId, projectId, @@ -495,7 +495,7 @@ function useCreateProject(environment: EnvironmentOption | null) { } function useEnvironmentFromParam(): EnvironmentOption | null { - const params = useLocalSearchParams<{ environmentId?: string }>(); + const params = useRouteParams<{ environmentId?: string }>(); const environmentOptions = useEnvironmentOptions(); const environmentId = stringParam(params.environmentId) as EnvironmentId | null; return ( @@ -509,8 +509,8 @@ export function AddProjectRepositoryScreen() { const lookupRepositoryQuery = useAtomQueryRunner(sourceControlEnvironment.repository, { reportFailure: false, }); - const router = useRouter(); - const params = useLocalSearchParams<{ environmentId?: string; source?: string }>(); + const router = useAppNavigation(); + const params = useRouteParams<{ environmentId?: string; source?: string }>(); const environment = useEnvironmentFromParam(); const source = sourceFromParam(params.source); const [repositoryInput, setRepositoryInput] = useState(""); @@ -525,7 +525,7 @@ export function AddProjectRepositoryScreen() { if (!provider) { const remoteUrl = repositoryInput.trim(); router.push({ - pathname: "/new/add-project/destination", + name: "AddProjectDestination", params: { environmentId: environment.environmentId, source, @@ -549,7 +549,7 @@ export function AddProjectRepositoryScreen() { } else { const repository = result.value; router.push({ - pathname: "/new/add-project/destination", + name: "AddProjectDestination", params: { environmentId: environment.environmentId, source, @@ -749,7 +749,7 @@ export function AddProjectDestinationScreen() { const cloneRepository = useAtomCommand(sourceControlEnvironment.cloneRepository, { reportFailure: false, }); - const params = useLocalSearchParams<{ + const params = useRouteParams<{ environmentId?: string; remoteUrl?: string; repositoryTitle?: string; diff --git a/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx b/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx index 862949db3b..3503a15021 100644 --- a/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx +++ b/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx @@ -1,4 +1,4 @@ -import { useLocalSearchParams, useRouter } from "../../navigation/router"; +import { useRouteParams, useAppNavigation } from "../../navigation/native-stack-header"; import { SymbolView } from "expo-symbols"; import { TextInputWrapper } from "expo-paste-input"; import type { EnvironmentId, ThreadId } from "@t3tools/contracts"; @@ -41,13 +41,13 @@ import { const REVIEW_COMMENT_PREVIEW_MAX_LINES = 5; export function ReviewCommentComposerSheet() { - const router = useRouter(); + const router = useAppNavigation(); const insets = useSafeAreaInsets(); const { width } = useWindowDimensions(); const colorScheme = useColorScheme(); const iconTint = String(useThemeColor("--color-icon")); const target = useReviewCommentTarget(); - const { environmentId, threadId } = useLocalSearchParams<{ + const { environmentId, threadId } = useRouteParams<{ environmentId: EnvironmentId; threadId: ThreadId; }>(); diff --git a/apps/mobile/src/features/review/ReviewSheet.tsx b/apps/mobile/src/features/review/ReviewSheet.tsx index fc78caf5c5..4b89795154 100644 --- a/apps/mobile/src/features/review/ReviewSheet.tsx +++ b/apps/mobile/src/features/review/ReviewSheet.tsx @@ -1,7 +1,10 @@ import type { EnvironmentId, ThreadId } from "@t3tools/contracts"; -import { useLocalSearchParams } from "../../navigation/router"; +import { useRouteParams } from "../../navigation/native-stack-header"; import { useHeaderHeight } from "@react-navigation/elements"; -import Stack from "../../navigation/router"; +import { + NativeHeaderToolbar, + NativeStackScreenOptions, +} from "../../navigation/native-stack-header"; import { SymbolView } from "expo-symbols"; import { memo, @@ -395,7 +398,7 @@ export function ReviewSheet() { const headerForeground = String(useThemeColor("--color-foreground")); const headerMuted = String(useThemeColor("--color-foreground-muted")); const headerIcon = String(useThemeColor("--color-icon")); - const { environmentId, threadId } = useLocalSearchParams<{ + const { environmentId, threadId } = useRouteParams<{ environmentId: EnvironmentId; threadId: ThreadId; }>(); @@ -584,7 +587,7 @@ export function ReviewSheet() { return ( <> - {layout.usesSplitView ? ( - - + - + ) : null} {showSectionToolbar || panes.supportsAuxiliaryPane ? ( - + {panes.supportsAuxiliaryPane ? ( - ) : null} {showSectionToolbar ? ( - - - + + { @@ -635,9 +638,9 @@ export function ReviewSheet() { } }} > - Working tree - - Working tree + + { @@ -646,9 +649,9 @@ export function ReviewSheet() { } }} > - Branch changes - - Branch changes + + { @@ -657,24 +660,24 @@ export function ReviewSheet() { } }} > - Latest turn - + Latest turn + {sectionMenu.turns.length > 0 ? ( - + {sectionMenu.turns.map((section) => ( - selectSection(section.id)} subtitle={section.subtitle ?? undefined} > - {section.title} - + {section.title} + ))} - + ) : null} - - + void refreshSelectedSection()} subtitle="Reload current diff" > - Refresh - - + Refresh + + ) : null} - + ) : null} diff --git a/apps/mobile/src/features/review/useReviewCommentSelectionController.ts b/apps/mobile/src/features/review/useReviewCommentSelectionController.ts index 30549bfc7a..557ce16b41 100644 --- a/apps/mobile/src/features/review/useReviewCommentSelectionController.ts +++ b/apps/mobile/src/features/review/useReviewCommentSelectionController.ts @@ -1,6 +1,6 @@ import { useCallback, useEffect, useMemo, useState } from "react"; import type { NativeSyntheticEvent } from "react-native"; -import { useRouter } from "../../navigation/router"; +import { useAppNavigation } from "../../navigation/native-stack-header"; import * as Arr from "effect/Array"; import { pipe } from "effect/Function"; import * as Result from "effect/Result"; @@ -34,7 +34,7 @@ export function useReviewCommentSelectionController(input: { readonly nativeReviewDiffData: NativeReviewDiffData; }) { const { environmentId, nativeReviewDiffData, selectedSection, threadId } = input; - const { push } = useRouter(); + const { push } = useAppNavigation(); const activeCommentTarget = useReviewCommentTarget(); const [pendingNativeCommentSelection, setPendingNativeCommentSelection] = useState(null); @@ -45,7 +45,7 @@ export function useReviewCommentSelectionController(input: { } push({ - pathname: "/threads/[environmentId]/[threadId]/review-comment", + name: "ThreadReviewComment", params: { environmentId, threadId }, }); }, [environmentId, push, threadId]); diff --git a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx index 6e2c386667..6f62d85c01 100644 --- a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx +++ b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx @@ -1,7 +1,12 @@ import { DEFAULT_TERMINAL_ID, EnvironmentId, ThreadId } from "@t3tools/contracts"; import { type KnownTerminalSession } from "@t3tools/client-runtime/state/terminal"; import { SymbolView } from "expo-symbols"; -import { Stack, useLocalSearchParams, useRouter } from "../../navigation/router"; +import { + NativeHeaderToolbar, + NativeStackScreenOptions, + useRouteParams, + useAppNavigation, +} from "../../navigation/native-stack-header"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { Platform, Pressable, Text as RNText, View, useColorScheme } from "react-native"; import { @@ -198,7 +203,7 @@ function pickRunningTerminalSessionForBootstrap( } export function ThreadTerminalRouteScreen() { - const router = useRouter(); + const router = useAppNavigation(); const writeTerminal = useAtomCommand(terminalEnvironment.write, "terminal write"); const resizeTerminal = useAtomCommand(terminalEnvironment.resize, "terminal resize"); const clearTerminal = useAtomCommand(terminalEnvironment.clear, "terminal clear"); @@ -206,7 +211,7 @@ export function ThreadTerminalRouteScreen() { const appearanceScheme = useColorScheme() === "light" ? "light" : "dark"; const { state: workspaceState } = useWorkspaceState(); const { layout, panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout(); - const params = useLocalSearchParams<{ + const params = useRouteParams<{ environmentId?: string | string[]; threadId?: string | string[]; terminalId?: string | string[]; @@ -960,7 +965,7 @@ export function ThreadTerminalRouteScreen() { return ( <> - {layout.usesSplitView ? ( - - + - + ) : null} {isEnvironmentReady ? ( - - - + + + {getTerminalStatusLabel({ status: terminal.status, hasRunningSubprocess: terminal.hasRunningSubprocess, })} - - - Text size - + + Text size + - {`A- ${Math.max(MIN_TERMINAL_FONT_SIZE, fontSize - TERMINAL_FONT_SIZE_STEP).toFixed(1)} pt`} - - {`A- ${Math.max(MIN_TERMINAL_FONT_SIZE, fontSize - TERMINAL_FONT_SIZE_STEP).toFixed(1)} pt`} + + = MAX_TERMINAL_FONT_SIZE} discoverabilityLabel="Increase terminal text size" onPress={handleIncreaseFontSize} > - {`A+ ${Math.min(MAX_TERMINAL_FONT_SIZE, fontSize + TERMINAL_FONT_SIZE_STEP).toFixed(1)} pt`} - - + {`A+ ${Math.min(MAX_TERMINAL_FONT_SIZE, fontSize + TERMINAL_FONT_SIZE_STEP).toFixed(1)} pt`} + + {terminalMenuSessions.map((session) => ( - handleSelectTerminal(session.terminalId)} @@ -1036,18 +1041,18 @@ export function ThreadTerminalRouteScreen() { .filter(Boolean) .join(" · ")} > - {session.displayLabel} - + {session.displayLabel} + ))} - - Open new terminal - - - + Open new terminal + + + ) : null} diff --git a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx index 60a5cac162..53cb3f4cef 100644 --- a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx +++ b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx @@ -1,4 +1,4 @@ -import { Stack, useRouter } from "../../navigation/router"; +import { NativeStackScreenOptions, useAppNavigation } from "../../navigation/native-stack-header"; import { useCallback, useEffect, useMemo, useRef } from "react"; import { Alert, InteractionManager, View, useColorScheme } from "react-native"; import { KeyboardAvoidingView, useKeyboardState } from "react-native-keyboard-controller"; @@ -58,7 +58,7 @@ export function NewTaskDraftScreen(props: { const projects = useProjects(); const createProjectThread = useCreateProjectThread(); const flow = useNewTaskFlow(); - const router = useRouter(); + const router = useAppNavigation(); const insets = useSafeAreaInsets(); const colorScheme = useColorScheme(); const isKeyboardVisible = useKeyboardState((state) => state.isVisible); @@ -435,14 +435,14 @@ export function NewTaskDraftScreen(props: { if (!selectedProject) { return ( - + ); } return ( - + diff --git a/apps/mobile/src/features/threads/ThreadFeed.tsx b/apps/mobile/src/features/threads/ThreadFeed.tsx index 89a977e8d7..3b52ae3559 100644 --- a/apps/mobile/src/features/threads/ThreadFeed.tsx +++ b/apps/mobile/src/features/threads/ThreadFeed.tsx @@ -4,7 +4,7 @@ import { type LegendListRef } from "@legendapp/list/react-native"; import type { EnvironmentId, MessageId, ThreadId, TurnId } from "@t3tools/contracts"; import { CHAT_LIST_ANCHOR_OFFSET, resolveChatListAnchoredEndSpace } from "@t3tools/shared/chatList"; import { SymbolView } from "expo-symbols"; -import { useRouter } from "../../navigation/router"; +import { useAppNavigation } from "../../navigation/native-stack-header"; import { memo, useCallback, @@ -1125,7 +1125,7 @@ function ThreadFeedPlaceholder(props: { } export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { - const router = useRouter(); + const router = useAppNavigation(); const copyFeedbackTimeoutRef = useRef | null>(null); const foldSettleFrameRef = useRef(null); const foldSettleSecondFrameRef = useRef(null); diff --git a/apps/mobile/src/features/threads/ThreadGitControls.tsx b/apps/mobile/src/features/threads/ThreadGitControls.tsx index 022f55947a..ee34a4f3d9 100644 --- a/apps/mobile/src/features/threads/ThreadGitControls.tsx +++ b/apps/mobile/src/features/threads/ThreadGitControls.tsx @@ -10,8 +10,8 @@ import { requiresDefaultBranchConfirmation, resolveQuickAction, } from "@t3tools/client-runtime/state/vcs"; -import { useLocalSearchParams, useRouter } from "../../navigation/router"; -import Stack from "../../navigation/router"; +import { useRouteParams, useAppNavigation } from "../../navigation/native-stack-header"; +import { NativeHeaderToolbar } from "../../navigation/native-stack-header"; import { useCallback, useMemo } from "react"; import { Alert } from "react-native"; import { buildThreadFilesNavigation, buildThreadReviewRoutePath } from "../../lib/routes"; @@ -102,8 +102,8 @@ type ThreadGitControlsProps = { }; function useThreadGitControlModel(props: ThreadGitControlsProps) { - const router = useRouter(); - const { environmentId, threadId } = useLocalSearchParams<{ + const router = useAppNavigation(); + const { environmentId, threadId } = useRouteParams<{ environmentId: EnvironmentId; threadId: ThreadId; }>(); @@ -171,7 +171,7 @@ function useThreadGitControlModel(props: ThreadGitControlsProps) { requiresDefaultBranchConfirmation(input.action, isDefaultRef) ) { router.push({ - pathname: "/threads/[environmentId]/[threadId]/git-confirm", + name: "GitConfirm", params: { environmentId, threadId, @@ -222,7 +222,7 @@ function useThreadGitControlModel(props: ThreadGitControlsProps) { return; } router.push({ - pathname: "/threads/[environmentId]/[threadId]/git", + name: "GitOverview", params: { environmentId, threadId }, }); }, [environmentId, props.onOpenGitInspector, router, threadId]); @@ -417,9 +417,9 @@ export function ThreadGitControls(props: ThreadGitControlsProps) { } return ( - + {showActionControls && props.auxiliaryPaneControl ? ( - ) : null} {showActionControls ? ( - + {props.projectScripts.length > 0 ? ( props.projectScripts.map((script) => ( - void props.onRunProjectScript(script)} subtitle={script.command} > - {projectScriptMenuLabel(script)} - + + {projectScriptMenuLabel(script)} + + )) ) : ( - {}} subtitle="This project has no saved scripts yet" > - No project scripts - + No project scripts + )} {props.terminalSessions.map((session) => ( - props.onOpenTerminal(session.terminalId)} @@ -464,20 +470,20 @@ export function ThreadGitControls(props: ThreadGitControlsProps) { .filter(Boolean) .join(" · ")} > - {session.displayLabel} - + {session.displayLabel} + ))} - - Open new terminal - - + Open new terminal + + ) : null} {showActionControls && props.showDirectFileControl ? ( - ) : null} {showActionControls ? ( - - + {}} subtitle={compactMenuStatus(props.gitStatus)} > - + {compactMenuBranchLabel(model.currentBranchLabel)} - - - + + void model.runQuickAction()} subtitle={model.quickActionHint ?? undefined} > - {model.quickAction.label} - - {model.quickAction.label} + + - Review changes - - Review changes + + - Files - - Files + + - More - - + More + + ) : null} - + ); } diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx index 47642b3728..893beb57b4 100644 --- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx +++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx @@ -2,7 +2,7 @@ import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell import { LegendList } from "@legendapp/list/react-native"; import type { MenuAction } from "@react-native-menu/menu"; import { SymbolView } from "expo-symbols"; -import { useRouter } from "../../navigation/router"; +import { useAppNavigation } from "../../navigation/native-stack-header"; import { memo, useCallback, useMemo, useRef, useState, type ComponentProps } from "react"; import type { ColorValue, NativeScrollEvent, NativeSyntheticEvent } from "react-native"; import { Platform, Pressable, StyleSheet, TextInput, View, useColorScheme } from "react-native"; @@ -257,7 +257,7 @@ export function ThreadNavigationSidebar(props: { }) { const insets = useSafeAreaInsets(); const colorScheme = useColorScheme() === "dark" ? "dark" : "light"; - const router = useRouter(); + const router = useAppNavigation(); const projects = useProjects(); const threads = useThreadShells(); const { state: catalogState } = useWorkspaceState(); diff --git a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx index e8f5ba82d8..559874f956 100644 --- a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx @@ -1,4 +1,9 @@ -import { Stack, useFocusEffect, useLocalSearchParams, useRouter } from "../../navigation/router"; +import { + NativeStackScreenOptions, + useFocusEffect, + useRouteParams, + useAppNavigation, +} from "../../navigation/native-stack-header"; import { useCallback, useEffect, @@ -153,7 +158,7 @@ export function ThreadRouteScreen(props: ThreadRouteScreenProps = {}) { const { state: workspaceState } = useWorkspaceState(); const { connectionState } = useRemoteConnectionStatus(); const { selectedThread } = useThreadSelection(); - const params = useLocalSearchParams<{ + const params = useRouteParams<{ environmentId?: string | string[]; threadId?: string | string[]; }>(); @@ -268,8 +273,8 @@ function ThreadRouteContent( const gitActions = useSelectedThreadGitActions(); const requests = useSelectedThreadRequests(); const interruptThreadTurn = useAtomCommand(threadEnvironment.interruptTurn, "thread interrupt"); - const router = useRouter(); - const params = useLocalSearchParams<{ + const router = useAppNavigation(); + const params = useRouteParams<{ environmentId?: string | string[]; threadId?: string | string[]; }>(); @@ -808,7 +813,7 @@ function ThreadRouteContent( return ( <> {activeInspectorRenderer ? : null} - + {activeInspectorRenderer ? : null} - {layout.usesSplitView || usesNativeHeaderGlass ? null : ( - + - + )} {renderThreadRouteBody(!layout.usesSplitView)} diff --git a/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx b/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx index da62cf856c..aed634b8d4 100644 --- a/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx +++ b/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx @@ -1,5 +1,5 @@ import { sanitizeFeatureBranchName } from "@t3tools/shared/git"; -import { useRouter } from "../../../navigation/router"; +import { useAppNavigation } from "../../../navigation/native-stack-header"; import { useState } from "react"; import { Pressable, ScrollView, View } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; @@ -15,7 +15,7 @@ import { vcsEnvironment } from "../../../state/vcs"; import { SheetActionButton } from "./gitSheetComponents"; export function GitBranchesSheet() { - const router = useRouter(); + const router = useAppNavigation(); const insets = useSafeAreaInsets(); const { selectedThread } = useThreadSelection(); const { selectedThreadCwd, selectedThreadWorktreePath } = useSelectedThreadWorktree(); diff --git a/apps/mobile/src/features/threads/git/GitCommitSheet.tsx b/apps/mobile/src/features/threads/git/GitCommitSheet.tsx index 5f9dd278b7..db0784ad4f 100644 --- a/apps/mobile/src/features/threads/git/GitCommitSheet.tsx +++ b/apps/mobile/src/features/threads/git/GitCommitSheet.tsx @@ -1,4 +1,4 @@ -import { useRouter } from "../../../navigation/router"; +import { useAppNavigation } from "../../../navigation/native-stack-header"; import { useCallback, useState } from "react"; import { Pressable, ScrollView, View, useColorScheme } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; @@ -14,7 +14,7 @@ import { vcsEnvironment } from "../../../state/vcs"; import { SheetActionButton } from "./gitSheetComponents"; export function GitCommitSheet() { - const router = useRouter(); + const router = useAppNavigation(); const insets = useSafeAreaInsets(); const isDarkMode = useColorScheme() === "dark"; const { selectedThread } = useThreadSelection(); diff --git a/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx b/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx index bc0021cc9e..e240d8c060 100644 --- a/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx +++ b/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx @@ -2,7 +2,7 @@ import { resolveDefaultBranchActionDialogCopy } from "@t3tools/client-runtime/st import { resolveAutoFeatureBranchName } from "@t3tools/shared/git"; import * as Arr from "effect/Array"; import * as Result from "effect/Result"; -import { useLocalSearchParams, useRouter } from "../../../navigation/router"; +import { useRouteParams, useAppNavigation } from "../../../navigation/native-stack-header"; import { useCallback, useMemo } from "react"; import { View } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; @@ -13,12 +13,12 @@ import { useSelectedThreadGitState } from "../../../state/use-selected-thread-gi import { SheetActionButton } from "./gitSheetComponents"; export function GitConfirmSheet() { - const router = useRouter(); + const router = useAppNavigation(); const insets = useSafeAreaInsets(); const gitState = useSelectedThreadGitState(); const gitActions = useSelectedThreadGitActions(); - const params = useLocalSearchParams<{ + const params = useRouteParams<{ confirmAction?: string; branchName?: string; includesCommit?: string; diff --git a/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx b/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx index c246c9b302..20e04b54df 100644 --- a/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx +++ b/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx @@ -5,7 +5,7 @@ import { requiresDefaultBranchConfirmation, } from "@t3tools/client-runtime/state/vcs"; import type { EnvironmentId, ThreadId } from "@t3tools/contracts"; -import { useLocalSearchParams, useRouter } from "../../../navigation/router"; +import { useRouteParams, useAppNavigation } from "../../../navigation/native-stack-header"; import { SymbolView } from "expo-symbols"; import { useCallback, useEffect, useMemo, type ComponentProps } from "react"; import { Alert, Platform, Pressable, ScrollView, View } from "react-native"; @@ -33,11 +33,11 @@ export function GitOverviewSheet( readonly presentation?: "sheet" | "inspector"; } = {}, ) { - const router = useRouter(); + const router = useAppNavigation(); const insets = useSafeAreaInsets(); const presentation = props.presentation ?? "sheet"; const isInspector = presentation === "inspector"; - const { environmentId, threadId } = useLocalSearchParams<{ + const { environmentId, threadId } = useRouteParams<{ environmentId: EnvironmentId; threadId: ThreadId; }>(); @@ -120,7 +120,7 @@ export function GitOverviewSheet( requiresDefaultBranchConfirmation(input.action, isDefaultRef) ) { router.push({ - pathname: "/threads/[environmentId]/[threadId]/git-confirm", + name: "GitConfirm", params: { environmentId, threadId, @@ -151,7 +151,7 @@ export function GitOverviewSheet( } if (item.dialogAction === "commit") { router.push({ - pathname: "/threads/[environmentId]/[threadId]/git/commit", + name: "GitCommit", params: { environmentId, threadId }, }); return; @@ -248,7 +248,7 @@ export function GitOverviewSheet( disabled={busy || !isRepo} onPress={() => router.push({ - pathname: "/threads/[environmentId]/[threadId]/git/branches", + name: "GitBranches", params: { environmentId, threadId }, }) } diff --git a/apps/mobile/src/lib/routes.test.ts b/apps/mobile/src/lib/routes.test.ts index 773de9d84f..dffe212457 100644 --- a/apps/mobile/src/lib/routes.test.ts +++ b/apps/mobile/src/lib/routes.test.ts @@ -23,7 +23,7 @@ describe("thread file routes", () => { it("builds typed navigation params for a file and source line", () => { expect(buildThreadFilesNavigation(thread, "src/main.ts", 42)).toEqual({ - pathname: "/threads/[environmentId]/[threadId]/files/[...path]", + name: "ThreadFile", params: { environmentId: "environment-1", threadId: "thread-1", @@ -35,7 +35,7 @@ describe("thread file routes", () => { it("targets the files index when no file path is provided", () => { expect(buildThreadFilesNavigation(thread)).toEqual({ - pathname: "/threads/[environmentId]/[threadId]/files", + name: "ThreadFiles", params: { environmentId: "environment-1", threadId: "thread-1", diff --git a/apps/mobile/src/lib/routes.ts b/apps/mobile/src/lib/routes.ts index a0ac64e68a..2cd9f243f1 100644 --- a/apps/mobile/src/lib/routes.ts +++ b/apps/mobile/src/lib/routes.ts @@ -1,10 +1,11 @@ -import type { Href, useRouter } from "../navigation/router"; import { type EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell"; import type { EnvironmentId, ThreadId } from "@t3tools/contracts"; +import type { AppNavigation } from "../navigation/app-navigation"; +import type { AppNavigationTarget } from "../navigation/route-model"; import type { SelectedThreadRef } from "../state/remote-runtime-types"; -type Router = ReturnType; +type Router = AppNavigation; type ThreadRouteInput = | Pick @@ -65,15 +66,10 @@ export function buildThreadTerminalRoutePath( return `${basePath}?terminalId=${encodeURIComponent(terminalId)}`; } -/** - * Prefer this over {@link buildThreadTerminalRoutePath} with `router.push(string)` — Expo Router - * often does not merge query strings into `useLocalSearchParams`, which breaks terminal bootstrap - * (`requestedTerminalId` stays null while the UI assumes `default`). - */ export function buildThreadTerminalNavigation( input: ThreadRouteInput | PlainThreadRouteInput, terminalId?: string | null, -): Href { +): AppNavigationTarget { const environmentId = String(input.environmentId); const threadId = String("threadId" in input ? input.threadId : input.id); @@ -87,7 +83,7 @@ export function buildThreadTerminalNavigation( } return { - pathname: "/threads/[environmentId]/[threadId]/terminal", + name: "ThreadTerminal", params, }; } @@ -96,14 +92,14 @@ export function buildThreadFilesNavigation( input: ThreadRouteInput | PlainThreadRouteInput, relativePath?: string | null, line?: number | null, -): Href { +): AppNavigationTarget { const environmentId = String(input.environmentId); const threadId = String("threadId" in input ? input.threadId : input.id); const path = relativePath?.split("/").filter((segment) => segment.length > 0) ?? []; if (path.length === 0) { return { - pathname: "/threads/[environmentId]/[threadId]/files", + name: "ThreadFiles", params: { environmentId, threadId }, }; } @@ -119,7 +115,7 @@ export function buildThreadFilesNavigation( } return { - pathname: "/threads/[environmentId]/[threadId]/files/[...path]", + name: "ThreadFile", params, }; } diff --git a/apps/mobile/src/navigation/RootNavigator.tsx b/apps/mobile/src/navigation/RootNavigator.tsx new file mode 100644 index 0000000000..484275d7f0 --- /dev/null +++ b/apps/mobile/src/navigation/RootNavigator.tsx @@ -0,0 +1,405 @@ +import { createNativeStackNavigator } from "@react-navigation/native-stack"; +import { useCallback, type ReactNode } from "react"; +import { StatusBar, useColorScheme, useWindowDimensions } from "react-native"; +import { useResolveClassNames } from "uniwind"; + +import { ArchivedThreadsRouteScreen } from "../features/archive/ArchivedThreadsRouteScreen"; +import { useAgentNotificationNavigation } from "../features/agent-awareness/notificationNavigation"; +import { + ClerkSettingsSheetDetentProvider, + useClerkSettingsSheetDetent, +} from "../features/cloud/ClerkSettingsSheetDetent"; +import { + AdaptiveWorkspaceLayout, + useAdaptiveWorkspaceLayout, +} from "../features/layout/AdaptiveWorkspaceLayout"; +import { ThreadFilesTreeScreen, ThreadFileScreen } from "../features/files/ThreadFilesRouteScreen"; +import { HardwareKeyboardCommandProvider } from "../features/keyboard/HardwareKeyboardCommandProvider"; +import { ReviewCommentComposerSheet } from "../features/review/ReviewCommentComposerSheet"; +import { ReviewHighlighterProvider } from "../features/review/ReviewHighlighterProvider"; +import { ReviewSheet } from "../features/review/ReviewSheet"; +import { ThreadTerminalRouteScreen } from "../features/terminal/ThreadTerminalRouteScreen"; +import { ThreadRouteScreen } from "../features/threads/ThreadRouteScreen"; +import { GitBranchesSheet } from "../features/threads/git/GitBranchesSheet"; +import { GitCommitSheet } from "../features/threads/git/GitCommitSheet"; +import { GitConfirmSheet } from "../features/threads/git/GitConfirmSheet"; +import { GitOverviewSheet } from "../features/threads/git/GitOverviewSheet"; +import { deriveStableFormSheetDetent } from "../lib/layout"; +import { useThemeColor } from "../lib/useThemeColor"; +import NotFoundRoute from "../screens/+not-found"; +import ConnectionsRouteScreen from "../screens/connections"; +import ConnectionsNewRouteScreen from "../screens/connections/new"; +import RnsGlassDebugRoute from "../screens/debug/rns-glass"; +import HomeRouteScreen from "../screens"; +import AddProjectRoute from "../screens/new/add-project"; +import AddProjectDestinationRoute from "../screens/new/add-project/destination"; +import AddProjectLocalRoute from "../screens/new/add-project/local"; +import AddProjectRepositoryRoute from "../screens/new/add-project/repository"; +import NewTaskDraftRoute from "../screens/new/draft"; +import NewTaskRoute from "../screens/new"; +import SettingsAuthRouteScreen from "../screens/settings/auth"; +import SettingsEnvironmentsRouteScreen from "../screens/settings/environments"; +import SettingsRouteScreen from "../screens/settings"; +import SettingsWaitlistRouteScreen from "../screens/settings/waitlist"; +import { ThreadSelectionProvider } from "../state/use-thread-selection"; +import { useThreadOutboxDrain } from "../state/use-thread-outbox-drain"; +import { useCurrentPathname } from "./app-navigation"; +import type { AppStackParamList } from "./route-model"; + +const RootStack = createNativeStackNavigator(); + +function ThreadSelectionRoute(props: { readonly children: ReactNode }) { + return {props.children}; +} + +function ThreadRoute() { + return ( + + + + ); +} + +function ThreadTerminalRoute() { + return ( + + + + ); +} + +function ThreadFilesRoute() { + return ( + + + + ); +} + +function ThreadFileRoute() { + return ( + + + + ); +} + +function ThreadReviewRoute() { + return ( + + + + + + ); +} + +function ThreadReviewCommentRoute() { + return ( + + + + ); +} + +function GitOverviewRoute() { + return ( + + + + ); +} + +function GitCommitRoute() { + return ( + + + + ); +} + +function GitBranchesRoute() { + return ( + + + + ); +} + +function GitConfirmRoute() { + return ( + + + + ); +} + +export function RootNavigator() { + const pathname = useCurrentPathname(); + const expandedSettingsRouteIsActive = + pathname === "/settings/archive" || pathname === "/settings/auth"; + + return ( + + + + + + ); +} + +function RootNavigatorContent() { + const pathname = useCurrentPathname(); + const isDebugRoute = pathname.startsWith("/debug/"); + + if (isDebugRoute) { + return ; + } + + return ; +} + +function DebugNavigatorHost() { + return ( + <> + + + + + + + + ); +} + +function WorkspaceNavigatorHost() { + const colorScheme = useColorScheme(); + const statusBarBg = useThemeColor("--color-status-bar"); + useAgentNotificationNavigation(); + useThreadOutboxDrain(); + + return ( + <> + + + + + + ); +} + +function WorkspaceNavigator() { + const { collapse, isExpanded } = useClerkSettingsSheetDetent(); + const { layout } = useAdaptiveWorkspaceLayout(); + const { height } = useWindowDimensions(); + const sheetStyle = useResolveClassNames("bg-sheet"); + + const handleSettingsTransitionEnd = useCallback( + (event: { data: { closing: boolean } }) => { + if (event.data.closing) { + collapse(); + } + }, + [collapse], + ); + + const connectionSheetScreenOptions = { + contentStyle: sheetStyle, + gestureEnabled: true, + headerShown: false, + presentation: "formSheet" as const, + sheetAllowedDetents: [0.55, 0.7], + sheetGrabberVisible: true, + }; + const settingsScreenOptions = layout.usesSplitView + ? { + animation: "none" as const, + contentStyle: sheetStyle, + gestureEnabled: false, + headerShown: false, + presentation: "card" as const, + } + : { + ...connectionSheetScreenOptions, + sheetAllowedDetents: isExpanded ? [0.92] : [0.7], + }; + const newTaskScreenOptions = { + contentStyle: sheetStyle, + gestureEnabled: true, + headerShown: false, + presentation: "formSheet" as const, + sheetAllowedDetents: [layout.usesSplitView ? deriveStableFormSheetDetent(height) : 0.92], + sheetGrabberVisible: !layout.usesSplitView, + }; + + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/apps/mobile/src/navigation/app-navigation.tsx b/apps/mobile/src/navigation/app-navigation.tsx new file mode 100644 index 0000000000..6bc4a7e2d5 --- /dev/null +++ b/apps/mobile/src/navigation/app-navigation.tsx @@ -0,0 +1,176 @@ +import { + CommonActions, + NavigationContainer, + StackActions, + type NavigationContainerRef, +} from "@react-navigation/native"; +import { createContext, use, useCallback, useMemo, useRef, useState, type ReactNode } from "react"; + +import { appLinking } from "./linking"; +import { + buildPathFromRoute, + getFocusedRoute, + resolveNavigationTarget, + type AppFocusedRoute, + type AppHref, + type AppStackParamList, + type RouteParams, +} from "./route-model"; + +export type AppNavigation = { + readonly push: (href: AppHref) => void; + readonly replace: (href: AppHref) => void; + readonly back: () => void; + readonly dismiss: () => void; + readonly dismissAll: () => void; + readonly canGoBack: () => boolean; + readonly setParams: (params: RouteParams) => void; +}; + +type AppNavigationContextValue = { + readonly navigationRef: React.RefObject | null>; + readonly pathname: string; + readonly params: RouteParams; + readonly navigation: AppNavigation; +}; + +export const AppNavigationContext = createContext(null); + +export function useAppNavigation(): AppNavigation { + const context = use(AppNavigationContext); + if (context === null) { + throw new Error("useAppNavigation must be used within AppNavigationProvider"); + } + return context.navigation; +} + +export function useCurrentPathname(): string { + const context = use(AppNavigationContext); + if (context === null) { + throw new Error("useCurrentPathname must be used within AppNavigationProvider"); + } + return context.pathname; +} + +export function useCurrentRouteParams(): T { + const context = use(AppNavigationContext); + if (context === null) { + throw new Error("useCurrentRouteParams must be used within AppNavigationProvider"); + } + return context.params as T; +} + +export function createAppNavigation( + navigationRef: React.RefObject | null>, +): AppNavigation { + const navigateWithAction = (href: AppHref, action: "push" | "replace" | "navigate"): void => { + const target = resolveNavigationTarget(href); + const navigation = navigationRef.current; + if (!navigation) { + return; + } + + if (action === "push") { + navigation.dispatch(StackActions.push(target.name, target.params)); + return; + } + if (action === "replace") { + navigation.dispatch(StackActions.replace(target.name, target.params)); + return; + } + navigation.dispatch( + CommonActions.navigate({ + name: target.name, + params: target.params, + }), + ); + }; + + return { + push: (href) => navigateWithAction(href, "push"), + replace: (href) => navigateWithAction(href, "replace"), + back: () => { + const navigation = navigationRef.current; + if (!navigation) return; + if (navigation.canGoBack()) { + navigation.goBack(); + return; + } + navigation.dispatch(StackActions.replace("Home")); + }, + dismiss: () => { + const navigation = navigationRef.current; + if (!navigation) return; + if (navigation.canGoBack()) { + navigation.goBack(); + return; + } + navigation.dispatch(StackActions.replace("Home")); + }, + dismissAll: () => { + const navigation = navigationRef.current; + if (!navigation) return; + navigation.dispatch( + CommonActions.reset({ + index: 0, + routes: [{ name: "Home" }], + }), + ); + }, + canGoBack: () => navigationRef.current?.canGoBack() ?? false, + setParams: (params) => { + navigationRef.current?.dispatch(CommonActions.setParams(params)); + }, + }; +} + +export function AppNavigationProvider(props: { readonly children: ReactNode }) { + const navigationRef = useRef>(null); + const [pathname, setPathname] = useState("/"); + const [params, setParams] = useState({}); + const navigation = useMemo(() => createAppNavigation(navigationRef), []); + const contextValue = useMemo( + () => ({ + navigationRef, + pathname, + params, + navigation, + }), + [navigation, params, pathname], + ); + const syncState = useCallback(() => { + const route = getFocusedRoute(navigationRef.current?.getRootState()); + if (!route) { + setPathname("/"); + setParams({}); + return; + } + + const current = pathAndParamsFromCurrentRoute(route); + setPathname(current.pathname); + setParams(current.params); + }, []); + + return ( + + + {props.children} + + + ); +} + +export function pathAndParamsFromCurrentRoute(route: AppFocusedRoute): { + readonly pathname: string; + readonly params: RouteParams; +} { + return { + pathname: buildPathFromRoute(route), + params: (route.params ?? {}) as RouteParams, + }; +} diff --git a/apps/mobile/src/navigation/linking.ts b/apps/mobile/src/navigation/linking.ts new file mode 100644 index 0000000000..55ecafd7cf --- /dev/null +++ b/apps/mobile/src/navigation/linking.ts @@ -0,0 +1,39 @@ +import type { LinkingOptions } from "@react-navigation/native"; +import * as Linking from "expo-linking"; + +import type { AppStackParamList } from "./route-model"; + +export const appLinking: LinkingOptions = { + prefixes: [Linking.createURL("/"), "t3code://", "t3code-dev://", "t3code-preview://"], + config: { + screens: { + Home: "", + DebugRnsGlass: "debug/rns-glass", + Settings: "settings", + SettingsEnvironments: "settings/environments", + SettingsEnvironmentNew: "settings/environment-new", + SettingsArchive: "settings/archive", + SettingsAuth: "settings/auth", + SettingsWaitlist: "settings/waitlist", + Connections: "connections", + ConnectionsNew: "connections/new", + NewTask: "new", + AddProject: "new/add-project", + AddProjectRepository: "new/add-project/repository", + AddProjectDestination: "new/add-project/destination", + AddProjectLocal: "new/add-project/local", + NewTaskDraft: "new/draft", + Thread: "threads/:environmentId/:threadId", + ThreadTerminal: "threads/:environmentId/:threadId/terminal", + ThreadReview: "threads/:environmentId/:threadId/review", + ThreadReviewComment: "threads/:environmentId/:threadId/review-comment", + ThreadFiles: "threads/:environmentId/:threadId/files", + ThreadFile: "threads/:environmentId/:threadId/files/:path*", + GitOverview: "threads/:environmentId/:threadId/git", + GitCommit: "threads/:environmentId/:threadId/git/commit", + GitBranches: "threads/:environmentId/:threadId/git/branches", + GitConfirm: "threads/:environmentId/:threadId/git-confirm", + NotFound: "*", + }, + }, +}; diff --git a/apps/mobile/src/navigation/router.tsx b/apps/mobile/src/navigation/native-stack-header.tsx similarity index 59% rename from apps/mobile/src/navigation/router.tsx rename to apps/mobile/src/navigation/native-stack-header.tsx index f97e534466..611d6ec1c2 100644 --- a/apps/mobile/src/navigation/router.tsx +++ b/apps/mobile/src/navigation/native-stack-header.tsx @@ -1,13 +1,9 @@ import { - CommonActions, - StackActions, useFocusEffect, useNavigation, useRoute, - type NavigationContainerRef, type ParamListBase, } from "@react-navigation/native"; -import type { ColorValue } from "react-native"; import type { NativeStackHeaderItem, NativeStackHeaderItemMenu, @@ -17,29 +13,24 @@ import type { import { Children, cloneElement, - createContext, createElement, Fragment, isValidElement, - use, useEffect, useMemo, type ReactElement, type ReactNode, } from "react"; +import type { ColorValue } from "react-native"; -import { - buildPathFromRoute, - resolveNavigationTarget, - type AppHref, - type AppStackParamList, - type AppFocusedRoute, - type RouteParams, -} from "./route-model"; +import { useAppNavigation } from "./app-navigation"; +import type { AppHref, RouteParams } from "./route-model"; export { useFocusEffect }; -export type Href = AppHref; -type CompatNativeStackNavigationOptions = Omit< +export { useAppNavigation, useCurrentPathname, useCurrentRouteParams } from "./app-navigation"; +export type { AppHref }; + +export type AppNativeStackNavigationOptions = Omit< NativeStackNavigationOptions, "headerTintColor" | "unstable_headerLeftItems" | "unstable_headerRightItems" > & { @@ -52,133 +43,11 @@ type CompatNativeStackNavigationOptions = Omit< readonly unstable_navigationItemStyle?: unknown; }; -export type { CompatNativeStackNavigationOptions as NativeStackNavigationOptions }; - -type RouterLike = { - readonly push: (href: AppHref) => void; - readonly replace: (href: AppHref) => void; - readonly back: () => void; - readonly dismiss: () => void; - readonly dismissAll: () => void; - readonly canGoBack: () => boolean; - readonly setParams: (params: RouteParams) => void; -}; - -type NavigationContextValue = { - readonly navigationRef: React.RefObject | null>; - readonly pathname: string; - readonly params: RouteParams; - readonly router: RouterLike; -}; - -export const AppNavigationContext = createContext(null); - -export function useRouter(): RouterLike { - const context = use(AppNavigationContext); - if (context === null) { - throw new Error("useRouter must be used within AppNavigationProvider"); - } - return context.router; -} - -export function usePathname(): string { - const context = use(AppNavigationContext); - if (context === null) { - throw new Error("usePathname must be used within AppNavigationProvider"); - } - return context.pathname; -} - -export function useLocalSearchParams(): T { +export function useRouteParams(): T { const route = useRoute(); return (route.params ?? {}) as RouteParams as T; } -export function useGlobalSearchParams(): T { - const context = use(AppNavigationContext); - if (context === null) { - throw new Error("useGlobalSearchParams must be used within AppNavigationProvider"); - } - return context.params as T; -} - -export function createRouter( - navigationRef: React.RefObject | null>, -): RouterLike { - const navigateWithAction = (href: AppHref, action: "push" | "replace" | "navigate"): void => { - const target = resolveNavigationTarget(href); - const navigation = navigationRef.current; - if (!navigation) { - return; - } - - if (action === "push") { - navigation.dispatch(StackActions.push(target.name, target.params)); - return; - } - if (action === "replace") { - navigation.dispatch(StackActions.replace(target.name, target.params)); - return; - } - navigation.dispatch( - CommonActions.navigate({ - name: target.name, - params: target.params, - }), - ); - }; - - return { - push: (href) => navigateWithAction(href, "push"), - replace: (href) => navigateWithAction(href, "replace"), - back: () => { - const navigation = navigationRef.current; - if (!navigation) return; - if (navigation.canGoBack()) { - navigation.goBack(); - return; - } - navigation.dispatch(StackActions.replace("Home")); - }, - dismiss: () => { - const navigation = navigationRef.current; - if (!navigation) return; - if (navigation.canGoBack()) { - navigation.goBack(); - return; - } - navigation.dispatch(StackActions.replace("Home")); - }, - dismissAll: () => { - const navigation = navigationRef.current; - if (!navigation) return; - navigation.dispatch( - CommonActions.reset({ - index: 0, - routes: [{ name: "Home" }], - }), - ); - }, - canGoBack: () => navigationRef.current?.canGoBack() ?? false, - setParams: (params) => { - navigationRef.current?.dispatch(CommonActions.setParams(params)); - }, - }; -} - -export function deriveNavigationContextValue(input: { - readonly navigationRef: React.RefObject | null>; - readonly pathname: string; - readonly params: RouteParams; -}): NavigationContextValue { - return { - navigationRef: input.navigationRef, - pathname: input.pathname, - params: input.params, - router: createRouter(input.navigationRef), - }; -} - function useNativeStackNavigation(): NativeStackNavigationProp | null { try { return useNavigation>(); @@ -188,7 +57,7 @@ function useNativeStackNavigation(): NativeStackNavigationProp | } function normalizeScreenOptions( - options: CompatNativeStackNavigationOptions | undefined, + options: AppNativeStackNavigationOptions | undefined, ): NativeStackNavigationOptions | undefined { if (!options) { return options; @@ -213,8 +82,8 @@ function normalizeScreenOptions( return normalized as NativeStackNavigationOptions; } -function StackScreen(props: { - readonly options?: CompatNativeStackNavigationOptions; +export function NativeStackScreenOptions(props: { + readonly options?: AppNativeStackNavigationOptions; readonly listeners?: Record void>; readonly name?: string; }) { @@ -282,7 +151,7 @@ function convertMenuAction( element: ReactElement, ): NativeStackHeaderItemMenu["menu"]["items"][number] | null { const typeName = elementTypeName(element); - if (typeName === "ToolbarMenuAction") { + if (typeName === "NativeHeaderToolbarMenuAction") { const label = labelFromChildren(element.props.children); return { type: "action", @@ -303,7 +172,7 @@ function convertMenuAction( }; } - if (typeName === "ToolbarMenu") { + if (typeName === "NativeHeaderToolbarMenu") { return { type: "submenu", label: @@ -341,7 +210,7 @@ function convertToolbarChild(child: ReactNode): NativeStackHeaderItem | null { } const typeName = elementTypeName(child); - if (typeName === "ToolbarButton") { + if (typeName === "NativeHeaderToolbarButton") { return { type: "button", label: "", @@ -360,7 +229,7 @@ function convertToolbarChild(child: ReactNode): NativeStackHeaderItem | null { }; } - if (typeName === "ToolbarMenu") { + if (typeName === "NativeHeaderToolbarMenu") { return { type: "menu", label: typeof child.props.title === "string" ? child.props.title : "", @@ -379,7 +248,7 @@ function convertToolbarChild(child: ReactNode): NativeStackHeaderItem | null { }; } - if (typeName === "ToolbarSpacer") { + if (typeName === "NativeHeaderToolbarSpacer") { return { type: "spacing", spacing: typeof child.props.width === "number" ? child.props.width : 8, @@ -400,7 +269,7 @@ function collectToolbarItems(children: ReactNode): NativeStackHeaderItem[] { return items; } -function Toolbar(props: { +function NativeHeaderToolbarRoot(props: { readonly placement?: "left" | "right" | "bottom"; readonly children?: ReactNode; }) { @@ -421,7 +290,7 @@ function Toolbar(props: { return null; } -function ToolbarButton(_props: { +function NativeHeaderToolbarButton(_props: { readonly accessibilityLabel?: string; readonly disabled?: boolean; readonly icon?: string; @@ -430,9 +299,9 @@ function ToolbarButton(_props: { }) { return null; } -ToolbarButton.displayName = "ToolbarButton"; +NativeHeaderToolbarButton.displayName = "NativeHeaderToolbarButton"; -function ToolbarMenu(_props: { +function NativeHeaderToolbarMenu(_props: { readonly accessibilityLabel?: string; readonly children?: ReactNode; readonly disabled?: boolean; @@ -443,9 +312,9 @@ function ToolbarMenu(_props: { }) { return null; } -ToolbarMenu.displayName = "ToolbarMenu"; +NativeHeaderToolbarMenu.displayName = "NativeHeaderToolbarMenu"; -function ToolbarMenuAction(_props: { +function NativeHeaderToolbarMenuAction(_props: { readonly children?: ReactNode; readonly destructive?: boolean; readonly disabled?: boolean; @@ -457,80 +326,70 @@ function ToolbarMenuAction(_props: { }) { return null; } -ToolbarMenuAction.displayName = "ToolbarMenuAction"; +NativeHeaderToolbarMenuAction.displayName = "NativeHeaderToolbarMenuAction"; -function ToolbarLabel(_props: { readonly children?: ReactNode }) { +function NativeHeaderToolbarLabel(_props: { readonly children?: ReactNode }) { return null; } -ToolbarLabel.displayName = "ToolbarLabel"; +NativeHeaderToolbarLabel.displayName = "NativeHeaderToolbarLabel"; -function ToolbarSpacer(_props: { readonly sharesBackground?: boolean; readonly width?: number }) { +function NativeHeaderToolbarSpacer(_props: { + readonly sharesBackground?: boolean; + readonly width?: number; +}) { return null; } -ToolbarSpacer.displayName = "ToolbarSpacer"; +NativeHeaderToolbarSpacer.displayName = "NativeHeaderToolbarSpacer"; -function ToolbarSearchBarSlot() { +function NativeHeaderToolbarSearchBarSlot() { return null; } -ToolbarSearchBarSlot.displayName = "ToolbarSearchBarSlot"; +NativeHeaderToolbarSearchBarSlot.displayName = "NativeHeaderToolbarSearchBarSlot"; -function StackScreenTitle(_props: { readonly asChild?: boolean; readonly children?: ReactNode }) { +export const NativeHeaderToolbar = Object.assign(NativeHeaderToolbarRoot, { + Button: NativeHeaderToolbarButton, + Label: NativeHeaderToolbarLabel, + Menu: Object.assign(NativeHeaderToolbarMenu, { + Action: NativeHeaderToolbarMenuAction, + }), + MenuAction: NativeHeaderToolbarMenuAction, + SearchBarSlot: NativeHeaderToolbarSearchBarSlot, + Spacer: NativeHeaderToolbarSpacer, +}); + +function NativeStackScreenTitle(_props: { + readonly asChild?: boolean; + readonly children?: ReactNode; +}) { return null; } -StackScreen.Title = StackScreenTitle; +NativeStackScreenOptions.Title = NativeStackScreenTitle; -export const Stack = Object.assign( - function StackCompat(props: { readonly children?: ReactNode }) { - return createElement(Fragment, null, props.children); - }, - { - Screen: StackScreen, - Toolbar: Object.assign(Toolbar, { - Button: ToolbarButton, - Label: ToolbarLabel, - Menu: Object.assign(ToolbarMenu, { - Action: ToolbarMenuAction, - }), - MenuAction: ToolbarMenuAction, - SearchBarSlot: ToolbarSearchBarSlot, - Spacer: ToolbarSpacer, - }), - }, -); - -export default Stack; - -export function Redirect(props: { readonly href: AppHref }) { - const router = useRouter(); +export function NavigateTo(props: { readonly href: AppHref }) { + const navigation = useAppNavigation(); useEffect(() => { - router.replace(props.href); - }, [props.href, router]); + navigation.replace(props.href); + }, [navigation, props.href]); return null; } -export function Link(props: { +export function NavigationLink(props: { readonly href: AppHref; readonly asChild?: boolean; readonly children?: ReactNode; }) { - const router = useRouter(); + const navigation = useAppNavigation(); if (props.asChild && isValidElement<{ onPress?: () => void }>(props.children)) { return cloneElement(props.children, { - onPress: () => router.push(props.href), + onPress: () => navigation.push(props.href), }); } return null; } -export function pathAndParamsFromCurrentRoute(route: { - readonly name: string; - readonly params?: object; -}): { readonly pathname: string; readonly params: RouteParams } { - return { - pathname: buildPathFromRoute(route as AppFocusedRoute), - params: (route.params ?? {}) as RouteParams, - }; -} - -export type Router = RouterLike; +export const NativeStackFragment = function NativeStackFragment(props: { + readonly children?: ReactNode; +}) { + return createElement(Fragment, null, props.children); +}; diff --git a/apps/mobile/src/navigation/route-model.ts b/apps/mobile/src/navigation/route-model.ts index 3da7df1764..e11e741e20 100644 --- a/apps/mobile/src/navigation/route-model.ts +++ b/apps/mobile/src/navigation/route-model.ts @@ -63,6 +63,7 @@ export type AppStackParamList = { export type AppHref = | string + | AppNavigationTarget | { readonly pathname: string; readonly params?: RouteParams; @@ -148,6 +149,9 @@ function mergeParams( export function resolveNavigationTarget(href: AppHref): AppNavigationTarget { if (typeof href !== "string") { + if ("name" in href) { + return withParams(href.name, href.params); + } return resolveNavigationObject(href.pathname, href.params); } diff --git a/apps/mobile/src/screens/+not-found.tsx b/apps/mobile/src/screens/+not-found.tsx index 94e24a7857..3d9f502e55 100644 --- a/apps/mobile/src/screens/+not-found.tsx +++ b/apps/mobile/src/screens/+not-found.tsx @@ -1,4 +1,4 @@ -import { Link } from "../navigation/router"; +import { NavigationLink } from "../navigation/native-stack-header"; import { Pressable, ScrollView, StyleSheet } from "react-native"; import { useResolveClassNames } from "uniwind"; @@ -32,11 +32,11 @@ export default function NotFoundRoute() { Route not found - + Return home - + ); } diff --git a/apps/mobile/src/screens/connections/index.tsx b/apps/mobile/src/screens/connections/index.tsx index d6f5f7b282..e459a141cc 100644 --- a/apps/mobile/src/screens/connections/index.tsx +++ b/apps/mobile/src/screens/connections/index.tsx @@ -1,4 +1,8 @@ -import { Stack, useRouter } from "../../navigation/router"; +import { + NativeHeaderToolbar, + NativeStackScreenOptions, + useAppNavigation, +} from "../../navigation/native-stack-header"; import { SymbolView } from "expo-symbols"; import type { EnvironmentId } from "@t3tools/contracts"; import { useCallback, useState } from "react"; @@ -18,7 +22,7 @@ export default function ConnectionsRouteScreen() { onRemoveEnvironmentPress, onUpdateEnvironment, } = useRemoteConnections(); - const router = useRouter(); + const router = useAppNavigation(); const insets = useSafeAreaInsets(); const hasEnvironments = connectedEnvironments.length > 0; const [expandedId, setExpandedId] = useState(null); @@ -31,18 +35,18 @@ export default function ConnectionsRouteScreen() { return ( - - - + router.push("/connections/new")} separateBackground /> - + (); + const router = useAppNavigation(); + const params = useRouteParams<{ mode?: string }>(); const insets = useSafeAreaInsets(); const [hostInput, setHostInput] = useState(""); const [codeInput, setCodeInput] = useState(""); @@ -124,13 +129,13 @@ export default function ConnectionsNewRouteScreen() { return ( - - - + { if (showScanner) { @@ -141,7 +146,7 @@ export default function ConnectionsNewRouteScreen() { }} separateBackground /> - + - + {usesWideSplit ? ( - router.push("/new")} diff --git a/apps/mobile/src/screens/new/add-project/repository.tsx b/apps/mobile/src/screens/new/add-project/repository.tsx index be3140937c..c085bcb94b 100644 --- a/apps/mobile/src/screens/new/add-project/repository.tsx +++ b/apps/mobile/src/screens/new/add-project/repository.tsx @@ -1,10 +1,10 @@ -import { Stack, useLocalSearchParams } from "../../../navigation/router"; +import { NativeStackScreenOptions, useRouteParams } from "../../../navigation/native-stack-header"; import { addProjectRemoteSourceLabel } from "@t3tools/client-runtime/operations/projects"; import { AddProjectRepositoryScreen } from "../../../features/projects/AddProjectScreen"; export default function AddProjectRepositoryRoute() { - const params = useLocalSearchParams<{ source?: string | string[] }>(); + const params = useRouteParams<{ source?: string | string[] }>(); const source = Array.isArray(params.source) ? params.source[0] : params.source; const title = source === "github" || @@ -16,7 +16,7 @@ export default function AddProjectRepositoryRoute() { return ( <> - + ); diff --git a/apps/mobile/src/screens/new/draft.tsx b/apps/mobile/src/screens/new/draft.tsx index f4cb57935c..b32d601596 100644 --- a/apps/mobile/src/screens/new/draft.tsx +++ b/apps/mobile/src/screens/new/draft.tsx @@ -1,9 +1,9 @@ -import { Stack, useLocalSearchParams } from "../../navigation/router"; +import { NativeStackScreenOptions, useRouteParams } from "../../navigation/native-stack-header"; import { NewTaskDraftScreen } from "../../features/threads/NewTaskDraftScreen"; export default function NewTaskDraftRoute() { - const params = useLocalSearchParams<{ + const params = useRouteParams<{ environmentId?: string | string[]; projectId?: string | string[]; title?: string | string[]; @@ -11,7 +11,7 @@ export default function NewTaskDraftRoute() { return ( <> - - - + + {layout.usesSplitView ? ( - router.dismiss()} separateBackground /> ) : null} - router.push("/new/add-project")} separateBackground /> - + - + ); })} diff --git a/apps/mobile/src/screens/settings/archive.tsx b/apps/mobile/src/screens/settings/archive.tsx deleted file mode 100644 index 2b900afbbc..0000000000 --- a/apps/mobile/src/screens/settings/archive.tsx +++ /dev/null @@ -1,3 +0,0 @@ -import { ArchivedThreadsRouteScreen } from "../../features/archive/ArchivedThreadsRouteScreen"; - -export default ArchivedThreadsRouteScreen; diff --git a/apps/mobile/src/screens/settings/auth.tsx b/apps/mobile/src/screens/settings/auth.tsx index 984e7fbb0d..0d5a1c04c2 100644 --- a/apps/mobile/src/screens/settings/auth.tsx +++ b/apps/mobile/src/screens/settings/auth.tsx @@ -1,6 +1,6 @@ import { useAuth } from "@clerk/expo"; import { AuthView, UserProfileView } from "@clerk/expo/native"; -import { Redirect, Stack } from "../../navigation/router"; +import { NavigateTo, NativeStackScreenOptions } from "../../navigation/native-stack-header"; import { View } from "react-native"; import { hasCloudPublicConfig } from "../../features/cloud/publicConfig"; @@ -9,7 +9,7 @@ export default function SettingsAuthRouteScreen() { return hasCloudPublicConfig() ? ( ) : ( - + ); } @@ -18,7 +18,7 @@ function ConfiguredSettingsAuthRouteScreen() { return ( <> - + {isLoaded ? ( isSignedIn ? ( diff --git a/apps/mobile/src/screens/settings/environment-new.tsx b/apps/mobile/src/screens/settings/environment-new.tsx deleted file mode 100644 index 3fb3e8d3a0..0000000000 --- a/apps/mobile/src/screens/settings/environment-new.tsx +++ /dev/null @@ -1 +0,0 @@ -export { default } from "../connections/new"; diff --git a/apps/mobile/src/screens/settings/environments.tsx b/apps/mobile/src/screens/settings/environments.tsx index 9584be950c..0af15c027f 100644 --- a/apps/mobile/src/screens/settings/environments.tsx +++ b/apps/mobile/src/screens/settings/environments.tsx @@ -1,5 +1,9 @@ import { useAuth } from "@clerk/expo"; -import { Stack, useRouter } from "../../navigation/router"; +import { + NativeHeaderToolbar, + NativeStackScreenOptions, + useAppNavigation, +} from "../../navigation/native-stack-header"; import { SymbolView } from "expo-symbols"; import { connectionStatusText, @@ -41,7 +45,7 @@ export default function SettingsEnvironmentsRouteScreen() { onRemoveEnvironmentPress, onUpdateEnvironment, } = useRemoteConnections(); - const router = useRouter(); + const router = useAppNavigation(); const insets = useSafeAreaInsets(); const { localEnvironments, connectedCloudEnvironments } = splitEnvironmentSections({ connectedEnvironments, @@ -57,18 +61,18 @@ export default function SettingsEnvironmentsRouteScreen() { return ( - - - + router.push("/settings/environment-new")} separateBackground /> - + {layout.usesSplitView ? ( - - + router.back()} separateBackground /> - + ) : null} {hasCloudPublicConfig() ? : } @@ -64,7 +69,7 @@ function LocalSettingsRouteScreen() { return ( - + - + + {content} - + ); } diff --git a/apps/mobile/src/screens/settings/waitlist.tsx b/apps/mobile/src/screens/settings/waitlist.tsx index 952d119d82..d83e3c966d 100644 --- a/apps/mobile/src/screens/settings/waitlist.tsx +++ b/apps/mobile/src/screens/settings/waitlist.tsx @@ -1,5 +1,10 @@ import { useAuth } from "@clerk/expo"; -import { Redirect, Stack, useFocusEffect, useRouter } from "../../navigation/router"; +import { + NavigateTo, + NativeStackScreenOptions, + useFocusEffect, + useAppNavigation, +} from "../../navigation/native-stack-header"; import { useCallback } from "react"; import { ScrollView } from "react-native"; @@ -11,14 +16,14 @@ export default function SettingsWaitlistRouteScreen() { return hasCloudPublicConfig() ? ( ) : ( - + ); } function ConfiguredSettingsWaitlistRouteScreen() { const { isLoaded, isSignedIn } = useAuth({ treatPendingAsSignedOut: false }); const { expand } = useClerkSettingsSheetDetent(); - const router = useRouter(); + const router = useAppNavigation(); useFocusEffect( useCallback(() => { @@ -30,7 +35,7 @@ function ConfiguredSettingsWaitlistRouteScreen() { return ( <> - + ; -} diff --git a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/files/index.tsx b/apps/mobile/src/screens/threads/[environmentId]/[threadId]/files/index.tsx deleted file mode 100644 index b67630dbf0..0000000000 --- a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/files/index.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { ThreadFilesTreeScreen } from "../../../../../features/files/ThreadFilesRouteScreen"; - -export default function ThreadFilesIndexRoute() { - return ; -} diff --git a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/git-confirm.tsx b/apps/mobile/src/screens/threads/[environmentId]/[threadId]/git-confirm.tsx deleted file mode 100644 index 3773ce55b2..0000000000 --- a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/git-confirm.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { GitConfirmSheet } from "../../../../features/threads/git/GitConfirmSheet"; - -export default function GitConfirmRoute() { - return ; -} diff --git a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/git/branches.tsx b/apps/mobile/src/screens/threads/[environmentId]/[threadId]/git/branches.tsx deleted file mode 100644 index 955e4febd7..0000000000 --- a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/git/branches.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { GitBranchesSheet } from "../../../../../features/threads/git/GitBranchesSheet"; - -export default function GitBranchesRoute() { - return ; -} diff --git a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/git/commit.tsx b/apps/mobile/src/screens/threads/[environmentId]/[threadId]/git/commit.tsx deleted file mode 100644 index 4510f81a8c..0000000000 --- a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/git/commit.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { GitCommitSheet } from "../../../../../features/threads/git/GitCommitSheet"; - -export default function GitCommitRoute() { - return ; -} diff --git a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/git/index.tsx b/apps/mobile/src/screens/threads/[environmentId]/[threadId]/git/index.tsx deleted file mode 100644 index dd099d80d2..0000000000 --- a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/git/index.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { GitOverviewSheet } from "../../../../../features/threads/git/GitOverviewSheet"; - -export default function GitRoute() { - return ; -} diff --git a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/index.tsx b/apps/mobile/src/screens/threads/[environmentId]/[threadId]/index.tsx deleted file mode 100644 index 4586ee93ca..0000000000 --- a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/index.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { ThreadRouteScreen } from "../../../../features/threads/ThreadRouteScreen"; - -export default function ThreadRoute() { - return ; -} diff --git a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/review-comment.tsx b/apps/mobile/src/screens/threads/[environmentId]/[threadId]/review-comment.tsx deleted file mode 100644 index 281ec34107..0000000000 --- a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/review-comment.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { ReviewCommentComposerSheet } from "../../../../features/review/ReviewCommentComposerSheet"; - -export default function ReviewCommentRoute() { - return ; -} diff --git a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/review.tsx b/apps/mobile/src/screens/threads/[environmentId]/[threadId]/review.tsx deleted file mode 100644 index ee993ee7c8..0000000000 --- a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/review.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { ReviewHighlighterProvider } from "../../../../features/review/ReviewHighlighterProvider"; -import { ReviewSheet } from "../../../../features/review/ReviewSheet"; - -export default function ReviewRoute() { - return ( - - - - ); -} diff --git a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/terminal.tsx b/apps/mobile/src/screens/threads/[environmentId]/[threadId]/terminal.tsx deleted file mode 100644 index e209a180a4..0000000000 --- a/apps/mobile/src/screens/threads/[environmentId]/[threadId]/terminal.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { ThreadTerminalRouteScreen } from "../../../../features/terminal/ThreadTerminalRouteScreen"; - -export default function ThreadTerminalRoute() { - return ; -} diff --git a/apps/mobile/src/state/use-thread-selection.ts b/apps/mobile/src/state/use-thread-selection.ts index c5eaf5743d..bc077f4c93 100644 --- a/apps/mobile/src/state/use-thread-selection.ts +++ b/apps/mobile/src/state/use-thread-selection.ts @@ -1,4 +1,4 @@ -import { useGlobalSearchParams } from "../navigation/router"; +import { useCurrentRouteParams } from "../navigation/native-stack-header"; import { createContext, createElement, use, useMemo, useRef, type ReactNode } from "react"; import { EnvironmentId, @@ -63,7 +63,7 @@ function threadDetailToShell( } function useResolvedThreadSelection() { - const params = useGlobalSearchParams<{ + const params = useCurrentRouteParams<{ environmentId?: string | string[]; threadId?: string | string[]; }>();