TypeScript
fix(mobile): center Android sheets and fit book-mode sheets in the left pane (#18492)
Alex5b15cfc1e8f3
diff --git a/apps/mobile/deps/react-native-screens-5.0.0-t3.45.tgz b/apps/mobile/deps/react-native-screens-5.0.0-t3.45.tgzdeleted file mode 100644index 2e076b177f3..00000000000Binary files a/apps/mobile/deps/react-native-screens-5.0.0-t3.45.tgz and /dev/null differdiff --git a/apps/mobile/deps/react-native-screens-5.0.0-t3.48.tgz b/apps/mobile/deps/react-native-screens-5.0.0-t3.48.tgznew file mode 100644index 00000000000..f1eb3858e98Binary files /dev/null and b/apps/mobile/deps/react-native-screens-5.0.0-t3.48.tgz differdiff --git a/apps/mobile/package.json b/apps/mobile/package.jsonindex e91ec70d0ba..f5e817165b9 100644--- a/apps/mobile/package.json+++ b/apps/mobile/package.json@@ -127,7 +127,7 @@"react-native-pdf-jsi": "5.0.0","react-native-reanimated": "4.7.1","react-native-safe-area-context": "~5.10.1",- "react-native-screens": "file:deps/react-native-screens-5.0.0-t3.45.tgz",+ "react-native-screens": "file:deps/react-native-screens-5.0.0-t3.48.tgz","react-native-svg": "15.16.0","react-native-webview": "14.0.1","react-native-worklets": "0.13.0",diff --git a/apps/mobile/src/components/ui/AndroidScreenHeader.tsx b/apps/mobile/src/components/ui/AndroidScreenHeader.tsxindex 1b259f1ecbf..7931717682f 100644--- a/apps/mobile/src/components/ui/AndroidScreenHeader.tsx+++ b/apps/mobile/src/components/ui/AndroidScreenHeader.tsx@@ -1,7 +1,7 @@import { AppActivityIndicator } from "./AppActivityIndicator";import { Column, Row, Text as NativeText, RNHostView } from "@expo/ui/jetpack-compose";import { weight } from "@expo/ui/jetpack-compose/modifiers";-import { useState, type ReactNode } from "react";+import { use, useState, type ReactNode } from "react";import { View } from "react-native";import type { AppSymbolName } from "./AppSymbol";@@ -12,6 +12,7 @@ import { splitAndroidHeaderActions } from "./headerMenu.android";import { useScaledTextRole } from "../../features/settings/appearance/useScaledTextRole";import { useToolbarLayout } from "./useToolbarLayout";import { useControlTheme } from "./useControlTheme";+import { RoutedFormSheetContext } from "./RoutedFormSheetContext";export interface AndroidHeaderAction {readonly accessibilityLabel: string;@@ -50,7 +51,8 @@ export function AndroidScreenHeader(props: {const { colors } = useControlTheme();const titleTypography = useScaledTextRole("title");const subtitleTypography = useScaledTextRole("label");- const { paddingTop, paddingBottom } = useToolbarLayout(props.embedded);+ const inFormSheet = use(RoutedFormSheetContext);+ const { paddingTop, paddingBottom } = useToolbarLayout(props.embedded || inFormSheet);const [headerWidth, setHeaderWidth] = useState(0);const { visibleActions, overflowActions } = splitAndroidHeaderActions(props.actions ?? [],@@ -67,6 +69,12 @@ export function AndroidScreenHeader(props: {borderBottomWidth: props.hideBottomBorder ? 0 : undefined,}}>+ {inFormSheet ? (+ <View+ pointerEvents="none"+ className="absolute top-1 h-1 w-8 self-center rounded-full bg-header-foreground/40"+ />+ ) : null}<NativeAppBarsingleLine={props.compact}navigationIcon={diff --git a/apps/mobile/src/components/ui/RoutedFormSheetContext.ts b/apps/mobile/src/components/ui/RoutedFormSheetContext.tsnew file mode 100644index 00000000000..29ee63d996e--- /dev/null+++ b/apps/mobile/src/components/ui/RoutedFormSheetContext.ts@@ -0,0 +1,3 @@+import { createContext } from "react";++export const RoutedFormSheetContext = createContext(false);diff --git a/apps/mobile/src/components/ui/Sheet.android.tsx b/apps/mobile/src/components/ui/Sheet.android.tsxindex ac222485cf0..aaafffb8013 100644--- a/apps/mobile/src/components/ui/Sheet.android.tsx+++ b/apps/mobile/src/components/ui/Sheet.android.tsx@@ -3,6 +3,7 @@ import { View } from "react-native";import { FormSheet } from "react-native-screens";import { useResolveClassNames } from "uniwind";import { AndroidSheetHeader } from "./AndroidScreenHeader";+import { RoutedFormSheetContext } from "./RoutedFormSheetContext";import { ScreenContent } from "./ScreenContent";import type { SheetProps } from "./Sheet.types";export type { SheetProps } from "./Sheet.types";@@ -19,15 +20,21 @@ export function Sheet(props: SheetProps) {onDismiss={props.onClose}onNativeDismiss={props.onClose}>- {/* Android FormSheet does not bound flex children. Material drags target the first scroll view, so place content before the header. */}- <View collapsable={false} className="absolute inset-0 flex-col-reverse bg-header">- <ScreenContent>{props.children}</ScreenContent>- <AndroidSheetHeader title={props.title} onBack={() => setIsOpen(false)} hideBottomBorder />- <View- pointerEvents="none"- className="absolute top-1 h-1 w-8 self-center rounded-full bg-header-foreground/40"- />- </View>+ <RoutedFormSheetContext value={false}>+ {/* Android FormSheet does not bound flex children. Material drags target the first scroll view, so place content before the header. */}+ <View collapsable={false} className="absolute inset-0 flex-col-reverse bg-header">+ <ScreenContent>{props.children}</ScreenContent>+ <AndroidSheetHeader+ title={props.title}+ onBack={() => setIsOpen(false)}+ hideBottomBorder+ />+ <View+ pointerEvents="none"+ className="absolute top-1 h-1 w-8 self-center rounded-full bg-header-foreground/40"+ />+ </View>+ </RoutedFormSheetContext></FormSheet>);}diff --git a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsxindex 98bd85d8d9e..53d2fb3e1d7 100644--- a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx+++ b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx@@ -1,3 +1,7 @@+import {+ WorkspaceColumnsRendererContext,+ WorkspacePresentationHostContext,+} from "./workspace-presentation-context";import { useAndroidFloatingTabs } from "../settings/appearance/AppearancePreferencesProvider";import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";import { AdaptiveWorkspaceContext, useAdaptiveWorkspaceLayout } from "./adaptive-workspace-context";@@ -176,6 +180,7 @@ function AdaptiveWorkspaceLayoutContent(const floatingTabsEnabled = useAndroidFloatingTabs();const projectGroupingMode = props.projectGroupingMode;const nativeWorkspace = use(NativeWorkspaceModeContext);+ const usesPresentationHost = use(WorkspacePresentationHostContext);const windowDimensions = useWindowDimensions();const nativeMetrics = useNativeLayoutMetrics();const { width: viewportWidth, height } = nativeMetrics ?? windowDimensions;@@ -839,181 +844,185 @@ function AdaptiveWorkspaceLayoutContent(</HomeListOptionsProvider>);}- return (- <HomeListOptionsProvider- projectGroupingMode={projectGroupingMode}- savedFilters={props.savedThreadListFilters}+ const renderColumns = (children: ReactNode) => (+ <View+ testID="adaptive-workspace-layout"+ className={Platform.OS === "android" ? "flex-1 flex-row bg-header" : "flex-1 flex-row"}>- <AdaptiveWorkspaceContext.Provider value={contextValue}>- <WindowHingeContext value={windowHinge}>- <View- testID="adaptive-workspace-layout"- className={Platform.OS === "android" ? "flex-1 flex-row bg-header" : "flex-1 flex-row"}- >- <AndroidHingeObserver onChange={handleHingeChange} />- {shouldRenderNavigationRail ? (- <Animated.View className="self-stretch" style={railAnimatedStyle} />- ) : null}- {shouldRenderPrimarySidebar && layout.listPaneWidth !== null ? (- <Animated.View- className="self-stretch overflow-hidden"- accessibilityElementsHidden={workspacePage || !panes.primarySidebarVisible}- collapsable={false}- importantForAccessibility={- !workspacePage && panes.primarySidebarVisible ? "auto" : "no-hide-descendants"- }- pointerEvents={!workspacePage && panes.primarySidebarVisible ? "auto" : "none"}- // Under a workspace page the sidebar leaves the row but keeps its size, so its- // lists never lay out at zero size and are ready, unchanged, on the way back. The- // content pane, laid out after it, covers it, in the same mount as the page.- style={[- workspacePage ? { position: "absolute", top: 0, bottom: 0, left: 0 } : null,- sidebarAnimatedStyle,- ]}+ <AndroidHingeObserver onChange={handleHingeChange} />+ {shouldRenderNavigationRail ? (+ <Animated.View className="self-stretch" style={railAnimatedStyle} />+ ) : null}+ {shouldRenderPrimarySidebar && layout.listPaneWidth !== null ? (+ <Animated.View+ className="self-stretch overflow-hidden"+ accessibilityElementsHidden={workspacePage || !panes.primarySidebarVisible}+ collapsable={false}+ importantForAccessibility={+ !workspacePage && panes.primarySidebarVisible ? "auto" : "no-hide-descendants"+ }+ pointerEvents={!workspacePage && panes.primarySidebarVisible ? "auto" : "none"}+ // Under a workspace page the sidebar leaves the row but keeps its size, so its+ // lists never lay out at zero size and are ready, unchanged, on the way back. The+ // content pane, laid out after it, covers it, in the same mount as the page.+ style={[+ workspacePage ? { position: "absolute", top: 0, bottom: 0, left: 0 } : null,+ sidebarAnimatedStyle,+ ]}+ >+ <Animated.View className="flex-1" style={listPaneAnimatedStyle}>+ <RenderErrorBoundary+ renderFallback={(fallback) => (+ <RenderFailureView+ {...fallback}+ title="The sidebar couldn't be displayed"+ exit={{ label: "Open settings", onPress: handleOpenSettings }}+ />+ )}+ >+ <AndroidWorkspaceSidebar+ onRequestVisibility={revealPrimarySidebar}+ selectedPullRequestKey={props.selectedPullRequestKey ?? null}>- <Animated.View className="flex-1" style={listPaneAnimatedStyle}>- <RenderErrorBoundary- renderFallback={(fallback) => (- <RenderFailureView- {...fallback}- title="The sidebar couldn't be displayed"- exit={{ label: "Open settings", onPress: handleOpenSettings }}- />- )}- >- <AndroidWorkspaceSidebar- onRequestVisibility={revealPrimarySidebar}- selectedPullRequestKey={props.selectedPullRequestKey ?? null}- >- <AndroidHomeFabLayout- sidebar- disabled={workspacePage}- paneWidth={layout.listPaneWidth}- onStartNewTask={handleStartNewTask}- >- <ThreadNavigationSidebar- width={layout.listPaneWidth}- visible={panes.primarySidebarVisible}- onRequestVisibility={revealPrimarySidebar}- selectedThreadKey={selectedThreadKey}- onOpenSettings={handleOpenSettings}- onOpenEnvironmentSettings={handleOpenEnvironmentSettings}- onNewThreadInProject={handleNewThreadInProject}- onNewThreadOnBranch={handleNewThreadOnBranch}- onOpenPendingTask={handleOpenPendingTask}- onSelectThread={handleSelectThread}- onOpenThreadPullRequests={handleOpenThreadPullRequests}- onSearchQueryChange={setPrimarySidebarSearchQuery}- searchQuery={primarySidebarSearchQuery}- />- </AndroidHomeFabLayout>- </AndroidWorkspaceSidebar>- </RenderErrorBoundary>- {/* Keep the pill under the content throughout the sidebar's clipping animation. */}- {floatingTabsEnabled && !workspacePage ? (- <FloatingWorkspaceTabs- paneWidth={layout.listPaneWidth}- onNewThread={handleStartNewTask}- onSelect={revealPrimarySidebar}- />- ) : null}- </Animated.View>- </Animated.View>+ <AndroidHomeFabLayout+ sidebar+ disabled={workspacePage}+ paneWidth={layout.listPaneWidth}+ onStartNewTask={handleStartNewTask}+ >+ <ThreadNavigationSidebar+ width={layout.listPaneWidth}+ visible={panes.primarySidebarVisible}+ onRequestVisibility={revealPrimarySidebar}+ selectedThreadKey={selectedThreadKey}+ onOpenSettings={handleOpenSettings}+ onOpenEnvironmentSettings={handleOpenEnvironmentSettings}+ onNewThreadInProject={handleNewThreadInProject}+ onNewThreadOnBranch={handleNewThreadOnBranch}+ onOpenPendingTask={handleOpenPendingTask}+ onSelectThread={handleSelectThread}+ onOpenThreadPullRequests={handleOpenThreadPullRequests}+ onSearchQueryChange={setPrimarySidebarSearchQuery}+ searchQuery={primarySidebarSearchQuery}+ />+ </AndroidHomeFabLayout>+ </AndroidWorkspaceSidebar>+ </RenderErrorBoundary>+ {/* Keep the pill under the content throughout the sidebar's clipping animation. */}+ {floatingTabsEnabled && !workspacePage ? (+ <FloatingWorkspaceTabs+ paneWidth={layout.listPaneWidth}+ onNewThread={handleStartNewTask}+ onSelect={revealPrimarySidebar}+ />) : null}- <View- className={- Platform.OS === "android"- ? "flex-1 overflow-hidden bg-header"- : "flex-1 overflow-hidden bg-screen"- }- collapsable={false}+ </Animated.View>+ </Animated.View>+ ) : null}+ <View+ className={+ Platform.OS === "android"+ ? "flex-1 overflow-hidden bg-header"+ : "flex-1 overflow-hidden bg-screen"+ }+ collapsable={false}+ >+ <View+ collapsable={false}+ style={+ contentTargetWidth !== null+ ? {+ flex: 1,+ width: contentTargetWidth,+ alignSelf: contentAnchor.end ? "flex-end" : "flex-start",+ }+ : { flex: 1 }+ }+ >+ {/* Android holds the content still, so its floating controls keep its width. */}+ <WorkspaceContentWidthContext+ value={layout.usesSplitView && Platform.OS !== "android" ? renderedContentWidth : null}+ >+ <WorkspaceSettledContentWidthContext+ value={Platform.OS === "android" && layout.usesSplitView ? contentTargetWidth : null}>- <View- collapsable={false}- style={- contentTargetWidth !== null+ {/* Compact Settings keeps the bottom navigation under all of its pages. */}+ <SafeAreaInsetsContext+ value={+ floatingTabsEnabled &&+ (compactAndroidSettings || (layout.usesSplitView && workspacePage))? {- flex: 1,- width: contentTargetWidth,- alignSelf: contentAnchor.end ? "flex-end" : "flex-start",+ ...safeAreaInsets,+ bottom:+ safeAreaInsets.bottom ++ FLOATING_TABS.bottom ++ FLOATING_TABS.edge ++ floatingTabs.height,}- : { flex: 1 }+ : compactAndroidSettings+ ? { ...safeAreaInsets, bottom: 0 }+ : safeAreaInsets}>- {/* Android holds the content still, so its floating controls keep its width. */}- <WorkspaceContentWidthContext- value={- layout.usesSplitView && Platform.OS !== "android" ? renderedContentWidth : null- }- >- <WorkspaceSettledContentWidthContext- value={- Platform.OS === "android" && layout.usesSplitView ? contentTargetWidth : null- }- >- {/* Compact Settings keeps the bottom navigation under all of its pages. */}- <SafeAreaInsetsContext- value={- floatingTabsEnabled &&- (compactAndroidSettings || (layout.usesSplitView && workspacePage))- ? {- ...safeAreaInsets,- bottom:- safeAreaInsets.bottom +- FLOATING_TABS.bottom +- FLOATING_TABS.edge +- floatingTabs.height,- }- : compactAndroidSettings- ? { ...safeAreaInsets, bottom: 0 }- : safeAreaInsets- }- >- <View className="flex-1">- <SettingsWorkspaceLayout>{props.children}</SettingsWorkspaceLayout>- </View>- </SafeAreaInsetsContext>- {floatingTabsEnabled &&- (compactAndroidSettings || (layout.usesSplitView && workspacePage)) ? (- <FloatingWorkspaceTabs- paneWidth={- layout.usesSplitView ? (layout.listPaneWidth ?? undefined) : undefined- }- fillWidth={compactAndroidSettings}- onNewThread={handleStartNewTask}- />- ) : compactAndroidSettings ? (- <AndroidWorkspaceNavigation onNewThread={handleStartNewTask} />- ) : null}- </WorkspaceSettledContentWidthContext>- </WorkspaceContentWidthContext>- </View>- </View>- <WorkspaceInspectorPane- pathname={props.pathname}- renderedInspectorWidth={renderedInspectorWidth}- active={workspaceInspector?.active ?? false}- panes={panes}- renderInspector={workspaceInspector?.render}- setAuxiliaryPaneWidth={setAuxiliaryPaneWidth}- onClosed={handleWorkspaceInspectorClosed}- />- {shouldRenderNavigationRail && navigationRailWidth > 0 ? (- // The rail reserves its slot above and draws over the panes, so it can widen over- // the list in place. It takes the whole workspace only while it is open.- <View- className="absolute inset-y-0 left-0"- style={railOverlay ? { right: 0 } : { width: navigationRailWidth }}- >- <AndroidWorkspaceNavigation+ <View className="flex-1">+ <SettingsWorkspaceLayout>{children}</SettingsWorkspaceLayout>+ </View>+ </SafeAreaInsetsContext>+ {floatingTabsEnabled &&+ (compactAndroidSettings || (layout.usesSplitView && workspacePage)) ? (+ <FloatingWorkspaceTabs+ paneWidth={layout.usesSplitView ? (layout.listPaneWidth ?? undefined) : undefined}+ fillWidth={compactAndroidSettings}onNewThread={handleStartNewTask}- rail- onSelect={revealPrimarySidebar}- onOverlayChange={setRailOverlay}/>- </View>- ) : null}- </View>+ ) : compactAndroidSettings ? (+ <AndroidWorkspaceNavigation onNewThread={handleStartNewTask} />+ ) : null}+ </WorkspaceSettledContentWidthContext>+ </WorkspaceContentWidthContext>+ </View>+ </View>+ <WorkspaceInspectorPane+ pathname={props.pathname}+ renderedInspectorWidth={renderedInspectorWidth}+ active={workspaceInspector?.active ?? false}+ panes={panes}+ renderInspector={workspaceInspector?.render}+ setAuxiliaryPaneWidth={setAuxiliaryPaneWidth}+ onClosed={handleWorkspaceInspectorClosed}+ />+ {shouldRenderNavigationRail && navigationRailWidth > 0 ? (+ // The rail reserves its slot above and draws over the panes, so it can widen over+ // the list in place. It takes the whole workspace only while it is open.+ <View+ className="absolute inset-y-0 left-0"+ style={railOverlay ? { right: 0 } : { width: navigationRailWidth }}+ >+ <AndroidWorkspaceNavigation+ onNewThread={handleStartNewTask}+ rail+ onSelect={revealPrimarySidebar}+ onOverlayChange={setRailOverlay}+ />+ </View>+ ) : null}+ </View>+ );++ return (+ <HomeListOptionsProvider+ projectGroupingMode={projectGroupingMode}+ savedFilters={props.savedThreadListFilters}+ >+ <AdaptiveWorkspaceContext.Provider value={contextValue}>+ <WindowHingeContext value={windowHinge}>+ {usesPresentationHost ? (+ <WorkspaceColumnsRendererContext value={renderColumns}>+ {props.children}+ </WorkspaceColumnsRendererContext>+ ) : (+ renderColumns(props.children)+ )}</WindowHingeContext></AdaptiveWorkspaceContext.Provider></HomeListOptionsProvider>diff --git a/apps/mobile/src/features/layout/createWorkspaceStackNavigator.android.tsx b/apps/mobile/src/features/layout/createWorkspaceStackNavigator.android.tsxnew file mode 100644index 00000000000..765b2324379--- /dev/null+++ b/apps/mobile/src/features/layout/createWorkspaceStackNavigator.android.tsx@@ -0,0 +1,152 @@+import {+ createNavigatorFactory,+ StackRouter,+ useNavigationBuilder,+ type NavigatorTypeBagBase,+ type ParamListBase,+ type StackActionHelpers,+ type StackNavigationState,+ type StackRouterOptions,+ type StaticConfig,+ type TypedNavigator,+} from "@react-navigation/native";+import {+ NativeStackView,+ type NativeStackNavigationEventMap,+ type NativeStackNavigationOptions,+ type NativeStackNavigatorProps,+ type NativeStackTypeBag,+} from "@react-navigation/native-stack";+import { use, type ComponentProps } from "react";++import { RoutedFormSheetContext } from "../../components/ui/RoutedFormSheetContext";++import { projectStackPresentation } from "../../native/workspace-stack-projection";+import {+ WorkspaceColumnsRendererContext,+ WorkspacePresentationHostContext,+} from "./workspace-presentation-context";++type ViewProps = ComponentProps<typeof NativeStackView>;+type Descriptor = ViewProps["descriptors"][string];+type Route = ViewProps["state"]["routes"][number];++function WorkspaceStackView(props: ViewProps) {+ const renderColumns = use(WorkspaceColumnsRendererContext);+ if (!renderColumns) return <NativeStackView {...props} />;++ const isOverlay = (route: Route) => {+ const descriptor = props.descriptors[route.key] ?? props.describe(route, true);+ const presentation = descriptor.options.presentation;+ return presentation !== undefined && presentation !== "card";+ };+ const projection = projectStackPresentation(props.state, isOverlay);+ const workspaceRoutes = projection.workspace;+ const visibleRoute = workspaceRoutes.at(-1);+ if (!visibleRoute) return <NativeStackView {...props} />;++ const visibleDescriptor = props.descriptors[visibleRoute.key]!;+ const baseRoute = { key: `${props.state.key}:workspace`, name: "Workspace" };+ const baseDescriptor: Descriptor = {+ ...visibleDescriptor,+ options: { headerShown: false, freezeOnBlur: false },+ render: () =>+ renderColumns(+ <NativeStackView+ {...props}+ state={{+ ...props.state,+ routes: workspaceRoutes,+ index: workspaceRoutes.length - 1,+ preloadedRoutes: props.state.preloadedRoutes.filter((route) => !isOverlay(route)),+ }}+ />,+ ),+ };+ const routes = [baseRoute, ...projection.overlays];+ return (+ <NativeStackView+ {...props}+ presentationEnvelope+ state={{+ ...props.state,+ routes,+ index: routes.length - 1,+ preloadedRoutes: props.state.preloadedRoutes.filter(isOverlay),+ }}+ descriptors={{ ...props.descriptors, [baseRoute.key]: baseDescriptor }}+ />+ );+}++function WorkspaceStackNavigator({+ id,+ initialRouteName,+ UNSTABLE_routeNamesChangeBehavior,+ children,+ layout,+ screenListeners,+ screenOptions,+ screenLayout,+ UNSTABLE_router,+ ...rest+}: NativeStackNavigatorProps) {+ const { state, describe, descriptors, navigation, NavigationContent } = useNavigationBuilder<+ StackNavigationState<ParamListBase>,+ StackRouterOptions,+ StackActionHelpers<ParamListBase>,+ NativeStackNavigationOptions,+ NativeStackNavigationEventMap+ >(StackRouter, {+ id,+ initialRouteName,+ UNSTABLE_routeNamesChangeBehavior,+ children,+ layout,+ screenListeners,+ screenOptions,+ screenLayout,+ UNSTABLE_router,+ });+ return (+ <WorkspacePresentationHostContext value>+ <NavigationContent>+ <WorkspaceStackView+ {...rest}+ state={state}+ describe={describe}+ descriptors={Object.fromEntries(+ Object.entries(descriptors).map(([key, descriptor]) => [+ key,+ descriptor.options.presentation === "formSheet"+ ? {+ ...descriptor,+ render: () => (+ <RoutedFormSheetContext value>{descriptor.render()}</RoutedFormSheetContext>+ ),+ }+ : descriptor,+ ]),+ )}+ navigation={navigation}+ />+ </NavigationContent>+ </WorkspacePresentationHostContext>+ );+}++type WorkspaceTypeBag<+ ParamList extends ParamListBase,+ NavigatorID extends string | undefined,+> = Omit<NativeStackTypeBag<ParamList, NavigatorID>, "Navigator"> & {+ Navigator: typeof WorkspaceStackNavigator;+};++export function createWorkspaceStackNavigator<+ const ParamList extends ParamListBase,+ const NavigatorID extends string | undefined = string | undefined,+ const TypeBag extends NavigatorTypeBagBase = WorkspaceTypeBag<ParamList, NavigatorID>,+ const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,+>(config?: Config): TypedNavigator<TypeBag, Config> {+ return createNavigatorFactory(WorkspaceStackNavigator)(config);+}diff --git a/apps/mobile/src/features/layout/workspace-presentation-context.tsx b/apps/mobile/src/features/layout/workspace-presentation-context.tsxnew file mode 100644index 00000000000..ec1544dce82--- /dev/null+++ b/apps/mobile/src/features/layout/workspace-presentation-context.tsx@@ -0,0 +1,7 @@+import { createContext, type ReactElement, type ReactNode } from "react";++/** Android's native presentation stack surrounds all workspace columns. */+export const WorkspacePresentationHostContext = createContext(false);+export const WorkspaceColumnsRendererContext = createContext<+ ((children: ReactNode) => ReactElement) | null+>(null);diff --git a/apps/mobile/src/features/threads/git/GitCommitSheet.tsx b/apps/mobile/src/features/threads/git/GitCommitSheet.tsxindex be0912a6ebe..68ea161b011 100644--- a/apps/mobile/src/features/threads/git/GitCommitSheet.tsx+++ b/apps/mobile/src/features/threads/git/GitCommitSheet.tsx@@ -1,3 +1,4 @@+import { ScreenContent } from "../../../components/ui/ScreenContent";import { SheetHeader } from "../../../components/ui/SheetHeader";import { Button } from "../../../components/ui/Button";import { useNavigation, type StaticScreenProps } from "@react-navigation/native";@@ -84,145 +85,149 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {onCancel={() => navigation.goBack()}accessibilityLabel="Cancel commit"/>- <ScrollView- nestedScrollEnabled- contentInsetAdjustmentBehavior="automatic"- className="android:shrink android:grow-0 ios:flex-1"- keyboardShouldPersistTaps="handled"- keyboardDismissMode="on-drag"- automaticallyAdjustKeyboardInsets- contentContainerClassName="px-5 pt-4 pb-6 gap-5"- contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}- >- {isDefaultRef ? (- <Text className="text-sm text-warning-foreground">- You’re on the default branch. You can create a new branch when committing.- </Text>- ) : null}- <View className="gap-2">- <Text className="text-sm font-t3-medium text-foreground">Commit message</Text>- <TextInput- multiline- accessibilityLabel="Commit message"- value={dialogCommitMessage}- onChangeText={setDialogCommitMessage}- placeholder="Describe your changes…"- textAlignVertical="top"- className="min-h-24 rounded-xl bg-subtle px-4 py-3 text-base"- />- <Text className="text-xs text-foreground-muted">- Leave empty to generate a message automatically.- </Text>- </View>- <View>- <View className="flex-row items-center justify-between gap-2 pb-2">- <View className="flex-1 gap-1">- <Text className="text-base font-t3-bold text-foreground">Changed files</Text>- <Text className="text-xs text-foreground-muted">- {selectedFiles.length} of {allFiles.length} selected · +- {formatDiffCount(selectedInsertions)} −{formatDiffCount(selectedDeletions)}- </Text>- </View>- {allFiles.length > 0 ? (- <Button- label={allSelected ? "Deselect all" : "Select all"}- tone="text"- onPress={() =>- setExcludedFiles(- allSelected ? new Set(allFiles.map((file) => file.path)) : new Set(),- )- }- />- ) : null}+ <ScreenContent fitToContents>+ <ScrollView+ nestedScrollEnabled+ contentInsetAdjustmentBehavior="automatic"+ className="android:shrink android:grow-0 ios:flex-1"+ keyboardShouldPersistTaps="handled"+ keyboardDismissMode="on-drag"+ automaticallyAdjustKeyboardInsets+ contentContainerClassName="px-5 pt-4 pb-6 gap-5"+ contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}+ >+ {isDefaultRef ? (+ <Text className="text-sm text-warning-foreground">+ You’re on the default branch. You can create a new branch when committing.+ </Text>+ ) : null}+ <View className="gap-2">+ <Text className="text-sm font-t3-medium text-foreground">Commit message</Text>+ <TextInput+ multiline+ accessibilityLabel="Commit message"+ value={dialogCommitMessage}+ onChangeText={setDialogCommitMessage}+ placeholder="Describe your changes…"+ textAlignVertical="top"+ className="min-h-24 rounded-xl bg-subtle px-4 py-3 text-base"+ />+ <Text className="text-xs text-foreground-muted">+ Leave empty to generate a message automatically.+ </Text></View>- {allFiles.length === 0 ? (- <Text className="py-4 text-sm text-foreground-muted">No changed files to commit.</Text>- ) : (- allFiles.map((file) => {- const included = !excludedFiles.has(file.path);- const slash = file.path.lastIndexOf("/");- const name = file.path.slice(slash + 1);- const directory = slash >= 0 ? file.path.slice(0, slash) : null;- return (- <Pressable- key={file.path}- className="min-h-16 flex-row items-center gap-3 border-t border-border-subtle py-3"- accessibilityRole="checkbox"- accessibilityLabel={file.path}- accessibilityState={{ checked: included }}+ <View>+ <View className="flex-row items-center justify-between gap-2 pb-2">+ <View className="flex-1 gap-1">+ <Text className="text-base font-t3-bold text-foreground">Changed files</Text>+ <Text className="text-xs text-foreground-muted">+ {selectedFiles.length} of {allFiles.length} selected · ++ {formatDiffCount(selectedInsertions)} −{formatDiffCount(selectedDeletions)}+ </Text>+ </View>+ {allFiles.length > 0 ? (+ <Button+ label={allSelected ? "Deselect all" : "Select all"}+ tone="text"onPress={() =>- setExcludedFiles((current) => {- const next = new Set(current);- if (next.has(file.path)) next.delete(file.path);- else next.add(file.path);- return next;- })+ setExcludedFiles(+ allSelected ? new Set(allFiles.map((file) => file.path)) : new Set(),+ )}- >- <View- className={cn(- "size-5 items-center justify-center rounded-full",- included ? "bg-primary" : "border border-input-border",- )}+ />+ ) : null}+ </View>+ {allFiles.length === 0 ? (+ <Text className="py-4 text-sm text-foreground-muted">+ No changed files to commit.+ </Text>+ ) : (+ allFiles.map((file) => {+ const included = !excludedFiles.has(file.path);+ const slash = file.path.lastIndexOf("/");+ const name = file.path.slice(slash + 1);+ const directory = slash >= 0 ? file.path.slice(0, slash) : null;+ return (+ <Pressable+ key={file.path}+ className="min-h-16 flex-row items-center gap-3 border-t border-border-subtle py-3"+ accessibilityRole="checkbox"+ accessibilityLabel={file.path}+ accessibilityState={{ checked: included }}+ onPress={() =>+ setExcludedFiles((current) => {+ const next = new Set(current);+ if (next.has(file.path)) next.delete(file.path);+ else next.add(file.path);+ return next;+ })+ }>- {included ? (- <SymbolView- name="checkmark"- size={13}- tintColorClassName="accent-primary-foreground"- />- ) : null}- </View>- <View className="flex-1 gap-1">- <Text- numberOfLines={1}- ellipsizeMode="middle"- className="text-sm font-t3-medium text-foreground"+ <View+ className={cn(+ "size-5 items-center justify-center rounded-full",+ included ? "bg-primary" : "border border-input-border",+ )}>- {name}- </Text>- {directory ? (+ {included ? (+ <SymbolView+ name="checkmark"+ size={13}+ tintColorClassName="accent-primary-foreground"+ />+ ) : null}+ </View>+ <View className="flex-1 gap-1"><TextnumberOfLines={1}ellipsizeMode="middle"- className="text-xs text-foreground-muted"+ className="text-sm font-t3-medium text-foreground">- {directory}+ {name}</Text>- ) : null}- </View>- <View className="flex-row gap-2">- <Text className="text-xs text-adaptive-emerald-700-300">- +{formatDiffCount(file.insertions)}- </Text>- <Text className="text-xs text-adaptive-rose-700-300">- −{formatDiffCount(file.deletions)}- </Text>- </View>- </Pressable>- );- })- )}- </View>- <View className="gap-2">- <Button- label="Commit changes"- icon="checkmark"- tone="primary"- fullWidth- disabled={!canWriteSourceControl || noneSelected || busy}- onPress={() => void runCommitAction(false)}- />- <Button- label="Commit on a new branch"- icon="arrow.branch"- tone="text"- fullWidth- disabled={!canWriteSourceControl || !canChangeThreadBranch || noneSelected || busy}- onPress={() => void runCommitAction(true)}- />- </View>- </ScrollView>+ {directory ? (+ <Text+ numberOfLines={1}+ ellipsizeMode="middle"+ className="text-xs text-foreground-muted"+ >+ {directory}+ </Text>+ ) : null}+ </View>+ <View className="flex-row gap-2">+ <Text className="text-xs text-adaptive-emerald-700-300">+ +{formatDiffCount(file.insertions)}+ </Text>+ <Text className="text-xs text-adaptive-rose-700-300">+ −{formatDiffCount(file.deletions)}+ </Text>+ </View>+ </Pressable>+ );+ })+ )}+ </View>+ <View className="gap-2">+ <Button+ label="Commit changes"+ icon="checkmark"+ tone="primary"+ fullWidth+ disabled={!canWriteSourceControl || noneSelected || busy}+ onPress={() => void runCommitAction(false)}+ />+ <Button+ label="Commit on a new branch"+ icon="arrow.branch"+ tone="text"+ fullWidth+ disabled={!canWriteSourceControl || !canChangeThreadBranch || noneSelected || busy}+ onPress={() => void runCommitAction(true)}+ />+ </View>+ </ScrollView>+ </ScreenContent></View>);}diff --git a/apps/mobile/src/native/workspace-stack-projection.test.ts b/apps/mobile/src/native/workspace-stack-projection.test.tsindex a3c44d16fb7..023afc637c0 100644--- a/apps/mobile/src/native/workspace-stack-projection.test.ts+++ b/apps/mobile/src/native/workspace-stack-projection.test.ts@@ -7,6 +7,7 @@ import {nativeStackPopAction,nativeWorkspacePopAction,nativeWorkspacePopCount,+ projectStackPresentation,projectWorkspaceStack,partitionStackPresentations,reconcileStackScreens,@@ -40,6 +41,65 @@ function history(};}+describe("workspace presentation envelope", () => {+ const isOverlay = (route: { name: string }) => route.name === "ReviewSheet";++ it("keeps card settings in the detail history and restores it after system Back closes a sheet", () => {+ const router = StackRouter({});+ const state = history([home, thread, settings]);+ const routerOptions = {+ routeNames: [...state.routeNames, "ReviewSheet", "ReviewDetails"],+ routeParamList: {},+ routeGetIdList: {},+ };+ const opened = router.getStateForAction(+ { ...state, routeNames: routerOptions.routeNames },+ { type: "PUSH", payload: { name: "ReviewSheet" } },+ routerOptions,+ );+ if (!opened || opened.stale !== false) throw new Error("Expected an opened sheet history");+ const projection = projectStackPresentation(opened, isOverlay);+ expect(projection.workspace).toEqual(state.routes);+ expect(projection.workspace.at(-1)).toBe(settings);+ expect(projection.overlays.map((route) => route.name)).toEqual(["ReviewSheet"]);+ const closed = router.getStateForAction(opened, { type: "GO_BACK" }, routerOptions);+ if (!closed || closed.stale !== false) throw new Error("Expected a restored workspace history");+ expect(projectStackPresentation(closed, isOverlay)).toEqual({+ workspace: state.routes,+ overlays: [],+ });+ });++ it("keeps pushed sheet pages above the workspace and dismisses the entire sheet group", () => {+ const sheet = { key: "review", name: "ReviewSheet" };+ const page = { key: "review-details", name: "ReviewDetails" };+ const state = history([home, thread, sheet, page]);+ expect(projectStackPresentation(state, isOverlay)).toEqual({+ workspace: [home, thread],+ overlays: [sheet, page],+ });+ const closed = StackRouter({}).getStateForAction(+ state,+ nativeWorkspacePopAction(state, sheet.key)!,+ { routeNames: state.routeNames, routeParamList: {}, routeGetIdList: {} },+ );+ if (!closed || closed.stale !== false) throw new Error("Expected a dismissed sheet history");+ expect(projectStackPresentation(closed, isOverlay)).toEqual({+ workspace: [home, thread],+ overlays: [],+ });+ expect(closed.routes[1]).toBe(thread);+ });++ it("preserves a cold-linked detail history without requiring a Home route", () => {+ const sheet = { key: "review", name: "ReviewSheet" };+ expect(projectStackPresentation(history([thread, files, sheet]), isOverlay)).toEqual({+ workspace: [thread, files],+ overlays: [sheet],+ });+ });+});+describe("workspace router projection", () => {it("keeps workspace flows beside Home and restores them after a modal closes", () => {const draft = { key: "draft", name: "Thread", params: { draft: {} } };diff --git a/apps/mobile/src/native/workspace-stack-projection.ts b/apps/mobile/src/native/workspace-stack-projection.tsindex 341a432b66b..7d12cc89a31 100644--- a/apps/mobile/src/native/workspace-stack-projection.ts+++ b/apps/mobile/src/native/workspace-stack-projection.ts@@ -6,18 +6,29 @@ import type {type Route = StackNavigationState<ParamListBase>["routes"][number];-export function projectWorkspaceStack(+/** Keep the presenting history mounted while modal routes cover the whole workspace. */+export function projectStackPresentation(state: StackNavigationState<ParamListBase>,isOverlay: (route: Route) => boolean,) {const firstOverlay = state.routes.findIndex(isOverlay);- const workspaceRoutes = state.routes.slice(0, firstOverlay < 0 ? undefined : firstOverlay);+ return {+ workspace: state.routes.slice(0, firstOverlay < 0 ? undefined : firstOverlay),+ overlays: firstOverlay < 0 ? [] : state.routes.slice(firstOverlay),+ };+}++/** Project one router history into native columns and a modal presentation stack. */+export function projectWorkspaceStack(+ state: StackNavigationState<ParamListBase>,+ isOverlay: (route: Route) => boolean,+) {+ const { workspace: workspaceRoutes, overlays } = projectStackPresentation(state, isOverlay);const primary = workspaceRoutes.find((route) => route.name === "Home");// The Settings tab's route only selects what Home shows; its pages are the detail.const detail = workspaceRoutes.filter((route) => route.name !== "Home" && route.name !== "Settings",);- const overlays = firstOverlay < 0 ? [] : state.routes.slice(firstOverlay);return { primary, detail, overlays };}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex c854ee33647..a7b5b20aa21 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -560,7 +560,7 @@ importers:version: 7.5.1([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])'@react-navigation/native-stack':specifier: 7.21.0- version: 7.21.0(patch_hash=990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42)(fedae76d040d2e46f454f147f7fa3a09)+ version: 7.21.0(patch_hash=990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42)(c96dd4885eac0393fe69fdf9aeb7f361)'@t3tools/client-runtime':specifier: workspace:*version: link:../../packages/client-runtime@@ -742,8 +742,8 @@ importers:specifier: ~5.10.1version: 5.10.1([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])react-native-screens:- specifier: file:deps/react-native-screens-5.0.0-t3.45.tgz- version: file:apps/mobile/deps/react-native-screens-5.0.0-t3.45.tgz([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])+ specifier: file:deps/react-native-screens-5.0.0-t3.48.tgz+ version: file:apps/mobile/deps/react-native-screens-5.0.0-t3.48.tgz([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])react-native-svg:specifier: 15.16.0version: 15.16.0([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])@@ -10914,9 +10914,9 @@ packages:react: '*'react-native: '*'- react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.45.tgz:- resolution: {integrity: sha512-FgmMB7T2tb0pEKgdsRs5sRCIRfIOHFqEk3lqaRA53dYb51rxlE9utrAoxbUPHcAROAAP2QA55KUTD9V71SoNqA==, tarball: file:apps/mobile/deps/react-native-screens-5.0.0-t3.45.tgz}- version: 5.0.0-t3.45+ react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.48.tgz:+ resolution: {integrity: sha512-DQa7yVsOye72bUNH4UVC3D8QicmOm+LMFLpZui6ZEnwU5wtlyEsqFX26kKSvDkpByAffQVIqqJ3s0QNCGNwF1A==, tarball: file:apps/mobile/deps/react-native-screens-5.0.0-t3.48.tgz}+ version: 5.0.0-t3.48peerDependencies:react: '*'react-native: '*'@@ -15896,7 +15896,7 @@ snapshots:optionalDependencies:'@react-native-masked-view/masked-view': 0.3.2([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])- '@react-navigation/[email protected](patch_hash=990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42)(fedae76d040d2e46f454f147f7fa3a09)':+ '@react-navigation/[email protected](patch_hash=990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42)(c96dd4885eac0393fe69fdf9aeb7f361)':dependencies:'@react-navigation/elements': 2.9.45(d8845bac868f4d8a58c8a8f12ad0d4a5)'@react-navigation/native': 7.5.1([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])@@ -15904,7 +15904,7 @@ snapshots:react: 19.3.0react-native: 0.88.0(@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected])react-native-safe-area-context: 5.10.1([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])- react-native-screens: file:apps/mobile/deps/react-native-screens-5.0.0-t3.45.tgz([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])+ react-native-screens: file:apps/mobile/deps/react-native-screens-5.0.0-t3.48.tgz([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])sf-symbols-typescript: 2.2.0warn-once: 0.1.1transitivePeerDependencies:@@ -21476,7 +21476,7 @@ snapshots:react: 19.3.0react-native: 0.88.0(@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected])- react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.45.tgz([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]):+ react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.48.tgz([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]):dependencies:react: 19.3.0react-freeze: 1.0.4([email protected])