TypeScript
refactor(mobile): the inspector's bar is its pane's AppBar (#27205)
Julius Marminge7448ad8f5843
diff --git a/apps/mobile/modules/t3-native-controls/ios/T3ScrollEdgeBleedView.swift b/apps/mobile/modules/t3-native-controls/ios/T3ScrollEdgeBleedView.swiftindex cb3c9041efc..0f4e70b20cc 100644--- a/apps/mobile/modules/t3-native-controls/ios/T3ScrollEdgeBleedView.swift+++ b/apps/mobile/modules/t3-native-controls/ios/T3ScrollEdgeBleedView.swift@@ -95,8 +95,11 @@ final class T3ScrollEdgeBleedView: ExpoView {// The vertical-bar API ships in the iOS 27.1 SDK (UIKit 9127.0.85); see T3LayoutMetricsView.#if canImport(UIKit, _version: 9127.0.85)if #available(iOS 27.1, *) {+ // UIKit leaves the trait unset in a split view's inspector column, though the bar overlaps+ // it; the flush check above still decides whether this view sits at the bar.+ let traits = window?.rootViewController?.traitCollection ?? traitCollectionlet rtl = effectiveUserInterfaceLayoutDirection == .rightToLeft- switch traitCollection.verticalBarEdge {+ switch traits.verticalBarEdge {case .leading: return rtl ? .right : .leftcase .trailing: return rtl ? .left : .rightdefault: return nildiff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsxindex 9986176c7a3..eea909a7294 100644--- a/apps/mobile/src/Stack.tsx+++ b/apps/mobile/src/Stack.tsx@@ -11,10 +11,7 @@ import {StackActions,useNavigation,} from "@react-navigation/native";-import {- createNativeStackScreen,- type NativeStackNavigationOptions,-} from "@react-navigation/native-stack";+import { createNativeStackScreen } from "@react-navigation/native-stack";import type { ReactNode } from "react";import { Platform, Pressable, ScrollView, StyleSheet, useWindowDimensions } from "react-native";import { useResolveClassNames } from "uniwind";@@ -141,33 +138,12 @@ import {SettingsLegalDocumentCloseHeaderButton,SettingsLegalDocumentExternalHeaderButton,} from "./features/settings/components/SettingsLegalDocumentRouteScreen";-import { NATIVE_LIQUID_GLASS_SUPPORTED } from "./native/native-glass";+import { GLASS_HEADER_OPTIONS, type AppScreenOptions } from "./native/glass-header-options";import { deriveLayout } from "./lib/layout";import { useNativeLayoutMetrics } from "./native/native-layout-metrics";-import { nativeHeaderScrollEdgeEffects } from "./native/StackHeader";import { HORIZONTAL_FORM_SHEET_OPTIONS, formSheetDetents } from "./native/sheet-surface";import { workspaceDetailRouter } from "./features/workspace/workspace-detail-selection";-const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);--type AppScreenOptions = NativeStackNavigationOptions & {- readonly unstable_navigationItemStyle?: "editor";- readonly unstable_headerMinimizationBehavior?: "onScrollUp" | "never";-};--const GLASS_HEADER_OPTIONS: AppScreenOptions = {- headerBackButtonDisplayMode: "minimal",- headerBackTitle: "",- headerLargeTitle: false,- headerShadowVisible: false,- headerShown: true,- headerStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? { backgroundColor: "transparent" } : undefined,- headerTitleStyle: { fontSize: 18, fontWeight: "800" },- headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,- scrollEdgeEffects: NATIVE_LIQUID_GLASS_SUPPORTED ? HEADER_SCROLL_EDGE_EFFECTS : undefined,- unstable_navigationItemStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? "editor" : undefined,-};-// Hiding Android's native header after mount can leave detail panes measured short.// These screens render their own Material toolbar, so hide it from the first layout.const DETAIL_HEADER_OPTIONS: AppScreenOptions = {diff --git a/apps/mobile/src/components/ui/AppBar.android.tsx b/apps/mobile/src/components/ui/AppBar.android.tsxindex 770a26c4661..a37ee4d74ad 100644--- a/apps/mobile/src/components/ui/AppBar.android.tsx+++ b/apps/mobile/src/components/ui/AppBar.android.tsx@@ -1,9 +1,10 @@-import { type RefObject, useRef, useState } from "react";+import { type RefObject, use, useRef, useState } from "react";import { Keyboard, type TextInputInstance, View } from "react-native";import { useHardwareBack } from "../../lib/backHandler";import { useToolbarLayout } from "./useToolbarLayout";import { NativeStackScreenOptions } from "../../native/StackHeader";import { useSidebarToggle } from "../../features/layout/useSidebarToggle";+import { InspectorCloseContext } from "../../features/layout/inspector-bar-store";import { useAppearancePreferences } from "../../features/settings/appearance/AppearancePreferencesProvider";import { AndroidHeaderIconButton, AndroidScreenHeader } from "./AndroidScreenHeader";import { ScreenHeaderButton } from "./ScreenHeaderButton.android";@@ -69,8 +70,15 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })const { themeVariables } = useAppearancePreferences();const inWorkspace = useHasWorkspaceAppBar();const sidebarToggle = useSidebarToggle();+ const closeInspector = use(InspectorCloseContext);const inline = search?.mode === "inline";const searching = searchState?.searching === true;+ const actions = props.refresh+ ? [+ ...(props.actions ?? []),+ { ...props.refresh, icon: "arrow.clockwise" as const, overflowOnly: true },+ ]+ : props.actions;const openSearch = () => searchState?.open();const closeSearch = () => searchState?.close();@@ -177,24 +185,22 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })icon: "magnifyingglass",onPress: openSearch,},- ...(search.refreshInToolbar && search.onRefresh- ? [- {- accessibilityLabel: search.refreshAccessibilityLabel ?? "Refresh",- icon: "arrow.clockwise" as const,- onPress: search.onRefresh,- },- ]- : []),- ...(props.actions ?? []),+ ...(actions ?? []),]- : props.actions+ : actions}trailing={- menuView?.length || props.trailing ? (+ menuView?.length || props.trailing || closeInspector ? (<>{menuView}{props.trailing}+ {closeInspector ? (+ <AndroidHeaderIconButton+ accessibilityLabel="Close inspector"+ icon="xmark"+ onPress={closeInspector}+ />+ ) : null}</>) : undefined}diff --git a/apps/mobile/src/components/ui/AppBar.tsx b/apps/mobile/src/components/ui/AppBar.tsxindex c343e7c5670..8061e2c467f 100644--- a/apps/mobile/src/components/ui/AppBar.tsx+++ b/apps/mobile/src/components/ui/AppBar.tsx@@ -1,15 +1,17 @@import { Toolbar } from "./Toolbar";import { AppActivityIndicator } from "./AppActivityIndicator";import type { HeaderBarButtonMailSearchToolbarItem } from "react-native-screens";-import { useId } from "react";+import { use, useId, useLayoutEffect } from "react";import { View } from "react-native";import { createNativeHeaderMenu } from "./nativeHeaderMenu.ios";import { ScreenHeaderButton } from "./ScreenHeaderButton";-import { NativeStackScreenOptions } from "../../native/StackHeader";+import { NativeStackScreenOptions, useScreenOptionsWriter } from "../../native/StackHeader";import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";import { useDeviceType } from "../../native/native-layout-metrics";+import { isDuoDevice } from "../../lib/device-type";import { useAdaptiveWorkspaceLayout } from "../../features/layout/AdaptiveWorkspaceLayout";import { useSidebarToggle } from "../../features/layout/useSidebarToggle";+import { InspectorCloseContext } from "../../features/layout/inspector-bar-store";import {createNativeMailSearchToolbarItem,NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED,@@ -44,6 +46,15 @@ export function AppBar(props: AppBarProps) {const headerId = useId();const { layout } = useAdaptiveWorkspaceLayout();const sidebarToggle = useSidebarToggle();+ const closeInspector = use(InspectorCloseContext);+ const setOptions = useScreenOptionsWriter();+ const ownsInspectorBar = closeInspector !== null && !props.embedded && !props.sheet;+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- an inspector pane that stops drawing its bar must not leave it in the out-of-tree inspector bar+ useLayoutEffect(() => {+ if (!ownsInspectorBar || !setOptions) return;+ setOptions({ headerShown: true });+ return () => setOptions({ headerShown: false });+ }, [ownsInspectorBar, setOptions]);// The Duo's native columns show their own sidebar button while the sidebar is open.const showsSidebarToggle =sidebarToggle !== null &&@@ -62,16 +73,18 @@ export function AppBar(props: AppBarProps) {(search.compactToolbar ?? !layout.usesSplitView) &&usesNativeMailSearchToolbar;const visibleMenus = compactSearch ? (menus?.slice(1) ?? []) : (menus ?? []);- const refresh = search?.refreshInToolbar ? search.onRefresh : undefined;+ // Where the mail toolbar isn't used, the Duo keeps search at the bottom of the pane like its+ // workspace lists; elsewhere inline search is a button in the bar.+ const duoBottomSearch =+ search !== undefined &&+ !compactSearch &&+ NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED &&+ isDuoDevice(deviceType);if (props.embedded || props.sheet) return null;return (<><NativeStackScreenOptions- optionsVersion={[- props.optionsVersion,- compactSearch ? menu : undefined,- compactSearch ? refresh : undefined,- ]}+ optionsVersion={[props.optionsVersion, compactSearch ? menu : undefined]}options={{headerShown: true,headerBackVisible: splitBack === null,@@ -89,13 +102,6 @@ export function AppBar(props: AppBarProps) {placeholder: search.compactPlaceholder ?? search.placeholder,onSearchTextChange: search.onChangeText,searchTextChangeId: `${headerId}-search-text`,- ...(refresh- ? {- composeButtonId: `${headerId}-refresh`,- composeSystemImageName: "arrow.clockwise",- onComposePress: refresh,- }- : undefined),...(menu? {filterButtonId: `${headerId}-filter`,@@ -110,12 +116,16 @@ export function AppBar(props: AppBarProps) {? undefined: {allowToolbarIntegration: true,- ...(NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED && search.mode === "inline"- ? { placement: "integratedButton" as const }- : undefined),+ ...(duoBottomSearch+ ? { placement: "integrated" as const }+ : NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED && search.mode === "inline"+ ? { placement: "integratedButton" as const }+ : undefined),autoCapitalize: "none",hideNavigationBar: false,- ...(search.mode === "inline" ? { obscureBackground: false } : undefined),+ ...(search.mode === "inline" || duoBottomSearch+ ? { obscureBackground: false }+ : undefined),placeholder: search.placeholder,onChangeText: (event) => search.onChangeText(event.nativeEvent.text),onCancelButtonPress: () => search.onChangeText(""),@@ -140,10 +150,7 @@ export function AppBar(props: AppBarProps) {) : null}</Toolbar>) : null}- {(props.actions?.length ||- (!compactSearch && refresh) ||- visibleMenus.length ||- props.trailing) &&+ {(props.actions?.length || visibleMenus.length || props.trailing || closeInspector) &&props.options?.unstable_headerRightItems === undefined ? (<Toolbar placement="right">{props.actions?.map(({ loading, ...action }) =>@@ -165,16 +172,21 @@ export function AppBar(props: AppBarProps) {/>),)}- {refresh && !compactSearch ? (+ {visibleMenus.map(createNativeHeaderMenu)}+ {props.trailing}+ {closeInspector ? (<ScreenHeaderButton- accessibilityLabel={search?.refreshAccessibilityLabel}- icon="arrow.clockwise"- onPress={refresh}+ accessibilityLabel="Close inspector"+ icon="xmark"+ onPress={closeInspector}separateBackground/>) : null}- {visibleMenus.map(createNativeHeaderMenu)}- {props.trailing}+ </Toolbar>+ ) : null}+ {duoBottomSearch ? (+ <Toolbar placement="bottom">+ <Toolbar.SearchBarSlot /></Toolbar>) : null}</>diff --git a/apps/mobile/src/components/ui/AppBar.types.ts b/apps/mobile/src/components/ui/AppBar.types.tsindex 11c358d4d71..94c4ad07879 100644--- a/apps/mobile/src/components/ui/AppBar.types.ts+++ b/apps/mobile/src/components/ui/AppBar.types.ts@@ -57,9 +57,6 @@ export interface AppBarSearch {readonly compactPlaceholder?: string;readonly closeAccessibilityLabel?: string;readonly clearAccessibilityLabel?: string;- readonly onRefresh?: () => void;- readonly refreshAccessibilityLabel?: string;- readonly refreshInToolbar?: boolean;/** Controlled open state. The owner then also handles back and the keyboard shortcut. */readonly active?: boolean;readonly onOpen?: () => void;@@ -72,6 +69,8 @@ export interface AppBarProps {readonly titleContent?: ReactNode;readonly subtitle?: string | null;readonly actions?: ReadonlyArray<AppBarAction>;+ /** Pull-to-refresh is the gesture on both platforms; Android also lists this in the overflow menu. */+ readonly refresh?: Pick<AppBarAction, "accessibilityLabel" | "disabled" | "onPress">;readonly menus?: ReadonlyArray<AppBarMenu>;readonly search?: AppBarSearch;readonly onBack?: () => void;diff --git a/apps/mobile/src/features/files/FilesHeader.tsx b/apps/mobile/src/features/files/FilesHeader.tsxdeleted file mode 100644index 4fdfe9ebf7a..00000000000--- a/apps/mobile/src/features/files/FilesHeader.tsx+++ /dev/null@@ -1,98 +0,0 @@-import { useRef, useState, type ReactNode } from "react";-import { Keyboard, type TextInputInstance, View } from "react-native";--import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";-import { AppBar } from "../../components/ui/AppBar";-import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";-import { SearchField } from "../../components/ui/SearchField";-import { useToolbarLayout } from "../../components/ui/useToolbarLayout";-import { useHardwareBack } from "../../lib/backHandler";--export function FilesHeader(props: {- readonly projectName: string;- readonly searchQuery: string;- readonly onSearchQueryChange: (query: string) => void;- readonly onRefresh: () => void;- readonly onBack?: () => void;- readonly leading?: ReactNode;-}) {- const { paddingTop, paddingBottom } = useToolbarLayout();- const searchRef = useRef<TextInputInstance>(null);- const [searchOpen, setSearchOpen] = useState(false);- const searching = searchOpen || props.searchQuery.length > 0;- const { onSearchQueryChange } = props;- const closeSearch = () => {- onSearchQueryChange("");- setSearchOpen(false);- Keyboard.dismiss();- };-- useHardwareBack(searching, () => {- closeSearch();- return true;- });-- return (- <View>- {}- <View- pointerEvents={searching ? "none" : "auto"}- accessibilityElementsHidden={searching}- importantForAccessibility={searching ? "no-hide-descendants" : "auto"}- style={{ opacity: searching ? 0 : 1 }}- >- <AppBar- embedded- title="Files"- subtitle={props.projectName}- hideBottomBorder- onBack={props.onBack}- leading={props.leading}- actions={[- {- accessibilityLabel: "Search files",- icon: "magnifyingglass",- onPress: () => setSearchOpen(true),- },- ]}- trailing={- <AndroidAnchoredMenu- title="File options"- actions={[{ id: "refresh", title: "Refresh files" }]}- onPressAction={({ nativeEvent }) => {- if (nativeEvent.event === "refresh") props.onRefresh();- }}- >- {(open) => (- <AndroidHeaderIconButton- accessibilityLabel="File options"- icon="ellipsis"- onPress={open}- />- )}- </AndroidAnchoredMenu>- }- />- </View>- {searching ? (- <View className="absolute inset-0 bg-header px-2" style={{ paddingTop, paddingBottom }}>- <View className="flex-1 flex-row items-center gap-1">- <AndroidHeaderIconButton- accessibilityLabel="Close file search"- icon="arrow.left"- onPress={closeSearch}- />- <SearchField- inputRef={searchRef}- accessibilityLabel="Search files"- clearAccessibilityLabel="Clear file search"- placeholder="Search files"- value={props.searchQuery}- onChangeText={onSearchQueryChange}- />- </View>- </View>- ) : null}- </View>- );-}diff --git a/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx b/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsxindex f383c0558ae..f3de5d80258 100644--- a/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx+++ b/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx@@ -42,7 +42,6 @@ import { useAppearancePreferences } from "../settings/appearance/AppearancePrefeimport { ThreadRouteScreen } from "../threads/ThreadRouteScreen";import { FilePreviewLoading, FilePreviewNotice } from "./FilePreviewFeedback";import { FileMarkdownPreview } from "./FileMarkdownPreview";-import { ThreadInspectorContentStack } from "../threads/thread-inspector-content-stack";import { FileTreeBrowser } from "./FileTreeBrowser";import { useFileTreeEntries } from "./useFileTreeEntries";import { preloadWorkspaceFileContents } from "./preload-workspace-file";@@ -486,12 +485,11 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {}navigation.navigate("ThreadFile", params);};- const renderInspector = (headerInset: number) =>+ const renderInspector = () =>environmentId !== null && cwd !== null ? (<ThreadFileNavigatorPanecwd={cwd}environmentId={environmentId}- headerInset={headerInset}projectName={projectName}selectedPath={null}onSelectFile={handleSelectFile}@@ -749,12 +747,11 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {if (directoryPath !== null) navigation.dispatch(StackActions.push("ThreadFile", destination));else navigation.navigate("ThreadFile", destination);};- const renderInspector = (headerInset: number) =>+ const renderInspector = () =>fileInspector.supported && environmentId !== null && cwd !== null ? (<ThreadFileNavigatorPanecwd={directoryPath ?? cwd}environmentId={environmentId}- headerInset={headerInset}projectName={directoryPath ?? projectName}selectedPath={directoryPath === null ? relativePath : null}onSelectFile={(path) => {@@ -763,17 +760,14 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {}}/>) : undefined;- const safeAreaInsets = useSafeAreaInsets();- const inspectorHeaderInset = Platform.OS === "ios" ? 0 : safeAreaInsets.top;- const renderWorkspaceInspector = () => (- <ThreadInspectorContentStack- mode="files"- resetKeys={[threadId, cwd]}- renderFiles={() => renderInspector(inspectorHeaderInset)}- />- );const inspector = fileInspector.supported ? (- <Inspector>{renderWorkspaceInspector()}</Inspector>+ <Inspector+ content={{+ active: "files",+ resetKeys: [threadId, cwd],+ panes: [{ key: "files", render: renderInspector }],+ }}+ />) : null;const withInspector = (content: ReactNode) => (<>diff --git a/apps/mobile/src/features/files/thread-file-navigator-pane.tsx b/apps/mobile/src/features/files/thread-file-navigator-pane.tsxindex 0c3d3f772a8..2fd52284106 100644--- a/apps/mobile/src/features/files/thread-file-navigator-pane.tsx+++ b/apps/mobile/src/features/files/thread-file-navigator-pane.tsx@@ -1,46 +1,27 @@import { resolveFilesystemReadAccess } from "@t3tools/client-runtime/state/filesystem";import { environmentSession } from "../../state/session";import type { EnvironmentId } from "@t3tools/contracts";-import { SymbolView } from "../../components/ui/AppSymbol";+import { AppBar } from "../../components/ui/AppBar";import { ScreenContent } from "../../components/ui/ScreenContent";-import { useState, type ComponentProps } from "react";-import { Platform, Pressable, View, type NativeSyntheticEvent } from "react-native";-import {- Screen,- ScreenStack,- ScreenStackHeaderConfig,- ScreenStackHeaderSearchBarView,- SearchBar,-} from "react-native-screens";+import { useState } from "react";+import { View } from "react-native";-import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText";-import { FilesHeader } from "./FilesHeader";-import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";-import { useUniwindTheme } from "../../lib/useUniwindTheme";import { useEnvironmentQuery } from "../../state/query";import { useEnvironmentPresentation } from "../../state/presentation";import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";import { FileTreeBrowser } from "./FileTreeBrowser";-import { NativeInspectorContent } from "../../native/NativeInspectorContent";import { useFileTreeEntries } from "./useFileTreeEntries";import { preloadWorkspaceFileContents } from "./preload-workspace-file";-import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";export function ThreadFileNavigatorPane(props: {readonly cwd: string;readonly environmentId: EnvironmentId;- readonly headerInset: number;readonly projectName: string;readonly selectedPath: string | null;readonly onSelectFile: (path: string) => void;}) {const [searchQuery, setSearchQuery] = useState("");- const { toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout();const { themeAppearance: highlightTheme } = useAppearancePreferences();- const theme = useUniwindTheme();- const foregroundColor = theme["--color-foreground"];- const sheetColor = theme["--color-sheet"];- const headerScrollEdgeEffects = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);const fileAccessSession = useEnvironmentQuery(environmentSession.sessionStateAtom(props.environmentId),);@@ -65,18 +46,6 @@ export function ThreadFileNavigatorPane(props: {theme: highlightTheme,});};- const nativeHeaderRightBarButtonItems = [- {- accessibilityLabel: "Close files",- icon: { name: "xmark", type: "sfSymbol" as const },- identifier: "thread-file-navigator-close",- onPress: toggleAuxiliaryPane,- sharesBackground: false,- tintColor: foregroundColor,- type: "button" as const,- },- ] as ComponentProps<typeof ScreenStackHeaderConfig>["headerRightBarButtonItems"];-const fileTree = (<FileTreeBrowserkey={JSON.stringify([props.environmentId, props.cwd])}@@ -108,122 +77,18 @@ export function ThreadFileNavigatorPane(props: {/>);- if (Platform.OS === "ios") {- return (- <View className="flex-1 border-l border-border bg-sheet">- <ScreenStack style={{ flex: 1 }}>- <Screen- activityState={2}- enabled- isNativeStack- screenId="thread-file-navigator-native"- scrollEdgeEffects={headerScrollEdgeEffects}- style={{ backgroundColor: sheetColor, flex: 1 }}- >- <NativeInspectorContent>{fileTree}</NativeInspectorContent>- <ScreenStackHeaderConfig- backgroundColor="rgba(0,0,0,0)"- color={foregroundColor}- headerRightBarButtonItems={nativeHeaderRightBarButtonItems}- hideBackButton- hideShadow={false}- navigationItemStyle="editor"- subtitle={props.projectName}- title="Files"- titleColor={foregroundColor}- titleFontSize={17}- titleFontWeight="700"- translucent- >- <ScreenStackHeaderSearchBarView>- <SearchBar- allowToolbarIntegration- autoCapitalize="none"- barTintColor={sheetColor}- hideNavigationBar={false}- hideWhenScrolling={false}- obscureBackground={false}- onCancelButtonPress={() => {- setSearchQuery("");- }}- onChangeText={(event: NativeSyntheticEvent<{ readonly text?: string }>) => {- setSearchQuery(event.nativeEvent.text ?? "");- }}- placement="integratedButton"- placeholder="Search files"- textColor={foregroundColor}- tintColor={foregroundColor}- />- </ScreenStackHeaderSearchBarView>- </ScreenStackHeaderConfig>- </Screen>- </ScreenStack>- </View>- );- }-return (- <View- className={- Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 border-l border-border bg-sheet"- }- >- <View- className="ios:border-b ios:border-border android:bg-header"- style={{ paddingTop: Platform.OS === "android" ? 0 : props.headerInset }}- >- {Platform.OS === "android" ? (- <FilesHeader- projectName={props.projectName}- searchQuery={searchQuery}- onSearchQueryChange={setSearchQuery}- onRefresh={entriesQuery.refresh}- />- ) : (- <View className="h-12 flex-row items-center gap-2 px-3">- <View className="min-w-0 flex-1">- <Text className="text-sm font-t3-bold text-foreground">Files</Text>- <Text className="text-xs text-foreground-muted" numberOfLines={1}>- {props.projectName}- </Text>- </View>- <Pressable- accessibilityRole="button"- accessibilityLabel="Refresh files"- hitSlop={8}- className="h-8 w-8 items-center justify-center rounded-full active:bg-subtle"- onPress={entriesQuery.refresh}- >- <SymbolView- name="arrow.clockwise"- size={14}- tintColorClassName="accent-icon-muted"- type="monochrome"- />- </Pressable>- </View>- )}- {Platform.OS !== "android" ? (- <View className="flex-row items-center gap-2 border-t border-border px-3 py-2">- <SymbolView- name="magnifyingglass"- size={15}- tintColorClassName="accent-icon-muted"- type="monochrome"- />- <TextInput- accessibilityLabel="Search files"- autoCapitalize="none"- autoCorrect={false}- clearButtonMode="while-editing"- className="min-h-10 flex-1 rounded-xl py-2 text-sm"- placeholder="Search files"- value={searchQuery}- onChangeText={setSearchQuery}- />- </View>- ) : null}- </View>+ <View className="flex-1 ios:bg-sheet android:bg-header">+ <AppBar+ title="Files"+ subtitle={props.projectName}+ search={{+ value: searchQuery,+ onChangeText: setSearchQuery,+ placeholder: "Search files",+ }}+ refresh={{ accessibilityLabel: "Refresh files", onPress: entriesQuery.refresh }}+ /><ScreenContent insetHorizontal>{fileTree}</ScreenContent></View>);diff --git a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsxindex 39eff844236..e106a4781e2 100644--- a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx+++ b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx@@ -82,6 +82,7 @@ import { PaneContext } from "../../components/ui/Pane";import { WORKSPACE_PANE_TIMING } from "./workspace-pane-animation";import { WorkspaceInspectorPane } from "./workspace-inspector-pane";import { WorkspaceInspectorSheet } from "./workspace-inspector-sheet";+import type { InspectorContent } from "./inspector-panes";import {WorkspaceContentWidthContext,WorkspaceSettledContentWidthContext,@@ -112,24 +113,31 @@ import { WorkspaceThreadSidebar } from "../workspace/WorkspaceThreadSidebar";export { useAdaptiveWorkspaceLayout };/**- * Shows its children in the workspace's inspector column while this screen is focused. Register on- * focus events because frozen blurred screens may never clean up.+ * Shows these panes in the workspace's inspector while this screen is focused. Register on focus+ * events because frozen blurred screens may never clean up.*/export function Inspector(props: {- readonly children: ReactNode;+ readonly content: InspectorContent;/** Opens the column the first time this key registers while its route stays on the stack. */readonly revealKey?: string;}) {const { registerWorkspaceInspector } = useAdaptiveWorkspaceLayout();const navigation = use(NavigationContext);const route = use(NavigationRouteContext);- const render = () => (- <NavigationContext.Provider value={navigation}>- <NavigationRouteContext.Provider value={route}>- {props.children}- </NavigationRouteContext.Provider>- </NavigationContext.Provider>- );+ const content: InspectorContent = {+ ...props.content,+ resetKeys: [route?.key, ...(props.content.resetKeys ?? [])],+ panes: props.content.panes.map((pane) => ({+ ...pane,+ render: () => (+ <NavigationContext.Provider value={navigation}>+ <NavigationRouteContext.Provider value={route}>+ {pane.render()}+ </NavigationRouteContext.Provider>+ </NavigationContext.Provider>+ ),+ })),+ };const focusedRef = useRef(false);const deactivateRef = useRef<(() => void) | null>(null);@@ -138,7 +146,7 @@ export function Inspector(props: {deactivateRef.current?.();return;}- deactivateRef.current = registerWorkspaceInspector(render, route?.key, props.revealKey);+ deactivateRef.current = registerWorkspaceInspector(content, route?.key, props.revealKey);});// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Navigation focus events own the inspector registration lifetime.@@ -171,7 +179,7 @@ export function Inspector(props: {syncRegistration();}// oxlint-disable-next-line react/exhaustive-effect-dependencies -- Changed column content replaces its existing native workspace registration.- }, [props.children, props.revealKey]);+ }, [props.content, props.revealKey]);return null;}@@ -350,7 +358,7 @@ function AdaptiveWorkspaceLayoutContent(],);const [workspaceInspector, setWorkspaceInspector] = useState<{- readonly render: () => ReactNode;+ readonly content: InspectorContent;readonly active: boolean;readonly routeKey: string | undefined;} | null>(null);@@ -393,13 +401,13 @@ function AdaptiveWorkspaceLayoutContent(const revealedInspectors = useRef<ReadonlyMap<string, string>>(new Map());const workspaceInspectorOwner = useRef<symbol | null>(null);const registerWorkspaceInspector = (- render: () => ReactNode,+ content: InspectorContent,routeKey: string | undefined,revealKey?: string,) => {const owner = Symbol("workspace-inspector");workspaceInspectorOwner.current = owner;- setWorkspaceInspector({ render, active: true, routeKey });+ setWorkspaceInspector({ content, active: true, routeKey });if (routeKey !== undefined &&revealKey !== undefined &&@@ -828,9 +836,11 @@ function AdaptiveWorkspaceLayoutContent(};const inspectorSheet = (- <WorkspaceInspectorSheet open={inspectorSheetOpen} onClose={dismissInspectorSheet}>- {workspaceInspector?.render()}- </WorkspaceInspectorSheet>+ <WorkspaceInspectorSheet+ open={inspectorSheetOpen}+ onClose={dismissInspectorSheet}+ content={workspaceInspector?.content}+ />);if (nativeWorkspace) {return (@@ -842,7 +852,7 @@ function AdaptiveWorkspaceLayoutContent(<NativeWorkspaceInspectorContextvalue={{// Without a column the sheet shows it; the hidden native column must not mount it too.- render: fileInspector.supported ? workspaceInspector?.render : undefined,+ content: fileInspector.supported ? workspaceInspector?.content : undefined,visible: inspectorColumnTargetWidth > 0,}}>@@ -999,12 +1009,12 @@ function AdaptiveWorkspaceLayoutContent() : null}<PaneContext value="inspector"><WorkspaceInspectorPane- pathname={props.pathname}renderedInspectorWidth={renderedInspectorWidth}active={workspaceInspector?.active ?? false}panes={panes}- renderInspector={workspaceInspector?.render}+ content={workspaceInspector?.content}setAuxiliaryPaneWidth={setFileInspectorPreferredWidth}+ onClose={() => setFileInspectorPreferredVisible(false)}onClosed={handleWorkspaceInspectorClosed}/></PaneContext>diff --git a/apps/mobile/src/features/layout/adaptive-workspace-context.ts b/apps/mobile/src/features/layout/adaptive-workspace-context.tsindex 419de9f4cb5..6a950949479 100644--- a/apps/mobile/src/features/layout/adaptive-workspace-context.ts+++ b/apps/mobile/src/features/layout/adaptive-workspace-context.ts@@ -1,5 +1,6 @@import type { WorkspaceTab } from "../workspace/workspace-tabs-state";-import { createContext, use, type ReactNode } from "react";+import { createContext, use } from "react";+import type { InspectorContent } from "./inspector-panes";import type {WorkspaceDetail,WorkspaceDetailSheet,@@ -22,7 +23,7 @@ interface AdaptiveWorkspaceContextValue {/** Use `useSelectWorkspaceDetail`, which also works outside the layout. */readonly selectDetail?: (detail: WorkspaceDetail, sheet?: WorkspaceDetailSheet) => void;readonly registerWorkspaceInspector: (- render: () => ReactNode,+ content: InspectorContent,routeKey: string | undefined,revealKey?: string,) => () => void;diff --git a/apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx b/apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsxindex 2deb592e9ea..6ad05e9f122 100644--- a/apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx+++ b/apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx@@ -48,6 +48,7 @@ import {useNativeWorkspaceColumnsSupported,} from "../../native/NativeWorkspaceColumns";import { V5StackHeader } from "../../native/V5StackHeader.ios";+import { InspectorColumnScreens } from "./inspector-host";import { PaneContext } from "../../components/ui/Pane";import { useWorkspaceSidebarHeaderItem } from "./useWorkspaceSidebarHeaderItem";import type { AppNativeStackNavigationOptions } from "../../native/StackHeader";@@ -248,6 +249,9 @@ function WorkspaceColumns(? openNewTask: undefined;const inspector = use(NativeWorkspaceInspectorContext);+ const hideInspector = () => {+ if (inspector.visible) toggleAuxiliaryPane();+ };const hostRef = useRef<SplitHostCommands>(null);const activeDetailKey = props.detail.at(-1)?.key;const compactColumn = activeDetailKey ? "secondary" : "primary";@@ -369,9 +373,7 @@ function WorkspaceColumns(displayModeButtonVisibility="never"presentsWithGestureshowInspector={inspector.visible}- onInspectorHide={() => {- if (inspector.visible) toggleAuxiliaryPane();- }}+ onInspectorHide={hideInspector}columnMetrics={{minimumPrimaryColumnWidth: 280,maximumPrimaryColumnWidth: Math.max(380, layout.listPaneWidth ?? 0),@@ -434,52 +436,44 @@ function WorkspaceColumns(})}</Split.Stack></Split.Column>- <Split.Inspector>- <Split.HeaderConfig hidden />- {/* Inspector panes host their own native stacks, which UIKit insets for the Duo's- vertical bar wherever they sit, so each pane insets its own content instead. */}- <ColumnContent insetHorizontally={false}>- <View className="flex-1 bg-screen">- <PaneContext value="inspector">{inspector.render?.()}</PaneContext>- {inspector.visible ? (- <GestureHandlerRootView- style={[StyleSheet.absoluteFill, { zIndex: 100 }]}- pointerEvents="box-none"- collapsable={false}- >- <SafeAreaView- style={{ flex: 1 }}- edges={["left", "right"]}- pointerEvents="box-none"- >- <View className="flex-1" pointerEvents="box-none">- <View- className="absolute inset-y-0 left-0 w-[22px] flex-row"- pointerEvents="box-none"- >- <WorkspacePaneDivider- accessibilityLabel="Resize inspector"- currentWidth={inspectorWidth}- resizeDirection={-1}- onResizeStart={() => {- resizeStartWidth.current = inspectorWidth;- }}- onResizeBy={(delta) => {- const width = Math.max(- 260,- Math.min(viewportWidth * 0.6, resizeStartWidth.current + delta),- );- setInspectorWidthFraction(width / viewportWidth);- }}- />- </View>+ <InspectorColumnScreens+ content={inspector.content}+ onClose={hideInspector}+ overlay={+ inspector.visible ? (+ <GestureHandlerRootView+ style={[StyleSheet.absoluteFill, { zIndex: 100 }]}+ pointerEvents="box-none"+ collapsable={false}+ >+ <SafeAreaView style={{ flex: 1 }} edges={["left", "right"]} pointerEvents="box-none">+ <View className="flex-1" pointerEvents="box-none">+ <View+ className="absolute inset-y-0 left-0 w-[22px] flex-row"+ pointerEvents="box-none"+ >+ <WorkspacePaneDivider+ accessibilityLabel="Resize inspector"+ currentWidth={inspectorWidth}+ resizeDirection={-1}+ onResizeStart={() => {+ resizeStartWidth.current = inspectorWidth;+ }}+ onResizeBy={(delta) => {+ const width = Math.max(+ 260,+ Math.min(viewportWidth * 0.6, resizeStartWidth.current + delta),+ );+ setInspectorWidthFraction(width / viewportWidth);+ }}+ /></View>- </SafeAreaView>- </GestureHandlerRootView>- ) : null}- </View>- </ColumnContent>- </Split.Inspector>+ </View>+ </SafeAreaView>+ </GestureHandlerRootView>+ ) : null+ }+ /></Split.Host>);}diff --git a/apps/mobile/src/features/layout/inspector-bar-store.tsx b/apps/mobile/src/features/layout/inspector-bar-store.tsxnew file mode 100644index 00000000000..92a86dc62eb--- /dev/null+++ b/apps/mobile/src/features/layout/inspector-bar-store.tsx@@ -0,0 +1,40 @@+import { createContext, useMemo, useState } from "react";++/** Closes the inspector from its bar: hides the column, or dismisses the sheet. */+export const InspectorCloseContext = createContext<(() => void) | null>(null);++const NO_ROUTES: ReadonlyMap<string, object> = new Map();++/** The options a pane's AppBar sets. External so a write re-renders the bar, not the pane. */+function createInspectorBarStore() {+ let snapshot: object | undefined;+ const listeners = new Set<() => void>();+ return {+ set(options: object) {+ snapshot = { ...snapshot, ...options };+ for (const listener of listeners) listener();+ },+ subscribe(listener: () => void) {+ listeners.add(listener);+ return () => {+ listeners.delete(listener);+ };+ },+ getSnapshot: () => snapshot,+ };+}++export type InspectorBarStore = ReturnType<typeof createInspectorBarStore>;++/** Routes a pane's AppBar options into its own bar instead of the thread route's. */+export function useInspectorBarSlot() {+ const [store] = useState(createInspectorBarStore);+ const slot = useMemo(+ () => ({+ byRoute: NO_ROUTES,+ set: (_routeKey: string, options: object) => store.set(options),+ }),+ [store],+ );+ return { store, slot };+}diff --git a/apps/mobile/src/features/layout/inspector-host.android.tsx b/apps/mobile/src/features/layout/inspector-host.android.tsxnew file mode 100644index 00000000000..9537811916f--- /dev/null+++ b/apps/mobile/src/features/layout/inspector-host.android.tsx@@ -0,0 +1,67 @@+import { View } from "react-native";++import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary";+import { PaneContext } from "../../components/ui/Pane";+import { WorkspaceSlotOptionsContext } from "../../native/v5-workspace-context";+import { InspectorCloseContext, useInspectorBarSlot } from "./inspector-bar-store";+import {+ useMountedInspectorPanes,+ type InspectorContent,+ type InspectorPane,+} from "./inspector-panes";++// AppBar draws the bar inline on Android; the slot keeps a pane's options off the thread's route.+function PaneContent(props: {+ readonly pane: InspectorPane;+ readonly resetKeys: ReadonlyArray<unknown> | undefined;+}) {+ const { slot } = useInspectorBarSlot();+ return (+ <WorkspaceSlotOptionsContext value={slot}>+ <RenderErrorBoundary+ resetKeys={props.resetKeys}+ renderFallback={(fallback) => (+ <RenderFailureView {...fallback} title="The inspector couldn't be displayed" />+ )}+ >+ {props.pane.render()}+ </RenderErrorBoundary>+ </WorkspaceSlotOptionsContext>+ );+}++/** The inspector's panes, stacked in place: Android draws no native chrome a hidden pane could leave. */+export function InspectorPanes(props: {+ readonly content: InspectorContent | undefined;+ readonly onClose: () => void;+}) {+ const panes = useMountedInspectorPanes(props.content);+ return (+ <InspectorCloseContext value={props.onClose}>+ <PaneContext value="inspector">+ <View className="flex-1">+ {panes.map((pane) => {+ const visible = pane.key === props.content?.active;+ return (+ <View+ key={pane.key}+ accessibilityElementsHidden={!visible}+ focusable={visible}+ importantForAccessibility={visible ? "auto" : "no-hide-descendants"}+ pointerEvents={visible ? "auto" : "none"}+ style={{+ position: "absolute",+ inset: 0,+ opacity: visible ? 1 : 0,+ zIndex: visible ? 1 : 0,+ }}+ >+ <PaneContent pane={pane} resetKeys={props.content?.resetKeys} />+ </View>+ );+ })}+ </View>+ </PaneContext>+ </InspectorCloseContext>+ );+}diff --git a/apps/mobile/src/features/layout/inspector-host.tsx b/apps/mobile/src/features/layout/inspector-host.tsxnew file mode 100644index 00000000000..bec36d336bd--- /dev/null+++ b/apps/mobile/src/features/layout/inspector-host.tsx@@ -0,0 +1,117 @@+import { useSyncExternalStore, type ReactNode } from "react";+import { Split, Stack } from "react-native-screens";++import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary";+import { PaneContext } from "../../components/ui/Pane";+import { GLASS_HEADER_OPTIONS } from "../../native/glass-header-options";+import { NativeColumnContent } from "../../native/NativeColumnContent.ios";+import { V5StackHeader } from "../../native/V5StackHeader.ios";+import { WorkspaceSlotOptionsContext } from "../../native/v5-workspace-context";+import {+ InspectorCloseContext,+ useInspectorBarSlot,+ type InspectorBarStore,+} from "./inspector-bar-store";+import {+ useMountedInspectorPanes,+ type InspectorContent,+ type InspectorPane,+} from "./inspector-panes";++// A pane without an AppBar has no bar; one with it gets the glass the workspace's screens get.+const PANE_HEADER_OPTIONS = { ...GLASS_HEADER_OPTIONS, headerShown: false };++function PaneHeader(props: { readonly store: InspectorBarStore }) {+ const options = useSyncExternalStore(props.store.subscribe, props.store.getSnapshot);+ return <V5StackHeader options={{ ...PANE_HEADER_OPTIONS, ...options }} canGoBack={false} />;+}++function PaneScreenContent(props: {+ readonly pane: InspectorPane;+ readonly resetKeys: ReadonlyArray<unknown> | undefined;+ readonly onClose: () => void;+}) {+ const { store, slot } = useInspectorBarSlot();+ const content = (+ <WorkspaceSlotOptionsContext value={slot}>+ <RenderErrorBoundary+ resetKeys={props.resetKeys}+ renderFallback={(fallback) => (+ <RenderFailureView {...fallback} title="The inspector couldn't be displayed" />+ )}+ >+ {props.pane.render()}+ </RenderErrorBoundary>+ </WorkspaceSlotOptionsContext>+ );+ return (+ <InspectorCloseContext value={props.onClose}>+ <PaneContext value="inspector">+ {props.pane.nativeStack ? (+ content+ ) : (+ <>+ <PaneHeader store={store} />+ <NativeColumnContent>{content}</NativeColumnContent>+ </>+ )}+ </PaneContext>+ </InspectorCloseContext>+ );+}++/**+ * The inspector column's panes, each a screen of the column like the detail column's routes.+ * Only the active one is attached, so UIKit sees one bar, one toolbar and one scroll view.+ */+export function InspectorColumnScreens(props: {+ readonly content: InspectorContent | undefined;+ readonly onClose: () => void;+ /** Drawn over the active pane. */+ readonly overlay?: ReactNode;+}) {+ const panes = useMountedInspectorPanes(props.content);+ return panes.map((pane) => {+ const active = pane.key === props.content?.active;+ return (+ <Split.Inspector+ key={pane.key}+ screenKey={`inspector:${pane.key}`}+ activityMode={active ? "attached" : "detached"}+ >+ <PaneScreenContent+ pane={pane}+ resetKeys={props.content?.resetKeys}+ onClose={props.onClose}+ />+ {active ? props.overlay : null}+ </Split.Inspector>+ );+ });+}++/** The inspector's panes where it has no column: a native stack with the active one attached. */+export function InspectorPanes(props: {+ readonly content: InspectorContent | undefined;+ readonly onClose: () => void;+}) {+ const panes = useMountedInspectorPanes(props.content);+ if (panes.length === 0) return null;+ return (+ <Stack.Host>+ {panes.map((pane) => (+ <Stack.Screen+ key={pane.key}+ screenKey={`inspector:${pane.key}`}+ activityMode={pane.key === props.content?.active ? "attached" : "detached"}+ >+ <PaneScreenContent+ pane={pane}+ resetKeys={props.content?.resetKeys}+ onClose={props.onClose}+ />+ </Stack.Screen>+ ))}+ </Stack.Host>+ );+}diff --git a/apps/mobile/src/features/layout/inspector-panes.ts b/apps/mobile/src/features/layout/inspector-panes.tsnew file mode 100644index 00000000000..ab0366341c0--- /dev/null+++ b/apps/mobile/src/features/layout/inspector-panes.ts@@ -0,0 +1,51 @@+import { useEffect, useState, type ReactNode } from "react";++export interface InspectorPane {+ readonly key: string;+ readonly render: () => ReactNode;+ /** Opening one of these panes soon mounts the others too, so switching between them is instant. */+ readonly prewarm?: boolean;+ /** The pane is a native stack of its own, which draws its bar and insets its content itself. */+ readonly nativeStack?: boolean;+}++/** What a route shows in the workspace's inspector: its panes and the one on screen. */+export interface InspectorContent {+ readonly panes: ReadonlyArray<InspectorPane>;+ readonly active: string;+ /** A failed pane renders again when one of these changes. */+ readonly resetKeys?: ReadonlyArray<unknown>;+}++const PREWARM_DELAY_MS = 350;++/**+ * The panes to keep mounted: every pane opened since the inspector appeared, plus prewarmed ones.+ * A mounted pane keeps its state and scroll position while another is on screen.+ */+export function useMountedInspectorPanes(content: InspectorContent | undefined) {+ const [opened, setOpened] = useState<ReadonlySet<string>>(() => new Set());+ const active = content?.active;+ const prewarms = content?.panes.filter((pane) => pane.prewarm) ?? [];+ const prewarmSignature = prewarms.some((pane) => pane.key === active)+ ? prewarms.map((pane) => pane.key).join("\n")+ : "";++ if (active !== undefined && !opened.has(active)) {+ setOpened(new Set([...opened, active]));+ }++ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- prewarms the other panes on a timer after one opens+ useEffect(() => {+ if (prewarmSignature === "") return;+ const timeout = setTimeout(() => {+ setOpened((current) => {+ const keys = prewarmSignature.split("\n");+ return keys.every((key) => current.has(key)) ? current : new Set([...current, ...keys]);+ });+ }, PREWARM_DELAY_MS);+ return () => clearTimeout(timeout);+ }, [prewarmSignature]);++ return content?.panes.filter((pane) => opened.has(pane.key)) ?? [];+}diff --git a/apps/mobile/src/features/layout/workspace-inspector-pane.tsx b/apps/mobile/src/features/layout/workspace-inspector-pane.tsxindex 4c003008d1d..c7a0e4cea17 100644--- a/apps/mobile/src/features/layout/workspace-inspector-pane.tsx+++ b/apps/mobile/src/features/layout/workspace-inspector-pane.tsx@@ -1,4 +1,4 @@-import { useEffect, useRef, useState, type ReactNode } from "react";+import { useEffect, useRef, useState } from "react";import Animated, {cubicBezier,runOnJS,@@ -10,26 +10,27 @@ import Animated, {} from "react-native-reanimated";import { constrainAuxiliaryPaneWidth, type WorkspacePaneLayout } from "../../lib/layout";-import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary";import { WORKSPACE_PANE_TIMING } from "./workspace-pane-animation";import { WorkspacePaneDivider } from "./workspace-pane-divider";+import { InspectorPanes } from "./inspector-host";+import type { InspectorContent } from "./inspector-panes";// CSS form of WORKSPACE_PANE_TIMING's Easing.inOut(Easing.cubic).const PANE_EASING = cubicBezier(0.65, 0, 0.35, 1);/** Pass layout props to avoid an import cycle with AdaptiveWorkspaceLayout. */export function WorkspaceInspectorPane(props: {- readonly pathname: string;readonly renderedInspectorWidth: SharedValue<number>;readonly active?: boolean;+ readonly onClose: () => void;readonly onClosed?: () => void;readonly panes: WorkspacePaneLayout;- readonly renderInspector?: () => ReactNode;+ readonly content: InspectorContent | undefined;readonly setAuxiliaryPaneWidth: (width: number) => void;}) {const { panes, setAuxiliaryPaneWidth } = props;const inspectorWidth = panes.auxiliaryPaneWidth;- const inspectorSupported = props.renderInspector !== undefined && inspectorWidth !== null;+ const inspectorSupported = props.content !== undefined && inspectorWidth !== null;const inspectorVisible =inspectorSupported && panes.auxiliaryPaneVisible && (props.active ?? true);const resizeStartWidth = useRef(0);@@ -116,21 +117,10 @@ export function WorkspaceInspectorPane(props: {style={inspectorStyle}><Animated.View className="flex-1" style={inspectorContentStyle}>- <RenderErrorBoundary- resetKeys={[props.pathname]}- renderFallback={(fallback) => (- <RenderFailureView {...fallback} title="The inspector couldn't be displayed" />- )}- >- <InspectorRenderer render={props.renderInspector} />- </RenderErrorBoundary>+ <InspectorPanes content={props.content} onClose={props.onClose} /></Animated.View></Animated.View>) : null}</>);}--function InspectorRenderer(props: { readonly render?: () => ReactNode }) {- return <>{props.render?.()}</>;-}diff --git a/apps/mobile/src/features/layout/workspace-inspector-sheet.tsx b/apps/mobile/src/features/layout/workspace-inspector-sheet.tsxindex 14f21fb7153..9fec5e64df6 100644--- a/apps/mobile/src/features/layout/workspace-inspector-sheet.tsx+++ b/apps/mobile/src/features/layout/workspace-inspector-sheet.tsx@@ -1,13 +1,14 @@-import { createContext, useRef, useState, type ReactNode } from "react";+import { createContext, useRef, useState } from "react";import { Platform, View } from "react-native";import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";import { FormSheet } from "react-native-screens";import { useResolveClassNames } from "uniwind";-import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary";import { PaneContext } from "../../components/ui/Pane";import { RoutedFormSheetContext } from "../../components/ui/RoutedFormSheetContext";import { formSheetDetents } from "../../native/sheet-surface";+import { InspectorPanes } from "./inspector-host";+import type { InspectorContent } from "./inspector-panes";/*** Closes the inspector sheet around the inspector, then runs `then` once it is gone: a route@@ -15,11 +16,11 @@ import { formSheetDetents } from "../../native/sheet-surface";*/export const InspectorSheetContext = createContext<((then?: () => void) => void) | null>(null);-/** The inspector where the window has no column for it. Its content draws its own bar. */+/** The inspector where the window has no column for it. Its panes draw their own bars. */export function WorkspaceInspectorSheet(props: {readonly open: boolean;readonly onClose: () => void;- readonly children: ReactNode;+ readonly content: InspectorContent | undefined;}) {const containerStyle = useResolveClassNames(Platform.OS === "android" ? "bg-header" : "bg-sheet");const insets = useSafeAreaInsets();@@ -77,13 +78,7 @@ export function WorkspaceInspectorSheet(props: {Platform.OS === "android" ? "absolute inset-0 bg-header pt-3" : "flex-1 bg-sheet"}>- <RenderErrorBoundary- renderFallback={(fallback) => (- <RenderFailureView {...fallback} title="The inspector couldn't be displayed" />- )}- >- {props.children}- </RenderErrorBoundary>+ <InspectorPanes content={props.content} onClose={() => close()} />{Platform.OS === "android" ? (<ViewpointerEvents="none"diff --git a/apps/mobile/src/features/review/ReviewSheet.tsx b/apps/mobile/src/features/review/ReviewSheet.tsxindex c75725389ad..b53d6129480 100644--- a/apps/mobile/src/features/review/ReviewSheet.tsx+++ b/apps/mobile/src/features/review/ReviewSheet.tsx@@ -4,12 +4,10 @@ import type { EnvironmentId, ThreadId } from "@t3tools/contracts";import { formatDiffCount } from "@t3tools/client-runtime/diff-count";import { useNavigation, type StaticScreenProps } from "@react-navigation/native";import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";-import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";import { AppBar } from "../../components/ui/AppBar";import type { AppBarMenuItem } from "../../components/ui/AppBar.types";import type { ReviewSectionItem } from "./reviewModel";import { useReviewHeaderPresentation } from "./useReviewHeaderPresentation";-import { Screen, ScreenStack, ScreenStackHeaderConfig } from "react-native-screens";import { type Ref, type ReactElement, useImperativeHandle, useRef, useState } from "react";import {FlatList,@@ -24,7 +22,7 @@ import {import { useSafeAreaInsets } from "react-native-safe-area-context";import { useReduceMotionEnabled } from "../../lib/appState";import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";-import { NativeInspectorContent } from "../../native/NativeInspectorContent";+import { NativeScrollView } from "../../native/NativeScrollViewMarker";import { AppText as Text } from "../../components/ui/AppText";import { SymbolView } from "../../components/ui/AppSymbol";@@ -284,23 +282,12 @@ interface ReviewFileNavigatorHandle {interface ReviewFileNavigatorProps {readonly files: ReadonlyArray<ReviewNavigatorFile>;- readonly headerInset: number;readonly sectionId: string | null;readonly onSelectFile: (fileId: string | null) => void;readonly ref?: Ref<ReviewFileNavigatorHandle>;}-function ReviewFileNavigator({- files,- headerInset,- sectionId,- onSelectFile,- ref,-}: ReviewFileNavigatorProps) {- const theme = useUniwindTheme();- const sheetColor = theme["--color-sheet"];- const foregroundColor = theme["--color-foreground"];- const headerScrollEdgeEffects = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);+function ReviewFileNavigator({ files, sectionId, onSelectFile, ref }: ReviewFileNavigatorProps) {const [fileSelection, setFileSelection] = useState<{readonly sectionId: string | null;readonly fileId: string | null;@@ -343,73 +330,24 @@ function ReviewFileNavigator({/>);- const fileList = (- <FlatList- data={files}- extraData={selectedFileId}- keyExtractor={(file) => file.id}- contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}- contentContainerStyle={{ paddingHorizontal: 8, paddingVertical: 8 }}- renderItem={renderFile}- />- );-- if (Platform.OS === "ios") {- return (- <View className="flex-1 border-l border-border bg-sheet">- <ScreenStack style={{ flex: 1 }}>- <Screen- activityState={2}- enabled- isNativeStack- screenId="review-file-navigator-native"- scrollEdgeEffects={headerScrollEdgeEffects}- style={{ backgroundColor: sheetColor, flex: 1 }}- >- <NativeInspectorContent>{fileList}</NativeInspectorContent>- <ScreenStackHeaderConfig- backgroundColor="rgba(0,0,0,0)"- color={foregroundColor}- hideBackButton- hideShadow={false}- navigationItemStyle="editor"- subtitle={`${files.length} ${files.length === 1 ? "file" : "files"}`}- title="Changed files"- titleColor={foregroundColor}- titleFontSize={17}- titleFontWeight="700"- translucent- />- </Screen>- </ScreenStack>- </View>- );- }-return (- <View- className={- Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 border-l border-border bg-sheet"- }- >- {Platform.OS === "android" ? (- <AppBar- embedded- title="Changed files"- subtitle={`${files.length} ${files.length === 1 ? "file" : "files"}`}- hideBottomBorder+ <View className="flex-1 ios:bg-sheet android:bg-header">+ <AppBar+ title="Changed files"+ subtitle={`${files.length} ${files.length === 1 ? "file" : "files"}`}+ hideBottomBorder={Platform.OS === "android"}+ />+ <ScreenContent insetHorizontal>+ <FlatList+ renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}+ data={files}+ extraData={selectedFileId}+ keyExtractor={(file) => file.id}+ contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}+ contentContainerStyle={{ paddingHorizontal: 8, paddingVertical: 8 }}+ renderItem={renderFile}/>- ) : (- <View className="border-b border-border" style={{ paddingTop: headerInset }}>- <View className="px-4 py-3">- <Text className="text-sm font-t3-bold text-foreground">Changed files</Text>- <Text className="text-xs text-foreground-muted">- {files.length} {files.length === 1 ? "file" : "files"}- </Text>- </View>- </View>- )}- <ScreenContent insetHorizontal>{fileList}</ScreenContent>+ </ScreenContent></View>);}@@ -568,7 +506,6 @@ export function ReviewSheet(props: ReviewSheetProps) {<ReviewFileNavigatorref={reviewFileNavigatorRef}files={nativeReviewDiffData.files}- headerInset={insets.top}sectionId={selectedSection?.id ?? null}onSelectFile={(fileId) => void handleSelectFile(fileId)}/>@@ -672,7 +609,10 @@ export function ReviewSheet(props: ReviewSheetProps) {return (<>{showChangedFilesPane ? (- <Inspector revealKey={`${environmentId}:${threadId}`}>{renderInspector()}</Inspector>+ <Inspector+ revealKey={`${environmentId}:${threadId}`}+ content={{ active: "changes", panes: [{ key: "changes", render: renderInspector }] }}+ />) : null}<ReviewHeaderenvironmentId={environmentId}diff --git a/apps/mobile/src/features/threads/ThreadHeader.tsx b/apps/mobile/src/features/threads/ThreadHeader.tsxindex 400c7a13bf3..065e643a4bf 100644--- a/apps/mobile/src/features/threads/ThreadHeader.tsx+++ b/apps/mobile/src/features/threads/ThreadHeader.tsx@@ -3,7 +3,7 @@ import { AppBar } from "../../components/ui/AppBar";import { ScreenHeaderButton } from "../../components/ui/ScreenHeaderButton";import type { AppBarAction } from "../../components/ui/AppBar.types";import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";-import type { ThreadInspectorMode } from "./thread-inspector-content-stack";+import type { ThreadInspectorMode } from "./thread-inspector-navigation";import { useThreadHeaderOptions } from "./useThreadHeaderOptions";import { useWorkspaceBackNavigation } from "../workspace/useAndroidWorkspaceNavigation";import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";diff --git a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx b/apps/mobile/src/features/threads/ThreadRouteScreen.tsxindex 35679ee1667..94ddab608bd 100644--- a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx+++ b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx@@ -32,7 +32,6 @@ import {} from "@t3tools/shared/projectScripts";import { Platform } from "react-native";import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";-import { useSafeAreaInsets } from "react-native-safe-area-context";import { useConnectionsReady } from "../../state/workspace";import { useEnvironmentShellReadiness } from "../../state/shell";import { restoredNewTaskDraftKey } from "../../state/new-task-draft-key";@@ -93,10 +92,7 @@ import { useAppearancePreferences } from "../settings/appearance/AppearancePrefeimport { Inspector, useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";import { ThreadFileNavigatorPane } from "../files/thread-file-navigator-pane";import { InspectorSheetContext } from "../layout/workspace-inspector-sheet";-import {- ThreadInspectorContentStack,- type ThreadInspectorMode,-} from "./thread-inspector-content-stack";+import type { InspectorContent } from "../layout/inspector-panes";import {threadDetailErrorIsCurrent,threadRouteIsHydrating,@@ -115,7 +111,7 @@ import {ThreadInspectorPreview,type ThreadInspectorPresentation,} from "./thread-inspector-preview";-import type { ThreadInspectorTarget } from "./thread-inspector-navigation";+import type { ThreadInspectorMode, ThreadInspectorTarget } from "./thread-inspector-navigation";import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";function firstRouteParam(value: string | string[] | undefined): string | null {@@ -166,7 +162,7 @@ type ThreadRouteScreenRouteProps = StaticScreenProps<{interface ThreadRouteScreenProps extends ThreadRouteScreenRouteProps {readonly inspectorPresentation?: ThreadInspectorPresentation;readonly onReturnToThread?: () => void;- readonly renderInspector?: (headerInset: number) => ReactNode;+ readonly renderInspector?: () => ReactNode;}function ThreadUnavailableScreen(props: {@@ -579,42 +575,28 @@ function ThreadRouteContent(navigation.navigate("ThreadFile", params);};const renderGitInspector = () => (- <InspectorHeaderInset>- {(headerInset) => (- <GitOverviewSheet- headerInset={headerInset}- presentation="inspector"- route={{ params: { environmentId: environmentId!, threadId: threadId! } }}- />- )}- </InspectorHeaderInset>+ <GitOverviewSheet+ presentation="inspector"+ route={{ params: { environmentId: environmentId!, threadId: threadId! } }}+ />);const renderFilesInspector = () =>selectedThread !== null && selectedThreadCwd !== null ? (- <InspectorHeaderInset>- {(headerInset) => (- <InspectorSheetContext.Consumer>- {(closeInspectorSheet) => (- <ThreadFileNavigatorPane- cwd={selectedThreadCwd}- environmentId={selectedThread.environmentId}- headerInset={headerInset}- projectName={selectedThreadProject?.title ?? "Files"}- selectedPath={null}- onSelectFile={(path) =>- closeInspectorSheet- ? closeInspectorSheet(() => handleSelectInspectorFile(path))- : handleSelectInspectorFile(path)- }- />- )}- </InspectorSheetContext.Consumer>+ <InspectorSheetContext.Consumer>+ {(closeInspectorSheet) => (+ <ThreadFileNavigatorPane+ cwd={selectedThreadCwd}+ environmentId={selectedThread.environmentId}+ projectName={selectedThreadProject?.title ?? "Files"}+ selectedPath={null}+ onSelectFile={(path) =>+ closeInspectorSheet+ ? closeInspectorSheet(() => handleSelectInspectorFile(path))+ : handleSelectInspectorFile(path)+ }+ />)}- </InspectorHeaderInset>- ) : null;- const renderRouteInspector = () =>- props.renderInspector ? (- <InspectorHeaderInset>{props.renderInspector}</InspectorHeaderInset>+ </InspectorSheetContext.Consumer>) : null;const renderPreviewInspector = () =>previewTarget && panes.auxiliaryPaneVisible ? (@@ -635,18 +617,28 @@ function ThreadRouteContent(}}/>) : null;- const renderInspectorStack = () =>- inspectorMode === null ? null : (- <ThreadInspectorContentStack- renderPreview={renderPreviewInspector}- renderFiles={renderFilesInspector}- renderGit={renderGitInspector}- mode={inspectorMode}- resetKeys={[routeThreadIdentity, selectedThreadCwd]}- renderRoute={props.renderInspector ? renderRouteInspector : undefined}- />- );- const showsInspector = !props.inspectorPresentation && inspectorMode !== null;+ const inspectorContent: InspectorContent | null =+ inspectorMode === null+ ? null+ : {+ active: inspectorMode,+ resetKeys: [routeThreadIdentity, selectedThreadCwd],+ panes: [+ ...(inspectorMode === "preview"+ ? [+ {+ key: "preview",+ render: renderPreviewInspector,+ // A thread preview runs its own navigator, whose screens draw its bar.+ nativeStack: previewTarget?.type === "thread",+ },+ ]+ : []),+ { key: "files", render: renderFilesInspector, prewarm: true },+ { key: "git", render: renderGitInspector, prewarm: true },+ ...(props.renderInspector ? [{ key: "route", render: props.renderInspector }] : []),+ ],+ };const handleOpenConnectionEditor = () => {void navigation.navigate("Connections");@@ -1093,7 +1085,7 @@ function ThreadRouteContent(return (<>- {showsInspector ? (+ {!props.inspectorPresentation && inspectorContent ? (<Inspector// A route's own inspector (files) opens once per thread; going back keeps the user's choice.revealKey={@@ -1101,9 +1093,8 @@ function ThreadRouteContent(? (routeThreadIdentity ?? undefined): undefined}- >- {renderInspectorStack()}- </Inspector>+ content={inspectorContent}+ />) : null}{renderThreadRouteBody()}@@ -1111,12 +1102,6 @@ function ThreadRouteContent();}-/** The inspector's top inset where it renders: under an Android column's status bar, not a sheet's. */-function InspectorHeaderInset(props: { readonly children: (headerInset: number) => ReactNode }) {- const insets = useSafeAreaInsets();- return props.children(Platform.OS === "ios" ? 0 : insets.top);-}-export function FullscreenThreadRouteScreen(props: StaticScreenProps<{readonly environmentId: string;diff --git a/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx b/apps/mobile/src/features/threads/git/GitOverviewSheet.tsxindex 96b3d98f0c6..1c246e694ec 100644--- a/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx+++ b/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx@@ -15,27 +15,19 @@ import {useNavigation,type StaticScreenProps,} from "@react-navigation/native";-import { SymbolView } from "../../../components/ui/AppSymbol";import { use, useEffect, useState } from "react";-import { Platform, Pressable, RefreshControl, ScrollView, View } from "react-native";+import { Platform, RefreshControl, View } from "react-native";+import { NativeScrollView } from "../../../native/NativeScrollViewMarker";-import { ScreenStack } from "react-native-screens";import { useSafeAreaInsets } from "react-native-safe-area-context";-import { NativeInspectorContent } from "../../../native/NativeInspectorContent";-import { NativeHeader, NativeScreen } from "../../../native/ThemedScreenStack";-import { AndroidHeaderIconButton } from "../../../components/ui/AndroidScreenHeader";import { AppBar } from "../../../components/ui/AppBar";-import { AndroidAnchoredMenu } from "../../../components/ui/AndroidAnchoredMenu";import { ListRow } from "../../../components/ui/ListRow";import { ListSection } from "../../../components/ui/ListSection";import { ScreenContent } from "../../../components/ui/ScreenContent";import { useAdaptiveWorkspaceLayout } from "../../layout/AdaptiveWorkspaceLayout";import { InspectorSheetContext } from "../../layout/workspace-inspector-sheet";import { AppText as Text } from "../../../components/ui/AppText";-import {- NativeStackScreenOptions,- nativeHeaderScrollEdgeEffects,-} from "../../../native/StackHeader";+import { NativeStackScreenOptions } from "../../../native/StackHeader";import { useEnvironmentQuery } from "../../../state/query";import { useThreadSelection } from "../../../state/use-thread-selection";import { useSelectedThreadGitActions } from "../../../state/use-selected-thread-git-actions";@@ -50,13 +42,10 @@ import {} from "../LinkedPullRequestList";import { useLinkedPullRequestActions } from "../useLinkedPullRequestActions";-const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);-type GitOverviewSheetProps = StaticScreenProps<{readonly environmentId: string;readonly threadId: string;}> & {- readonly headerInset?: number;readonly presentation?: "sheet" | "inspector";};@@ -242,7 +231,7 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {};const content = (- <ScrollView+ <NativeScrollViewnestedScrollEnabledalwaysBounceVerticalclassName="flex-1 android:bg-sheet-solid ios:bg-screen"@@ -350,36 +339,20 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {</Text></ListSection>) : null}- </ScrollView>+ </NativeScrollView>);- if (isInspector && Platform.OS === "ios") {+ const refresh = {+ accessibilityLabel: "Refresh repository status",+ disabled: busy || isRefreshing,+ onPress: () => void handleRefresh(),+ };++ if (isInspector) {return (- <View collapsable={false} className="flex-1 border-l border-border bg-sheet">- <ScreenStack style={{ flex: 1 }}>- <NativeScreen- activityState={2}- enabled- isNativeStack- screenId="thread-git-inspector-native"- scrollEdgeEffects={HEADER_SCROLL_EDGE_EFFECTS}- className="flex-1 bg-sheet"- >- <NativeInspectorContent>{content}</NativeInspectorContent>- <NativeHeader- backgroundColor="rgba(0,0,0,0)"- tintColorClassName="accent-foreground"- hideBackButton- hideShadow={false}- navigationItemStyle="editor"- title={currentBranchLabel}- titleColorClassName="accent-foreground"- titleFontSize={17}- titleFontWeight="700"- translucent- />- </NativeScreen>- </ScreenStack>+ <View collapsable={false} className="flex-1 ios:bg-screen android:bg-header">+ <AppBar title={currentBranchLabel} subtitle={currentStatusSummary} refresh={refresh} />+ <ScreenContent insetHorizontal>{content}</ScreenContent></View>);}@@ -398,108 +371,22 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {);}- const refreshMenu = (- <AndroidAnchoredMenu- title="Repository options"- actions={[- {- id: "refresh",- title: "Refresh repository status",- attributes: { disabled: busy || isRefreshing },- },- ]}- onPressAction={({ nativeEvent }) => {- if (nativeEvent.event === "refresh") void handleRefresh();- }}- >- {(open) => (- <AndroidHeaderIconButton- accessibilityLabel="Repository options"- icon="ellipsis"- onPress={open}- />- )}- </AndroidAnchoredMenu>- );-return (<Viewcollapsable={false}- className={- Platform.OS === "android"- ? "flex-1 bg-header"- : isInspector- ? "flex-1 border-l border-border bg-sheet"- : "flex-1 bg-sheet"- }+ className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-sheet"}>- {!isInspector ? (- <NativeStackScreenOptions- options={{ sheetCornerRadius: Platform.OS === "android" ? 28 : undefined }}- />- ) : null}- {isInspector ? (- <View- style={{- minHeight: props.headerInset ?? 0,- paddingTop: props.headerInset ?? 0,- }}- />- ) : null}-- {isInspector ? (- <View className="gap-1 px-4 pb-4 pt-3 android:bg-header ios:border-b ios:border-border">- {Platform.OS === "android" ? (- <View className="absolute right-3 top-4 z-[1]">{refreshMenu}</View>- ) : (- <Pressable- className={- busy- ? "absolute right-3 top-4 z-[1] h-9 w-9 items-center justify-center rounded-full bg-subtle opacity-[0.45]"- : "absolute right-3 top-4 z-[1] h-9 w-9 items-center justify-center rounded-full bg-subtle"- }- disabled={busy}- onPress={() => void gitActions.refreshSelectedThreadGitStatus()}- >- <SymbolView- name="arrow.clockwise"- size={16}- tintColorClassName="accent-icon"- type="monochrome"- weight="medium"- />- </Pressable>- )}- <Text className="text-xs font-t3-bold tracking-[1px] uppercase text-foreground-muted">- Repository- </Text>- <Text className="pr-10 text-xl font-t3-bold">{currentBranchLabel}</Text>- <Text className="text-foreground-secondary text-sm font-medium leading-normal">- {currentStatusSummary}- </Text>- </View>- ) : (- <AppBar- sheet- title={currentBranchLabel}- hideBottomBorder={Platform.OS === "android"}- subtitle={currentStatusSummary}- onBack={() => navigation.goBack()}- trailing={Platform.OS === "android" ? refreshMenu : undefined}- actions={- Platform.OS === "android"- ? undefined- : [- {- accessibilityLabel: "Refresh repository status",- disabled: busy,- icon: "arrow.clockwise",- onPress: () => void gitActions.refreshSelectedThreadGitStatus(),- },- ]- }- />- )}+ <NativeStackScreenOptions+ options={{ sheetCornerRadius: Platform.OS === "android" ? 28 : undefined }}+ />+ <AppBar+ sheet+ title={currentBranchLabel}+ hideBottomBorder={Platform.OS === "android"}+ subtitle={currentStatusSummary}+ onBack={() => navigation.goBack()}+ refresh={refresh}+ /><ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent></View>diff --git a/apps/mobile/src/features/threads/thread-inspector-content-stack.tsx b/apps/mobile/src/features/threads/thread-inspector-content-stack.tsxdeleted file mode 100644index ef4efad1926..00000000000--- a/apps/mobile/src/features/threads/thread-inspector-content-stack.tsx+++ /dev/null@@ -1,127 +0,0 @@-import { useEffect, useState, type ReactNode } from "react";-import { View } from "react-native";--import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary";-import { NativeInspectorContent } from "../../native/NativeInspectorContent";--export type ThreadInspectorMode = "route" | "git" | "files" | "preview";--const INSPECTOR_PREWARM_DELAY_MS = 350;--function InspectorContentPane(props: {- readonly children: ReactNode;- readonly mounted: boolean;- readonly resetKeys: readonly [string | null, string | null];- readonly visible: boolean;-}) {- if (!props.mounted) {- return null;- }-- return (- <View- accessibilityElementsHidden={!props.visible}- focusable={props.visible}- importantForAccessibility={props.visible ? "auto" : "no-hide-descendants"}- pointerEvents={props.visible ? "auto" : "none"}- style={{- position: "absolute",- inset: 0,- opacity: props.visible ? 1 : 0,- zIndex: props.visible ? 1 : 0,- }}- >- <RenderErrorBoundary- resetKeys={props.resetKeys}- renderFallback={(fallback) => (- <NativeInspectorContent>- <RenderFailureView {...fallback} title="The inspector couldn't be displayed" />- </NativeInspectorContent>- )}- >- {props.children}- </RenderErrorBoundary>- </View>- );-}--export function ThreadInspectorContentStack(props: {- readonly renderPreview?: () => ReactNode;- readonly renderFiles: () => ReactNode;- readonly renderGit?: () => ReactNode;- readonly mode: ThreadInspectorMode;- readonly resetKeys: readonly [string | null, string | null];- readonly renderRoute?: () => ReactNode;-}) {- const [mountedModes, setMountedModes] = useState<ReadonlySet<ThreadInspectorMode>>(- () => new Set([props.mode]),- );-- // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- keeps opened UIKit inspector views mounted and prewarms the alternate inspector after a timer- useEffect(() => {- // oxlint-disable-next-line react/set-state-in-effect -- Keeps opened inspector views mounted so UIKit keeps their focus and scroll.- setMountedModes((current) => {- if (current.has(props.mode)) {- return current;- }- return new Set([...current, props.mode]);- });-- if (props.mode === "route" || props.mode === "preview") {- return;- }-- // Keep both inspectors alive after opening; detaching the file tree makes UIKit rebuild its expensive focus graph.- const alternateMode = props.mode === "files" ? "git" : "files";- const timeout = setTimeout(() => {- setMountedModes((current) => {- if (current.has(alternateMode)) {- return current;- }- return new Set([...current, alternateMode]);- });- }, INSPECTOR_PREWARM_DELAY_MS);-- return () => clearTimeout(timeout);- }, [props.mode]);-- return (- <View className="flex-1">- {props.mode === "preview" && props.renderPreview ? (- <InspectorContentPane mounted resetKeys={props.resetKeys} visible>- <InspectorRenderer render={props.renderPreview} />- </InspectorContentPane>- ) : null}- <InspectorContentPane- mounted={mountedModes.has("files") || props.mode === "files"}- resetKeys={props.resetKeys}- visible={props.mode === "files"}- >- <InspectorRenderer render={props.renderFiles} />- </InspectorContentPane>- {props.renderGit ? (- <InspectorContentPane- mounted={mountedModes.has("git") || props.mode === "git"}- resetKeys={props.resetKeys}- visible={props.mode === "git"}- >- <InspectorRenderer render={props.renderGit} />- </InspectorContentPane>- ) : null}- {props.renderRoute ? (- <InspectorContentPane- mounted={mountedModes.has("route") || props.mode === "route"}- resetKeys={props.resetKeys}- visible={props.mode === "route"}- >- <InspectorRenderer render={props.renderRoute} />- </InspectorContentPane>- ) : null}- </View>- );-}--// Render callbacks carry changing route data; they are not component types.-function InspectorRenderer(props: { readonly render: () => ReactNode }) {- return <>{props.render()}</>;-}diff --git a/apps/mobile/src/features/threads/thread-inspector-navigation.test.tsx b/apps/mobile/src/features/threads/thread-inspector-navigation.test.tsxindex 0f7e45ca4ca..a2a764a6ec3 100644--- a/apps/mobile/src/features/threads/thread-inspector-navigation.test.tsx+++ b/apps/mobile/src/features/threads/thread-inspector-navigation.test.tsx@@ -179,10 +179,12 @@ it("keeps a focused inspector registered across renders and updates its content"const deactivate = vi.fn(() => {activeRender = undefined;});- const registerWorkspaceInspector = vi.fn((render: () => React.ReactNode) => {- activeRender = render;- return deactivate;- });+ const registerWorkspaceInspector = vi.fn(+ (content: { readonly panes: ReadonlyArray<{ readonly render: () => React.ReactNode }> }) => {+ activeRender = content.panes[0]?.render;+ return deactivate;+ },+ );const navigation = {isFocused: () => focused,addListener(event: "focus" | "blur", listener: () => void) {@@ -221,7 +223,12 @@ it("keeps a focused inspector registered across renders and updates its content"},);const exports: {- Inspector?: (props: { readonly children: React.ReactNode }) => null;+ Inspector?: (props: {+ readonly content: {+ readonly active: string;+ readonly panes: ReadonlyArray<{ readonly key: string; readonly render: () => string }>;+ };+ }) => null;} = {};const load = (name: string) => {if (name === "react" || name.startsWith("react/")) return requireMobile(name);@@ -238,8 +245,15 @@ it("keeps a focused inspector registered across renders and updates its content"};new Function("require", "exports", compiled.code)(load, exports);const Inspector = exports.Inspector!;+ const contents = new Map<string, Parameters<typeof Inspector>[0]["content"]>();function Screen({ content }: { content: string | undefined }) {- return content === undefined ? null : <Inspector>{content}</Inspector>;+ if (content === undefined) return null;+ let panes = contents.get(content);+ if (!panes) {+ panes = { active: "main", panes: [{ key: "main", render: () => content }] };+ contents.set(content, panes);+ }+ return <Inspector content={panes} />;}const root = createRoot(document.createElement("div"));using _root = { [Symbol.dispose]: () => act(() => root.unmount()) };diff --git a/apps/mobile/src/features/threads/thread-inspector-navigation.ts b/apps/mobile/src/features/threads/thread-inspector-navigation.tsindex 3acd7e61397..a671350c764 100644--- a/apps/mobile/src/features/threads/thread-inspector-navigation.ts+++ b/apps/mobile/src/features/threads/thread-inspector-navigation.ts@@ -4,6 +4,8 @@ import { Platform } from "react-native";import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";+export type ThreadInspectorMode = "route" | "git" | "files" | "preview";+export type ThreadInspectorTarget = {readonly type: "thread" | "device";readonly environmentId: string;diff --git a/apps/mobile/src/features/threads/thread-inspector-preview.tsx b/apps/mobile/src/features/threads/thread-inspector-preview.tsxindex 7c4e1e52c88..b999e225e75 100644--- a/apps/mobile/src/features/threads/thread-inspector-preview.tsx+++ b/apps/mobile/src/features/threads/thread-inspector-preview.tsx@@ -11,7 +11,7 @@ import { View } from "react-native";import { IconButton } from "../../components/ui/IconButton";import { SheetHeader } from "../../components/ui/SheetHeader";-import { NativeInspectorContent } from "../../native/NativeInspectorContent";+import { InspectorCloseContext } from "../layout/inspector-bar-store";import { createV5StackNavigator } from "../../native/createV5StackNavigator";import { NativeStackScreenOptions } from "../../native/StackHeader";import { WorkspaceSlotOptionsContext } from "../../native/v5-workspace-context";@@ -62,11 +62,13 @@ const PreviewStack = createV5StackNavigator<{export function InspectorContentScope({ children }: { readonly children: ReactNode }) {return (<WorkspaceSlotOptionsContext value={null}>- <WorkspaceContentWidthContext value={null}>- <WorkspaceSettledContentWidthContext value={null}>- {children}- </WorkspaceSettledContentWidthContext>- </WorkspaceContentWidthContext>+ <InspectorCloseContext value={null}>+ <WorkspaceContentWidthContext value={null}>+ <WorkspaceSettledContentWidthContext value={null}>+ {children}+ </WorkspaceSettledContentWidthContext>+ </WorkspaceContentWidthContext>+ </InspectorCloseContext></WorkspaceSlotOptionsContext>);}@@ -97,45 +99,43 @@ export function ThreadInspectorPreview(props: {return (<ThreadInspectorNavigationContext value={props.onOpen}><InspectorContentScope>- <NativeInspectorContent>- {target.type === "device" ? (- <DevicePreviewScreen- key={`${target.environmentId}:${target.threadId}`}- environmentId={EnvironmentId.make(target.environmentId)}- threadId={ThreadId.make(target.threadId)}- initialDeviceKey={target.deviceKey}- onClose={props.onClose}- onMaximize={maximizeDevice}- />- ) : (- <View className="flex-1 bg-screen">- <NavigationIndependentTree>- <NavigationContainer theme={theme} onUnhandledAction={navigation.dispatch}>- <PreviewStack.Navigator- key={`${target.environmentId}:${target.threadId}`}- screenOptions={{ headerBackVisible: false }}- >- <PreviewStack.Screen name="Thread" initialParams={target}>- {(screen) =>- props.renderThread({- route: screen.route,- inspectorPresentation: {- onClose: props.onClose,- onMaximize: () =>- navigation.navigate("ThreadInspectorFullscreen", {- environmentId: screen.route.params.environmentId,- threadId: screen.route.params.threadId,- }),- },- })- }- </PreviewStack.Screen>- </PreviewStack.Navigator>- </NavigationContainer>- </NavigationIndependentTree>- </View>- )}- </NativeInspectorContent>+ {target.type === "device" ? (+ <DevicePreviewScreen+ key={`${target.environmentId}:${target.threadId}`}+ environmentId={EnvironmentId.make(target.environmentId)}+ threadId={ThreadId.make(target.threadId)}+ initialDeviceKey={target.deviceKey}+ onClose={props.onClose}+ onMaximize={maximizeDevice}+ />+ ) : (+ <View className="flex-1 bg-screen">+ <NavigationIndependentTree>+ <NavigationContainer theme={theme} onUnhandledAction={navigation.dispatch}>+ <PreviewStack.Navigator+ key={`${target.environmentId}:${target.threadId}`}+ screenOptions={{ headerBackVisible: false }}+ >+ <PreviewStack.Screen name="Thread" initialParams={target}>+ {(screen) =>+ props.renderThread({+ route: screen.route,+ inspectorPresentation: {+ onClose: props.onClose,+ onMaximize: () =>+ navigation.navigate("ThreadInspectorFullscreen", {+ environmentId: screen.route.params.environmentId,+ threadId: screen.route.params.threadId,+ }),+ },+ })+ }+ </PreviewStack.Screen>+ </PreviewStack.Navigator>+ </NavigationContainer>+ </NavigationIndependentTree>+ </View>+ )}</InspectorContentScope></ThreadInspectorNavigationContext>);diff --git a/apps/mobile/src/native/NativeInspectorContent.tsx b/apps/mobile/src/native/NativeInspectorContent.tsxdeleted file mode 100644index 4907618f2d4..00000000000--- a/apps/mobile/src/native/NativeInspectorContent.tsx+++ /dev/null@@ -1,17 +0,0 @@-import type { ReactNode } from "react";-import { SafeAreaView } from "react-native-safe-area-context";--import { useNativeWorkspaceColumnsSupported } from "./NativeWorkspaceColumns";--// Pads with the inspector column's insets, which the column leaves to its panes so their-// native headers lay out against the vertical bar themselves.-export function NativeInspectorContent(props: { readonly children: ReactNode }) {- const usesNativeWorkspaceColumns = useNativeWorkspaceColumnsSupported();- if (!usesNativeWorkspaceColumns) return <>{props.children}</>;-- return (- <SafeAreaView edges={["left", "right"]} style={{ flex: 1 }}>- {props.children}- </SafeAreaView>- );-}diff --git a/apps/mobile/src/native/glass-header-options.ts b/apps/mobile/src/native/glass-header-options.tsnew file mode 100644index 00000000000..083834140d2--- /dev/null+++ b/apps/mobile/src/native/glass-header-options.ts@@ -0,0 +1,26 @@+import type { NativeStackNavigationOptions } from "@react-navigation/native-stack";+import { Platform } from "react-native";++import { NATIVE_LIQUID_GLASS_SUPPORTED } from "./native-glass";+import { nativeHeaderScrollEdgeEffects } from "./scrollEdgeEffects";++export type AppScreenOptions = NativeStackNavigationOptions & {+ readonly unstable_navigationItemStyle?: "editor";+ readonly unstable_headerMinimizationBehavior?: "onScrollUp" | "never";+};++/** A transparent bar that content scrolls under, with UIKit's scroll-edge blur where it has one. */+export const GLASS_HEADER_OPTIONS: AppScreenOptions = {+ headerBackButtonDisplayMode: "minimal",+ headerBackTitle: "",+ headerLargeTitle: false,+ headerShadowVisible: false,+ headerShown: true,+ headerStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? { backgroundColor: "transparent" } : undefined,+ headerTitleStyle: { fontSize: 18, fontWeight: "800" },+ headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,+ scrollEdgeEffects: NATIVE_LIQUID_GLASS_SUPPORTED+ ? nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version)+ : undefined,+ unstable_navigationItemStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? "editor" : undefined,+};diff --git a/apps/mobile/src/native/v5-workspace-context.tsx b/apps/mobile/src/native/v5-workspace-context.tsxindex af20431771a..4c4dbf562f0 100644--- a/apps/mobile/src/native/v5-workspace-context.tsx+++ b/apps/mobile/src/native/v5-workspace-context.tsx@@ -1,4 +1,6 @@-import { createContext, type ReactNode } from "react";+import { createContext } from "react";++import type { InspectorContent } from "../features/layout/inspector-panes";export const NativeWorkspaceModeContext = createContext(false);/**@@ -33,6 +35,6 @@ export const NativePrimaryColumnContext = createContext<{readonly selectedPullRequestKey: string | null;} | null>(null);export const NativeWorkspaceInspectorContext = createContext<{- readonly render: (() => ReactNode) | undefined;+ readonly content: InspectorContent | undefined;readonly visible: boolean;-}>({ render: undefined, visible: false });+}>({ content: undefined, visible: false });diff --git a/docs/internals/mobile-layout.md b/docs/internals/mobile-layout.mdindex c5e7b28b391..c1f44c62db0 100644--- a/docs/internals/mobile-layout.md+++ b/docs/internals/mobile-layout.md@@ -20,8 +20,8 @@ screen never asks which platform or window width it is on.- _Medium_ (600–720pt wide): the sidebar sits beside a list and floats over a page.- _Compact_ (under 600pt either way): the sidebar is the root, and pages push.- Where the inspector column does not fit, the inspector is a sheet.-3. **Feature screens.** A screen places content by role. It renders its page and declares side- content with `<Inspector>`, and asks for it with `showInspector()`. The shell decides+3. **Feature screens.** A screen places content by role. It renders its page and declares its+ inspector panes with `<Inspector>`, and asks for them with `showInspector()`. The shell decidesbetween column and sheet. Choosing a route or a component by width or platform here is the bugthis structure exists to prevent.4. **Design system.** Every pane has an `AppBar` with the same contract as a full screen.@@ -43,5 +43,8 @@ Platform splits live in layers 1, 2 and 4, as `.ios` and `.android` files.must also accept `usePaneRole() === "sidebar"`.- Modals and full-screen pages are presented over the columns and render with no pane role, sothey get no column chrome.+- On iOS each inspector pane is a native screen of its own, and only the active one is attached.+ A pane hidden with opacity still has its native bar, toolbar and scroll view in the window,+ and UIKit shows them over the visible pane.- A route opened from the inspector sheet must wait for the sheet to close, through`InspectorSheetContext`. Presenting over a closing sheet races its dismissal on iOS.