From 10ca14a362a3a0db516e43f75f4d4f4335b4268d Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 30 Jun 2026 17:32:34 -0700 Subject: [PATCH] Tighten mobile navigation targets --- .../agent-awareness/notificationNavigation.ts | 6 +- .../features/files/ThreadFilesRouteScreen.tsx | 26 +-- .../HardwareKeyboardCommandProvider.tsx | 25 +-- .../layout/AdaptiveWorkspaceLayout.tsx | 31 ++-- .../features/projects/AddProjectScreen.tsx | 81 ++++----- .../review/ReviewCommentComposerSheet.tsx | 6 +- .../useReviewCommentSelectionController.ts | 10 +- .../terminal/ThreadTerminalRouteScreen.tsx | 16 +- .../features/threads/NewTaskDraftScreen.tsx | 10 +- .../src/features/threads/ThreadFeed.tsx | 6 +- .../features/threads/ThreadGitControls.tsx | 50 +++--- .../threads/ThreadNavigationSidebar.tsx | 7 +- .../features/threads/ThreadRouteScreen.tsx | 47 ++--- .../features/threads/git/GitBranchesSheet.tsx | 8 +- .../features/threads/git/GitCommitSheet.tsx | 6 +- .../features/threads/git/GitConfirmSheet.tsx | 17 +- .../features/threads/git/GitOverviewSheet.tsx | 53 +++--- apps/mobile/src/lib/routes.test.ts | 67 ++++++- apps/mobile/src/lib/routes.ts | 165 +++++++++++++++++- apps/mobile/src/navigation/app-navigation.tsx | 13 +- .../src/navigation/native-stack-header.tsx | 8 +- apps/mobile/src/navigation/route-model.ts | 57 +----- apps/mobile/src/screens/+not-found.tsx | 3 +- apps/mobile/src/screens/connections/index.tsx | 5 +- apps/mobile/src/screens/connections/new.tsx | 6 +- apps/mobile/src/screens/index.tsx | 26 +-- apps/mobile/src/screens/new/index.tsx | 28 +-- apps/mobile/src/screens/settings/auth.tsx | 3 +- .../src/screens/settings/environments.tsx | 5 +- apps/mobile/src/screens/settings/index.tsx | 30 ++-- apps/mobile/src/screens/settings/waitlist.tsx | 11 +- 31 files changed, 523 insertions(+), 309 deletions(-) diff --git a/apps/mobile/src/features/agent-awareness/notificationNavigation.ts b/apps/mobile/src/features/agent-awareness/notificationNavigation.ts index 2662566e28..15ff1e09a8 100644 --- a/apps/mobile/src/features/agent-awareness/notificationNavigation.ts +++ b/apps/mobile/src/features/agent-awareness/notificationNavigation.ts @@ -6,7 +6,7 @@ import { routeAgentNotificationResponseOnce } from "./notificationPayload"; import { consumeLastAgentNotificationResponse } from "./notificationResponseConsumer"; export function useAgentNotificationNavigation(): void { - const router = useAppNavigation(); + const navigation = useAppNavigation(); const handledResponseIds = useRef(new Set()); useEffect(() => { @@ -14,7 +14,7 @@ export function useAgentNotificationNavigation(): void { routeAgentNotificationResponseOnce({ handledResponseIds: handledResponseIds.current, response, - navigate: (deepLink) => router.push(deepLink as never), + navigate: (deepLink) => navigation.push(deepLink as never), }); }; @@ -28,5 +28,5 @@ export function useAgentNotificationNavigation(): void { return () => { subscription.remove(); }; - }, [router]); + }, [navigation]); } diff --git a/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx b/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx index b6bf434b6b..8a1aa1614d 100644 --- a/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx +++ b/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx @@ -30,7 +30,7 @@ import { cn } from "../../lib/cn"; import { resolveFileSelectionNavigationAction } from "../../lib/adaptive-navigation"; import { nativeHeaderScrollEdgeEffects } from "../../lib/native-scroll-edge-effect"; import { tryOpenExternalUrl } from "../../lib/openExternalUrl"; -import { buildThreadFilesNavigation, buildThreadRoutePath } from "../../lib/routes"; +import { buildThreadFilesNavigation, threadNavigation } from "../../lib/routes"; import { MOBILE_TYPOGRAPHY } from "../../lib/typography"; import { useThemeColor } from "../../lib/useThemeColor"; import { useThreadSelection } from "../../state/use-thread-selection"; @@ -468,7 +468,7 @@ function FilesToolbarBottomFade() { export function ThreadFilesTreeScreen() { useAdaptiveWorkspacePaneRole("inspector"); - const router = useAppNavigation(); + const navigation = useAppNavigation(); const { fileInspector, layout, panes, showAuxiliaryPane, togglePrimarySidebar } = useAdaptiveWorkspaceLayout(); const [searchQuery, setSearchQuery] = useState(""); @@ -486,14 +486,14 @@ export function ThreadFilesTreeScreen() { ); const entriesData = entriesQuery.data as ProjectListEntriesResult | null; const handleReturnToThread = useCallback(() => { - if (router.canGoBack()) { - router.back(); + if (navigation.canGoBack()) { + navigation.back(); return; } if (environmentId !== null && threadId !== null) { - router.replace(buildThreadRoutePath({ environmentId, threadId })); + navigation.replace(threadNavigation({ environmentId, threadId })); } - }, [environmentId, router, threadId]); + }, [environmentId, navigation, threadId]); const handleSelectFile = useCallback( (path: string) => { @@ -505,12 +505,12 @@ export function ThreadFilesTreeScreen() { hasPersistentFileInspector: fileInspector.supported, }); if (navigationAction === "replace") { - router.replace(destination); + navigation.replace(destination); return; } - router.push(destination); + navigation.push(destination); }, - [environmentId, fileInspector.supported, router, threadId], + [environmentId, fileInspector.supported, navigation, threadId], ); const renderInspector = useCallback( (headerInset: number) => @@ -661,7 +661,7 @@ export function ThreadFilesTreeScreen() { export function ThreadFileScreen() { useAdaptiveWorkspacePaneRole("inspector"); - const router = useAppNavigation(); + const navigation = useAppNavigation(); const { fileInspector, panes, toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout(); const iconColor = useThemeColor("--color-icon"); const params = useRouteParams<{ @@ -714,12 +714,12 @@ export function ThreadFileScreen() { // We are already on the catch-all file route. Updating its params keeps // the current native screen mounted while replacing the selected file in // place, avoiding an RNSScreen snapshot/unmount for every tree click. - router.setParams({ + navigation.setParams({ line: undefined, path: path.split("/").filter(Boolean), }); }, - [router], + [navigation], ); const renderInspector = useCallback( (headerInset: number) => @@ -774,7 +774,7 @@ export function ThreadFileScreen() { accessibilityLabel="Return to chat" icon="chevron.left" onPress={() => { - router.replace(buildThreadRoutePath({ environmentId, threadId })); + navigation.replace(threadNavigation({ environmentId, threadId })); }} /> ) : null} diff --git a/apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx b/apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx index ddf79b8cc2..132a14cd87 100644 --- a/apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx +++ b/apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx @@ -2,10 +2,11 @@ import { useCurrentPathname, useAppNavigation } from "../../navigation/native-st import { useCallback, useMemo, useSyncExternalStore, type PropsWithChildren } from "react"; import { - buildThreadFilesRoutePath, - buildThreadReviewRoutePath, - buildThreadTerminalRoutePath, + buildThreadFilesNavigation, + buildThreadReviewNavigation, + buildThreadTerminalNavigation, dismissRoute, + newTaskNavigation, } from "../../lib/routes"; import { T3KeyboardCommands } from "../../native/T3KeyboardCommands"; import { @@ -19,7 +20,7 @@ import { export function HardwareKeyboardCommandProvider({ children }: PropsWithChildren) { const pathname = useCurrentPathname(); - const router = useAppNavigation(); + const navigation = useAppNavigation(); const registrationVersion = useSyncExternalStore( subscribeToHardwareKeyboardCommandRegistrations, getHardwareKeyboardCommandRegistrationVersion, @@ -28,41 +29,41 @@ export function HardwareKeyboardCommandProvider({ children }: PropsWithChildren) const enabledCommands = useMemo(() => { const commands = new Set(getRegisteredHardwareKeyboardCommands()); commands.add("newTask"); - if (pathname !== "/" || router.canGoBack()) commands.add("back"); + if (pathname !== "/" || navigation.canGoBack()) commands.add("back"); if (parseActiveThreadPath(pathname)) { commands.add("files"); commands.add("terminal"); commands.add("review"); } return [...commands]; - }, [pathname, registrationVersion, router]); + }, [pathname, registrationVersion, navigation]); const onCommand = useCallback( (command: HardwareKeyboardCommand) => { if (dispatchHardwareKeyboardCommand(command)) return; if (command === "newTask") { - router.push("/new"); + navigation.push(newTaskNavigation()); return; } if (command === "back") { - dismissRoute(router); + dismissRoute(navigation); return; } const thread = parseActiveThreadPath(pathname); if (!thread) return; if (command === "files" && !/\/files(?:\/|$)/.test(pathname)) { - router.push(buildThreadFilesRoutePath(thread)); + navigation.push(buildThreadFilesNavigation(thread)); } if (command === "terminal" && !/\/terminal(?:\/|$)/.test(pathname)) { - router.push(buildThreadTerminalRoutePath(thread)); + navigation.push(buildThreadTerminalNavigation(thread)); } if (command === "review" && !/\/review(?:\/|$)/.test(pathname)) { - router.push(buildThreadReviewRoutePath(thread)); + navigation.push(buildThreadReviewNavigation(thread)); } }, - [pathname, router], + [pathname, navigation], ); return ( diff --git a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx index a575926d7d..6c2ae88b68 100644 --- a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx +++ b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx @@ -35,7 +35,12 @@ import { type WorkspacePaneLayout, } from "../../lib/layout"; import { resolveThreadSelectionNavigationAction } from "../../lib/adaptive-navigation"; -import { buildThreadFilesNavigation, buildThreadRoutePath } from "../../lib/routes"; +import { + buildThreadFilesNavigation, + newTaskNavigation, + settingsNavigation, + threadNavigation, +} from "../../lib/routes"; import { scopedThreadKey } from "../../lib/scopedEntities"; import { parseActiveThreadPath, @@ -100,7 +105,7 @@ export function useAdaptiveWorkspacePaneRole(role: WorkspaceAuxiliaryPaneRole) { export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) { const { width, height } = useWindowDimensions(); const pathname = useCurrentPathname(); - const router = useAppNavigation(); + const navigation = useAppNavigation(); const activeRoleOwner = useRef(null); const [primarySidebarPreferredVisible, setPrimarySidebarPreferredVisible] = useState(true); const [supplementaryPanePreferredVisible, setSupplementaryPanePreferredVisible] = useState(true); @@ -222,9 +227,9 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) if (/\/files(?:\/|$)/.test(pathname)) { return true; } - router.replace(buildThreadFilesNavigation(activeThread)); + navigation.replace(buildThreadFilesNavigation(activeThread)); return true; - }, [fileInspector.supported, layout.usesSplitView, pathname, router, showAuxiliaryPane]); + }, [fileInspector.supported, layout.usesSplitView, pathname, navigation, showAuxiliaryPane]); useHardwareKeyboardCommand("files", handleOpenFilesCommand); const toggleAuxiliaryPane = useCallback(() => { if (auxiliaryPaneRole === "inspector") { @@ -271,11 +276,11 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) ); const handleOpenSettings = useCallback(() => { - router.push("/settings"); - }, [router]); + navigation.push(settingsNavigation()); + }, [navigation]); const handleStartNewTask = useCallback(() => { - router.push("/new"); - }, [router]); + navigation.push(newTaskNavigation()); + }, [navigation]); const renderedSidebarWidth = useSharedValue( panes.primarySidebarVisible ? (layout.listPaneWidth ?? 0) : 0, @@ -295,7 +300,7 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) const handleSelectThread = useCallback( (thread: EnvironmentThreadShell) => { - const destination = buildThreadRoutePath(thread); + const destination = threadNavigation(thread); const navigationAction = resolveThreadSelectionNavigationAction({ usesSplitView: layout.usesSplitView, pathname, @@ -306,7 +311,7 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) return; } setFileInspectorPreferredVisible(false); - router.setParams({ + navigation.setParams({ environmentId: String(thread.environmentId), threadId: String(thread.id), }); @@ -314,12 +319,12 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) } if (navigationAction === "replace") { setFileInspectorPreferredVisible(false); - router.replace(destination); + navigation.replace(destination); return; } - router.push(destination); + navigation.push(destination); }, - [layout.usesSplitView, pathname, router, selectedThreadKey], + [layout.usesSplitView, pathname, navigation, selectedThreadKey], ); return ( diff --git a/apps/mobile/src/features/projects/AddProjectScreen.tsx b/apps/mobile/src/features/projects/AddProjectScreen.tsx index a1aaf7df93..4b70aa9bbd 100644 --- a/apps/mobile/src/features/projects/AddProjectScreen.tsx +++ b/apps/mobile/src/features/projects/AddProjectScreen.tsx @@ -40,6 +40,13 @@ import { sourceControlEnvironment } from "../../state/sourceControl"; import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText"; import { ErrorBanner } from "../../components/ErrorBanner"; import { SourceControlIcon } from "../../components/SourceControlIcon"; +import { + addProjectDestinationNavigation, + addProjectLocalNavigation, + addProjectRepositoryNavigation, + connectionsNewNavigation, + newTaskDraftNavigation, +} from "../../lib/routes"; import { useThemeColor } from "../../lib/useThemeColor"; import { uuidv4 } from "../../lib/uuid"; import { useAtomCommand } from "../../state/use-atom-command"; @@ -250,7 +257,7 @@ function useSelectedEnvironment(): { readonly selectedEnvironment: EnvironmentOption | null; readonly setSelectedEnvironmentId: (environmentId: EnvironmentId) => void; } { - const router = useAppNavigation(); + const navigation = useAppNavigation(); const params = useRouteParams<{ environmentId?: string }>(); const environmentOptions = useEnvironmentOptions(); const requestedEnvironmentId = stringParam(params.environmentId) as EnvironmentId | null; @@ -264,12 +271,12 @@ function useSelectedEnvironment(): { return { environmentOptions, selectedEnvironment, - setSelectedEnvironmentId: (environmentId) => router.setParams({ environmentId }), + setSelectedEnvironmentId: (environmentId) => navigation.setParams({ environmentId }), }; } function EmptyEnvironmentState() { - const router = useAppNavigation(); + const navigation = useAppNavigation(); return ( @@ -278,7 +285,7 @@ function EmptyEnvironmentState() { Add an environment before adding a project. router.replace("/connections/new")} + onPress={() => navigation.replace(connectionsNewNavigation())} className="mt-1 rounded-full bg-primary px-4 py-2.5 active:opacity-70" > Add environment @@ -294,7 +301,7 @@ function SourceControlRow(props: { readonly hint: string; readonly isFirst: boolean; }) { - const router = useAppNavigation(); + const navigation = useAppNavigation(); const iconColor = useThemeColor("--color-icon"); const title = props.source === "url" ? "Git URL" : `${addProjectRemoteSourceLabel(props.source)} repository`; @@ -322,20 +329,19 @@ function SourceControlRow(props: { icon={icon} isFirst={props.isFirst} onPress={() => - router.push({ - name: "AddProjectRepository", - params: { + navigation.push( + addProjectRepositoryNavigation({ environmentId: props.selectedEnvironmentId, source: props.source, - }, - }) + }), + ) } /> ); } export function AddProjectSourceScreen() { - const router = useAppNavigation(); + const navigation = useAppNavigation(); const accentColor = useThemeColor("--color-icon-muted"); const iconColor = useThemeColor("--color-icon"); const { environmentOptions, selectedEnvironment, setSelectedEnvironmentId } = @@ -409,10 +415,11 @@ export function AddProjectSourceScreen() { } isFirst onPress={() => - router.push({ - name: "AddProjectLocal", - params: { environmentId: selectedEnvironment.environmentId }, - }) + navigation.push( + addProjectLocalNavigation({ + environmentId: selectedEnvironment.environmentId, + }), + ) } /> {(["url", ...sortAddProjectProviderSources(readiness)] as AddProjectRemoteSource[]).map( @@ -440,7 +447,7 @@ export function AddProjectSourceScreen() { } function useCreateProject(environment: EnvironmentOption | null) { - const router = useAppNavigation(); + const navigation = useAppNavigation(); const createProject = useAtomCommand(projectEnvironment.create, { reportFailure: false }); const projects = useProjects(); @@ -455,14 +462,13 @@ function useCreateProject(environment: EnvironmentOption | null) { }); if (existing) { Alert.alert("Project already exists", existing.title); - router.replace({ - name: "NewTaskDraft", - params: { + navigation.replace( + newTaskDraftNavigation({ environmentId: existing.environmentId, projectId: existing.id, title: existing.title, - }, - }); + }), + ); return; } @@ -480,17 +486,16 @@ function useCreateProject(environment: EnvironmentOption | null) { if (AsyncResult.isFailure(result)) { return result; } - router.replace({ - name: "NewTaskDraft", - params: { + navigation.replace( + newTaskDraftNavigation({ environmentId: environment.environmentId, projectId, title: inferProjectTitleFromPath(workspaceRoot), - }, - }); + }), + ); return result; }, - [createProject, environment, projects, router], + [createProject, environment, projects, navigation], ); } @@ -509,7 +514,7 @@ export function AddProjectRepositoryScreen() { const lookupRepositoryQuery = useAtomQueryRunner(sourceControlEnvironment.repository, { reportFailure: false, }); - const router = useAppNavigation(); + const navigation = useAppNavigation(); const params = useRouteParams<{ environmentId?: string; source?: string }>(); const environment = useEnvironmentFromParam(); const source = sourceFromParam(params.source); @@ -524,15 +529,14 @@ export function AddProjectRepositoryScreen() { const provider = addProjectRemoteSourceProvider(source); if (!provider) { const remoteUrl = repositoryInput.trim(); - router.push({ - name: "AddProjectDestination", - params: { + navigation.push( + addProjectDestinationNavigation({ environmentId: environment.environmentId, source, remoteUrl, repositoryTitle: remoteUrl, - }, - }); + }), + ); setIsSubmitting(false); return; } @@ -548,18 +552,17 @@ export function AddProjectRepositoryScreen() { setError(errorMessage(Cause.squash(result.cause))); } else { const repository = result.value; - router.push({ - name: "AddProjectDestination", - params: { + navigation.push( + addProjectDestinationNavigation({ environmentId: environment.environmentId, source, remoteUrl: repository.sshUrl, repositoryTitle: repository.nameWithOwner, - }, - }); + }), + ); } setIsSubmitting(false); - }, [environment, isSubmitting, lookupRepositoryQuery, repositoryInput, router, source]); + }, [environment, isSubmitting, lookupRepositoryQuery, repositoryInput, navigation, source]); return ( diff --git a/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx b/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx index 3503a15021..3383b25c69 100644 --- a/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx +++ b/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx @@ -41,7 +41,7 @@ import { const REVIEW_COMMENT_PREVIEW_MAX_LINES = 5; export function ReviewCommentComposerSheet() { - const router = useAppNavigation(); + const navigation = useAppNavigation(); const insets = useSafeAreaInsets(); const { width } = useWindowDimensions(); const colorScheme = useColorScheme(); @@ -84,8 +84,8 @@ export function ReviewCommentComposerSheet() { const previewViewportWidth = Math.max(width - 40, 280); const dismissComposer = useCallback(() => { clearReviewCommentTarget(); - router.dismiss(); - }, [router]); + navigation.dismiss(); + }, [navigation]); const handleNativePaste = useNativePaste((uris) => { void (async () => { try { diff --git a/apps/mobile/src/features/review/useReviewCommentSelectionController.ts b/apps/mobile/src/features/review/useReviewCommentSelectionController.ts index 557ce16b41..e7d9e790de 100644 --- a/apps/mobile/src/features/review/useReviewCommentSelectionController.ts +++ b/apps/mobile/src/features/review/useReviewCommentSelectionController.ts @@ -6,6 +6,7 @@ import { pipe } from "effect/Function"; import * as Result from "effect/Result"; import type { EnvironmentId, ThreadId } from "@t3tools/contracts"; +import { buildThreadReviewCommentNavigation } from "../../lib/routes"; import { buildReviewCommentTarget, @@ -34,7 +35,7 @@ export function useReviewCommentSelectionController(input: { readonly nativeReviewDiffData: NativeReviewDiffData; }) { const { environmentId, nativeReviewDiffData, selectedSection, threadId } = input; - const { push } = useAppNavigation(); + const navigation = useAppNavigation(); const activeCommentTarget = useReviewCommentTarget(); const [pendingNativeCommentSelection, setPendingNativeCommentSelection] = useState(null); @@ -44,11 +45,8 @@ export function useReviewCommentSelectionController(input: { return; } - push({ - name: "ThreadReviewComment", - params: { environmentId, threadId }, - }); - }, [environmentId, push, threadId]); + navigation.push(buildThreadReviewCommentNavigation({ environmentId, threadId })); + }, [environmentId, navigation, threadId]); const selectedRowIds = useMemo(() => { if ( diff --git a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx index 6f62d85c01..033270b4cc 100644 --- a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx +++ b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx @@ -203,7 +203,7 @@ function pickRunningTerminalSessionForBootstrap( } export function ThreadTerminalRouteScreen() { - const router = useAppNavigation(); + const navigation = useAppNavigation(); const writeTerminal = useAtomCommand(terminalEnvironment.write, "terminal write"); const resizeTerminal = useAtomCommand(terminalEnvironment.resize, "terminal resize"); const clearTerminal = useAtomCommand(terminalEnvironment.clear, "terminal clear"); @@ -613,8 +613,10 @@ export function ThreadTerminalRouteScreen() { if (!shouldRedirectToRunningTerminal || !selectedThread || !runningSession) { return; } - router.replace(buildThreadTerminalNavigation(selectedThread, runningSession.target.terminalId)); - }, [router, runningSession, selectedThread, shouldRedirectToRunningTerminal]); + navigation.replace( + buildThreadTerminalNavigation(selectedThread, runningSession.target.terminalId), + ); + }, [navigation, runningSession, selectedThread, shouldRedirectToRunningTerminal]); useEffect(() => { const initialInput = pendingLaunch?.initialInput; @@ -839,9 +841,9 @@ export function ThreadTerminalRouteScreen() { return; } - router.replace(buildThreadTerminalNavigation(selectedThread, nextTerminalId)); + navigation.replace(buildThreadTerminalNavigation(selectedThread, nextTerminalId)); }, - [router, selectedThread, terminalId], + [navigation, selectedThread, terminalId], ); const handleOpenNewTerminal = useCallback(() => { @@ -849,7 +851,7 @@ export function ThreadTerminalRouteScreen() { return; } - router.replace( + navigation.replace( buildThreadTerminalNavigation( selectedThread, nextOpenTerminalId({ @@ -858,7 +860,7 @@ export function ThreadTerminalRouteScreen() { }), ), ); - }, [router, selectedThread, terminalId, terminalMenuSessions]); + }, [navigation, selectedThread, terminalId, terminalMenuSessions]); const adjustFontSize = useCallback((delta: number) => { setTimeout(() => { diff --git a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx index 53cb3f4cef..55faf2228f 100644 --- a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx +++ b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx @@ -29,7 +29,7 @@ import { providerOptionsConfigurationLabel, resolveProviderOptionDescriptors, } from "../../lib/providerOptions"; -import { buildThreadRoutePath } from "../../lib/routes"; +import { newTaskNavigation, threadNavigation } from "../../lib/routes"; import { scopedProjectKey } from "../../lib/scopedEntities"; import { MOBILE_TYPOGRAPHY } from "../../lib/typography"; import { getComposerDraftSnapshot } from "../../state/use-composer-drafts"; @@ -58,7 +58,7 @@ export function NewTaskDraftScreen(props: { const projects = useProjects(); const createProjectThread = useCreateProjectThread(); const flow = useNewTaskFlow(); - const router = useAppNavigation(); + const navigation = useAppNavigation(); const insets = useSafeAreaInsets(); const colorScheme = useColorScheme(); const isKeyboardVisible = useKeyboardState((state) => state.isVisible); @@ -101,13 +101,13 @@ export function NewTaskDraftScreen(props: { return; } - router.replace("/new"); + navigation.replace(newTaskNavigation()); }, [ logicalProjects, projects, props.initialProjectRef?.environmentId, props.initialProjectRef?.projectId, - router, + navigation, selectedProject, setProject, ]); @@ -429,7 +429,7 @@ export function NewTaskDraftScreen(props: { flow.setPrompt(""); flow.clearAttachments(); - router.replace(buildThreadRoutePath(result.value)); + navigation.replace(threadNavigation(result.value)); } if (!selectedProject) { diff --git a/apps/mobile/src/features/threads/ThreadFeed.tsx b/apps/mobile/src/features/threads/ThreadFeed.tsx index 3b52ae3559..fbc6c25de5 100644 --- a/apps/mobile/src/features/threads/ThreadFeed.tsx +++ b/apps/mobile/src/features/threads/ThreadFeed.tsx @@ -1125,7 +1125,7 @@ function ThreadFeedPlaceholder(props: { } export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { - const router = useAppNavigation(); + const navigation = useAppNavigation(); const copyFeedbackTimeoutRef = useRef | null>(null); const foldSettleFrameRef = useRef(null); const foldSettleSecondFrameRef = useRef(null); @@ -1180,7 +1180,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { ); if (relativePath) { void Haptics.selectionAsync(); - router.push( + navigation.push( buildThreadFilesNavigation( { environmentId: props.environmentId, threadId: props.threadId }, relativePath, @@ -1195,7 +1195,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { void Linking.openURL(presentation.href); } }, - [props.environmentId, props.threadId, props.workspaceRoot, router], + [props.environmentId, props.threadId, props.workspaceRoot, navigation], ); const markdownStyles = useMarkdownStyles(onMarkdownLinkPress); const reviewCommentColors = useReviewCommentColors(); diff --git a/apps/mobile/src/features/threads/ThreadGitControls.tsx b/apps/mobile/src/features/threads/ThreadGitControls.tsx index ee34a4f3d9..c28d55d914 100644 --- a/apps/mobile/src/features/threads/ThreadGitControls.tsx +++ b/apps/mobile/src/features/threads/ThreadGitControls.tsx @@ -14,7 +14,12 @@ import { useRouteParams, useAppNavigation } from "../../navigation/native-stack- import { NativeHeaderToolbar } from "../../navigation/native-stack-header"; import { useCallback, useMemo } from "react"; import { Alert } from "react-native"; -import { buildThreadFilesNavigation, buildThreadReviewRoutePath } from "../../lib/routes"; +import { + buildGitConfirmNavigation, + buildGitOverviewNavigation, + buildThreadFilesNavigation, + buildThreadReviewNavigation, +} from "../../lib/routes"; import { tryOpenExternalUrl } from "../../lib/openExternalUrl"; import { basename, @@ -102,7 +107,7 @@ type ThreadGitControlsProps = { }; function useThreadGitControlModel(props: ThreadGitControlsProps) { - const router = useAppNavigation(); + const navigation = useAppNavigation(); const { environmentId, threadId } = useRouteParams<{ environmentId: EnvironmentId; threadId: ThreadId; @@ -170,24 +175,24 @@ function useThreadGitControlModel(props: ThreadGitControlsProps) { !input.featureBranch && requiresDefaultBranchConfirmation(input.action, isDefaultRef) ) { - router.push({ - name: "GitConfirm", - params: { - environmentId, - threadId, - confirmAction: confirmableAction, - branchName, - includesCommit: String( - input.action === "commit_push" || input.action === "commit_push_pr", - ), - }, - }); + navigation.push( + buildGitConfirmNavigation( + { environmentId, threadId }, + { + confirmAction: confirmableAction, + branchName, + includesCommit: String( + input.action === "commit_push" || input.action === "commit_push_pr", + ), + }, + ), + ); return; } await onRunAction(input); }, - [environmentId, gitStatus, isDefaultRef, onRunAction, router, threadId], + [environmentId, gitStatus, isDefaultRef, onRunAction, navigation, threadId], ); const runQuickAction = useCallback(async () => { @@ -209,23 +214,20 @@ function useThreadGitControlModel(props: ThreadGitControlsProps) { props.onOpenFilesInspector(); return; } - router.push(buildThreadFilesNavigation({ environmentId, threadId })); - }, [environmentId, props.onOpenFilesInspector, router, threadId]); + navigation.push(buildThreadFilesNavigation({ environmentId, threadId })); + }, [environmentId, props.onOpenFilesInspector, navigation, threadId]); const openReview = useCallback(() => { - router.push(buildThreadReviewRoutePath({ environmentId, threadId })); - }, [environmentId, router, threadId]); + navigation.push(buildThreadReviewNavigation({ environmentId, threadId })); + }, [environmentId, navigation, threadId]); const openGitInspector = useCallback(() => { if (props.onOpenGitInspector) { props.onOpenGitInspector(); return; } - router.push({ - name: "GitOverview", - params: { environmentId, threadId }, - }); - }, [environmentId, props.onOpenGitInspector, router, threadId]); + navigation.push(buildGitOverviewNavigation({ environmentId, threadId })); + }, [environmentId, props.onOpenGitInspector, navigation, threadId]); return { currentBranchLabel, diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx index 893beb57b4..1cf8d448df 100644 --- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx +++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx @@ -15,6 +15,7 @@ import { AppText as Text } from "../../components/AppText"; import { ControlPillMenu } from "../../components/ControlPill"; import { StatusPill } from "../../components/StatusPill"; import { nativeHeaderScrollEdgeEffects } from "../../lib/native-scroll-edge-effect"; +import { settingsEnvironmentsNavigation } from "../../lib/routes"; import { scopedThreadKey } from "../../lib/scopedEntities"; import { relativeTime } from "../../lib/time"; import { useThemeColor } from "../../lib/useThemeColor"; @@ -257,7 +258,7 @@ export function ThreadNavigationSidebar(props: { }) { const insets = useSafeAreaInsets(); const colorScheme = useColorScheme() === "dark" ? "dark" : "light"; - const router = useAppNavigation(); + const navigation = useAppNavigation(); const projects = useProjects(); const threads = useThreadShells(); const { state: catalogState } = useWorkspaceState(); @@ -693,7 +694,7 @@ export function ThreadNavigationSidebar(props: { showsConnectionStatus ? ( router.push("/settings/environments")} + onPress={() => navigation.push(settingsEnvironmentsNavigation())} state={catalogState} variant="sidebar" /> @@ -870,7 +871,7 @@ export function ThreadNavigationSidebar(props: { {showsConnectionStatus ? ( router.push("/settings/environments")} + onPress={() => navigation.push(settingsEnvironmentsNavigation())} state={catalogState} variant="sidebar" /> diff --git a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx index 559874f956..2d0c37a71f 100644 --- a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx @@ -42,8 +42,11 @@ import { EmptyState } from "../../components/EmptyState"; import { LoadingScreen } from "../../components/LoadingScreen"; import { buildThreadFilesNavigation, - buildThreadRoutePath, buildThreadTerminalNavigation, + connectionsNavigation, + homeNavigation, + newTaskNavigation, + threadNavigation, } from "../../lib/routes"; import { scopedThreadKey } from "../../lib/scopedEntities"; import { MOBILE_TYPOGRAPHY } from "../../lib/typography"; @@ -273,7 +276,7 @@ function ThreadRouteContent( const gitActions = useSelectedThreadGitActions(); const requests = useSelectedThreadRequests(); const interruptThreadTurn = useAtomCommand(threadEnvironment.interruptTurn, "thread interrupt"); - const router = useAppNavigation(); + const navigation = useAppNavigation(); const params = useRouteParams<{ environmentId?: string | string[]; threadId?: string | string[]; @@ -476,14 +479,14 @@ function ThreadRouteContent( if (selectedThread === null) { return; } - const navigation = buildThreadFilesNavigation(selectedThread, path); + const destination = buildThreadFilesNavigation(selectedThread, path); if (fileInspector.supported) { - router.replace(navigation); + navigation.replace(destination); return; } - router.push(navigation); + navigation.push(destination); }, - [fileInspector.supported, router, selectedThread], + [fileInspector.supported, navigation, selectedThread], ); const GitInspector = useCallback( () => , @@ -519,8 +522,8 @@ function ThreadRouteContent( const activeInspectorRenderer = inspectorMode === null ? undefined : renderInspectorStack; const handleOpenConnectionEditor = useCallback(() => { - void router.push("/connections"); - }, [router]); + void navigation.push(connectionsNavigation()); + }, [navigation]); const handleStopThread = useCallback(() => { if ( !selectedThread || @@ -552,9 +555,9 @@ function ThreadRouteContent( return; } - void router.push(buildThreadTerminalNavigation(selectedThread, nextTerminalId)); + void navigation.push(buildThreadTerminalNavigation(selectedThread, nextTerminalId)); }, - [router, selectedThread, selectedThreadProject?.workspaceRoot], + [navigation, selectedThread, selectedThreadProject?.workspaceRoot], ); const handleOpenNewTerminal = useCallback(() => { @@ -571,8 +574,8 @@ function ThreadRouteContent( const nextId = nextOpenTerminalId({ listedTerminalIds: terminalMenuSessions.map((session) => session.terminalId), }); - void router.push(buildThreadTerminalNavigation(selectedThread, nextId)); - }, [router, selectedThread, selectedThreadProject?.workspaceRoot, terminalMenuSessions]); + void navigation.push(buildThreadTerminalNavigation(selectedThread, nextId)); + }, [navigation, selectedThread, selectedThreadProject?.workspaceRoot, terminalMenuSessions]); const handleRunProjectScript = useCallback( async (script: ProjectScript) => { @@ -629,10 +632,10 @@ function ThreadRouteContent( worktreePath: preferredWorktreePath, }); - void router.push(buildThreadTerminalNavigation(selectedThread, targetTerminalId)); + void navigation.push(buildThreadTerminalNavigation(selectedThread, targetTerminalId)); }, [ - router, + navigation, selectedThread, selectedThreadDetailWorktreePath, selectedThreadProject, @@ -673,16 +676,16 @@ function ThreadRouteContent( icon: { name: "chevron.left", type: "sfSymbol" as const }, identifier: "thread-compact-back", onPress: () => { - if (router.canGoBack()) { - router.back(); + if (navigation.canGoBack()) { + navigation.back(); return; } - router.replace("/"); + navigation.replace(homeNavigation()); }, type: "button" as const, }), ], - [router], + [navigation], ); const splitLeftHeaderItems = useMemo( () => [ @@ -719,11 +722,11 @@ function ThreadRouteContent( accessibilityLabel: "New task", icon: { name: "square.and.pencil", type: "sfSymbol" as const }, identifier: "thread-left-new-task", - onPress: () => router.push("/new"), + onPress: () => navigation.push(newTaskNavigation()), type: "button" as const, }), ], - [panes.primarySidebarVisible, props.onReturnToThread, router, togglePrimarySidebar], + [panes.primarySidebarVisible, props.onReturnToThread, navigation, togglePrimarySidebar], ); if (!environmentId || !threadId) { @@ -799,9 +802,9 @@ function ThreadRouteContent( selectedThreadKey={selectedThreadKey} onClose={() => setDrawerVisible(false)} onSelectThread={(thread) => { - router.replace(buildThreadRoutePath(thread)); + navigation.replace(threadNavigation(thread)); }} - onStartNewTask={() => router.push("/new")} + onStartNewTask={() => navigation.push(newTaskNavigation())} /> )} diff --git a/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx b/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx index aed634b8d4..ec5e2283cc 100644 --- a/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx +++ b/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx @@ -15,7 +15,7 @@ import { vcsEnvironment } from "../../../state/vcs"; import { SheetActionButton } from "./gitSheetComponents"; export function GitBranchesSheet() { - const router = useAppNavigation(); + const navigation = useAppNavigation(); const insets = useSafeAreaInsets(); const { selectedThread } = useThreadSelection(); const { selectedThreadCwd, selectedThreadWorktreePath } = useSelectedThreadWorktree(); @@ -96,7 +96,7 @@ export function GitBranchesSheet() { if (branch.length === 0) return; void gitActions.onCreateSelectedThreadBranch(branch).then(() => { setNewBranchName(""); - router.dismiss(); + navigation.dismiss(); }); }} /> @@ -146,7 +146,7 @@ export function GitBranchesSheet() { if (baseBranch.length === 0 || newBranch.length === 0) return; void gitActions.onCreateSelectedThreadWorktree({ baseBranch, newBranch }).then(() => { setWorktreeBranchName(""); - router.dismiss(); + navigation.dismiss(); }); }} /> @@ -188,7 +188,7 @@ export function GitBranchesSheet() { }} onPress={() => { void gitActions.onCheckoutSelectedThreadBranch(branch.name).then(() => { - router.dismiss(); + navigation.dismiss(); }); }} > diff --git a/apps/mobile/src/features/threads/git/GitCommitSheet.tsx b/apps/mobile/src/features/threads/git/GitCommitSheet.tsx index db0784ad4f..7a093a565f 100644 --- a/apps/mobile/src/features/threads/git/GitCommitSheet.tsx +++ b/apps/mobile/src/features/threads/git/GitCommitSheet.tsx @@ -14,7 +14,7 @@ import { vcsEnvironment } from "../../../state/vcs"; import { SheetActionButton } from "./gitSheetComponents"; export function GitCommitSheet() { - const router = useAppNavigation(); + const navigation = useAppNavigation(); const insets = useSafeAreaInsets(); const isDarkMode = useColorScheme() === "dark"; const { selectedThread } = useThreadSelection(); @@ -55,7 +55,7 @@ export function GitCommitSheet() { const runCommitAction = useCallback( async (featureBranch: boolean) => { const commitMessage = dialogCommitMessage.trim(); - router.dismiss(); + navigation.dismiss(); await gitActions.onRunSelectedThreadGitAction({ action: "commit", featureBranch, @@ -63,7 +63,7 @@ export function GitCommitSheet() { ...(!allSelected ? { filePaths: selectedFiles.map((file) => file.path) } : {}), }); }, - [allSelected, dialogCommitMessage, gitActions, router, selectedFiles], + [allSelected, dialogCommitMessage, gitActions, navigation, selectedFiles], ); return ( diff --git a/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx b/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx index e240d8c060..df2a7514fd 100644 --- a/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx +++ b/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx @@ -13,7 +13,7 @@ import { useSelectedThreadGitState } from "../../../state/use-selected-thread-gi import { SheetActionButton } from "./gitSheetComponents"; export function GitConfirmSheet() { - const router = useAppNavigation(); + const navigation = useAppNavigation(); const insets = useSafeAreaInsets(); const gitState = useSelectedThreadGitState(); const gitActions = useSelectedThreadGitActions(); @@ -49,17 +49,17 @@ export function GitConfirmSheet() { const continuePendingAction = useCallback(async () => { if (!confirmAction) return; - router.dismissAll(); + navigation.dismissAll(); await gitActions.onRunSelectedThreadGitAction({ action: confirmAction, ...(params.commitMessage ? { commitMessage: params.commitMessage } : {}), ...(params.filePaths ? { filePaths: params.filePaths.split(",") } : {}), }); - }, [confirmAction, gitActions, params, router]); + }, [confirmAction, gitActions, params, navigation]); const movePendingActionToFeatureBranch = useCallback(async () => { if (!confirmAction) return; - router.dismissAll(); + navigation.dismissAll(); if (includesCommit) { await gitActions.onRunSelectedThreadGitAction({ @@ -82,7 +82,14 @@ export function GitConfirmSheet() { ); await gitActions.onCreateSelectedThreadBranch(newBranchName); await gitActions.onRunSelectedThreadGitAction({ action: confirmAction }); - }, [confirmAction, gitActions, gitState.selectedThreadBranches, includesCommit, params, router]); + }, [ + confirmAction, + gitActions, + gitState.selectedThreadBranches, + includesCommit, + params, + navigation, + ]); return ( diff --git a/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx b/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx index 20e04b54df..5e0c1c4a3f 100644 --- a/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx +++ b/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx @@ -16,7 +16,12 @@ import { useThemeColor } from "../../../lib/useThemeColor"; import { AppText as Text } from "../../../components/AppText"; import { nativeHeaderScrollEdgeEffects } from "../../../lib/native-scroll-edge-effect"; import { tryOpenExternalUrl } from "../../../lib/openExternalUrl"; -import { buildThreadReviewRoutePath } from "../../../lib/routes"; +import { + buildGitBranchesNavigation, + buildGitCommitNavigation, + buildGitConfirmNavigation, + buildThreadReviewNavigation, +} from "../../../lib/routes"; import { useEnvironmentQuery } from "../../../state/query"; import { useThreadSelection } from "../../../state/use-thread-selection"; import { useSelectedThreadGitActions } from "../../../state/use-selected-thread-git-actions"; @@ -33,7 +38,7 @@ export function GitOverviewSheet( readonly presentation?: "sheet" | "inspector"; } = {}, ) { - const router = useAppNavigation(); + const navigation = useAppNavigation(); const insets = useSafeAreaInsets(); const presentation = props.presentation ?? "sheet"; const isInspector = presentation === "inspector"; @@ -119,27 +124,27 @@ export function GitOverviewSheet( !input.featureBranch && requiresDefaultBranchConfirmation(input.action, isDefaultRef) ) { - router.push({ - name: "GitConfirm", - params: { - environmentId, - threadId, - confirmAction: confirmableAction, - branchName, - includesCommit: String( - input.action === "commit_push" || input.action === "commit_push_pr", - ), - }, - }); + navigation.push( + buildGitConfirmNavigation( + { environmentId, threadId }, + { + confirmAction: confirmableAction, + branchName, + includesCommit: String( + input.action === "commit_push" || input.action === "commit_push_pr", + ), + }, + ), + ); return; } if (!isInspector) { - router.dismiss(); + navigation.dismiss(); } await gitActions.onRunSelectedThreadGitAction(input); }, - [environmentId, gitActions, gitStatus.data, isDefaultRef, isInspector, router, threadId], + [environmentId, gitActions, gitStatus.data, isDefaultRef, isInspector, navigation, threadId], ); const onPressMenuItem = useCallback( @@ -150,10 +155,7 @@ export function GitOverviewSheet( return; } if (item.dialogAction === "commit") { - router.push({ - name: "GitCommit", - params: { environmentId, threadId }, - }); + navigation.push(buildGitCommitNavigation({ environmentId, threadId })); return; } if (item.dialogAction === "push") { @@ -164,7 +166,7 @@ export function GitOverviewSheet( await runActionWithPrompt({ action: "create_pr" }); } }, - [environmentId, openExistingPr, router, runActionWithPrompt, threadId], + [environmentId, openExistingPr, navigation, runActionWithPrompt, threadId], ); const inspectorHeaderRightBarButtonItems = useMemo( @@ -238,7 +240,7 @@ export function GitOverviewSheet( title="Review changes" subtitle="Inspect turn diffs, worktree changes, and base branch diff" disabled={busy || !isRepo} - onPress={() => router.push(buildThreadReviewRoutePath({ environmentId, threadId }))} + onPress={() => navigation.push(buildThreadReviewNavigation({ environmentId, threadId }))} /> - router.push({ - name: "GitBranches", - params: { environmentId, threadId }, - }) - } + onPress={() => navigation.push(buildGitBranchesNavigation({ environmentId, threadId }))} /> diff --git a/apps/mobile/src/lib/routes.test.ts b/apps/mobile/src/lib/routes.test.ts index dffe212457..aad266bab0 100644 --- a/apps/mobile/src/lib/routes.test.ts +++ b/apps/mobile/src/lib/routes.test.ts @@ -1,7 +1,14 @@ import { describe, expect, it } from "vite-plus/test"; import { EnvironmentId, ThreadId } from "@t3tools/contracts"; -import { buildThreadFilesNavigation, buildThreadFilesRoutePath } from "./routes"; +import { + buildGitConfirmNavigation, + buildThreadFilesNavigation, + buildThreadFilesRoutePath, + buildThreadReviewCommentNavigation, + newTaskDraftNavigation, + threadNavigation, +} from "./routes"; const thread = { environmentId: EnvironmentId.make("environment-1"), @@ -43,3 +50,61 @@ describe("thread file routes", () => { }); }); }); + +describe("named navigation targets", () => { + it("builds thread params without string route templates", () => { + expect(threadNavigation(thread)).toEqual({ + name: "Thread", + params: { + environmentId: "environment-1", + threadId: "thread-1", + }, + }); + }); + + it("builds review comment params without string route templates", () => { + expect(buildThreadReviewCommentNavigation(thread)).toEqual({ + name: "ThreadReviewComment", + params: { + environmentId: "environment-1", + threadId: "thread-1", + }, + }); + }); + + it("builds git confirmation params with action metadata", () => { + expect( + buildGitConfirmNavigation(thread, { + branchName: "main", + confirmAction: "push", + includesCommit: "false", + }), + ).toEqual({ + name: "GitConfirm", + params: { + environmentId: "environment-1", + threadId: "thread-1", + branchName: "main", + confirmAction: "push", + includesCommit: "false", + }, + }); + }); + + it("builds new task draft params in one place", () => { + expect( + newTaskDraftNavigation({ + environmentId: "environment-1", + projectId: "project-1", + title: "Project", + }), + ).toEqual({ + name: "NewTaskDraft", + params: { + environmentId: "environment-1", + projectId: "project-1", + title: "Project", + }, + }); + }); +}); diff --git a/apps/mobile/src/lib/routes.ts b/apps/mobile/src/lib/routes.ts index 2cd9f243f1..37c358b867 100644 --- a/apps/mobile/src/lib/routes.ts +++ b/apps/mobile/src/lib/routes.ts @@ -5,7 +5,7 @@ import type { AppNavigation } from "../navigation/app-navigation"; import type { AppNavigationTarget } from "../navigation/route-model"; import type { SelectedThreadRef } from "../state/remote-runtime-types"; -type Router = AppNavigation; +type Navigation = AppNavigation; type ThreadRouteInput = | Pick @@ -27,12 +27,157 @@ export function buildThreadRoutePath(input: ThreadRouteInput | PlainThreadRouteI return `/threads/${encodeURIComponent(environmentId)}/${encodeURIComponent(threadId)}`; } +export function homeNavigation(): AppNavigationTarget { + return { name: "Home" }; +} + +export function settingsNavigation(): AppNavigationTarget { + return { name: "Settings" }; +} + +export function settingsEnvironmentsNavigation(): AppNavigationTarget { + return { name: "SettingsEnvironments" }; +} + +export function settingsEnvironmentNewNavigation(): AppNavigationTarget { + return { name: "SettingsEnvironmentNew" }; +} + +export function settingsAuthNavigation(): AppNavigationTarget { + return { name: "SettingsAuth" }; +} + +export function settingsArchiveNavigation(): AppNavigationTarget { + return { name: "SettingsArchive" }; +} + +export function settingsWaitlistNavigation(): AppNavigationTarget { + return { name: "SettingsWaitlist" }; +} + +export function connectionsNavigation(): AppNavigationTarget { + return { name: "Connections" }; +} + +export function connectionsNewNavigation(): AppNavigationTarget { + return { name: "ConnectionsNew" }; +} + +export function newTaskNavigation(): AppNavigationTarget { + return { name: "NewTask" }; +} + +export function addProjectNavigation(): AppNavigationTarget { + return { name: "AddProject" }; +} + +export function addProjectRepositoryNavigation(params: { + readonly environmentId?: string; + readonly source?: string; +}): AppNavigationTarget { + return { name: "AddProjectRepository", params }; +} + +export function addProjectLocalNavigation(params: { + readonly environmentId?: string; +}): AppNavigationTarget { + return { name: "AddProjectLocal", params }; +} + +export function addProjectDestinationNavigation(params: { + readonly environmentId?: string; + readonly source?: string; + readonly remoteUrl?: string; + readonly repositoryTitle?: string; +}): AppNavigationTarget { + return { name: "AddProjectDestination", params }; +} + +export function newTaskDraftNavigation(params: { + readonly environmentId: string; + readonly projectId: string; + readonly title: string; +}): AppNavigationTarget { + return { name: "NewTaskDraft", params }; +} + +export function threadNavigation( + input: ThreadRouteInput | PlainThreadRouteInput, +): AppNavigationTarget { + return { + name: "Thread", + params: threadRouteParams(input), + }; +} + export function buildThreadReviewRoutePath( input: ThreadRouteInput | PlainThreadRouteInput, ): string { return `${buildThreadRoutePath(input)}/review`; } +export function buildThreadReviewNavigation( + input: ThreadRouteInput | PlainThreadRouteInput, +): AppNavigationTarget { + return { + name: "ThreadReview", + params: threadRouteParams(input), + }; +} + +export function buildThreadReviewCommentNavigation( + input: ThreadRouteInput | PlainThreadRouteInput, +): AppNavigationTarget { + return { + name: "ThreadReviewComment", + params: threadRouteParams(input), + }; +} + +export function buildGitOverviewNavigation( + input: ThreadRouteInput | PlainThreadRouteInput, +): AppNavigationTarget { + return { + name: "GitOverview", + params: threadRouteParams(input), + }; +} + +export function buildGitCommitNavigation( + input: ThreadRouteInput | PlainThreadRouteInput, +): AppNavigationTarget { + return { + name: "GitCommit", + params: threadRouteParams(input), + }; +} + +export function buildGitBranchesNavigation( + input: ThreadRouteInput | PlainThreadRouteInput, +): AppNavigationTarget { + return { + name: "GitBranches", + params: threadRouteParams(input), + }; +} + +export function buildGitConfirmNavigation( + input: ThreadRouteInput | PlainThreadRouteInput, + params: { + readonly confirmAction: string; + readonly branchName: string; + readonly includesCommit: string; + }, +): AppNavigationTarget { + return { + name: "GitConfirm", + params: { + ...threadRouteParams(input), + ...params, + }, + }; +} + export function buildThreadFilesRoutePath( input: ThreadRouteInput | PlainThreadRouteInput, relativePath?: string | null, @@ -120,11 +265,21 @@ export function buildThreadFilesNavigation( }; } -export function dismissRoute(router: Router) { - if (router.canGoBack()) { - router.back(); +export function dismissRoute(navigation: Navigation) { + if (navigation.canGoBack()) { + navigation.back(); return; } - router.replace("/"); + navigation.replace(homeNavigation()); +} + +function threadRouteParams(input: ThreadRouteInput | PlainThreadRouteInput): { + readonly environmentId: string; + readonly threadId: string; +} { + return { + environmentId: String(input.environmentId), + threadId: String("threadId" in input ? input.threadId : input.id), + }; } diff --git a/apps/mobile/src/navigation/app-navigation.tsx b/apps/mobile/src/navigation/app-navigation.tsx index 6bc4a7e2d5..512c960081 100644 --- a/apps/mobile/src/navigation/app-navigation.tsx +++ b/apps/mobile/src/navigation/app-navigation.tsx @@ -12,14 +12,14 @@ import { getFocusedRoute, resolveNavigationTarget, type AppFocusedRoute, - type AppHref, + type AppNavigationInput, type AppStackParamList, type RouteParams, } from "./route-model"; export type AppNavigation = { - readonly push: (href: AppHref) => void; - readonly replace: (href: AppHref) => void; + readonly push: (target: AppNavigationInput) => void; + readonly replace: (target: AppNavigationInput) => void; readonly back: () => void; readonly dismiss: () => void; readonly dismissAll: () => void; @@ -63,8 +63,11 @@ export function useCurrentRouteParams(): T export function createAppNavigation( navigationRef: React.RefObject | null>, ): AppNavigation { - const navigateWithAction = (href: AppHref, action: "push" | "replace" | "navigate"): void => { - const target = resolveNavigationTarget(href); + const navigateWithAction = ( + input: AppNavigationInput, + action: "push" | "replace" | "navigate", + ): void => { + const target = resolveNavigationTarget(input); const navigation = navigationRef.current; if (!navigation) { return; diff --git a/apps/mobile/src/navigation/native-stack-header.tsx b/apps/mobile/src/navigation/native-stack-header.tsx index 611d6ec1c2..64ad7404bd 100644 --- a/apps/mobile/src/navigation/native-stack-header.tsx +++ b/apps/mobile/src/navigation/native-stack-header.tsx @@ -24,11 +24,11 @@ import { import type { ColorValue } from "react-native"; import { useAppNavigation } from "./app-navigation"; -import type { AppHref, RouteParams } from "./route-model"; +import type { AppNavigationInput, RouteParams } from "./route-model"; export { useFocusEffect }; export { useAppNavigation, useCurrentPathname, useCurrentRouteParams } from "./app-navigation"; -export type { AppHref }; +export type { AppNavigationInput }; export type AppNativeStackNavigationOptions = Omit< NativeStackNavigationOptions, @@ -366,7 +366,7 @@ function NativeStackScreenTitle(_props: { NativeStackScreenOptions.Title = NativeStackScreenTitle; -export function NavigateTo(props: { readonly href: AppHref }) { +export function NavigateTo(props: { readonly href: AppNavigationInput }) { const navigation = useAppNavigation(); useEffect(() => { navigation.replace(props.href); @@ -375,7 +375,7 @@ export function NavigateTo(props: { readonly href: AppHref }) { } export function NavigationLink(props: { - readonly href: AppHref; + readonly href: AppNavigationInput; readonly asChild?: boolean; readonly children?: ReactNode; }) { diff --git a/apps/mobile/src/navigation/route-model.ts b/apps/mobile/src/navigation/route-model.ts index e11e741e20..72fbd7bba5 100644 --- a/apps/mobile/src/navigation/route-model.ts +++ b/apps/mobile/src/navigation/route-model.ts @@ -61,13 +61,7 @@ export type AppStackParamList = { NotFound: RouteParams | undefined; }; -export type AppHref = - | string - | AppNavigationTarget - | { - readonly pathname: string; - readonly params?: RouteParams; - }; +export type AppNavigationInput = string | AppNavigationTarget; export type AppNavigationTarget = { readonly name: AppRouteName; @@ -147,57 +141,16 @@ function mergeParams( return normalizeRouteParams({ ...base, ...extra }); } -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); +export function resolveNavigationTarget(input: AppNavigationInput): AppNavigationTarget { + if (typeof input !== "string") { + return withParams(input.name, input.params); } - const { pathname, query } = splitPathAndQuery(href); + const { pathname, query } = splitPathAndQuery(input); const target = resolveNavigationPath(pathname); return { name: target.name, params: mergeParams(target.params, query) }; } -function resolveNavigationObject( - pathname: string, - params: RouteParams | undefined, -): AppNavigationTarget { - switch (pathname) { - case "/threads/[environmentId]/[threadId]/terminal": - return withParams("ThreadTerminal", params); - case "/threads/[environmentId]/[threadId]/files": - return withParams("ThreadFiles", params); - case "/threads/[environmentId]/[threadId]/files/[...path]": - return withParams("ThreadFile", params); - case "/threads/[environmentId]/[threadId]/review": - return withParams("ThreadReview", params); - case "/threads/[environmentId]/[threadId]/review-comment": - return withParams("ThreadReviewComment", params); - case "/threads/[environmentId]/[threadId]/git": - return withParams("GitOverview", params); - case "/threads/[environmentId]/[threadId]/git/commit": - return withParams("GitCommit", params); - case "/threads/[environmentId]/[threadId]/git/branches": - return withParams("GitBranches", params); - case "/threads/[environmentId]/[threadId]/git-confirm": - return withParams("GitConfirm", params); - case "/new/draft": - return withParams("NewTaskDraft", params); - case "/new/add-project/repository": - return withParams("AddProjectRepository", params); - case "/new/add-project/destination": - return withParams("AddProjectDestination", params); - case "/new/add-project/local": - return withParams("AddProjectLocal", params); - default: { - const target = resolveNavigationPath(pathname); - return { ...target, params: mergeParams(target.params, params) }; - } - } -} - export function resolveNavigationPath(pathname: string): AppNavigationTarget { const segments = pathSegments(pathname); diff --git a/apps/mobile/src/screens/+not-found.tsx b/apps/mobile/src/screens/+not-found.tsx index 3d9f502e55..7dc664b8c1 100644 --- a/apps/mobile/src/screens/+not-found.tsx +++ b/apps/mobile/src/screens/+not-found.tsx @@ -3,6 +3,7 @@ import { Pressable, ScrollView, StyleSheet } from "react-native"; import { useResolveClassNames } from "uniwind"; import { AppText as Text } from "../components/AppText"; +import { homeNavigation } from "../lib/routes"; export default function NotFoundRoute() { const screenBgStyle = StyleSheet.flatten(useResolveClassNames("bg-screen")); @@ -32,7 +33,7 @@ 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 e459a141cc..15084bfc8a 100644 --- a/apps/mobile/src/screens/connections/index.tsx +++ b/apps/mobile/src/screens/connections/index.tsx @@ -12,6 +12,7 @@ import { useThemeColor } from "../../lib/useThemeColor"; import { AppText as Text } from "../../components/AppText"; import { cn } from "../../lib/cn"; +import { connectionsNewNavigation } from "../../lib/routes"; import { useRemoteConnections } from "../../state/use-remote-environment-registry"; import { ConnectionEnvironmentRow } from "../../features/connection/ConnectionEnvironmentRow"; @@ -22,7 +23,7 @@ export default function ConnectionsRouteScreen() { onRemoveEnvironmentPress, onUpdateEnvironment, } = useRemoteConnections(); - const router = useAppNavigation(); + const navigation = useAppNavigation(); const insets = useSafeAreaInsets(); const hasEnvironments = connectedEnvironments.length > 0; const [expandedId, setExpandedId] = useState(null); @@ -43,7 +44,7 @@ export default function ConnectionsRouteScreen() { router.push("/connections/new")} + onPress={() => navigation.push(connectionsNewNavigation())} separateBackground /> diff --git a/apps/mobile/src/screens/connections/new.tsx b/apps/mobile/src/screens/connections/new.tsx index 1673a392ae..a08fd9b164 100644 --- a/apps/mobile/src/screens/connections/new.tsx +++ b/apps/mobile/src/screens/connections/new.tsx @@ -26,7 +26,7 @@ export default function ConnectionsNewRouteScreen() { onConnectPress, pairingConnectionError, } = useRemoteConnections(); - const router = useAppNavigation(); + const navigation = useAppNavigation(); const params = useRouteParams<{ mode?: string }>(); const insets = useSafeAreaInsets(); const [hostInput, setHostInput] = useState(""); @@ -121,11 +121,11 @@ export default function ConnectionsNewRouteScreen() { onChangeConnectionPairingUrl(pairingUrl); const result = await onConnectPress(pairingUrl); if (AsyncResult.isSuccess(result)) { - dismissRoute(router); + dismissRoute(navigation); } else { setIsSubmitting(false); } - }, [codeInput, hostInput, onChangeConnectionPairingUrl, onConnectPress, router]); + }, [codeInput, hostInput, onChangeConnectionPairingUrl, onConnectPress, navigation]); return ( diff --git a/apps/mobile/src/screens/index.tsx b/apps/mobile/src/screens/index.tsx index 56605d123f..0eca8a62bb 100644 --- a/apps/mobile/src/screens/index.tsx +++ b/apps/mobile/src/screens/index.tsx @@ -9,7 +9,13 @@ import { useMemo, useState } from "react"; import { useProjects, useThreadShells } from "../state/entities"; import { useWorkspaceState } from "../state/workspace"; -import { buildThreadRoutePath } from "../lib/routes"; +import { + connectionsNewNavigation, + newTaskNavigation, + settingsEnvironmentsNavigation, + settingsNavigation, + threadNavigation, +} from "../lib/routes"; import { useSavedRemoteConnections } from "../state/use-remote-environment-registry"; import { HomeScreen } from "../features/home/HomeScreen"; import { HomeHeader } from "../features/home/HomeHeader"; @@ -27,7 +33,7 @@ export default function HomeRouteScreen() { const threads = useThreadShells(); const { state: catalogState } = useWorkspaceState(); const { savedConnectionsById } = useSavedRemoteConnections(); - const router = useAppNavigation(); + const navigation = useAppNavigation(); const [searchQuery, setSearchQuery] = useState(""); const { archiveThread, confirmDeleteThread } = useThreadListActions(); const environments = useMemo( @@ -73,7 +79,7 @@ export default function HomeRouteScreen() { router.push("/new")} + onPress={() => navigation.push(newTaskNavigation())} /> } /> @@ -91,30 +97,30 @@ export default function HomeRouteScreen() { threadSortOrder={listOptions.threadSortOrder} projectGroupingMode={listOptions.projectGroupingMode} onEnvironmentChange={setSelectedEnvironmentId} - onOpenSettings={() => router.push("/settings")} + onOpenSettings={() => navigation.push(settingsNavigation())} onProjectGroupingModeChange={setProjectGroupingMode} onProjectSortOrderChange={setProjectSortOrder} onSearchQueryChange={setSearchQuery} - onStartNewTask={() => router.push("/new")} + onStartNewTask={() => navigation.push(newTaskNavigation())} onThreadSortOrderChange={setThreadSortOrder} /> router.push("/connections/new")} + onAddConnection={() => navigation.push(connectionsNewNavigation())} onArchiveThread={archiveThread} onDeleteThread={confirmDeleteThread} onEnvironmentChange={setSelectedEnvironmentId} - onOpenEnvironments={() => router.push("/settings/environments")} - onOpenSettings={() => router.push("/settings")} + onOpenEnvironments={() => navigation.push(settingsEnvironmentsNavigation())} + onOpenSettings={() => navigation.push(settingsNavigation())} onProjectGroupingModeChange={setProjectGroupingMode} onProjectSortOrderChange={setProjectSortOrder} onSearchQueryChange={setSearchQuery} onSelectThread={(thread) => { - router.push(buildThreadRoutePath(thread)); + navigation.push(threadNavigation(thread)); }} - onStartNewTask={() => router.push("/new")} + onStartNewTask={() => navigation.push(newTaskNavigation())} onThreadSortOrderChange={setThreadSortOrder} projectGroupingMode={listOptions.projectGroupingMode} projects={projects} diff --git a/apps/mobile/src/screens/new/index.tsx b/apps/mobile/src/screens/new/index.tsx index 75e23e2d91..64760e9d4e 100644 --- a/apps/mobile/src/screens/new/index.tsx +++ b/apps/mobile/src/screens/new/index.tsx @@ -17,6 +17,11 @@ import { useProjects, useThreadShells } from "../../state/entities"; import type { WorkspaceState } from "../../state/workspaceModel"; import { useWorkspaceState } from "../../state/workspace"; import { groupProjectsByRepository } from "../../lib/repositoryGroups"; +import { + addProjectNavigation, + connectionsNewNavigation, + newTaskDraftNavigation, +} from "../../lib/routes"; import { useAdaptiveWorkspaceLayout } from "../../features/layout/AdaptiveWorkspaceLayout"; function deriveProjectEmptyState(catalogState: WorkspaceState): { @@ -78,7 +83,7 @@ export default function NewTaskRoute() { const projects = useProjects(); const threads = useThreadShells(); const { state: catalogState } = useWorkspaceState(); - const router = useAppNavigation(); + const navigation = useAppNavigation(); const { layout } = useAdaptiveWorkspaceLayout(); const insets = useSafeAreaInsets(); const chevronColor = useThemeColor("--color-chevron"); @@ -121,13 +126,13 @@ export default function NewTaskRoute() { router.dismiss()} + onPress={() => navigation.dismiss()} separateBackground /> ) : null} router.push("/new/add-project")} + onPress={() => navigation.push(addProjectNavigation())} separateBackground /> @@ -153,7 +158,7 @@ export default function NewTaskRoute() { {!catalogState.hasReadyEnvironment ? ( router.push("/connections/new")} + onPress={() => navigation.push(connectionsNewNavigation())} > Add environment @@ -162,7 +167,7 @@ export default function NewTaskRoute() { ) : ( router.push("/new/add-project")} + onPress={() => navigation.push(addProjectNavigation())} > Add new project @@ -179,14 +184,11 @@ export default function NewTaskRoute() { return ( ) : ( - + ); } diff --git a/apps/mobile/src/screens/settings/environments.tsx b/apps/mobile/src/screens/settings/environments.tsx index 0af15c027f..3bfb01c827 100644 --- a/apps/mobile/src/screens/settings/environments.tsx +++ b/apps/mobile/src/screens/settings/environments.tsx @@ -34,6 +34,7 @@ import { ConnectionStatusDot } from "../../features/connection/ConnectionStatusD import { splitEnvironmentSections } from "../../features/connection/environmentSections"; import { cn } from "../../lib/cn"; import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic"; +import { settingsEnvironmentNewNavigation } from "../../lib/routes"; import { useThemeColor } from "../../lib/useThemeColor"; import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-types"; import { useRemoteConnections } from "../../state/use-remote-environment-registry"; @@ -45,7 +46,7 @@ export default function SettingsEnvironmentsRouteScreen() { onRemoveEnvironmentPress, onUpdateEnvironment, } = useRemoteConnections(); - const router = useAppNavigation(); + const navigation = useAppNavigation(); const insets = useSafeAreaInsets(); const { localEnvironments, connectedCloudEnvironments } = splitEnvironmentSections({ connectedEnvironments, @@ -69,7 +70,7 @@ export default function SettingsEnvironmentsRouteScreen() { router.push("/settings/environment-new")} + onPress={() => navigation.push(settingsEnvironmentNewNavigation())} separateBackground /> diff --git a/apps/mobile/src/screens/settings/index.tsx b/apps/mobile/src/screens/settings/index.tsx index 23a82f1e86..c2c1bae8bc 100644 --- a/apps/mobile/src/screens/settings/index.tsx +++ b/apps/mobile/src/screens/settings/index.tsx @@ -35,13 +35,19 @@ import { WorkspaceSidebarToolbar } from "../../features/layout/workspace-sidebar import { runtime } from "../../lib/runtime"; import { loadPreferences } from "../../lib/storage"; import { useThemeColor } from "../../lib/useThemeColor"; +import { + settingsArchiveNavigation, + settingsAuthNavigation, + settingsEnvironmentsNavigation, + settingsWaitlistNavigation, +} from "../../lib/routes"; import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry"; type NotificationStatus = "checking" | "enabled" | "disabled" | "unsupported"; type LiveActivityStatus = "checking" | "enabled" | "disabled" | "signed-out" | "linking"; export default function SettingsRouteScreen() { - const router = useAppNavigation(); + const navigation = useAppNavigation(); const { layout } = useAdaptiveWorkspaceLayout(); return ( @@ -52,7 +58,7 @@ export default function SettingsRouteScreen() { router.back()} + onPress={() => navigation.back()} separateBackground /> @@ -86,7 +92,7 @@ function LocalSettingsRouteScreen() { icon="desktopcomputer" label="Environments" value={`${environmentCount}`} - href="/settings/environments" + href={settingsEnvironmentsNavigation()} /> @@ -100,7 +106,7 @@ function LocalSettingsRouteScreen() { function ConfiguredSettingsRouteScreen() { const insets = useSafeAreaInsets(); - const { push } = useAppNavigation(); + const navigation = useAppNavigation(); const { expand: expandClerkSheet } = useClerkSettingsSheetDetent(); const { getToken, isLoaded, isSignedIn } = useAuth({ treatPendingAsSignedOut: false }); const { user } = useUser(); @@ -211,10 +217,10 @@ function ConfiguredSettingsRouteScreen() { "Live Activity updates require approved T3 Cloud access so relay can deliver updates to this device.", [ { text: "Cancel", style: "cancel" }, - { text: "Continue", onPress: () => push("/settings/waitlist") }, + { text: "Continue", onPress: () => navigation.push(settingsWaitlistNavigation()) }, ], ); - }, [push]); + }, [navigation]); const linkEnvironments = useCallback(async () => { if (!isSignedIn) { @@ -341,12 +347,12 @@ function ConfiguredSettingsRouteScreen() { const openAccount = useCallback(() => { if (!isLoaded) return; if (!isSignedIn) { - push("/settings/waitlist"); + navigation.push(settingsWaitlistNavigation()); return; } expandClerkSheet(); - push("/settings/auth"); - }, [expandClerkSheet, isLoaded, isSignedIn, push]); + navigation.push(settingsAuthNavigation()); + }, [expandClerkSheet, isLoaded, isSignedIn, navigation]); return ( @@ -381,7 +387,7 @@ function ConfiguredSettingsRouteScreen() { icon="desktopcomputer" label="Environments" value={`${environmentCount}`} - href="/settings/environments" + href={settingsEnvironmentsNavigation()} /> - + ); } @@ -458,7 +464,7 @@ function SettingsRow(props: { readonly icon: SymbolName; readonly label: string; readonly value?: string; - readonly href?: "/settings/archive" | "/settings/environments"; + readonly href?: ComponentProps["href"]; readonly onPress?: () => void; }) { const icon = useThemeColor("--color-icon"); diff --git a/apps/mobile/src/screens/settings/waitlist.tsx b/apps/mobile/src/screens/settings/waitlist.tsx index d83e3c966d..057ea5eabe 100644 --- a/apps/mobile/src/screens/settings/waitlist.tsx +++ b/apps/mobile/src/screens/settings/waitlist.tsx @@ -11,26 +11,27 @@ import { ScrollView } from "react-native"; import { CloudWaitlistEnrollment } from "../../features/cloud/CloudWaitlistEnrollment"; import { useClerkSettingsSheetDetent } from "../../features/cloud/ClerkSettingsSheetDetent"; import { hasCloudPublicConfig } from "../../features/cloud/publicConfig"; +import { settingsAuthNavigation, settingsNavigation } from "../../lib/routes"; export default function SettingsWaitlistRouteScreen() { return hasCloudPublicConfig() ? ( ) : ( - + ); } function ConfiguredSettingsWaitlistRouteScreen() { const { isLoaded, isSignedIn } = useAuth({ treatPendingAsSignedOut: false }); const { expand } = useClerkSettingsSheetDetent(); - const router = useAppNavigation(); + const navigation = useAppNavigation(); useFocusEffect( useCallback(() => { if (isLoaded && isSignedIn) { - router.replace("/settings"); + navigation.replace(settingsNavigation()); } - }, [isLoaded, isSignedIn, router]), + }, [isLoaded, isSignedIn, navigation]), ); return ( @@ -51,7 +52,7 @@ function ConfiguredSettingsWaitlistRouteScreen() { { expand(); - router.push("/settings/auth"); + navigation.push(settingsAuthNavigation()); }} />