TypeScript
refactor(mobile): features stop building navigators for their bars
Julius Marminge8897f1e00a74
diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsxindex 0877e28ec3e..8e460609598 100644--- a/apps/mobile/src/Stack.tsx+++ b/apps/mobile/src/Stack.tsx@@ -619,7 +619,7 @@ const RootStackConfig = createWorkspaceStackNavigator({ThreadBrowserPreview: createNativeStackScreen({screen: BrowserPreviewRouteScreen,linking: `${THREAD_LINKING_PREFIX}/browser`,- options: immersiveRoute(),+ options: { ...modalRoute({ header: "solid" }), gestureEnabled: false },}),ThreadReview: createNativeStackScreen({screen: ReviewSheet,@@ -657,15 +657,15 @@ const RootStackConfig = createWorkspaceStackNavigator({}),ThreadQueue: createNativeStackScreen({screen: ThreadQueueSheet,- options: sheetRoute({ detent: 0.65, androidMaxDetent: 0.95, header: "none" }),+ options: sheetRoute({ detent: 0.65, androidMaxDetent: 0.95 }),}),ThreadBackgroundWork: createNativeStackScreen({screen: ThreadBackgroundWorkSheet,- options: sheetRoute({ detent: 0.5, androidMaxDetent: 0.9, header: "none" }),+ options: sheetRoute({ detent: 0.5, androidMaxDetent: 0.9 }),}),ThreadAgents: createNativeStackScreen({screen: ThreadAgentsSheet,- options: sheetRoute({ detent: 0.5, androidMaxDetent: 0.9, header: "none" }),+ options: sheetRoute({ detent: 0.5, androidMaxDetent: 0.9 }),}),GitOverview: createNativeStackScreen({screen: GitOverviewSheet,diff --git a/apps/mobile/src/components/ui/SheetHeader.android.tsx b/apps/mobile/src/components/ui/SheetHeader.android.tsxindex 156c7f0e91e..0a3f5ba2778 100644--- a/apps/mobile/src/components/ui/SheetHeader.android.tsx+++ b/apps/mobile/src/components/ui/SheetHeader.android.tsx@@ -48,6 +48,7 @@ export function SheetHeader(props: SheetHeaderProps) {title={props.title}subtitle={props.subtitle}actions={props.actions}+ menus={props.menus}leading={<SheetCloseButton{...(props.onCancel ? { onCancel: props.onCancel } : { onClose: props.onClose })}diff --git a/apps/mobile/src/components/ui/SheetHeader.tsx b/apps/mobile/src/components/ui/SheetHeader.tsxindex 6f2037558c6..17f9507b30e 100644--- a/apps/mobile/src/components/ui/SheetHeader.tsx+++ b/apps/mobile/src/components/ui/SheetHeader.tsx@@ -6,6 +6,7 @@ import { AppText } from "./AppText";import { SymbolView } from "./AppSymbol";import { IconButton } from "./IconButton";import { Toolbar } from "./Toolbar";+import { createNativeHeaderMenu } from "./nativeHeaderMenu.ios";import { useControlTheme } from "./useControlTheme";import type { SheetCloseButtonProps, SheetHeaderProps } from "./SheetHeader.types";@@ -65,7 +66,7 @@ function NativeSheetHeader(props: SheetHeaderProps) {disabled={props.dismissDisabled}/></Toolbar>- {confirmation || props.trailing || props.actions?.length ? (+ {confirmation || props.trailing || props.actions?.length || props.menus?.length ? (<Toolbar placement="right">{props.actions?.map((action) => (<Toolbar.Button@@ -77,6 +78,7 @@ function NativeSheetHeader(props: SheetHeaderProps) {onPress={action.onPress}/>))}+ {props.menus?.map(createNativeHeaderMenu)}{props.trailing ? (<Toolbar.Custom><View>{props.trailing}</View>diff --git a/apps/mobile/src/components/ui/SheetHeader.types.ts b/apps/mobile/src/components/ui/SheetHeader.types.tsindex e39442c1fe5..010dfeedf1d 100644--- a/apps/mobile/src/components/ui/SheetHeader.types.ts+++ b/apps/mobile/src/components/ui/SheetHeader.types.ts@@ -1,6 +1,6 @@import type { ReactNode } from "react";-import type { AppBarAction } from "./AppBar.types";+import type { AppBarAction, AppBarMenu } from "./AppBar.types";type SheetDismissAction =| { readonly onCancel: () => void; readonly onClose?: never }@@ -21,6 +21,7 @@ export type SheetHeaderProps = SheetDismissAction & {readonly confirm?: SheetConfirmation;readonly presentation?: "native" | "inline";readonly actions?: ReadonlyArray<AppBarAction>;+ readonly menus?: ReadonlyArray<AppBarMenu>;readonly trailing?: ReactNode;};diff --git a/apps/mobile/src/features/browser/BrowserPreviewRouteScreen.tsx b/apps/mobile/src/features/browser/BrowserPreviewRouteScreen.tsxindex 8be58a11465..c499e12b64a 100644--- a/apps/mobile/src/features/browser/BrowserPreviewRouteScreen.tsx+++ b/apps/mobile/src/features/browser/BrowserPreviewRouteScreen.tsx@@ -2,7 +2,6 @@ import { SheetHeader } from "../../components/ui/SheetHeader";import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";import * as Dialog from "../../components/ui/Dialog";import { useIsFocused, useNavigation, type StaticScreenProps } from "@react-navigation/native";-import { createNativeStackNavigator } from "@react-navigation/native-stack";import { EnvironmentId, ThreadId, type PreviewSessionSnapshot } from "@t3tools/contracts";import { normalizePreviewUrl, previewPdfAssetUrl } from "@t3tools/shared/preview";import * as Option from "effect/Option";@@ -12,7 +11,6 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";import { ControlPill } from "../../components/ui/ControlPill";import { useAppForeground } from "../../lib/appState";-import { AppBar } from "../../components/ui/AppBar";import { useThreadServerBrowserTabs } from "../../state/preview";import { usePreparedConnection } from "../../state/session";@@ -25,8 +23,6 @@ import {type PreviewStreamRef,} from "./PreviewStreamWebView";-const BrowserPreviewStack = createNativeStackNavigator<{ BrowserPreview: undefined }>();-const NO_PICTURE_IN_PICTURE: PreviewPictureInPictureState = { supported: false, active: false };type BrowserPreviewRouteScreenProps = StaticScreenProps<{@@ -39,28 +35,12 @@ export function BrowserPreviewRouteScreen({ route }: BrowserPreviewRouteScreenPrconst navigation = useNavigation();const onClose = () => navigation.goBack();return (- <View collapsable={false} className="flex-1 bg-sheet">- <BrowserPreviewStack.Navigator- screenOptions={{- headerShown: Platform.OS === "ios",- headerBackVisible: false,- headerShadowVisible: false,- headerTransparent: false,- headerTitleStyle: { fontSize: 17, fontWeight: "600" },- }}- >- <BrowserPreviewStack.Screen name="BrowserPreview">- {() => (- <BrowserPreviewScreen- environmentId={EnvironmentId.make(route.params.environmentId)}- threadId={ThreadId.make(route.params.threadId)}- initialTabId={route.params.tabId ?? null}- onClose={onClose}- />- )}- </BrowserPreviewStack.Screen>- </BrowserPreviewStack.Navigator>- </View>+ <BrowserPreviewScreen+ environmentId={EnvironmentId.make(route.params.environmentId)}+ threadId={ThreadId.make(route.params.threadId)}+ initialTabId={route.params.tabId ?? null}+ onClose={onClose}+ />);}@@ -111,10 +91,10 @@ function BrowserPreviewScreen({return (<View className="flex-1 bg-sheet" style={{ paddingBottom: insets.bottom }}>- <AppBar+ <SheetHeadertitle={tab ? browserTabTitle(tab) : "Browser"}- onBack={onClose}- options={{ headerBackVisible: false }}+ onClose={onClose}+ accessibilityLabel="Close browser"actions={// Android WebView cannot play video in picture in picture.Platform.OS === "ios" &&@@ -153,13 +133,6 @@ function BrowserPreviewScreen({: []}/>- {Platform.OS === "ios" ? (- <SheetHeader- title={tab ? browserTabTitle(tab) : "Browser"}- onClose={onClose}- accessibilityLabel="Close browser"- />- ) : null}{tab ? (<><BrowserAddressBardiff --git a/apps/mobile/src/features/layout/nested-stacks.tsx b/apps/mobile/src/features/layout/nested-stacks.tsxnew file mode 100644index 00000000000..7ee894db659--- /dev/null+++ b/apps/mobile/src/features/layout/nested-stacks.tsx@@ -0,0 +1,59 @@+import { NavigationContainer, NavigationIndependentTree } from "@react-navigation/native";+import type { ReactNode } from "react";+import { Platform } from "react-native";++import { useMobileNavigationTheme } from "../../lib/useMobileNavigationTheme";+import { useUniwindTheme } from "../../lib/useUniwindTheme";+import { createV5StackNavigator } from "../../native/createV5StackNavigator";+import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";+import type { AppScreenOptions } from "../../native/glass-header-options";+import { pageRoute } from "./route-options";++/**+ * Screen options for a stack nested in a sheet, so its pages push inside the sheet with the+ * same bar as a sheet route. Android hides the native header: pages draw AppBar in-tree.+ */+export function useSheetStackOptions(): AppScreenOptions {+ const theme = useUniwindTheme();+ const background = theme["--color-sheet-solid"];+ return {+ ...pageRoute({ itemStyle: "standard" }),+ animation: Platform.OS === "android" ? "default" : "slide_from_right",+ contentStyle: { backgroundColor: background },+ gestureEnabled: true,+ headerShown: Platform.OS !== "android",+ headerStyle: { backgroundColor: NATIVE_LIQUID_GLASS_SUPPORTED ? "transparent" : background },+ headerTintColor: theme["--color-foreground"],+ };+}++const Standalone = createV5StackNavigator<{ Standalone: undefined }>();++/**+ * One native stack screen outside the app's navigation tree, for content that needs a native bar+ * but is not a route: a popover, or a column the workspace hosts. Its bar is set from inside with+ * AppBar or SheetHeader like any screen.+ */+export function StandaloneStack(props: {+ readonly surface?: "screen" | "sidebar";+ readonly options?: AppScreenOptions;+ readonly children: ReactNode;+}) {+ const navigationTheme = useMobileNavigationTheme(props.surface);+ return (+ <NavigationIndependentTree>+ <NavigationContainer theme={navigationTheme}>+ <Standalone.Navigator+ screenOptions={{+ ...pageRoute({ itemStyle: "standard" }),+ contentStyle: { backgroundColor: "transparent" },+ headerShown: Platform.OS !== "android",+ ...props.options,+ }}+ >+ <Standalone.Screen name="Standalone">{() => props.children}</Standalone.Screen>+ </Standalone.Navigator>+ </NavigationContainer>+ </NavigationIndependentTree>+ );+}diff --git a/apps/mobile/src/features/threads/CustomSnoozeSheet.ios.tsx b/apps/mobile/src/features/threads/CustomSnoozeSheet.ios.tsxindex 850251fb5aa..65537d287cc 100644--- a/apps/mobile/src/features/threads/CustomSnoozeSheet.ios.tsx+++ b/apps/mobile/src/features/threads/CustomSnoozeSheet.ios.tsx@@ -29,16 +29,12 @@ import {type CustomSnoozeInput,} from "@t3tools/client-runtime/state/thread-settled";import { useState, type ReactNode } from "react";-import { NavigationContainer, NavigationIndependentTree } from "@react-navigation/native";-import { createV5StackNavigator as createNativeStackNavigator } from "../../native/createV5StackNavigator";+import { StandaloneStack } from "../layout/nested-stacks";import { ScrollView, useWindowDimensions, View } from "react-native";-import { useMobileNavigationTheme } from "../../lib/useMobileNavigationTheme";-import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";const durationAmounts = Array.from({ length: 99 }, (_, index) => index + 1);-const SnoozeStack = createNativeStackNavigator<{ CustomSnooze: undefined }>();const modes = [{ value: "date", label: "Date and time" },{ value: "duration", label: "Duration" },@@ -222,51 +218,24 @@ function SnoozePopoverNavigation(props: {readonly onSubmit: () => void;readonly children: ReactNode;}) {- const navigationTheme = useMobileNavigationTheme();- const { themeVariables: colors } = useAppearancePreferences();-return (<VStack modifiers={[frame({ width: props.width, height: props.height })]}><RNHostView><View style={{ width: props.width, height: props.height }}>- <NavigationIndependentTree>- <NavigationContainer theme={navigationTheme}>- <SnoozeStack.Navigator- screenOptions={{- contentStyle: { backgroundColor: "transparent" },- headerShadowVisible: false,- headerStyle: {- backgroundColor: NATIVE_LIQUID_GLASS_SUPPORTED- ? "transparent"- : colors["--color-card"],- },- headerTintColor: colors["--color-foreground"],- headerTitleStyle: { fontSize: 17, fontWeight: "700" },- headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,- title: "Custom snooze",- }}- >- <SnoozeStack.Screen name="CustomSnooze">- {() => (- <>- <SheetHeader- title="Custom snooze"- onCancel={props.onClose}- accessibilityLabel="Cancel custom snooze"- confirm={{ label: "Snooze", onPress: props.onSubmit }}- />- <ScrollView- contentInsetAdjustmentBehavior="automatic"- showsVerticalScrollIndicator={false}- >- {props.children}- </ScrollView>- </>- )}- </SnoozeStack.Screen>- </SnoozeStack.Navigator>- </NavigationContainer>- </NavigationIndependentTree>+ <StandaloneStack>+ <SheetHeader+ title="Custom snooze"+ onCancel={props.onClose}+ accessibilityLabel="Cancel custom snooze"+ confirm={{ label: "Snooze", onPress: props.onSubmit }}+ />+ <ScrollView+ contentInsetAdjustmentBehavior="automatic"+ showsVerticalScrollIndicator={false}+ >+ {props.children}+ </ScrollView>+ </StandaloneStack></View></RNHostView></VStack>diff --git a/apps/mobile/src/features/threads/ThreadAgentsSheet.tsx b/apps/mobile/src/features/threads/ThreadAgentsSheet.tsxindex e223090c3eb..c4c5fa58e22 100644--- a/apps/mobile/src/features/threads/ThreadAgentsSheet.tsx+++ b/apps/mobile/src/features/threads/ThreadAgentsSheet.tsx@@ -16,15 +16,12 @@ import * as DateTime from "effect/DateTime";import { Atom } from "effect/reactivity";import * as Haptics from "expo-haptics";import { useMemo } from "react";-import { Platform, Pressable, ScrollView, View } from "react-native";-import { ScreenStack } from "react-native-screens";+import { Pressable, ScrollView, View } from "react-native";import { useSafeAreaInsets } from "react-native-safe-area-context";-import { AppBar } from "../../components/ui/AppBar";+import { SheetHeader } from "../../components/ui/SheetHeader";import { AppText as Text } from "../../components/ui/AppText";import { environmentThreadDetails } from "../../state/threads";-import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";-import { NativeHeader, NativeScreen } from "../../native/ThemedScreenStack";import { useEnvironments } from "../../state/environments";import { SubagentRow } from "./SubagentRow";import { useVisibleSecondClock } from "./use-visible-second-clock";@@ -36,8 +33,6 @@ import { subagentThreadTarget } from "./threadAgentsPresentation";import { useOpenThreadInspector } from "./thread-inspector-navigation";-const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);-type AgentsTarget = { readonly environmentId: EnvironmentId; readonly threadId: ThreadId };const EMPTY_TURN_SUBAGENTS_ATOM = Atom.make<ThreadTurnSubagents | null>(null).pipe(@@ -96,7 +91,7 @@ export function ThreadAgentsSheet({ route }: StaticScreenProps<AgentsTarget>) {nestedScrollEnabledclassName="flex-1"// UIKit must inset content beneath the floating translucent iOS header.- contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}+ contentInsetAdjustmentBehavior="automatic"contentContainerClassName="px-5 pb-6"contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 16) + 8 }}>@@ -132,40 +127,9 @@ export function ThreadAgentsSheet({ route }: StaticScreenProps<AgentsTarget>) {</ScrollView>);- if (Platform.OS === "ios") {- // Plain formSheets lack stack headers; host one in a nested native stack.- return (- <View collapsable={false} className="flex-1 bg-sheet">- <ScreenStack style={{ flex: 1 }}>- <NativeScreen- activityState={2}- enabled- isNativeStack- screenId="thread-agents-sheet-native"- scrollEdgeEffects={HEADER_SCROLL_EDGE_EFFECTS}- className="flex-1 bg-sheet"- >- {content}- <NativeHeader- backgroundColor="rgba(0,0,0,0)"- tintColorClassName="accent-foreground"- hideBackButton- hideShadow={false}- title="Agents"- titleColorClassName="accent-foreground"- titleFontSize={18}- titleFontWeight="800"- translucent- />- </NativeScreen>- </ScreenStack>- </View>- );- }-return (<View collapsable={false} className="flex-1 bg-sheet">- <AppBar sheet title="Agents" onBack={() => navigation.goBack()} />+ <SheetHeader title="Agents" onClose={() => navigation.goBack()} /><ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent></View>);diff --git a/apps/mobile/src/features/threads/ThreadBackgroundWorkSheet.tsx b/apps/mobile/src/features/threads/ThreadBackgroundWorkSheet.tsxindex 351e723fbbc..123b2611bce 100644--- a/apps/mobile/src/features/threads/ThreadBackgroundWorkSheet.tsx+++ b/apps/mobile/src/features/threads/ThreadBackgroundWorkSheet.tsx@@ -7,20 +7,16 @@ import {} from "@t3tools/client-runtime/state/thread-execution";import type { EnvironmentId, ThreadId } from "@t3tools/contracts";import * as Haptics from "expo-haptics";-import { Platform, Pressable, ScrollView, View } from "react-native";-import { ScreenStack } from "react-native-screens";+import { Pressable, ScrollView, View } from "react-native";import { useSafeAreaInsets } from "react-native-safe-area-context";-import { AppBar } from "../../components/ui/AppBar";+import { SheetHeader } from "../../components/ui/SheetHeader";import { SymbolView } from "../../components/ui/AppSymbol";import { AppText as Text } from "../../components/ui/AppText";import { ScreenContent } from "../../components/ui/ScreenContent";-import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";-import { NativeHeader, NativeScreen } from "../../native/ThemedScreenStack";import { environmentThreadShells } from "../../state/threads";import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";-const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);const KIND_LABELS = {subagent: "Subagent",command: "Command",@@ -50,7 +46,7 @@ export function ThreadBackgroundWorkSheet({ route }: StaticScreenProps<Backgroun<ScrollViewnestedScrollEnabledclassName="flex-1"- contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}+ contentInsetAdjustmentBehavior="automatic"contentContainerClassName="px-5 pb-6"contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 16) + 8 }}>@@ -65,38 +61,9 @@ export function ThreadBackgroundWorkSheet({ route }: StaticScreenProps<Backgroun)}</ScrollView>);- if (Platform.OS === "ios") {- return (- <View collapsable={false} className="flex-1 bg-sheet">- <ScreenStack style={{ flex: 1 }}>- <NativeScreen- activityState={2}- enabled- isNativeStack- screenId="thread-background-work-sheet-native"- scrollEdgeEffects={HEADER_SCROLL_EDGE_EFFECTS}- className="flex-1 bg-sheet"- >- {content}- <NativeHeader- backgroundColor="rgba(0,0,0,0)"- tintColorClassName="accent-foreground"- hideBackButton- hideShadow={false}- title="Background work"- titleColorClassName="accent-foreground"- titleFontSize={18}- titleFontWeight="800"- translucent- />- </NativeScreen>- </ScreenStack>- </View>- );- }return (<View collapsable={false} className="flex-1 bg-sheet">- <AppBar sheet title="Background work" onBack={() => navigation.goBack()} />+ <SheetHeader title="Background work" onClose={() => navigation.goBack()} /><ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent></View>);diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsxindex f03f8296ced..6e8c4fa251e 100644--- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx+++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx@@ -64,7 +64,9 @@ import { ThreadListToolbar } from "../home/ThreadListToolbar";import { useFabScroll } from "../home/FabScrollContext";import { SidebarFilterButton } from "./sidebar-filter-button";import { createSidebarHeaderItems } from "./sidebar-native-header-items";-import { SidebarNavigationShell } from "./sidebar-navigation-shell";+import { getCompactBrandHeaderOptions } from "../../components/CompactBrandTitle";+import { StandaloneStack } from "../layout/nested-stacks";+import { pageRoute } from "../layout/route-options";import {ThreadListV2PendingRow,ThreadListV2Row,@@ -116,6 +118,12 @@ interface ThreadNavigationSidebarProps {readonly searchQuery: string;}+// The iOS sidebar column hosts its own stack so it gets a native bar with the brand title.+const SIDEBAR_COLUMN_OPTIONS = {+ ...pageRoute(),+ ...getCompactBrandHeaderOptions({ fontSize: 18, fontWeight: "800" }),+};+export function ThreadNavigationSidebar(props: ThreadNavigationSidebarProps) {return (<ThreadPrDemandProvider visible={props.visible}>@@ -135,9 +143,9 @@ function NativeSidebarContainer(props: ThreadNavigationSidebarProps) {className="flex-1 border-border bg-drawer"style={{ borderRightWidth: StyleSheet.hairlineWidth, width: props.width }}>- <SidebarNavigationShell>+ <StandaloneStack surface="sidebar" options={SIDEBAR_COLUMN_OPTIONS}><ThreadNavigationSidebarPane {...props} nativeChrome />- </SidebarNavigationShell>+ </StandaloneStack></View>);}diff --git a/apps/mobile/src/features/threads/ThreadQueueControl.tsx b/apps/mobile/src/features/threads/ThreadQueueControl.tsxindex 12e01311148..6ee507918f8 100644--- a/apps/mobile/src/features/threads/ThreadQueueControl.tsx+++ b/apps/mobile/src/features/threads/ThreadQueueControl.tsx@@ -16,18 +16,16 @@ import { GestureHandlerRootView } from "react-native-gesture-handler";import ReanimatedSwipeable, {type SwipeableMethods,} from "react-native-gesture-handler/ReanimatedSwipeable";-import { Screen, ScreenStack, ScreenStackHeaderConfig } from "react-native-screens";+import { useUniwindTheme } from "../../lib/useUniwindTheme";import { useSafeAreaInsets } from "react-native-safe-area-context";import { Button } from "../../components/ui/Button";-import { AppBar } from "../../components/ui/AppBar";+import { SheetHeader } from "../../components/ui/SheetHeader";import { AppText as Text } from "../../components/ui/AppText";import { SymbolView } from "../../components/ui/AppSymbol";import { Menu } from "../../components/ui/Menu";import { ScreenContent } from "../../components/ui/ScreenContent";import { scopedThreadKey } from "../../lib/scopedEntities";-import { useUniwindTheme } from "../../lib/useUniwindTheme";-import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";import { useAssetUrl } from "../../state/assets";import { useQuietThreadShell } from "../../state/entities";import { useEnvironmentQuery } from "../../state/query";@@ -43,7 +41,6 @@ import {resolveThreadQueueRowControls,} from "./threadQueueControlPresentation";-const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);const REMOVE_ACTION_WIDTH = 76;const THUMBNAIL_LIMIT = 3;const EMPTY_QUEUED_COUNT_ATOM = Atom.make(0).pipe(@@ -121,10 +118,10 @@ function QueuedRunSender(props: {export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {const { layout } = useAdaptiveWorkspaceLayout();+ const theme = useUniwindTheme();const target = route.params;const navigation = useNavigation();const insets = useSafeAreaInsets();- const theme = useUniwindTheme();const workflow = useThreadQueueWorkflow(target);const threadKey = scopedThreadKey(target.environmentId, target.threadId);const editing = useQueuedRunEdit(threadKey);@@ -206,7 +203,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {nestedScrollEnabledclassName="flex-1"// UIKit must inset content beneath the floating translucent iOS header.- contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}+ contentInsetAdjustmentBehavior="automatic"contentContainerClassName="px-5 pb-6"contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 16) + 8 }}>@@ -361,43 +358,10 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {</ScrollView>);- if (Platform.OS === "ios") {- // Plain formSheets lack stack headers; host one in a nested native stack.- return (- <GestureHandlerRootView style={{ flex: 1 }}>- <View collapsable={false} className="flex-1 bg-sheet">- <ScreenStack style={{ flex: 1 }}>- <Screen- activityState={2}- enabled- isNativeStack- screenId="thread-queue-sheet-native"- scrollEdgeEffects={HEADER_SCROLL_EDGE_EFFECTS}- style={{ backgroundColor: theme["--color-sheet"], flex: 1 }}- >- {content}- <ScreenStackHeaderConfig- backgroundColor="rgba(0,0,0,0)"- color={theme["--color-foreground"]}- hideBackButton- hideShadow={false}- title="Queued"- titleColor={theme["--color-foreground"]}- titleFontSize={18}- titleFontWeight="800"- translucent- />- </Screen>- </ScreenStack>- </View>- </GestureHandlerRootView>- );- }-return (<GestureHandlerRootView style={{ flex: 1 }}><View collapsable={false} className="flex-1 bg-sheet">- <AppBar sheet title="Queued" onBack={() => navigation.goBack()} />+ <SheetHeader title="Queued" onClose={() => navigation.goBack()} /><ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent></View></GestureHandlerRootView>diff --git a/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx b/apps/mobile/src/features/threads/ThreadSettingsSheet.tsxindex e907e243713..8c6c7998fe7 100644--- a/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx+++ b/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx@@ -6,6 +6,7 @@ import { SheetHeader } from "../../components/ui/SheetHeader";import { Toolbar } from "../../components/ui/Toolbar";import * as Dialog from "../../components/ui/Dialog";import { createV5StackNavigator as createNativeStackNavigator } from "../../native/createV5StackNavigator";+import { useSheetStackOptions } from "../layout/nested-stacks";import { DEFAULT_SERVER_SETTINGS } from "@t3tools/contracts";import {modelPreferencesMigrationPatch,@@ -74,13 +75,11 @@ import {} from "../../lib/modelOptions";import { applyProviderOptionSelection } from "../../lib/providerOptions";import { resolveProviderOptionDescriptors } from "../../lib/providerOptions";-import { useUniwindTheme } from "../../lib/useUniwindTheme";import {rememberModelOptions,withRememberedModelOptions,} from "../../state/use-model-option-memory";-import { NativeStackScreenOptions, nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";-import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";+import { NativeStackScreenOptions } from "../../native/StackHeader";import { ChatGptSharingStatus } from "./ChatGptSharingStatus";import { environmentCatalog } from "../../connection/catalog";import { useEnvironmentQuery } from "../../state/query";@@ -146,10 +145,6 @@ const THREAD_SETTINGS_CATALOG_EXIT_TRANSITION = FadeOut.duration(120);const THREAD_SETTINGS_OPTIONS_LAYOUT_TRANSITION = LinearTransition.duration(180);const THREAD_SETTINGS_OPTION_ENTER_TRANSITION = FadeIn.duration(140);const THREAD_SETTINGS_OPTION_EXIT_TRANSITION = FadeOut.duration(100);-const THREAD_SETTINGS_HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(- Platform.OS,- Platform.Version,-);const EMPTY_MODEL_FAVORITES: ReadonlyArray<{readonly provider: ProviderInstanceId;readonly model: string;@@ -1431,15 +1426,7 @@ function ThreadSettingsChoiceScreen() {return (<>- <NativeStackScreenOptions options={{ headerShown: Platform.OS !== "android" }} />- {Platform.OS === "android" ? (- <AppBar- embedded- title={route.params.title}- onBack={() => navigation.goBack()}- hideBottomBorder- />- ) : null}+ <AppBar title={route.params.title} onBack={() => navigation.goBack()} hideBottomBorder /><ScreenContent><ThreadSettingsChoiceContentsubmenu={route.params}@@ -1451,9 +1438,7 @@ function ThreadSettingsChoiceScreen() {}function ThreadSettingsPickerNavigator(props: ThreadSettingsPickerPresentation) {- const theme = useUniwindTheme();- const solidSheetBackground = theme["--color-sheet-solid"];- const foreground = theme["--color-foreground"];+ const screenOptions = useSheetStackOptions();const presentation = {onClose: props.onClose,};@@ -1462,24 +1447,7 @@ function ThreadSettingsPickerNavigator(props: ThreadSettingsPickerPresentation)<ThreadSettingsPickerPresentationContext.Provider value={presentation}><ThreadSettingsPickerStack.NavigatorinitialRouteName="ThreadSettingsModels"- screenOptions={{- animation: Platform.OS === "android" ? "default" : "slide_from_right",- contentStyle: { backgroundColor: solidSheetBackground },- gestureEnabled: true,- headerBackButtonDisplayMode: "minimal",- headerBackTitle: "",- headerShown: Platform.OS !== "android",- headerShadowVisible: false,- headerStyle: {- backgroundColor: NATIVE_LIQUID_GLASS_SUPPORTED ? "transparent" : solidSheetBackground,- },- headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,- headerTintColor: foreground,- headerTitleStyle: { fontSize: 17, fontWeight: "700" },- scrollEdgeEffects: NATIVE_LIQUID_GLASS_SUPPORTED- ? THREAD_SETTINGS_HEADER_SCROLL_EDGE_EFFECTS- : undefined,- }}+ screenOptions={screenOptions}><ThreadSettingsPickerStack.Screenname="ThreadSettingsModels"diff --git a/apps/mobile/src/features/threads/sidebar-navigation-shell.tsx b/apps/mobile/src/features/threads/sidebar-navigation-shell.tsxdeleted file mode 100644index 0eeb394af87..00000000000--- a/apps/mobile/src/features/threads/sidebar-navigation-shell.tsx+++ /dev/null@@ -1,48 +0,0 @@-import { createV5StackNavigator as createNativeStackNavigator } from "../../native/createV5StackNavigator";-import { NavigationContainer, NavigationIndependentTree } from "@react-navigation/native";-import { type NativeStackNavigationOptions } from "@react-navigation/native-stack";-import type { ReactNode } from "react";-import { Platform } from "react-native";--import { getCompactBrandHeaderOptions } from "../../components/CompactBrandTitle";-import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";-import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";-import { useMobileNavigationTheme } from "../../lib/useMobileNavigationTheme";--const SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);--type SidebarScreenOptions = NativeStackNavigationOptions & {- // Patched RNS editor style leading-aligns iOS 26 inline titles, matching Stack.tsx presets.- readonly unstable_navigationItemStyle?: "editor";-};--const SIDEBAR_SCREEN_OPTIONS: SidebarScreenOptions = {- contentStyle: { backgroundColor: "transparent" },- headerLargeTitle: false,- headerShadowVisible: false,- headerShown: true,- headerStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? { backgroundColor: "transparent" } : undefined,- ...getCompactBrandHeaderOptions({ fontSize: 18, fontWeight: "800" }),- headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,- scrollEdgeEffects: NATIVE_LIQUID_GLASS_SUPPORTED ? SCROLL_EDGE_EFFECTS : undefined,- unstable_navigationItemStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? "editor" : undefined,-};--const SidebarStack = createNativeStackNavigator();--export function SidebarNavigationShell(props: { readonly children: ReactNode }) {- const navigationTheme = useMobileNavigationTheme("sidebar");-- return (- <NavigationIndependentTree>- <NavigationContainer theme={navigationTheme}>- <SidebarStack.Navigator- screenOptions={SIDEBAR_SCREEN_OPTIONS}- initialRouteName="SidebarThreads"- >- <SidebarStack.Screen name="SidebarThreads">{() => props.children}</SidebarStack.Screen>- </SidebarStack.Navigator>- </NavigationContainer>- </NavigationIndependentTree>- );-}diff --git a/apps/mobile/src/features/threads/thread-inspector-preview.tsx b/apps/mobile/src/features/threads/thread-inspector-preview.tsxindex 85c08546e7d..d41d1f0c7e9 100644--- a/apps/mobile/src/features/threads/thread-inspector-preview.tsx+++ b/apps/mobile/src/features/threads/thread-inspector-preview.tsx@@ -1,34 +1,10 @@-import {- createNavigatorFactory,- NavigationContainer,- NavigationIndependentTree,- StackRouter,- useIsFocused,- useNavigation,- useNavigationBuilder,- type NavigatorTypeBagBase,- type ParamListBase,- type StackActionHelpers,- type StackNavigationState,- type StackRouterOptions,- type StaticConfig,- type StaticScreenProps,- type TypedNavigator,-} from "@react-navigation/native";-import type {- NativeStackNavigationEventMap,- NativeStackNavigationOptions,- NativeStackNavigatorProps,- NativeStackTypeBag,-} from "@react-navigation/native-stack";+import { useIsFocused, useNavigation, type StaticScreenProps } from "@react-navigation/native";import { EnvironmentId, ThreadId } from "@t3tools/contracts";import { type ReactNode } from "react";import { View } from "react-native";import { AppBar } from "../../components/ui/AppBar";import { SheetHeader } from "../../components/ui/SheetHeader";-import { NativeStackScreenOptions } from "../../native/StackHeader";-import { useMobileNavigationTheme } from "../../lib/useMobileNavigationTheme";import { DevicePreviewScreen } from "../devices/DevicePreviewRouteScreen";import {WorkspaceContentWidthContext,@@ -38,6 +14,7 @@ import {ThreadInspectorNavigationContext,type ThreadInspectorTarget,} from "./thread-inspector-navigation";+import { ThreadPreviewRoute } from "./thread-preview-route";/** A thread shown outside its route: in the inspector pane, or presented full screen with a close. */export type ThreadInspectorPresentation =@@ -62,65 +39,10 @@ export function ThreadInspectorHeader();}return (- <>- <NativeStackScreenOptions options={{ headerShown: true, headerTransparent: true }} />- <SheetHeader title={props.title} onClose={props.onClose} accessibilityLabel="Close thread" />- </>+ <SheetHeader title={props.title} onClose={props.onClose} accessibilityLabel="Close thread" />);}-/**- * Gives the previewed thread a route of its own, so its route hooks and actions never reach the- * host thread. It draws nothing: the thread's AppBar writes into the pane's bar.- */-function PreviewRouteNavigator({- id,- initialRouteName,- UNSTABLE_routeNamesChangeBehavior,- children,- layout,- screenListeners,- screenOptions,- screenLayout,- UNSTABLE_router,-}: NativeStackNavigatorProps) {- const { state, descriptors, NavigationContent } = useNavigationBuilder<- StackNavigationState<ParamListBase>,- StackRouterOptions,- StackActionHelpers<ParamListBase>,- NativeStackNavigationOptions,- NativeStackNavigationEventMap- >(StackRouter, {- id,- initialRouteName,- UNSTABLE_routeNamesChangeBehavior,- children,- layout,- screenListeners,- screenOptions,- screenLayout,- UNSTABLE_router,- });- const route = state.routes[state.index];- return <NavigationContent>{route ? descriptors[route.key]?.render() : null}</NavigationContent>;-}--type PreviewTypeBag<ParamList extends ParamListBase> = Omit<- NativeStackTypeBag<ParamList, undefined>,- "Navigator"-> & { Navigator: typeof PreviewRouteNavigator };-function createPreviewRouteNavigator<- const ParamList extends ParamListBase,- const TypeBag extends NavigatorTypeBagBase = PreviewTypeBag<ParamList>,- const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,->(config?: Config): TypedNavigator<TypeBag, Config> {- return createNavigatorFactory(PreviewRouteNavigator)(config);-}--const PreviewStack = createPreviewRouteNavigator<{- Thread: { readonly environmentId: string; readonly threadId: string };-}>();-/** A thread shown beside or over the workspace does not take the workspace's content width. */export function InspectorContentScope({ children }: { readonly children: ReactNode }) {return (@@ -144,7 +66,6 @@ export function ThreadInspectorPreview(props: {}) {const navigation = useNavigation();const focused = useIsFocused();- const theme = useMobileNavigationTheme();const { target } = props;const maximizeDevice = (deviceKey: string | null) => {props.onOpen({ ...target, deviceKey: deviceKey ?? undefined });@@ -169,26 +90,20 @@ export function ThreadInspectorPreview(props: {/>) : (<View className="flex-1 bg-screen">- <NavigationIndependentTree>- <NavigationContainer theme={theme} onUnhandledAction={navigation.dispatch}>- <PreviewStack.Navigator key={`${target.environmentId}:${target.threadId}`}>- <PreviewStack.Screen name="Thread" initialParams={target}>- {(screen) =>- props.renderThread({- route: screen.route,- inspectorPresentation: {- onMaximize: () =>- navigation.navigate("ThreadInspectorFullscreen", {- environmentId: screen.route.params.environmentId,- threadId: screen.route.params.threadId,- }),- },- })- }- </PreviewStack.Screen>- </PreviewStack.Navigator>- </NavigationContainer>- </NavigationIndependentTree>+ <ThreadPreviewRoute environmentId={target.environmentId} threadId={target.threadId}>+ {(route) =>+ props.renderThread({+ route,+ inspectorPresentation: {+ onMaximize: () =>+ navigation.navigate("ThreadInspectorFullscreen", {+ environmentId: route.params.environmentId,+ threadId: route.params.threadId,+ }),+ },+ })+ }+ </ThreadPreviewRoute></View>)}</InspectorContentScope>diff --git a/apps/mobile/src/features/threads/thread-preview-route.tsx b/apps/mobile/src/features/threads/thread-preview-route.tsxnew file mode 100644index 00000000000..e8c57c8db24--- /dev/null+++ b/apps/mobile/src/features/threads/thread-preview-route.tsx@@ -0,0 +1,100 @@+import {+ createNavigatorFactory,+ NavigationContainer,+ NavigationIndependentTree,+ StackRouter,+ useNavigation,+ useNavigationBuilder,+ type NavigatorTypeBagBase,+ type ParamListBase,+ type RouteProp,+ type StackActionHelpers,+ type StackNavigationState,+ type StackRouterOptions,+ type StaticConfig,+ type TypedNavigator,+} from "@react-navigation/native";+import type {+ NativeStackNavigationEventMap,+ NativeStackNavigationOptions,+ NativeStackNavigatorProps,+ NativeStackTypeBag,+} from "@react-navigation/native-stack";+import type { ReactNode } from "react";++import { useMobileNavigationTheme } from "../../lib/useMobileNavigationTheme";++function ThreadPreviewNavigator({+ id,+ initialRouteName,+ UNSTABLE_routeNamesChangeBehavior,+ children,+ layout,+ screenListeners,+ screenOptions,+ screenLayout,+ UNSTABLE_router,+}: NativeStackNavigatorProps) {+ const { state, descriptors, NavigationContent } = useNavigationBuilder<+ StackNavigationState<ParamListBase>,+ StackRouterOptions,+ StackActionHelpers<ParamListBase>,+ NativeStackNavigationOptions,+ NativeStackNavigationEventMap+ >(StackRouter, {+ id,+ initialRouteName,+ UNSTABLE_routeNamesChangeBehavior,+ children,+ layout,+ screenListeners,+ screenOptions,+ screenLayout,+ UNSTABLE_router,+ });+ const route = state.routes[state.index];+ return <NavigationContent>{route ? descriptors[route.key]?.render() : null}</NavigationContent>;+}++type ThreadPreviewTypeBag<ParamList extends ParamListBase> = Omit<+ NativeStackTypeBag<ParamList, undefined>,+ "Navigator"+> & { Navigator: typeof ThreadPreviewNavigator };++function createThreadPreviewNavigator<+ const ParamList extends ParamListBase,+ const TypeBag extends NavigatorTypeBagBase = ThreadPreviewTypeBag<ParamList>,+ const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,+>(config?: Config): TypedNavigator<TypeBag, Config> {+ return createNavigatorFactory(ThreadPreviewNavigator)(config);+}++type ThreadPreviewParams = { readonly environmentId: string; readonly threadId: string };++const Preview = createThreadPreviewNavigator<{ Thread: ThreadPreviewParams }>();++/**+ * A `Thread` route of its own for a thread shown inside another screen. Thread state resolves the+ * thread from route params, so the preview needs its own params, and its `replace` must not swap+ * the host thread. Draws no native UI; actions it can't handle go to the host.+ */+export function ThreadPreviewRoute(+ props: ThreadPreviewParams & {+ readonly children: (route: RouteProp<{ Thread: ThreadPreviewParams }, "Thread">) => ReactNode;+ },+) {+ const host = useNavigation();+ const theme = useMobileNavigationTheme();+ const { environmentId, threadId } = props;+ return (+ <NavigationIndependentTree>+ <NavigationContainer theme={theme} onUnhandledAction={host.dispatch}>+ <Preview.Navigator key={`${environmentId}:${threadId}`}>+ <Preview.Screen name="Thread" initialParams={{ environmentId, threadId }}>+ {(screen) => props.children(screen.route)}+ </Preview.Screen>+ </Preview.Navigator>+ </NavigationContainer>+ </NavigationIndependentTree>+ );+}diff --git a/vite.config.ts b/vite.config.tsindex c92ad24843f..d5ee6c9d0df 100644--- a/vite.config.ts+++ b/vite.config.ts@@ -631,6 +631,7 @@ export default defineConfig({"apps/mobile/src/features/files/AttachmentFileScreen.tsx","apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx","apps/mobile/src/features/files/thread-file-navigator-pane.tsx",+ "apps/mobile/src/features/layout/nested-stacks.tsx","apps/mobile/src/features/review/ReviewSheet.tsx","apps/mobile/src/features/review/useNativeReviewDiffBridge.ts","apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx",@@ -638,7 +639,6 @@ export default defineConfig({"apps/mobile/src/features/threads/ThreadFeed.tsx","apps/mobile/src/features/threads/ThreadQueueControl.tsx","apps/mobile/src/features/review/ReviewCommentCard.tsx",- "apps/mobile/src/features/threads/ThreadSettingsSheet.tsx","apps/mobile/src/features/threads/thread-list-v2-items.tsx","apps/mobile/src/lib/useMobileNavigationTheme.ts","apps/mobile/src/native/T3ComposerEditor.ios.tsx",