Skip to content
TypeScript

refactor(mobile): every screen draws one AppBar or SheetHeader, on both platforms

Julius Marminge162f81fd05f0
diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsx
index 8e460609598..9977e733c8c 100644
--- a/apps/mobile/src/Stack.tsx
+++ b/apps/mobile/src/Stack.tsx
@@ -629,7 +629,7 @@ const RootStackConfig = createWorkspaceStackNavigator({
ThreadReviewComment: createNativeStackScreen({
screen: ReviewCommentComposerSheet,
linking: `${THREAD_LINKING_PREFIX}/review-comment`,
- options: sheetRoute({ detent: 0.55, header: "none", android: "fullScreen" }),
+ options: sheetRoute({ detent: 0.55, android: "fullScreen" }),
}),
ThreadFiles: createNativeStackScreen({
screen: ThreadFilesTreeScreen,
@@ -644,7 +644,7 @@ const RootStackConfig = createWorkspaceStackNavigator({
ThreadMcpApp: createNativeStackScreen({
screen: McpAppFullscreenScreen,
linking: `${THREAD_LINKING_PREFIX}/apps/:itemId`,
- options: immersiveRoute(),
+ options: { ...modalRoute({ header: "solid" }), gestureEnabled: false },
}),
ThreadAttachment: createNativeStackScreen({
screen: AttachmentFileScreen,
@@ -690,7 +690,7 @@ const RootStackConfig = createWorkspaceStackNavigator({
GitConfirm: createNativeStackScreen({
screen: GitConfirmSheet,
linking: `${THREAD_LINKING_PREFIX}/git-confirm`,
- options: sheetRoute({ detent: 0.55, maxDetent: 0.7, header: "none", androidFit: true }),
+ options: sheetRoute({ detent: 0.55, maxDetent: 0.7, androidFit: true }),
}),
...SETTINGS_SCREENS,
SettingsLegal: createNativeStackScreen({
diff --git a/apps/mobile/src/components/ComposerContextSheet.tsx b/apps/mobile/src/components/ComposerContextSheet.tsx
index 8121bfdece7..d7fb3a3c4cd 100644
--- a/apps/mobile/src/components/ComposerContextSheet.tsx
+++ b/apps/mobile/src/components/ComposerContextSheet.tsx
@@ -13,7 +13,7 @@ import type {
import { formatAttachmentSize } from "@t3tools/client-runtime/state/attachments";
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
import { videoMimeType } from "@t3tools/shared/video";
-import { Platform, Pressable, ScrollView, View } from "react-native";
+import { Pressable, ScrollView, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { REVIEW_MONO_FONT_FAMILY } from "../features/review/reviewDiffRendering";
import { ReviewCommentCard, useReviewCommentColors } from "../features/review/ReviewCommentCard";
@@ -193,7 +193,7 @@ export function ComposerContextSheet(props: {
<ScrollView
nestedScrollEnabled
className="flex-1"
- contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
+ contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={{
paddingHorizontal: 20,
paddingTop: 12,
diff --git a/apps/mobile/src/components/FilePreview.tsx b/apps/mobile/src/components/FilePreview.tsx
index a7c2de56d83..f733c59ff7e 100644
--- a/apps/mobile/src/components/FilePreview.tsx
+++ b/apps/mobile/src/components/FilePreview.tsx
@@ -12,7 +12,7 @@ import type {
} from "./FilePreviewModal.types";
import { imageViewingProps, MediaImagePreview } from "./MediaImagePreview";
import { PdfPreview } from "./PdfPreview";
-import { ControlPill } from "./ui/ControlPill";
+import { SheetHeader } from "./ui/SheetHeader";
import { AppText as Text } from "./ui/AppText";
function PdfDocumentPreview(props: {
@@ -31,12 +31,11 @@ function PdfDocumentPreview(props: {
className="flex-1 bg-card"
style={{ paddingTop: insets.top, paddingBottom: insets.bottom }}
>
- <View className="flex-row items-center gap-3 border-b border-border px-4 py-2">
- <Text className="flex-1 font-t3-semibold text-foreground" numberOfLines={1}>
- {props.source.name ?? "PDF"}
- </Text>
- <ControlPill label="Close" variant="pill" onPress={props.onRequestClose} />
- </View>
+ <SheetHeader
+ presentation="inline"
+ title={props.source.name ?? "PDF"}
+ onClose={props.onRequestClose}
+ />
<PdfPreview uri={props.source.uri} />
</View>
</Modal>
diff --git a/apps/mobile/src/components/MediaImagePreview.tsx b/apps/mobile/src/components/MediaImagePreview.tsx
index 52c294e3646..2a7b226574e 100644
--- a/apps/mobile/src/components/MediaImagePreview.tsx
+++ b/apps/mobile/src/components/MediaImagePreview.tsx
@@ -1,14 +1,11 @@
import { createContext, useContext } from "react";
-import { Pressable, View } from "react-native";
+import { View } from "react-native";
import ImageViewing from "react-native-image-viewing";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useMediaActions } from "../state/mediaActions";
-import { AppText } from "./ui/AppText";
-import { SymbolView } from "./ui/AppSymbol";
import type { FilePreviewImages } from "./FilePreviewModal.types";
-import { MediaActionsMenu } from "./MediaActionsMenu";
-import { MediaSourceCaption } from "./MediaSourceCaption";
+import { MediaPreviewHeader } from "./MediaPreviewHeader";
type MediaImagePreviewProps = {
readonly source: FilePreviewImages;
@@ -24,21 +21,12 @@ function ImagePreviewHeader(header: { readonly imageIndex: number }) {
const mediaActions = useMediaActions(source?.actionsSource, props.onRequestClose);
return (
<View className="bg-black/70" style={{ paddingTop: insets.top }}>
- <View className="flex-row items-center gap-2 px-3">
- <AppText className="flex-1 text-base text-white" numberOfLines={2}>
- {source?.name ?? "Image"}
- </AppText>
- <MediaActionsMenu media={mediaActions} inModal />
- <Pressable
- accessibilityRole="button"
- accessibilityLabel="Close image"
- onPress={props.onRequestClose}
- className="min-h-11 min-w-11 items-center justify-center"
- >
- <SymbolView name="xmark" size={20} tintColor="#ffffff" type="monochrome" />
- </Pressable>
- </View>
- <MediaSourceCaption source={mediaActions.title} />
+ <MediaPreviewHeader
+ title={source?.name ?? "Image"}
+ media={mediaActions}
+ closeAccessibilityLabel="Close image"
+ onClose={props.onRequestClose}
+ />
</View>
);
}
diff --git a/apps/mobile/src/components/MediaPreviewHeader.tsx b/apps/mobile/src/components/MediaPreviewHeader.tsx
new file mode 100644
index 00000000000..c6d405ff94e
--- /dev/null
+++ b/apps/mobile/src/components/MediaPreviewHeader.tsx
@@ -0,0 +1,35 @@
+import { Pressable, View } from "react-native";
+
+import type { useMediaActions } from "../state/mediaActions";
+import { SymbolView } from "./ui/AppSymbol";
+import { AppText } from "./ui/AppText";
+import { MediaActionsMenu } from "./MediaActionsMenu";
+import { MediaSourceCaption } from "./MediaSourceCaption";
+
+/** The bar over a full-screen image or video: always dark, whatever the app theme. */
+export function MediaPreviewHeader(props: {
+ readonly title: string;
+ readonly media: ReturnType<typeof useMediaActions>;
+ readonly closeAccessibilityLabel: string;
+ readonly onClose: () => void;
+}) {
+ return (
+ <>
+ <View className="min-h-14 flex-row items-center gap-3 pl-4 pr-2">
+ <AppText className="flex-1 font-t3-medium text-base text-white" numberOfLines={2}>
+ {props.title}
+ </AppText>
+ <MediaActionsMenu media={props.media} inModal />
+ <Pressable
+ accessibilityRole="button"
+ accessibilityLabel={props.closeAccessibilityLabel}
+ onPress={props.onClose}
+ className="size-12 items-center justify-center"
+ >
+ <SymbolView name="xmark" size={20} tintColor="#ffffff" type="monochrome" />
+ </Pressable>
+ </View>
+ <MediaSourceCaption source={props.media.title} />
+ </>
+ );
+}
diff --git a/apps/mobile/src/components/VideoPreviewModal.tsx b/apps/mobile/src/components/VideoPreviewModal.tsx
index 4e63851dcd3..2f9d0063ca9 100644
--- a/apps/mobile/src/components/VideoPreviewModal.tsx
+++ b/apps/mobile/src/components/VideoPreviewModal.tsx
@@ -17,9 +17,7 @@ import {
import { useAssetUrlState, useRefreshAssetUrl } from "../state/assets";
import { usePreparedConnection } from "../state/session";
import { AppText } from "./ui/AppText";
-import { SymbolView } from "./ui/AppSymbol";
-import { MediaActionsMenu } from "./MediaActionsMenu";
-import { MediaSourceCaption } from "./MediaSourceCaption";
+import { MediaPreviewHeader } from "./MediaPreviewHeader";
import { MediaVideoPlayer } from "./MediaVideoPlayer";
export type { VideoPreviewSource } from "../lib/videoPreviewSource";
@@ -118,21 +116,12 @@ function OpenVideoPreviewModal(props: {
className="flex-1 bg-black"
style={{ paddingTop: insets.top, paddingBottom: insets.bottom }}
>
- <View className="min-h-14 flex-row items-center gap-3 pl-4 pr-2">
- <AppText className="flex-1 font-t3-medium text-base text-white" numberOfLines={2}>
- {props.name}
- </AppText>
- <MediaActionsMenu media={mediaActions} inModal />
- <Pressable
- accessibilityRole="button"
- accessibilityLabel="Close video"
- onPress={props.onRequestClose}
- className="size-12 items-center justify-center"
- >
- <SymbolView name="xmark" size={20} tintColor="#ffffff" type="monochrome" />
- </Pressable>
- </View>
- <MediaSourceCaption source={mediaActions.title} />
+ <MediaPreviewHeader
+ title={props.name}
+ media={mediaActions}
+ closeAccessibilityLabel="Close video"
+ onClose={props.onRequestClose}
+ />
{playback.uri === null && !playback.unavailable ? (
<View className="flex-1 items-center justify-center gap-3 px-6">
<AppActivityIndicator color="#ffffff" />
diff --git a/apps/mobile/src/components/ui/AppBar.android.test.tsx b/apps/mobile/src/components/ui/AppBar.android.test.tsx
index c4cf88d185a..12859f11dfe 100644
--- a/apps/mobile/src/components/ui/AppBar.android.test.tsx
+++ b/apps/mobile/src/components/ui/AppBar.android.test.tsx
@@ -23,6 +23,10 @@ vi.mock("./WorkspaceAppBar.android", () => ({
vi.mock("./Menu", () => ({ Menu: (props: { readonly children?: ReactNode }) => props.children }));
vi.mock("./ScreenHeaderButton.android", () => ({ ScreenHeaderButton: () => null }));
vi.mock("./SearchField", () => ({ SearchField: () => null }));
+vi.mock("./Button", () => ({ Button: () => null }));
+vi.mock("../../features/layout/adaptive-workspace-context", () => ({
+ useAdaptiveWorkspaceLayout: () => ({ layout: { usesSplitView: false } }),
+}));
vi.mock("./useToolbarLayout", () => ({
useToolbarLayout: () => ({ height: 48, paddingTop: 0, paddingBottom: 0 }),
}));
diff --git a/apps/mobile/src/components/ui/AppBar.android.tsx b/apps/mobile/src/components/ui/AppBar.android.tsx
index a37ee4d74ad..f312999c58d 100644
--- a/apps/mobile/src/components/ui/AppBar.android.tsx
+++ b/apps/mobile/src/components/ui/AppBar.android.tsx
@@ -2,13 +2,16 @@ 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 { RoutedFormSheetContext } from "./RoutedFormSheetContext";
import { NativeStackScreenOptions } from "../../native/StackHeader";
import { useSidebarToggle } from "../../features/layout/useSidebarToggle";
+import { useAdaptiveWorkspaceLayout } from "../../features/layout/adaptive-workspace-context";
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";
import { Menu } from "./Menu";
+import { Button } from "./Button";
import { SearchField } from "./SearchField";
import { androidHeaderMenuActions, findHeaderMenuAction } from "./headerMenu.android";
import type { AppBarMenuItem, AppBarProps, AppBarSearch } from "./AppBar.types";
@@ -26,7 +29,14 @@ interface SearchState {
readonly inputRef: RefObject<TextInputInstance | null>;
}
-export function AppBar(props: AppBarProps) {
+export function AppBar(barProps: AppBarProps) {
+ const { layout } = useAdaptiveWorkspaceLayout();
+ const props = {
+ ...barProps,
+ onBack:
+ barProps.onBack ??
+ (layout.usesSplitView ? barProps.backInSplitView?.onPress : barProps.onBackToList),
+ };
return props.search ? (
<SearchableAppBar {...props} search={props.search} />
) : (
@@ -66,7 +76,8 @@ function SearchableAppBar(props: AppBarProps & { readonly search: AppBarSearch }
function AppBarView(props: AppBarProps & { readonly searchState?: SearchState }) {
const { search, searchState } = props;
- const { paddingTop, paddingBottom } = useToolbarLayout(props.sheet);
+ const inFormSheet = use(RoutedFormSheetContext);
+ const { paddingTop, paddingBottom } = useToolbarLayout(props.sheet || inFormSheet);
const { themeVariables } = useAppearancePreferences();
const inWorkspace = useHasWorkspaceAppBar();
const sidebarToggle = useSidebarToggle();
@@ -143,11 +154,19 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
<ScreenHeaderButton accessibilityLabel={menu.title} icon={menu.icon} />
</Menu>
));
+ const confirmButton = props.confirm ? (
+ <Button
+ label={props.confirm.label}
+ tone="text"
+ loading={props.confirm.loading}
+ disabled={props.confirm.disabled}
+ onPress={props.confirm.onPress}
+ />
+ ) : null;
const options =
props.embedded || props.sheet ? null : (
<NativeStackScreenOptions
options={{
- ...props.options,
...(props.matchSearchSurface
? { contentStyle: { backgroundColor: themeVariables["--color-header"] } }
: undefined),
@@ -162,8 +181,15 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
title={props.title}
titleContent={props.titleContent}
subtitle={props.subtitle}
- onBack={props.onBack}
+ onBack={props.onClose ? undefined : props.onBack}
leading={
+ (props.onClose ? (
+ <AndroidHeaderIconButton
+ accessibilityLabel={props.closeAccessibilityLabel ?? "Close"}
+ icon="xmark"
+ onPress={props.onClose}
+ />
+ ) : undefined) ??
props.leading ??
// Only a real button: any leading content takes the bar's navigation slot.
(sidebarToggle && !props.sheet ? (
@@ -190,10 +216,11 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
: actions
}
trailing={
- menuView?.length || props.trailing || closeInspector ? (
+ menuView?.length || props.trailing || props.confirm || closeInspector ? (
<>
{menuView}
{props.trailing}
+ {confirmButton}
{closeInspector ? (
<AndroidHeaderIconButton
accessibilityLabel="Close inspector"
@@ -234,7 +261,13 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
>
<View className="flex-1 flex-row items-center gap-1">
{inline ? (
- props.onBack ? (
+ props.onClose ? (
+ <ScreenHeaderButton
+ accessibilityLabel={props.closeAccessibilityLabel ?? "Close"}
+ icon="xmark"
+ onPress={props.onClose}
+ />
+ ) : props.onBack ? (
<ScreenHeaderButton
accessibilityLabel="Navigate up"
icon="arrow.left"
@@ -250,6 +283,7 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
)}
{searchField}
{inline ? menuView : null}
+ {inline ? confirmButton : null}
</View>
</View>
) : null}
diff --git a/apps/mobile/src/components/ui/AppBar.tsx b/apps/mobile/src/components/ui/AppBar.tsx
index 8061e2c467f..d837ed32e1b 100644
--- a/apps/mobile/src/components/ui/AppBar.tsx
+++ b/apps/mobile/src/components/ui/AppBar.tsx
@@ -1,6 +1,7 @@
import { Toolbar } from "./Toolbar";
import { AppActivityIndicator } from "./AppActivityIndicator";
import type { HeaderBarButtonMailSearchToolbarItem } from "react-native-screens";
+import { NavigationContext } from "@react-navigation/native";
import { use, useId, useLayoutEffect } from "react";
import { View } from "react-native";
import { createNativeHeaderMenu } from "./nativeHeaderMenu.ios";
@@ -20,6 +21,7 @@ import { useAppearancePreferences } from "../../features/settings/appearance/App
import type { AppBarMenuItem, AppBarProps } from "./AppBar.types";
import type { AppSymbolName } from "./AppSymbol";
import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
+import { useControlTheme } from "./useControlTheme";
function iosIcon(icon: AppSymbolName) {
return typeof icon === "string" ? icon : icon.ios;
@@ -64,7 +66,19 @@ export function AppBar(props: AppBarProps) {
layout.usesSplitView && props.backInSplitView && splitBackPress
? { ...props.backInSplitView, onPress: splitBackPress }
: null;
+ const navigation = use(NavigationContext);
+ const rootBack =
+ !layout.usesSplitView && props.onBackToList && navigation?.canGoBack() === false
+ ? props.onBackToList
+ : props.guardBack && props.onBack
+ ? props.onBack
+ : null;
+ const compose =
+ layout.usesSplitView && !(usesNativeWorkspaceColumns && isDuoDevice(deviceType))
+ ? props.onCompose
+ : undefined;
const { themeVariables } = useAppearancePreferences();
+ const { colors } = useControlTheme();
const usesNativeMailSearchToolbar = useNativeMailSearchToolbar();
const { search, menus } = props;
const menu = menus?.[0];
@@ -87,7 +101,12 @@ export function AppBar(props: AppBarProps) {
optionsVersion={[props.optionsVersion, compactSearch ? menu : undefined]}
options={{
headerShown: true,
- headerBackVisible: splitBack === null,
+ headerBackVisible:
+ props.onClose === undefined &&
+ splitBack === null &&
+ !(layout.usesSplitView && props.onBackToList) &&
+ !(props.guardBack && props.onBack),
+ ...(props.guardBack ? { gestureEnabled: false } : undefined),
title: props.title,
unstable_headerSubtitle: props.subtitle || undefined,
...(props.matchSearchSurface
@@ -132,12 +151,26 @@ export function AppBar(props: AppBarProps) {
},
}
: undefined),
- ...props.options,
}}
/>
- {(splitBack || showsSidebarToggle) &&
- props.options?.unstable_headerLeftItems === undefined ? (
+ {props.onClose ? (
<Toolbar placement="left">
+ <Toolbar.Button
+ icon="xmark"
+ accessibilityLabel={props.closeAccessibilityLabel ?? "Close"}
+ onPress={props.onClose}
+ />
+ </Toolbar>
+ ) : rootBack || splitBack || showsSidebarToggle || compose ? (
+ <Toolbar placement="left">
+ {rootBack ? (
+ <ScreenHeaderButton
+ accessibilityLabel="Back"
+ icon="chevron.left"
+ onPress={rootBack}
+ separateBackground
+ />
+ ) : null}
{splitBack ? <ScreenHeaderButton {...splitBack} /> : null}
{showsSidebarToggle ? (
<ScreenHeaderButton
@@ -148,10 +181,22 @@ export function AppBar(props: AppBarProps) {
separateBackground={splitBack ? splitBack.separateBackground : true}
/>
) : null}
+ {compose ? (
+ <ScreenHeaderButton
+ accessibilityLabel="New task"
+ label="New task"
+ icon="square.and.pencil"
+ onPress={compose}
+ separateBackground
+ />
+ ) : null}
</Toolbar>
) : null}
- {(props.actions?.length || visibleMenus.length || props.trailing || closeInspector) &&
- props.options?.unstable_headerRightItems === undefined ? (
+ {props.actions?.length ||
+ visibleMenus.length ||
+ props.trailing ||
+ props.confirm ||
+ closeInspector ? (
<Toolbar placement="right">
{props.actions?.map(({ loading, ...action }) =>
loading ? (
@@ -168,12 +213,34 @@ export function AppBar(props: AppBarProps) {
key={action.accessibilityLabel}
{...action}
icon={iosIcon(action.icon)}
- separateBackground
+ separateBackground={action.separateBackground ?? true}
/>
),
)}
{visibleMenus.map(createNativeHeaderMenu)}
{props.trailing}
+ {props.confirm?.loading ? (
+ <Toolbar.Custom>
+ <View
+ className="size-11 items-center justify-center"
+ accessible
+ accessibilityLabel={props.confirm.label}
+ accessibilityState={{ busy: true }}
+ >
+ <AppActivityIndicator colorClassName="accent-prominent-action" />
+ </View>
+ </Toolbar.Custom>
+ ) : props.confirm ? (
+ <Toolbar.Button
+ icon="checkmark"
+ variant="prominent"
+ visibilityPriority="high"
+ tintColor={colors["--color-prominent-action"]}
+ accessibilityLabel={props.confirm.label}
+ disabled={props.confirm.disabled}
+ onPress={props.confirm.onPress}
+ />
+ ) : null}
{closeInspector ? (
<ScreenHeaderButton
accessibilityLabel="Close inspector"
@@ -195,6 +262,7 @@ export function AppBar(props: AppBarProps) {
export type {
AppBarAction,
+ AppBarConfirm,
AppBarMenu,
AppBarMenuItem,
AppBarProps,
diff --git a/apps/mobile/src/components/ui/AppBar.types.ts b/apps/mobile/src/components/ui/AppBar.types.ts
index 94c4ad07879..a77811be81d 100644
--- a/apps/mobile/src/components/ui/AppBar.types.ts
+++ b/apps/mobile/src/components/ui/AppBar.types.ts
@@ -1,6 +1,5 @@
import type { ReactNode } from "react";
import type { ColorValue } from "react-native";
-import type { AppNativeStackNavigationOptions } from "../../native/StackHeader";
import type { AppSymbolName } from "./AppSymbol";
export interface AppBarAction {
@@ -16,6 +15,8 @@ export interface AppBarAction {
readonly destructive?: boolean;
/** Android: always in the overflow menu, never a toolbar button. */
readonly overflowOnly?: boolean;
+ /** iOS: false shares one glass capsule with neighbouring items. Defaults to true. */
+ readonly separateBackground?: boolean;
}
export type AppBarMenuItem =
@@ -28,6 +29,7 @@ export type AppBarMenuItem =
readonly subtitle?: string;
readonly disabled?: boolean;
readonly selected?: boolean;
+ readonly destructive?: boolean;
readonly onPress: () => void;
}
| {
@@ -46,6 +48,13 @@ export interface AppBarMenu {
readonly items: ReadonlyArray<AppBarMenuItem>;
}
+export interface AppBarConfirm {
+ readonly label: string;
+ readonly onPress: () => void;
+ readonly disabled?: boolean;
+ readonly loading?: boolean;
+}
+
export interface AppBarSearch {
readonly value: string;
readonly onChangeText: (value: string) => void;
@@ -74,11 +83,35 @@ export interface AppBarProps {
readonly menus?: ReadonlyArray<AppBarMenu>;
readonly search?: AppBarSearch;
readonly onBack?: () => void;
+ /** Back runs `onBack` and swipe-back is off, so a `usePreventRemove` guard sees it first. */
+ readonly guardBack?: boolean;
+ /**
+ * Back for a page whose parent is the workspace list. Hidden in split view, where the list is
+ * beside the page; shown even when the page opened with nothing beneath it.
+ */
+ readonly onBackToList?: () => void;
+ /**
+ * iOS: a labelled compose button beside the sidebar button in split view. The Duo's column bar
+ * and Android's sidebar compose on their own, so they ignore it.
+ */
+ readonly onCompose?: () => void;
+ /**
+ * The bar of a sheet or modal: a close button leads the bar in place of Back and the sidebar
+ * button, on both platforms.
+ */
+ readonly onClose?: () => void;
+ /** Defaults to "Close". */
+ readonly closeAccessibilityLabel?: string;
+ /** A sheet's confirm button, last in the bar. */
+ readonly confirm?: AppBarConfirm;
/** Android: replaces the sidebar button at the start of the bar. */
readonly leading?: ReactNode;
- /** Leaves route options to the screen: in-screen bars, and screens that set their own. iOS draws nothing. */
+ /**
+ * Workspace shell only: a second bar inside a route whose own bar is drawn elsewhere, such as
+ * a workspace tab pane. Leaves route options alone; iOS draws nothing. Screens never set it.
+ */
readonly embedded?: boolean;
- /** An embedded bar at the top of a sheet. */
+ /** A bar at the top of a sheet that is not a route (routed sheets are detected). */
readonly sheet?: boolean;
readonly backInSplitView?: {
readonly accessibilityLabel: string;
@@ -91,6 +124,5 @@ export interface AppBarProps {
readonly compact?: boolean;
readonly trailing?: ReactNode;
readonly matchSearchSurface?: boolean;
- readonly options?: AppNativeStackNavigationOptions;
readonly optionsVersion?: unknown;
}
diff --git a/apps/mobile/src/components/ui/ScreenContent.tsx b/apps/mobile/src/components/ui/ScreenContent.tsx
index 554f5d964d9..7a89cc89b66 100644
--- a/apps/mobile/src/components/ui/ScreenContent.tsx
+++ b/apps/mobile/src/components/ui/ScreenContent.tsx
@@ -1,6 +1,8 @@
import type { ReactNode } from "react";
import { Platform, View, type LayoutChangeEvent } from "react-native";
+import { useAdaptiveWorkspaceLayout } from "../../features/layout/adaptive-workspace-context";
+
const SURFACE_CLASS_NAMES = {
sheet: "bg-sheet-solid",
screen: "bg-screen",
@@ -15,16 +17,18 @@ const SURFACE_CLASS_NAMES = {
export function ScreenContent({
children,
surface = "sheet",
- insetHorizontal = false,
+ insetHorizontal,
fitToContents = false,
onLayout,
}: {
readonly children: ReactNode;
readonly surface?: keyof typeof SURFACE_CLASS_NAMES;
+ /** Keeps the card off the window edge. Defaults to on wherever the workspace is split. */
readonly insetHorizontal?: boolean;
readonly fitToContents?: boolean;
readonly onLayout?: (event: LayoutChangeEvent) => void;
}) {
+ const { layout } = useAdaptiveWorkspaceLayout();
if (Platform.OS !== "android") {
return onLayout ? (
<View className="flex-1" onLayout={onLayout}>
@@ -45,7 +49,7 @@ export function ScreenContent({
flexShrink: 1,
flexGrow: fitToContents ? 0 : 1,
flexBasis: fitToContents ? "auto" : 0,
- marginHorizontal: insetHorizontal ? 4 : 0,
+ marginHorizontal: (insetHorizontal ?? layout.usesSplitView) ? 4 : 0,
}}
>
{children}
diff --git a/apps/mobile/src/components/ui/Sheet.android.tsx b/apps/mobile/src/components/ui/Sheet.android.tsx
index b8eed81bdae..d4eac0cb94c 100644
--- a/apps/mobile/src/components/ui/Sheet.android.tsx
+++ b/apps/mobile/src/components/ui/Sheet.android.tsx
@@ -16,6 +16,7 @@ export function Sheet(props: SheetProps) {
isOpen={isOpen}
detents={[0.5, 0.9]}
prefersGrabberVisible={false}
+ preventNativeDismiss={props.dismissDisabled}
nativeContainerStyle={containerStyle}
onDismiss={props.onClose}
onNativeDismiss={props.onClose}
@@ -24,7 +25,12 @@ export function Sheet(props: SheetProps) {
{/* Android FormSheet does not bound flex children. Material drags target the first scroll view, so place content before the header. */}
<View collapsable={false} className="absolute inset-0 flex-col-reverse bg-header">
<ScreenContent>{props.children}</ScreenContent>
- <AppBar sheet title={props.title} onBack={() => setIsOpen(false)} hideBottomBorder />
+ <AppBar
+ sheet
+ title={props.title}
+ onBack={props.dismissDisabled ? undefined : () => setIsOpen(false)}
+ hideBottomBorder
+ />
<View
pointerEvents="none"
className="absolute top-1 h-1 w-8 self-center rounded-full bg-header-foreground/40"
diff --git a/apps/mobile/src/components/ui/Sheet.tsx b/apps/mobile/src/components/ui/Sheet.tsx
index 56994803b4a..75866175bbf 100644
--- a/apps/mobile/src/components/ui/Sheet.tsx
+++ b/apps/mobile/src/components/ui/Sheet.tsx
@@ -17,13 +17,16 @@ export function Sheet(props: SheetProps) {
const containerStyle = useResolveClassNames("bg-sheet");
const screenId = useId();
const [isOpen, setIsOpen] = useState(true);
- const close = () => setIsOpen(false);
+ const close = () => {
+ if (!props.dismissDisabled) setIsOpen(false);
+ };
return (
<FormSheet
isOpen={isOpen}
detents={formSheetDetents(0.5, 0.9)}
prefersGrabberVisible
+ preventNativeDismiss={props.dismissDisabled}
// The header holds the close button, so the Duo needs no rail inside this sheet.
prefersHorizontalBars
nativeContainerStyle={containerStyle}
@@ -57,6 +60,7 @@ export function Sheet(props: SheetProps) {
icon: { name: "xmark", type: "sfSymbol" },
accessibilityLabel: `Close ${props.title}`,
identifier: `app-sheet-close-${screenId}`,
+ disabled: props.dismissDisabled,
onPress: close,
},
]}
diff --git a/apps/mobile/src/components/ui/Sheet.types.ts b/apps/mobile/src/components/ui/Sheet.types.ts
index 8c0af06edb3..bcd9c598dff 100644
--- a/apps/mobile/src/components/ui/Sheet.types.ts
+++ b/apps/mobile/src/components/ui/Sheet.types.ts
@@ -4,4 +4,6 @@ export interface SheetProps {
readonly title: string;
readonly children: ReactNode;
readonly onClose: () => void;
+ /** Blocks the close button and the swipe, such as while a submit is in flight. */
+ readonly dismissDisabled?: boolean;
}
diff --git a/apps/mobile/src/components/ui/headerMenu.android.ts b/apps/mobile/src/components/ui/headerMenu.android.ts
index 1fe463b936f..793055c4afd 100644
--- a/apps/mobile/src/components/ui/headerMenu.android.ts
+++ b/apps/mobile/src/components/ui/headerMenu.android.ts
@@ -22,7 +22,10 @@ export function androidHeaderMenuActions(items: ReadonlyArray<AppBarMenuItem>):
image: item.icon,
imageColor: item.iconColor,
state: item.selected ? "on" : undefined,
- attributes: item.disabled ? { disabled: true } : undefined,
+ attributes:
+ item.disabled || item.destructive
+ ? { disabled: item.disabled, destructive: item.destructive }
+ : undefined,
},
],
);
diff --git a/apps/mobile/src/components/ui/nativeHeaderMenu.ios.tsx b/apps/mobile/src/components/ui/nativeHeaderMenu.ios.tsx
index f566d3b0dff..52af2c3d34d 100644
--- a/apps/mobile/src/components/ui/nativeHeaderMenu.ios.tsx
+++ b/apps/mobile/src/components/ui/nativeHeaderMenu.ios.tsx
@@ -14,6 +14,7 @@ function renderMenuItems(items: ReadonlyArray<AppBarMenuItem>) {
icon={item.icon}
subtitle={item.subtitle}
disabled={item.disabled}
+ destructive={item.destructive}
isOn={item.selected}
onPress={item.onPress}
>
diff --git a/apps/mobile/src/components/ui/useBarInset.ts b/apps/mobile/src/components/ui/useBarInset.ts
new file mode 100644
index 00000000000..469b3bd1e0d
--- /dev/null
+++ b/apps/mobile/src/components/ui/useBarInset.ts
@@ -0,0 +1,60 @@
+import { HeaderHeightContext } from "@react-navigation/elements";
+import { use } from "react";
+import { Platform } from "react-native";
+
+import { useAdaptiveWorkspaceLayout } from "../../features/layout/adaptive-workspace-context";
+import { NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET } from "../../features/layout/native-mail-search-toolbar";
+import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
+import type { AppBarSearch } from "./AppBar.types";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+
+import { IOS_NAV_BAR_HEIGHT } from "../../lib/layoutMetrics";
+import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
+import { useToolbarLayout } from "./useToolbarLayout";
+
+/**
+ * How far below the screen's top edge its AppBar ends: where content that scrolls under a
+ * translucent bar starts, and where an overlay pinned under the bar goes. Measured by the native
+ * column or stack on iOS; Android draws the bar in-tree from the toolbar geometry.
+ */
+export function useBarInset(): number {
+ const headerHeight = use(HeaderHeightContext);
+ const columnMetrics = useNativeColumnLayoutMetrics();
+ const insets = useSafeAreaInsets();
+ const toolbar = useToolbarLayout();
+ if (Platform.OS === "android") {
+ return toolbar.paddingTop + toolbar.height + toolbar.paddingBottom;
+ }
+ return headerHeight ?? columnMetrics?.safeArea.top ?? insets.top + IOS_NAV_BAR_HEIGHT;
+}
+
+/**
+ * How far the bar covers the top of the body below it: the bar inset where the body runs under
+ * the iOS bar, 0 on Android, where the bar sits above the body in flow.
+ */
+export function useBarOverlap(): number {
+ const barInset = useBarInset();
+ return Platform.OS === "android" ? 0 : barInset;
+}
+
+/**
+ * The content's top safe area under the AppBar: a translucent bar's height, zero under a solid
+ * one or on Android, where the bar sits in flow. For scroll content insets, which must not
+ * double-count a solid bar.
+ */
+export function useContentTopInset(): number {
+ const insets = useSafeAreaInsets();
+ const columnMetrics = useNativeColumnLayoutMetrics();
+ return Platform.OS === "ios" ? (columnMetrics?.safeArea.top ?? insets.top) : 0;
+}
+
+/** How much of the screen's bottom edge an AppBar `search` covers: iOS's bottom search toolbar. */
+export function useSearchToolbarInset(search: AppBarSearch | undefined): number {
+ const { layout } = useAdaptiveWorkspaceLayout();
+ const usesNativeMailSearchToolbar = useNativeMailSearchToolbar();
+ return search !== undefined &&
+ (search.compactToolbar ?? !layout.usesSplitView) &&
+ usesNativeMailSearchToolbar
+ ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET
+ : 0;
+}
diff --git a/apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx b/apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx
index b18e3051db7..fd3ce42403c 100644
--- a/apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx
+++ b/apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx
@@ -16,7 +16,7 @@ import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import { AppBar } from "../../components/ui/AppBar";
import { SymbolView } from "../../components/ui/AppSymbol";
import { useMemo, useRef, type ComponentProps } from "react";
-import { Platform, RefreshControl, useWindowDimensions, View } from "react-native";
+import { RefreshControl, useWindowDimensions, View } from "react-native";
import { GestureDetector, useNativeGesture } from "react-native-gesture-handler";
import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
@@ -105,15 +105,11 @@ function ArchivedThreadsHeader(props: {
},
],
},
- ...(Platform.OS === "android"
- ? [
- {
- id: "refresh",
- title: "Refresh archived threads",
- onPress: props.onRefresh,
- },
- ]
- : []),
+ {
+ id: "refresh",
+ title: "Refresh archived threads",
+ onPress: props.onRefresh,
+ },
],
},
]}
@@ -418,7 +414,7 @@ export function ArchivedThreadsScreen(props: {
<SettingsScreenContent>
<GestureDetector gesture={archiveScrollGesture}>
<LegendList
- renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
+ renderScrollComponent={NativeScrollView}
className="flex-1"
contentContainerStyle={{
paddingBottom: 32,
diff --git a/apps/mobile/src/features/cloud/ConnectOnboardingRouteScreen.tsx b/apps/mobile/src/features/cloud/ConnectOnboardingRouteScreen.tsx
index 4d0b340317c..463c11aaf64 100644
--- a/apps/mobile/src/features/cloud/ConnectOnboardingRouteScreen.tsx
+++ b/apps/mobile/src/features/cloud/ConnectOnboardingRouteScreen.tsx
@@ -1,13 +1,11 @@
-import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
-import { SheetHeader } from "../../components/ui/SheetHeader";
-import { IconButton } from "../../components/ui/IconButton";
+import { AppBar } from "../../components/ui/AppBar";
import { Button } from "../../components/ui/Button";
import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
import { useAuth } from "@clerk/expo";
import { useNavigation } from "@react-navigation/native";
import { useState } from "react";
-import { Platform, RefreshControl, View } from "react-native";
+import { RefreshControl, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { reportAtomCommandResult, settlePromise } from "@t3tools/client-runtime/state/runtime";
@@ -60,30 +58,14 @@ function ConfiguredConnectOnboardingRouteScreen() {
return (
<View collapsable={false} className="flex-1 bg-sheet">
- <SheetHeader
- presentation={Platform.OS === "android" ? "inline" : "native"}
+ <AppBar
title="Set up T3 Connect"
onClose={handleClose}
- trailing={
- Platform.OS === "android" ? (
- isRefreshing ? (
- <View
- className="size-12 items-center justify-center"
- accessible
- accessibilityLabel="Refreshing environments"
- accessibilityState={{ busy: true }}
- >
- <AppActivityIndicator />
- </View>
- ) : (
- <IconButton
- accessibilityLabel="Refresh environments"
- icon="arrow.clockwise"
- onPress={handleRefresh}
- />
- )
- ) : undefined
- }
+ refresh={{
+ accessibilityLabel: "Refresh environments",
+ disabled: isRefreshing,
+ onPress: handleRefresh,
+ }}
/>
<ScrollView
nestedScrollEnabled
@@ -97,11 +79,7 @@ function ConfiguredConnectOnboardingRouteScreen() {
paddingHorizontal: 20,
paddingTop: 16,
}}
- refreshControl={
- Platform.OS === "ios" ? (
- <RefreshControl refreshing={isRefreshing} onRefresh={handleRefresh} />
- ) : undefined
- }
+ refreshControl={<RefreshControl refreshing={isRefreshing} onRefresh={handleRefresh} />}
>
{isSignedIn ? (
<CloudEnvironmentRows
diff --git a/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx b/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx
index 6f4e85d1d0d..f7e69cb881f 100644
--- a/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx
+++ b/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx
@@ -8,7 +8,6 @@ import {
StackActions,
useIsFocused,
useNavigation,
- useRoute,
type StaticScreenProps,
} from "@react-navigation/native";
import type { EnvironmentId } from "@t3tools/contracts";
@@ -66,7 +65,6 @@ function PairingForm({
const { connectionPairingUrl, onChangeConnectionPairingUrl, onConnectPress } =
useRemoteConnections();
const navigation = useNavigation();
- const routeName = useRoute().name;
const insets = useSafeAreaInsets();
const [initialPairing] = useState(() => parsePairingUrl(routePairingUrl || connectionPairingUrl));
const [hostInput, setHostInput] = useState(initialPairing.host);
@@ -178,7 +176,6 @@ function PairingForm({
return (
<SettingsScreen
- formSheet={routeName === "ConnectionsNew"}
title="Add environment"
actions={[
{
diff --git a/apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx b/apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx
index 482d553467c..1a380949e14 100644
--- a/apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx
+++ b/apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx
@@ -9,8 +9,7 @@ import {
import { useIsFocused, useNavigation, type StaticScreenProps } from "@react-navigation/native";
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
import * as Cause from "effect/Cause";
-import { use, useEffect, useRef, useState, type RefObject } from "react";
-import { HeaderHeightContext } from "@react-navigation/elements";
+import { useEffect, useRef, useState, type RefObject } from "react";
import * as Haptics from "expo-haptics";
import { Accelerometer } from "expo-sensors";
import { Pressable, StatusBar, View } from "react-native";
@@ -28,6 +27,7 @@ import {
findHeaderMenuAction,
} from "../../components/ui/headerMenu.android";
import { AppBar } from "../../components/ui/AppBar";
+import { useBarOverlap } from "../../components/ui/useBarInset";
import type { AppBarMenuItem } from "../../components/ui/AppBar.types";
import { useAppForeground } from "../../lib/appState";
import { useHardwareBack } from "../../lib/backHandler";
@@ -91,7 +91,7 @@ export function DevicePreviewScreen({
const embedded = onMaximize !== undefined;
const insets = useSafeAreaInsets();
// In a pane the stream sits below the pane's bar, which content otherwise slides under.
- const headerHeight = use(HeaderHeightContext) ?? 0;
+ const barOverlap = useBarOverlap();
// NativeColumnContent already insets the sides, so only a book fold moves the hidden-controls pill.
const handleBounds = deriveBottomControlInsets(useNativeColumnLayoutMetrics());
const { themeVariables } = useAppearancePreferences();
@@ -280,7 +280,7 @@ export function DevicePreviewScreen({
},
]}
/>
- <View style={{ height: headerHeight }} />
+ <View style={{ height: barOverlap }} />
</>
) : null}
{preview && focused && foreground ? (
diff --git a/apps/mobile/src/features/files/AttachmentFileScreen.tsx b/apps/mobile/src/features/files/AttachmentFileScreen.tsx
index 7e095eea01c..d5e560e3267 100644
--- a/apps/mobile/src/features/files/AttachmentFileScreen.tsx
+++ b/apps/mobile/src/features/files/AttachmentFileScreen.tsx
@@ -1,25 +1,19 @@
-import { Toolbar } from "../../components/ui/Toolbar";
import * as Dialog from "../../components/ui/Dialog";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
-import type { MenuAction } from "@react-native-menu/menu";
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
import {
clampFileAttachmentUploadBytes,
formatAttachmentSize,
} from "@t3tools/client-runtime/state/attachments";
import { useRef, useState } from "react";
-import { Platform, View } from "react-native";
+import { View } from "react-native";
-import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
-import { AppBar } from "../../components/ui/AppBar";
-import { Menu } from "../../components/ui/Menu";
+import { AppBar, type AppBarMenu } from "../../components/ui/AppBar";
import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
import { useAttachmentDocument } from "../../lib/attachmentDocument";
import { nativeViewerErrorMessage } from "../../lib/attachmentDownload";
import { isFileBackedComposerAttachment } from "../../lib/composerImages";
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
-import { useUniwindTheme } from "../../lib/useUniwindTheme";
import { removeComposerDraftAttachment, useComposerDraft } from "../../state/use-composer-drafts";
import { useEnvironmentServerConfig } from "../../state/entities";
import { useRefreshAssetUrl } from "../../state/assets";
@@ -44,8 +38,6 @@ type AttachmentFileScreenProps = StaticScreenProps<AttachmentFileRouteParams>;
export function AttachmentFileScreen(props: AttachmentFileScreenProps) {
const navigation = useNavigation();
const { appearance, setCodeWordBreak } = useAppearancePreferences();
- const iconColor = useUniwindTheme()["--color-icon"];
- const isAndroid = Platform.OS === "android";
const params = props.route.params;
const environmentId = params.environmentId?.trim()
? EnvironmentId.make(params.environmentId)
@@ -185,15 +177,37 @@ export function AttachmentFileScreen(props: AttachmentFileScreenProps) {
: null,
].filter((action) => action !== null);
const selectedAction = activeMode === "source" ? "source" : "preview";
- const androidMenuActions = menuActions.map((action) => ({
- id: action.id,
- title: action.title,
- image: action.icon,
- state: action.inline ? (action.id === selectedAction ? "on" : "off") : undefined,
- ...("destructive" in action ? { attributes: { destructive: true } } : {}),
- })) satisfies MenuAction[];
- const handleAndroidMenuAction = (event: { nativeEvent: { event: string } }) => {
- menuActions.find(({ id }) => id === event.nativeEvent.event)?.onPress();
+ const fileMenu: AppBarMenu = {
+ title: "File actions",
+ icon: "ellipsis",
+ items: [
+ ...(renderedMode
+ ? [
+ {
+ id: "modes",
+ inline: true,
+ items: menuActions
+ .filter(({ inline }) => inline)
+ .map((action) => ({
+ id: action.id,
+ title: action.title,
+ icon: action.icon,
+ selected: action.id === selectedAction,
+ onPress: action.onPress,
+ })),
+ },
+ ]
+ : []),
+ ...menuActions
+ .filter(({ inline }) => !inline)
+ .map((action) => ({
+ id: action.id,
+ title: action.title,
+ icon: action.icon,
+ destructive: "destructive" in action,
+ onPress: action.onPress,
+ })),
+ ],
};
const subtitle = `${draftKey ? "Draft attachment" : "Attachment"}${sizeBytes > 0 ? ` · ${formatAttachmentSize(sizeBytes)}` : ""}`;
const refresh = useRefreshAssetUrl(environmentId, resource);
@@ -208,7 +222,6 @@ export function AttachmentFileScreen(props: AttachmentFileScreenProps) {
<ZipArchiveView
name={params.name}
subtitle={subtitle}
- tintColor={iconColor}
sizeBytes={sizeBytes}
uri={uri}
isLocal={localAttachment !== null}
@@ -229,65 +242,7 @@ export function AttachmentFileScreen(props: AttachmentFileScreenProps) {
return (
<View className="flex-1 bg-sheet">
- <NativeStackScreenOptions
- options={{
- headerShown: !isAndroid,
- headerTintColor: iconColor,
- headerTitle: params.name,
- title: params.name,
- unstable_headerSubtitle: Platform.OS === "ios" ? subtitle : undefined,
- }}
- />
- {isAndroid ? (
- <AppBar
- embedded
- title={params.name}
- subtitle={subtitle}
- onBack={handleBack}
- trailing={
- <Menu
- actions={androidMenuActions}
- isAnchoredToRight
- title="File actions"
- onPressAction={handleAndroidMenuAction}
- >
- <AndroidHeaderIconButton accessibilityLabel="File actions" icon="ellipsis" />
- </Menu>
- }
- />
- ) : null}
- <Toolbar placement="right">
- <Toolbar.Menu accessibilityLabel="File actions" icon="ellipsis">
- {renderedMode ? (
- <Toolbar.Menu inline>
- {menuActions
- .filter(({ inline }) => inline)
- .map((action) => (
- <Toolbar.MenuAction
- key={action.id}
- icon={action.icon}
- isOn={action.id === selectedAction}
- onPress={action.onPress}
- >
- {action.title}
- </Toolbar.MenuAction>
- ))}
- </Toolbar.Menu>
- ) : null}
- {menuActions
- .filter(({ inline }) => !inline)
- .map((action) => (
- <Toolbar.MenuAction
- key={action.id}
- icon={action.icon}
- destructive={"destructive" in action}
- onPress={action.onPress}
- >
- {action.title}
- </Toolbar.MenuAction>
- ))}
- </Toolbar.Menu>
- </Toolbar>
+ <AppBar title={params.name} subtitle={subtitle} onBack={handleBack} menus={[fileMenu]} />
<AttachmentDocumentBody
document={document}
name={params.name}
diff --git a/apps/mobile/src/features/files/FileTreeBrowser.tsx b/apps/mobile/src/features/files/FileTreeBrowser.tsx
index e041fa5212f..cf35f7ac536 100644
--- a/apps/mobile/src/features/files/FileTreeBrowser.tsx
+++ b/apps/mobile/src/features/files/FileTreeBrowser.tsx
@@ -5,13 +5,12 @@ import type { ProjectEntry } from "@t3tools/contracts";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import { SymbolView } from "../../components/ui/AppSymbol";
import { useEffect, useRef, useState } from "react";
-import { Platform, Pressable, RefreshControl, View } from "react-native";
-import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { Pressable, RefreshControl, View } from "react-native";
import { AppText as Text } from "../../components/ui/AppText";
import { PierreEntryIcon } from "../../components/PierreEntryIcon";
import { cn } from "../../lib/cn";
-import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
+import { useContentTopInset } from "../../components/ui/useBarInset";
import {
buildFileTree,
flattenFileTree,
@@ -122,9 +121,7 @@ export function FileTreeBrowser(props: {
readonly path: string;
readonly selectedPathAtPress: string | null;
} | null>(null);
- const insets = useSafeAreaInsets();
- const columnMetrics = useNativeColumnLayoutMetrics();
- const headerInset = Platform.OS === "ios" ? (columnMetrics?.safeArea.top ?? insets.top) : 0;
+ const headerInset = useContentTopInset();
const {
onLoadDirectory,
onPreviewFile,
@@ -216,14 +213,14 @@ export function FileTreeBrowser(props: {
// Keep the list as direct screen content so UIKit can apply header insets.
return (
<LegendList
- renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
+ renderScrollComponent={NativeScrollView}
contentInsetStartAdjustment={headerInset}
alwaysBounceVertical
className="flex-1"
data={visibleNodes}
keyExtractor={(item) => item.node.path}
- contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
- automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
+ contentInsetAdjustmentBehavior="automatic"
+ automaticallyAdjustsScrollIndicatorInsets
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps="handled"
estimatedItemSize={42}
diff --git a/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx b/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx
index f3de5d80258..0bdadd4bea0 100644
--- a/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx
+++ b/apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx
@@ -2,11 +2,9 @@ import { formatFilePathForClipboard } from "@t3tools/client-runtime/media-action
import { resolvePathLinkTarget } from "@t3tools/shared/fileLinks";
import { resolveFilesystemReadAccess } from "@t3tools/client-runtime/state/filesystem";
import { environmentSession } from "../../state/session";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
import { type ReactNode, useId, useState } from "react";
import { Platform, View } from "react-native";
-import { useSafeAreaInsets } from "react-native-safe-area-context";
import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
import { EnvironmentId, type ProjectReadFileResult, ThreadId } from "@t3tools/contracts";
import { videoMimeType } from "@t3tools/shared/video";
@@ -46,9 +44,9 @@ import { FileTreeBrowser } from "./FileTreeBrowser";
import { useFileTreeEntries } from "./useFileTreeEntries";
import { preloadWorkspaceFileContents } from "./preload-workspace-file";
import { SourceFileSurface } from "./SourceFileSurface";
-import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
import { ThreadFileNavigatorPane } from "./thread-file-navigator-pane";
import { AppBar } from "../../components/ui/AppBar";
+import { useContentTopInset } from "../../components/ui/useBarInset";
import { WorkspaceFileImagePreview } from "./WorkspaceFileImagePreview";
import { WorkspaceFilePreviewError } from "./WorkspaceFilePreviewError";
import { WorkspaceFileVideoPreview } from "./WorkspaceFileVideoPreview";
@@ -88,17 +86,7 @@ function FilesBrowserHeader(props: {
closeAccessibilityLabel: "Close file search",
clearAccessibilityLabel: "Clear file search",
}}
- menus={
- Platform.OS === "android"
- ? [
- {
- title: "File options",
- icon: "ellipsis",
- items: [{ id: "refresh", title: "Refresh files", onPress: props.onRefresh }],
- },
- ]
- : undefined
- }
+ refresh={{ accessibilityLabel: "Refresh files", onPress: props.onRefresh }}
/>
);
}
@@ -106,7 +94,6 @@ function FilesBrowserHeader(props: {
function FileHeader(props: {
readonly title: string;
readonly subtitle: string;
- readonly iconColor: string;
readonly activeMode: string;
readonly fileInspectorSupported: boolean;
readonly onBack: () => void;
@@ -127,7 +114,6 @@ function FileHeader(props: {
subtitle={props.subtitle}
onBack={props.onBack}
hideBottomBorder
- options={{ headerTintColor: props.iconColor, headerTitle: props.title }}
backInSplitView={
props.fileInspectorSupported
? {
@@ -231,10 +217,8 @@ function FileContent(props: {
}) {
// Reopening a mutable host file must not reuse a poster from an earlier visit.
const thumbnailInstanceId = useId();
- const insets = useSafeAreaInsets();
- const columnMetrics = useNativeColumnLayoutMetrics();
- const reservedHeaderInset =
- Platform.OS === "ios" && props.truncated ? (columnMetrics?.safeArea.top ?? insets.top) : 0;
+ const barOverlap = useContentTopInset();
+ const reservedHeaderInset = props.truncated ? barOverlap : 0;
const isMarkdown = isMarkdownPreviewFile(props.relativePath);
const delimiter = filePreviewDelimiter({ name: props.relativePath });
const isBrowserFile = isWorkspaceBrowserPreviewPath(props.relativePath);
@@ -386,14 +370,22 @@ function useThreadFilesWorkspace(params: {
}
function FilesUnavailable({
+ title = "Files unavailable",
detail = "This thread does not have an active workspace path.",
+ onBack,
}: {
+ title?: string;
detail?: string;
+ onBack: () => void;
}) {
return (
- <View className="flex-1 items-center justify-center bg-sheet px-6">
- <NativeStackScreenOptions options={{ title: "Files" }} />
- <EmptyState title="Files unavailable" detail={detail} />
+ <View className="flex-1 bg-sheet">
+ <AppBar title="Files" onBack={onBack} onBackToList={onBack} hideBottomBorder />
+ <ScreenContent>
+ <View className="flex-1 items-center justify-center px-6">
+ <EmptyState title={title} detail={detail} />
+ </View>
+ </ScreenContent>
</View>
);
}
@@ -428,7 +420,7 @@ function FilesToolbarBottomFade() {
export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
const navigation = useNavigation();
- const { fileInspector, layout } = useAdaptiveWorkspaceLayout();
+ const { fileInspector } = useAdaptiveWorkspaceLayout();
const [searchQuery, setSearchQuery] = useState("");
const { themeAppearance: highlightTheme } = useAppearancePreferences();
const { cwd, environmentId, projectName, selectedThread, threadId } = useThreadFilesWorkspace(
@@ -524,11 +516,14 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
return <LoadingScreen message="Checking file access..." messagePlacement="above-spinner" />;
}
return (
- <FilesUnavailable detail={fileAccess.error ?? "This connection cannot read host files."} />
+ <FilesUnavailable
+ detail={fileAccess.error ?? "This connection cannot read host files."}
+ onBack={handleReturnToThread}
+ />
);
}
if (cwd === null) {
- return <FilesUnavailable />;
+ return <FilesUnavailable onBack={handleReturnToThread} />;
}
if (hasFileInspector) {
@@ -541,8 +536,8 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
);
}
- const content = (
- <>
+ return (
+ <View className="flex-1">
<FilesBrowserHeader
projectName={projectName}
searchQuery={searchQuery}
@@ -550,7 +545,7 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
onRefresh={entriesQuery.refresh}
onBack={handleReturnToThread}
/>
- <ScreenContent insetHorizontal={layout.usesSplitView}>
+ <ScreenContent>
<FileTreeBrowser
key={JSON.stringify([environmentId, cwd])}
revealSelection={entriesQuery.revealSelection}
@@ -575,17 +570,14 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
/>
<FilesToolbarBottomFade />
</ScreenContent>
- </>
+ </View>
);
-
- return Platform.OS === "android" ? <View className="flex-1 bg-header">{content}</View> : content;
}
export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
const navigation = useNavigation();
const { fileInspector } = useAdaptiveWorkspaceLayout();
const { appearance, setCodeWordBreak } = useAppearancePreferences();
- const iconColor = useUniwindTheme()["--color-icon"];
const params = props.route.params;
const targetLine = normalizeRouteLine(firstRouteParam(params.line));
const { cwd, environmentId, projectName, relativePath, selectedThread, threadId } =
@@ -912,19 +904,23 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
);
}
return withInspector(
- <FilesUnavailable detail={fileAccess.error ?? "This connection cannot read host files."} />,
+ <FilesUnavailable
+ detail={fileAccess.error ?? "This connection cannot read host files."}
+ onBack={handleBack}
+ />,
);
}
if (cwd === null) {
- return withInspector(<FilesUnavailable />);
+ return withInspector(<FilesUnavailable onBack={handleBack} />);
}
if (relativePath === null) {
return withInspector(
- <View className="flex-1 items-center justify-center bg-sheet px-6">
- <NativeStackScreenOptions options={{ title: "Files" }} />
- <EmptyState title="File unavailable" detail="This file path is invalid." />
- </View>,
+ <FilesUnavailable
+ title="File unavailable"
+ detail="This file path is invalid."
+ onBack={handleBack}
+ />,
);
}
@@ -935,7 +931,7 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
}
if (directoryPath !== null) {
return withInspector(
- <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-sheet"}>
+ <View className="flex-1 bg-sheet">
<FilesBrowserHeader
projectName={directoryPath}
searchQuery={searchQuery}
@@ -978,7 +974,6 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
<FileHeader
title={basename(relativePath)}
subtitle={headerSubtitle}
- iconColor={iconColor}
activeMode={resolvedActiveMode}
fileInspectorSupported={fileInspector.supported}
onBack={handleBack}
diff --git a/apps/mobile/src/features/files/WorkspaceFileWebPreview.tsx b/apps/mobile/src/features/files/WorkspaceFileWebPreview.tsx
index 78f5e183f4e..e105d208249 100644
--- a/apps/mobile/src/features/files/WorkspaceFileWebPreview.tsx
+++ b/apps/mobile/src/features/files/WorkspaceFileWebPreview.tsx
@@ -1,7 +1,7 @@
import { useState } from "react";
-import { Platform, View } from "react-native";
+import { View } from "react-native";
import { WebView } from "react-native-webview";
-import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
+import { SafeAreaView } from "react-native-safe-area-context";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import { AppText as Text } from "../../components/ui/AppText";
@@ -11,7 +11,7 @@ import { PdfPreview } from "../../components/PdfPreview";
import { ControlPill } from "../../components/ui/ControlPill";
import { useHardwareBack } from "../../lib/backHandler";
import { isPdfPreviewUri } from "../../lib/pdfPreview";
-import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
+import { useContentTopInset } from "../../components/ui/useBarInset";
export function WorkspaceFileWebPreview(props: { readonly uri: string | null }) {
if (props.uri === null) {
@@ -21,10 +21,7 @@ export function WorkspaceFileWebPreview(props: { readonly uri: string | null })
}
function DocumentWebPreview(props: { readonly uri: string }) {
- const insets = useSafeAreaInsets();
- const columnMetrics = useNativeColumnLayoutMetrics();
- // iOS headers float over this column, so content starts below them.
- const headerInset = Platform.OS === "ios" ? (columnMetrics?.safeArea.top ?? insets.top) : 0;
+ const headerInset = useContentTopInset();
const [loadProgress, setLoadProgress] = useState(0);
const [loadError, setLoadError] = useState<string | null>(null);
const [linkedPdf, setLinkedPdf] = useState<string | null>(null);
diff --git a/apps/mobile/src/features/files/ZipArchiveView.test.tsx b/apps/mobile/src/features/files/ZipArchiveView.test.tsx
index d6b1c4740c4..5b9dc240697 100644
--- a/apps/mobile/src/features/files/ZipArchiveView.test.tsx
+++ b/apps/mobile/src/features/files/ZipArchiveView.test.tsx
@@ -102,32 +102,32 @@ vi.mock("@react-navigation/native", () => ({
navigation.remove = enabled ? remove : null;
},
}));
-vi.mock("react-native-safe-area-context", () => ({
- useSafeAreaInsets: () => ({ top: 0, right: 0, bottom: 0, left: 0 }),
-}));
vi.mock("../../native/NativeScrollViewMarker", () => ({ NativeScrollView: () => null }));
-vi.mock("../../native/StackHeader", () => ({ NativeStackScreenOptions: () => null }));
-vi.mock("../../components/ui/Toolbar", () => {
- const Slot = (props: { readonly children?: ReactNode }) => <div>{props.children}</div>;
- return {
- Toolbar: Object.assign(Slot, {
- Button: () => null,
- Menu: Slot,
- MenuAction: (props: {
- readonly children?: ReactNode;
- readonly disabled?: boolean;
- readonly onPress?: () => void;
- }) => (
- <button disabled={props.disabled} onClick={props.onPress}>
- {props.children}
+vi.mock("../../components/ui/AppBar", () => {
+ interface Item {
+ readonly id: string;
+ readonly title?: string;
+ readonly disabled?: boolean;
+ readonly onPress?: () => void;
+ readonly items?: ReadonlyArray<Item>;
+ }
+ const renderItems = (items: ReadonlyArray<Item>): ReactNode =>
+ items.map((item) =>
+ item.items ? (
+ renderItems(item.items)
+ ) : (
+ <button key={item.id} disabled={item.disabled} onClick={item.onPress}>
+ {item.title}
</button>
),
- }),
+ );
+ return {
+ AppBar: (props: {
+ readonly menus?: ReadonlyArray<{ readonly items: ReadonlyArray<Item> }>;
+ }) => <div>{props.menus?.map((menu) => renderItems(menu.items))}</div>,
};
});
-vi.mock("../../components/ui/AppBar", () => ({ AppBar: () => null }));
-vi.mock("../../components/ui/AndroidScreenHeader", () => ({ AndroidHeaderIconButton: () => null }));
-vi.mock("../../components/ui/Menu", () => ({ Menu: () => null }));
+vi.mock("../../components/ui/useBarInset", () => ({ useContentTopInset: () => 0 }));
vi.mock("../../components/ui/AppSymbol", () => ({ SymbolView: () => null }));
vi.mock("../../components/ui/Progress", () => ({ Progress: () => null }));
vi.mock("../../components/PierreEntryIcon", () => ({ PierreEntryIcon: () => null }));
@@ -182,7 +182,6 @@ function setup() {
const props: ComponentProps<typeof ZipArchiveView> = {
name: "archive.zip",
subtitle: "ZIP",
- tintColor: "#000000",
sizeBytes: 0,
uri: "file:///first.zip",
isLocal: true,
diff --git a/apps/mobile/src/features/files/ZipArchiveView.tsx b/apps/mobile/src/features/files/ZipArchiveView.tsx
index 66290e9d6c3..fb79723d6e3 100644
--- a/apps/mobile/src/features/files/ZipArchiveView.tsx
+++ b/apps/mobile/src/features/files/ZipArchiveView.tsx
@@ -17,20 +17,17 @@ import { fetch } from "expo/fetch";
import { File } from "expo-file-system";
import { useNavigation, usePreventRemove } from "@react-navigation/native";
import { useEffect, useEffectEvent, useRef, useState } from "react";
-import { Keyboard, Platform, Pressable, ScrollView, TextInput, View } from "react-native";
-import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { Keyboard, Pressable, ScrollView, TextInput, View } from "react-native";
import { PierreEntryIcon } from "../../components/PierreEntryIcon";
import { AppBar } from "../../components/ui/AppBar";
+import { useContentTopInset } from "../../components/ui/useBarInset";
import { SymbolView } from "../../components/ui/AppSymbol";
import { AppText as Text } from "../../components/ui/AppText";
import { Button } from "../../components/ui/Button";
import { EmptyState } from "../../components/ui/EmptyState";
import { Progress } from "../../components/ui/Progress";
-import { Toolbar } from "../../components/ui/Toolbar";
-import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
import { NativeScrollView } from "../../native/NativeScrollViewMarker";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
import * as Dialog from "../../components/ui/Dialog";
import { FilePreviewModal } from "../../components/FilePreviewModal";
import {
@@ -296,67 +293,32 @@ function ZipTreeRowView(props: {
function ZipArchiveHeader(props: {
readonly name: string;
readonly subtitle: string;
- readonly tintColor: string;
readonly onSave: () => void;
readonly onRemove: (() => void) | null;
}) {
const navigation = useNavigation();
- const isAndroid = Platform.OS === "android";
return (
- <>
- <NativeStackScreenOptions
- options={{
- headerShown: !isAndroid,
- headerTintColor: props.tintColor,
- headerTitle: props.name,
- title: props.name,
- unstable_headerSubtitle: isAndroid ? undefined : props.subtitle,
- }}
- />
- {isAndroid ? (
- <AppBar
- embedded
- title={props.name}
- subtitle={props.subtitle}
- onBack={() => {
- if (navigation.canGoBack()) navigation.goBack();
- }}
- actions={[
- { accessibilityLabel: "Save ZIP", icon: "square.and.arrow.up", onPress: props.onSave },
- ...(props.onRemove
- ? [
- {
- accessibilityLabel: "Remove from draft",
- icon: "trash" as const,
- onPress: props.onRemove,
- destructive: true,
- overflowOnly: true,
- },
- ]
- : []),
- ]}
- />
- ) : (
- <Toolbar placement="right">
- {props.onRemove ? (
- <Toolbar.Menu accessibilityLabel="ZIP actions" icon="ellipsis">
- <Toolbar.MenuAction icon="square.and.arrow.up" onPress={props.onSave}>
- Save ZIP
- </Toolbar.MenuAction>
- <Toolbar.MenuAction icon="trash" destructive onPress={props.onRemove}>
- Remove from draft
- </Toolbar.MenuAction>
- </Toolbar.Menu>
- ) : (
- <Toolbar.Button
- accessibilityLabel="Save ZIP"
- icon="square.and.arrow.up"
- onPress={props.onSave}
- />
- )}
- </Toolbar>
- )}
- </>
+ <AppBar
+ title={props.name}
+ subtitle={props.subtitle}
+ onBack={() => {
+ if (navigation.canGoBack()) navigation.goBack();
+ }}
+ actions={[
+ { accessibilityLabel: "Save ZIP", icon: "square.and.arrow.up", onPress: props.onSave },
+ ...(props.onRemove
+ ? [
+ {
+ accessibilityLabel: "Remove from draft",
+ icon: "trash" as const,
+ onPress: props.onRemove,
+ destructive: true,
+ overflowOnly: true,
+ },
+ ]
+ : []),
+ ]}
+ />
);
}
@@ -436,13 +398,13 @@ function ZipArchiveList(props: {
return (
<View className="flex-1 bg-sheet">
<LegendList
- renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
+ renderScrollComponent={NativeScrollView}
contentInsetStartAdjustment={props.headerInset}
className="flex-1"
data={rows}
keyExtractor={(row) => `${row.node.entry ? "f" : "d"}:${row.node.path}`}
- contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
- automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
+ contentInsetAdjustmentBehavior="automatic"
+ automaticallyAdjustsScrollIndicatorInsets
estimatedItemSize={44}
recycleItems
keyboardDismissMode="on-drag"
@@ -509,7 +471,6 @@ function ZipArchiveList(props: {
export function ZipArchiveView(props: {
readonly name: string;
readonly subtitle: string;
- readonly tintColor: string;
readonly sizeBytes: number;
readonly uri: string | null;
readonly isLocal: boolean;
@@ -529,9 +490,7 @@ export function ZipArchiveView(props: {
const selected = selection && selection.archive === archive ? selection.entry : null;
const entryOpen = selected !== null;
usePreventRemove(entryOpen, () => setSelection(null));
- const insets = useSafeAreaInsets();
- const columnMetrics = useNativeColumnLayoutMetrics();
- const headerInset = Platform.OS === "ios" ? (columnMetrics?.safeArea.top ?? insets.top) : 0;
+ const headerInset = useContentTopInset();
return (
<View className="flex-1 bg-sheet">
{entryOpen ? null : (
@@ -542,7 +501,6 @@ export function ZipArchiveView(props: {
? `${archive.fileCount} ${archive.fileCount === 1 ? "file" : "files"}${props.sizeBytes > 0 ? ` · ${formatAttachmentSize(props.sizeBytes)}` : ""}`
: props.subtitle
}
- tintColor={props.tintColor}
onSave={props.onSave}
onRemove={props.onRemove}
/>
@@ -753,73 +711,49 @@ function ZipEntryView(props: {
});
const folders = entry.path.split("/").slice(0, -1);
const subtitle = `${[props.archiveName, ...folders].join(" / ")} · ${formatAttachmentSize(entry.sizeBytes)}`;
- const isAndroid = Platform.OS === "android";
return (
<View className="flex-1 bg-sheet">
- <NativeStackScreenOptions
- options={{
- headerShown: !isAndroid,
- headerTitle: entry.name,
- title: entry.name,
- unstable_headerSubtitle: isAndroid ? undefined : subtitle,
- }}
+ <AppBar
+ title={entry.name}
+ subtitle={subtitle}
+ onBack={props.onBack}
+ menus={[
+ {
+ title: "File actions",
+ icon: "ellipsis",
+ items: [
+ ...(renderedMode
+ ? [
+ {
+ id: "toggle-rendered",
+ title: rendered ? "Show source" : "Show preview",
+ icon: rendered ? "doc.text" : "eye",
+ onPress: () => setRendered((value) => !value),
+ },
+ ]
+ : []),
+ ...(canAddToChat
+ ? [
+ {
+ id: "add-to-chat",
+ title: "Add to chat",
+ icon: "plus.bubble",
+ disabled: busy !== null,
+ onPress: addToChat,
+ },
+ ]
+ : []),
+ {
+ id: "save",
+ title: "Save file",
+ icon: "square.and.arrow.up",
+ disabled: busy !== null,
+ onPress: save,
+ },
+ ],
+ },
+ ]}
/>
- {isAndroid ? (
- <AppBar
- embedded
- title={entry.name}
- subtitle={subtitle}
- onBack={props.onBack}
- actions={[
- ...(renderedMode
- ? [
- {
- accessibilityLabel: rendered ? "Show source" : "Show preview",
- icon: rendered ? ("doc.text" as const) : ("eye" as const),
- onPress: () => setRendered((value) => !value),
- },
- ]
- : []),
- ...(canAddToChat
- ? [
- {
- accessibilityLabel: "Add to chat",
- icon: "plus.bubble" as const,
- onPress: addToChat,
- disabled: busy !== null,
- },
- ]
- : []),
- {
- accessibilityLabel: "Save file",
- icon: "square.and.arrow.up",
- onPress: save,
- loading: busy === "save",
- },
- ]}
- />
- ) : (
- <Toolbar placement="right">
- <Toolbar.Menu accessibilityLabel="File actions" icon="ellipsis">
- {renderedMode ? (
- <Toolbar.MenuAction
- icon={rendered ? "doc.text" : "eye"}
- onPress={() => setRendered((value) => !value)}
- >
- {rendered ? "Show source" : "Show preview"}
- </Toolbar.MenuAction>
- ) : null}
- {canAddToChat ? (
- <Toolbar.MenuAction icon="plus.bubble" disabled={busy !== null} onPress={addToChat}>
- Add to chat
- </Toolbar.MenuAction>
- ) : null}
- <Toolbar.MenuAction icon="square.and.arrow.up" disabled={busy !== null} onPress={save}>
- Save file
- </Toolbar.MenuAction>
- </Toolbar.Menu>
- </Toolbar>
- )}
{content.status === "failed" ? (
<ScrollView contentContainerClassName="flex-grow items-center justify-center px-6">
<EmptyState
diff --git a/apps/mobile/src/features/files/useFileTreeEntries.test.tsx b/apps/mobile/src/features/files/useFileTreeEntries.test.tsx
index 8d707fd379a..4076dd865fa 100644
--- a/apps/mobile/src/features/files/useFileTreeEntries.test.tsx
+++ b/apps/mobile/src/features/files/useFileTreeEntries.test.tsx
@@ -141,6 +141,7 @@ vi.mock("react-native", () => ({
vi.mock("react-native-safe-area-context", () => ({ useSafeAreaInsets: () => ({ top: 0 }) }));
vi.mock("../../native/NativeScrollViewMarker", () => ({ NativeScrollView: Nothing }));
vi.mock("../../native/native-layout-metrics", () => ({ useNativeColumnLayoutMetrics: () => null }));
+vi.mock("../../components/ui/useBarInset", () => ({ useContentTopInset: () => 0 }));
vi.mock("@legendapp/list/react-native", () => ({
LegendList: <T,>(props: {
data: ReadonlyArray<T>;
diff --git a/apps/mobile/src/features/home/HomeHeader.android.tsx b/apps/mobile/src/features/home/HomeHeader.android.tsx
index 70c23920b76..ed161ef9abf 100644
--- a/apps/mobile/src/features/home/HomeHeader.android.tsx
+++ b/apps/mobile/src/features/home/HomeHeader.android.tsx
@@ -1,5 +1,4 @@
import type { MenuAction } from "@react-native-menu/menu";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
import { ThreadListToolbar } from "./ThreadListToolbar";
import type { HomeHeaderProps } from "./HomeHeader.types";
@@ -83,16 +82,13 @@ export function HomeHeader(props: HomeHeaderProps) {
};
return (
- <>
- <NativeStackScreenOptions options={{ headerShown: false }} />
- <ThreadListToolbar
- searchQuery={props.searchQuery}
- onSearchQueryChange={props.onSearchQueryChange}
- filterActions={menuActions}
- filterCustomized={hasCustomListOptions}
- onFilterSelect={(event) => handleMenuAction({ nativeEvent: { event } })}
- onOpenEnvironments={props.onOpenEnvironments}
- />
- </>
+ <ThreadListToolbar
+ searchQuery={props.searchQuery}
+ onSearchQueryChange={props.onSearchQueryChange}
+ filterActions={menuActions}
+ filterCustomized={hasCustomListOptions}
+ onFilterSelect={(event) => handleMenuAction({ nativeEvent: { event } })}
+ onOpenEnvironments={props.onOpenEnvironments}
+ />
);
}
diff --git a/apps/mobile/src/features/home/HomeRouteScreen.tsx b/apps/mobile/src/features/home/HomeRouteScreen.tsx
index 40d540104ee..b83e0178268 100644
--- a/apps/mobile/src/features/home/HomeRouteScreen.tsx
+++ b/apps/mobile/src/features/home/HomeRouteScreen.tsx
@@ -163,29 +163,23 @@ export function HomeRouteScreen() {
return (
<>
<NativeStackScreenOptions
- options={
- Platform.OS === "android"
- ? { headerShown: false }
- : {
- title: "",
- headerTitle: "",
- unstable_headerLeftItems: () => [],
- headerSearchBarOptions: undefined,
- unstable_headerRightItems: () => [],
- unstable_headerToolbarItems: () => [],
- }
- }
+ options={{
+ title: "",
+ headerTitle: "",
+ unstable_headerLeftItems: () => [],
+ headerSearchBarOptions: undefined,
+ unstable_headerRightItems: () => [],
+ unstable_headerToolbarItems: () => [],
+ }}
/>
- {Platform.OS === "ios" ? (
- <Toolbar placement="left">
- <Toolbar.Button
- accessibilityLabel="New task"
- icon="square.and.pencil"
- onPress={startNewTask}
- />
- </Toolbar>
- ) : null}
- {Platform.OS === "android" ? <AppBar embedded title="Threads" /> : null}
+ <Toolbar placement="left">
+ <Toolbar.Button
+ accessibilityLabel="New task"
+ icon="square.and.pencil"
+ onPress={startNewTask}
+ />
+ </Toolbar>
+ <AppBar embedded title="Threads" />
<WorkspaceEmptyDetail
onAddConnection={
Platform.OS === "android" && !catalogState.hasConnections
@@ -207,17 +201,14 @@ export function HomeRouteScreen() {
>
<>
{/* Screen options merge shallowly; restore the header after split view. */}
- {workspace !== null && Platform.OS === "ios" ? null : (
+ {workspace !== null ? null : (
<NativeStackScreenOptions
optionsVersion={headerWidth}
- options={{
- ...getConnectionAwareBrandHeaderOptions({
- headerWidth,
- trailingItemCount: nativePrimaryColumn && deviceType === "pad" ? 2 : 1,
- onOpenEnvironments: () => openSettings(navigation, "SettingsEnvironments"),
- }),
- headerShown: Platform.OS !== "android",
- }}
+ options={getConnectionAwareBrandHeaderOptions({
+ headerWidth,
+ trailingItemCount: nativePrimaryColumn && deviceType === "pad" ? 2 : 1,
+ onOpenEnvironments: () => openSettings(navigation, "SettingsEnvironments"),
+ })}
/>
)}
<HomeHeader
diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsx
index 94e5327e45e..77d0cd2e66c 100644
--- a/apps/mobile/src/features/home/HomeScreen.tsx
+++ b/apps/mobile/src/features/home/HomeScreen.tsx
@@ -797,7 +797,7 @@ export function HomeScreen(props: HomeScreenProps) {
onTouchStart={(event) => trackListTouches(event, true)}
onTouchEnd={(event) => trackListTouches(event, false)}
onTouchCancel={(event) => trackListTouches(event, false)}
- renderScrollComponent={Platform.OS === "ios" ? renderHomeScrollView : undefined}
+ renderScrollComponent={renderHomeScrollView}
data={threadListV2Items}
renderItem={renderV2Item}
keyExtractor={v2KeyExtractor}
@@ -826,7 +826,7 @@ export function HomeScreen(props: HomeScreenProps) {
}
ListEmptyComponent={v2ListEmpty}
style={{ flex: 1 }}
- automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
+ automaticallyAdjustsScrollIndicatorInsets
// UIKit owns the bar's inset, so a minimizing bar and a resized column move
// the list in the same frame as the bar.
contentInsetAdjustmentBehavior="automatic"
diff --git a/apps/mobile/src/features/layout/useOpenWorkspaceDetail.ts b/apps/mobile/src/features/layout/useOpenWorkspaceDetail.ts
new file mode 100644
index 00000000000..994b1ecc0a4
--- /dev/null
+++ b/apps/mobile/src/features/layout/useOpenWorkspaceDetail.ts
@@ -0,0 +1,23 @@
+import { StackActions, useNavigation } from "@react-navigation/native";
+import { Platform } from "react-native";
+
+import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";
+import type {
+ WorkspaceDetail,
+ WorkspaceDetailSheet,
+} from "../workspace/workspace-detail-selection";
+
+/**
+ * Opens a thread or pull request from another page. Android shows one detail page at a time, so
+ * it selects the detail; iOS pushes it over the current page, so Back returns there. A `sheet`
+ * opens over the detail on Android and on its own over the current page on iOS.
+ */
+export function useOpenWorkspaceDetail() {
+ const navigation = useNavigation();
+ const selectDetail = useSelectWorkspaceDetail();
+ return (detail: WorkspaceDetail, sheet?: WorkspaceDetailSheet) => {
+ if (Platform.OS === "android") selectDetail(detail, sheet);
+ else if (sheet) navigation.navigate(sheet.name, sheet.params);
+ else navigation.dispatch(StackActions.push(detail.name, detail.params));
+ };
+}
diff --git a/apps/mobile/src/features/projects/AddProjectRepositoryRoute.tsx b/apps/mobile/src/features/projects/AddProjectRepositoryRoute.tsx
index 8812c7347a5..3a1b640b419 100644
--- a/apps/mobile/src/features/projects/AddProjectRepositoryRoute.tsx
+++ b/apps/mobile/src/features/projects/AddProjectRepositoryRoute.tsx
@@ -1,9 +1,4 @@
import type { StaticScreenProps } from "@react-navigation/native";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
-import {
- addProjectRemoteSourceLabel,
- parseAddProjectRemoteSource,
-} from "@t3tools/client-runtime/operations/projects";
import { AddProjectRepositoryScreen } from "./AddProjectScreen";
@@ -15,14 +10,5 @@ type AddProjectRepositoryRouteParams = {
export function AddProjectRepositoryRoute({
route,
}: StaticScreenProps<AddProjectRepositoryRouteParams>) {
- const params = route.params ?? {};
- const source = Array.isArray(params.source) ? params.source[0] : params.source;
- const title = addProjectRemoteSourceLabel(parseAddProjectRemoteSource(source));
-
- return (
- <>
- <NativeStackScreenOptions options={{ title }} />
- <AddProjectRepositoryScreen {...params} />
- </>
- );
+ return <AddProjectRepositoryScreen {...(route.params ?? {})} />;
}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
index b298094f74b..f80e9a5a093 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
@@ -1,4 +1,3 @@
-import { Toolbar } from "../../components/ui/Toolbar";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import { useAtomRefresh } from "@effect/atom-react";
import { useFocusEffect, useNavigation, type StaticScreenProps } from "@react-navigation/native";
@@ -9,7 +8,7 @@ import {
import { AsyncResult } from "effect/reactivity";
import type { PullRequestThreadComment } from "@t3tools/contracts";
import { useRef, useState } from "react";
-import { Platform, ScrollView, View } from "react-native";
+import { ScrollView, View } from "react-native";
import { KeyboardAvoidingView, useKeyboardState } from "react-native-keyboard-controller";
import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -17,7 +16,6 @@ import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/
import { AppBar } from "../../components/ui/AppBar";
import { Button } from "../../components/ui/Button";
import { GlassSurface } from "../../components/ui/GlassSurface";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
import { relativeTime } from "../../lib/time";
import { composerPullRequests } from "../../state/pull-requests";
import { useAtomCommand } from "../../state/use-atom-command";
@@ -136,38 +134,23 @@ function Discussion({ params }: { params: PullRequestParams & { readonly discuss
return (
<PullRequestMarkdownRepository params={params} changeRequest={detail.data}>
<KeyboardAvoidingView automaticOffset behavior="height" className="flex-1 bg-screen">
- <NativeStackScreenOptions
- options={{ title: "Discussion", unstable_headerSubtitle: `#${params.number}` }}
+ <AppBar
+ title="Discussion"
+ subtitle={`#${params.number}`}
+ onBack={() => navigation.goBack()}
+ actions={
+ permissions.canResolve && thread
+ ? [
+ {
+ accessibilityLabel: resolveLabel,
+ icon: thread.isResolved ? "arrow.uturn.backward" : "checkmark",
+ disabled: busy || activity.isPending,
+ onPress: () => void toggleResolved(),
+ },
+ ]
+ : []
+ }
/>
- {Platform.OS === "android" ? (
- <AppBar
- embedded
- title="Discussion"
- subtitle={`#${params.number}`}
- onBack={() => navigation.goBack()}
- actions={
- permissions.canResolve && thread
- ? [
- {
- accessibilityLabel: resolveLabel,
- icon: thread.isResolved ? "arrow.uturn.backward" : "checkmark",
- disabled: busy || activity.isPending,
- onPress: () => void toggleResolved(),
- },
- ]
- : []
- }
- />
- ) : null}
- {permissions.canResolve && thread ? (
- <Toolbar placement="right">
- <Toolbar.Button
- label={resolveLabel}
- disabled={busy || activity.isPending}
- onPress={() => void toggleResolved()}
- />
- </Toolbar>
- ) : null}
<ScrollViewMarker style={{ flex: 1 }}>
<ScrollView
className="flex-1"
diff --git a/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx b/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx
index b03a35e0096..72449458788 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx
@@ -4,7 +4,7 @@ import { AnimatedLegendList } from "@legendapp/list/reanimated";
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
import type { PullRequestChangeBreakdown } from "@t3tools/contracts";
import { useState } from "react";
-import { Platform, View } from "react-native";
+import { View } from "react-native";
import Animated from "react-native-reanimated";
import { PierreEntryIcon } from "../../components/PierreEntryIcon";
import { AppText as Text } from "../../components/ui/AppText";
@@ -16,7 +16,6 @@ import { Menu } from "../../components/ui/Menu";
import { RowPressable } from "../../components/ui/RowPressable";
import { ScreenContent } from "../../components/ui/ScreenContent";
import { SheetHeader } from "../../components/ui/SheetHeader";
-import { Toolbar } from "../../components/ui/Toolbar";
import { composerPullRequests } from "../../state/pull-requests";
import { useEnvironmentQuery } from "../../state/query";
import type { ReviewParsedDiff, ReviewRenderableFile } from "../review/reviewModel";
@@ -413,31 +412,28 @@ export function PullRequestFilesSheet({ route }: StaticScreenProps<PullRequestDi
return (
<View collapsable={false} className="flex-1 bg-sheet">
<SheetHeader
- presentation={Platform.OS === "android" ? "inline" : "native"}
title="Changed files"
subtitle={`#${params.number} · ${params.commit?.slice(0, 7) ?? params.repository}`}
onClose={() => navigation.goBack()}
- // iOS gets the native menu below; SheetHeader would render this as a custom bar item.
- trailing={Platform.OS === "android" ? <FileFilterMenu filter={filter} /> : undefined}
+ menus={[
+ {
+ title: "Filter review files",
+ icon: "line.3.horizontal.decrease",
+ items: [
+ {
+ id: "hide-tests",
+ title: "Hide test files",
+ icon: "line.3.horizontal.decrease",
+ selected: filter.hideTestFiles,
+ onPress: filter.toggle,
+ },
+ ],
+ },
+ ]}
/>
- <Toolbar placement="right">
- <Toolbar.Menu
- title="Review files"
- accessibilityLabel="Filter review files"
- icon="line.3.horizontal.decrease"
- >
- <Toolbar.MenuAction
- icon="line.3.horizontal.decrease"
- isOn={filter.hideTestFiles}
- onPress={filter.toggle}
- >
- <Toolbar.Label>Hide test files</Toolbar.Label>
- </Toolbar.MenuAction>
- </Toolbar.Menu>
- </Toolbar>
<ScreenContent>
<AnimatedLegendList
- renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
+ renderScrollComponent={NativeScrollView}
className="flex-1"
data={parsed.kind === "files" ? groupByDirectory(parsed.files, collapsed) : []}
keyExtractor={(item) => item.key}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestFilterSearchScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestFilterSearchScreen.tsx
index b932412d2f1..8be52952fe5 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestFilterSearchScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestFilterSearchScreen.tsx
@@ -117,7 +117,6 @@ export function PullRequestFilterSearchScreen({
placeholder={placeholder}
closeAccessibilityLabel={kind === "labels" ? "Close label filter" : "Close author filter"}
clearAccessibilityLabel={kind === "labels" ? "Clear label search" : "Clear author search"}
- searchTextChangeId="pr-filter-option-search"
query={query}
onQueryChange={setQuery}
>
diff --git a/apps/mobile/src/features/pull-requests/PullRequestLabelsScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestLabelsScreen.tsx
index 85a2d70da2b..56464842fa8 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestLabelsScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestLabelsScreen.tsx
@@ -75,7 +75,6 @@ export function PullRequestLabelsScreen({ route }: StaticScreenProps<PullRequest
placeholder="Search labels"
closeAccessibilityLabel="Close labels"
clearAccessibilityLabel="Clear label search"
- searchTextChangeId="pr-label-search"
query={query}
onQueryChange={setQuery}
>
diff --git a/apps/mobile/src/features/pull-requests/PullRequestReviewersScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestReviewersScreen.tsx
index 829a62d4b4b..dad9ba1c1aa 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestReviewersScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestReviewersScreen.tsx
@@ -1,4 +1,4 @@
-import { SheetHeader } from "../../components/ui/SheetHeader";
+import { AppBar, type AppBarSearch } from "../../components/ui/AppBar";
import { AsyncResult } from "effect/reactivity";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import { usePullRequestConnected } from "./usePullRequestConnected";
@@ -8,48 +8,23 @@ import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime"
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
import type { PullRequestReviewerCandidate } from "@t3tools/contracts";
import { useRef, useState } from "react";
-import {
- FlatList,
- Platform,
- Pressable,
- ScrollView,
- View,
- type ScrollViewProps,
-} from "react-native";
-import { useSafeAreaInsets } from "react-native-safe-area-context";
-import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
+import { FlatList, Pressable, ScrollView, View } from "react-native";
+import { NativeScrollView } from "../../native/NativeScrollViewMarker";
+import { useContentTopInset, useSearchToolbarInset } from "../../components/ui/useBarInset";
import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText";
import { EmptyState } from "../../components/ui/EmptyState";
import { Button } from "../../components/ui/Button";
import { SymbolView } from "../../components/ui/AppSymbol";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
-import { useNativeLayoutMetrics } from "../../native/native-layout-metrics";
import { composerPullRequests } from "../../state/pull-requests";
import { useEnvironmentQuery } from "../../state/query";
import { useAtomCommand } from "../../state/use-atom-command";
-import {
- createNativeMailSearchToolbarItem,
- NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED,
-} from "../layout/native-mail-search-toolbar";
import { PullRequestAvatar } from "./PullRequestPresentation";
import { pullRequestTarget, type PullRequestParams } from "./usePullRequestDiff";
-function ReviewerScrollView(props: ScrollViewProps) {
- return (
- <ScrollViewMarker style={{ flex: 1 }}>
- <ScrollView {...props} contentInsetAdjustmentBehavior="automatic" />
- </ScrollViewMarker>
- );
-}
-
export function PullRequestReviewersScreen({ route }: StaticScreenProps<PullRequestParams>) {
const navigation = useNavigation();
- const insets = useSafeAreaInsets();
+ const contentTopInset = useContentTopInset();
const listRef = useRef<FlatList<PullRequestReviewerCandidate>>(null);
- const nativeMetrics = useNativeLayoutMetrics();
- const integratedSearch =
- NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED &&
- (!nativeMetrics || nativeMetrics.verticalBarEdge === "none");
const target = pullRequestTarget(route.params);
const detail = useEnvironmentQuery(composerPullRequests.detail(target));
const pr = detail.data;
@@ -90,7 +65,7 @@ export function PullRequestReviewersScreen({ route }: StaticScreenProps<PullRequ
const search = (next: string) => {
setQuery(next);
listRef.current?.scrollToOffset({
- offset: Platform.OS === "ios" ? -insets.top : 0,
+ offset: -contentTopInset,
animated: false,
});
};
@@ -124,70 +99,41 @@ export function PullRequestReviewersScreen({ route }: StaticScreenProps<PullRequ
}
};
const listCandidates = pr?.capabilities.reviewers.listCandidates === true;
- const searchOptions = {
- placeholder: "Search reviewers",
- autoCapitalize: "none" as const,
- onChangeText: (event: { nativeEvent: { text: string } }) => search(event.nativeEvent.text),
- onCancelButtonPress: () => search(""),
- hideNavigationBar: false,
- hideWhenScrolling: false,
- obscureBackground: false,
- allowToolbarIntegration: integratedSearch,
- placement: integratedSearch ? ("automatic" as const) : ("stacked" as const),
- };
+ const reviewerSearch: AppBarSearch | undefined = listCandidates
+ ? {
+ mode: "inline",
+ compactToolbar: true,
+ value: query,
+ onChangeText: search,
+ placeholder: "Search reviewers",
+ }
+ : undefined;
+ const searchToolbarInset = useSearchToolbarInset(reviewerSearch);
return (
<View className="flex-1 bg-sheet">
- <SheetHeader
+ <AppBar
title="Request review"
subtitle={`#${route.params.number} · ${route.params.repository}`}
onClose={() => navigation.goBack()}
- accessibilityLabel="Close request review"
- />
- <NativeStackScreenOptions
- options={{
- headerSearchBarOptions: listCandidates ? searchOptions : undefined,
- unstable_headerToolbarItems: () =>
- listCandidates && integratedSearch
- ? [
- createNativeMailSearchToolbarItem({
- placeholder: "Search reviewers",
- onSearchTextChange: search,
- showsSearchDismissButton: true,
- searchTextChangeId: "pr-reviewer-search",
- }),
- ]
- : [],
- }}
+ closeAccessibilityLabel="Close request review"
+ search={reviewerSearch}
/>
{listCandidates ? (
<FlatList
ref={listRef}
data={candidates}
keyExtractor={(candidate) => `${candidate.kind}:${candidate.id}`}
- renderScrollComponent={
- Platform.OS === "ios" ? (props) => <ReviewerScrollView {...props} /> : undefined
- }
- contentInsetAdjustmentBehavior="never"
+ renderScrollComponent={NativeScrollView}
+ contentInsetAdjustmentBehavior="automatic"
automaticallyAdjustKeyboardInsets
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps="handled"
- contentContainerStyle={{ paddingBottom: 24 }}
+ contentContainerStyle={{ paddingBottom: 24 + searchToolbarInset }}
ListHeaderComponent={
<View className="gap-3 px-4 py-4">
<Text className="text-xs text-foreground-muted">
Tap someone to request a review. Tap a requested reviewer to remove the request.
</Text>
- {Platform.OS === "android" ? (
- <TextInput
- accessibilityLabel="Search reviewers"
- placeholder="Search reviewers"
- placeholderTextColorClassName="accent-foreground-muted"
- value={query}
- onChangeText={search}
- autoCapitalize="none"
- className="min-h-11 rounded-xl bg-grouped-card px-3 text-sm"
- />
- ) : null}
{!allowed ? (
<Text className="text-xs text-foreground-muted">
Requesting reviews requires write access and an open {singular}.
diff --git a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
index 306864ecd23..12c755a0b5a 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
@@ -1,4 +1,3 @@
-import { Toolbar } from "../../components/ui/Toolbar";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import { Chip } from "../../components/ui/Chip";
import { pullRequestTabOffset } from "./pullRequestTabScroll";
@@ -27,8 +26,6 @@ import {
pullRequestActionLabel,
} from "./pullRequestActions";
import * as Clipboard from "expo-clipboard";
-import { Menu } from "../../components/ui/Menu";
-import { IconButton } from "../../components/ui/IconButton";
import { Button } from "../../components/ui/Button";
import { usePullRequestReviewDraft } from "./usePullRequestReviewDraft";
import { usePullRequestFilesViewed } from "./usePullRequestFilesViewed";
@@ -56,31 +53,21 @@ import { PullRequestOverviewLoading } from "./PullRequestOverviewLoading";
import { copyPullRequestLink, sharePullRequestLink } from "./pullRequestLink";
import { pullRequestStatus } from "./pullRequestStatus";
import { use, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
-import {
- Linking,
- Platform,
- Pressable,
- RefreshControl,
- ScrollView,
- type ScrollViewProps,
- StyleSheet,
- View,
-} from "react-native";
-import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
+import { Linking, Platform, Pressable, RefreshControl, StyleSheet, View } from "react-native";
+import { NativeScrollView } from "../../native/NativeScrollViewMarker";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppText as Text } from "../../components/ui/AppText";
import { AppBar } from "../../components/ui/AppBar";
+import { useContentTopInset } from "../../components/ui/useBarInset";
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
-import { useWorkspaceSidebarHeaderItem } from "../layout/useWorkspaceSidebarHeaderItem";
import { useAndroidWorkspaceBack } from "../workspace/useAndroidWorkspaceNavigation";
import { EmptyState } from "../../components/ui/EmptyState";
import { SegmentedControl } from "../../components/ui/SegmentedControl";
import { SymbolView } from "../../components/ui/AppSymbol";
import { ScreenContent } from "../../components/ui/ScreenContent";
import { RelativeTime } from "../../components/RelativeTime";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
import { usePullRequestConnected } from "./usePullRequestConnected";
import { usePullRequestLiveChecks } from "./usePullRequestLiveChecks";
import { pullRequestLabelColor } from "./pullRequestList";
@@ -138,14 +125,6 @@ import {
const EMPTY_IDS: readonly string[] = [];
-function PullRequestTabScrollView(props: ScrollViewProps) {
- return (
- <ScrollViewMarker style={{ flex: 1 }}>
- <ScrollView {...props} />
- </ScrollViewMarker>
- );
-}
-
function usePullRequestActivityRows(params: PullRequestParams, filter: ActivityFilter) {
const navigation = useNavigation();
const result = useEnvironmentQuery(composerPullRequests.activity(requestTarget(params)));
@@ -346,12 +325,12 @@ function usePullRequestToolbarHeight(bottomInset: number) {
export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestParams>) {
const returnToList = useAndroidWorkspaceBack("pullRequests");
const { layout } = useAdaptiveWorkspaceLayout();
- const sidebarHeaderItem = useWorkspaceSidebarHeaderItem();
const navigation = useNavigation();
const insets = useSafeAreaInsets();
const [toolbarHeight, setToolbarHeight] = usePullRequestToolbarHeight(insets.bottom);
- // Only iOS lists run under the bars; Android lists start below the header.
- const barInsets = Platform.OS === "ios" ? insets : { top: 0, bottom: 0 };
+ const contentTopInset = useContentTopInset();
+ // Only iOS lists run under the bottom safe area; Android's floating toolbar pads its own.
+ const contentBottomInset = Platform.OS === "ios" ? insets.bottom : 0;
const params = route.params;
usePullRequestEnvironmentFallback(params);
const connected = usePullRequestConnected(params.environmentId);
@@ -373,7 +352,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
// has its own offset, which only its next scroll would record here.
const currentScrollOffset = useRef<{ tab: typeof section; offset: number }>({
tab: "overview",
- offset: -barInsets.top,
+ offset: -contentTopInset,
});
const bodyY = useRef(0);
const [headerHeight, setHeaderHeight] = useState(0);
@@ -397,9 +376,9 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
const current =
currentScrollOffset.current.tab === from
? currentScrollOffset.current.offset
- : (scrollOffsets.current[from] ?? -barInsets.top);
+ : (scrollOffsets.current[from] ?? -contentTopInset);
scrollOffsets.current[section] = current;
- const headerEnd = Math.max(-barInsets.top, bodyY.current - barInsets.top);
+ const headerEnd = Math.max(-contentTopInset, bodyY.current - contentTopInset);
const offset = pullRequestTabOffset(current, scrollOffsets.current[next], headerEnd);
requestedSection.current = next;
scrollOffsets.current[next] = offset;
@@ -466,7 +445,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
});
const jumpToFiles = () => {
scrollViews.current.overview?.scrollToOffset({
- offset: bodyY.current + filesY.current - barInsets.top,
+ offset: bodyY.current + filesY.current - contentTopInset,
animated: true,
});
pendingFilesJump.current = false;
@@ -481,237 +460,126 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
};
return (
<PullRequestMarkdownRepository params={params} changeRequest={pr}>
- <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
- <NativeStackScreenOptions
- options={{
- title: `#${params.number}`,
- headerTitle: `#${params.number}`,
- unstable_headerSubtitle: connected
- ? params.repository
- : `${params.repository} · Offline`,
- unstable_headerLeftItems: sidebarHeaderItem ? () => [sidebarHeaderItem] : undefined,
- }}
- optionsVersion={[sidebarHeaderItem]}
+ <View className="flex-1 android:bg-header ios:bg-screen">
+ <AppBar
+ title={`#${params.number}`}
+ subtitle={connected ? params.repository : `${params.repository} · Offline`}
+ onBack={layout.usesSplitView ? undefined : returnToList}
+ menus={[
+ {
+ title: `${capitalizeTerm(terminology.singular)} actions`,
+ icon: "ellipsis",
+ items: [
+ ...(permissions.verdicts.length
+ ? [
+ {
+ id: "submit-review",
+ title: "Submit review",
+ icon: "text.bubble",
+ onPress: () =>
+ navigation.navigate("PullRequestReview", { ...params, mode: "review" }),
+ },
+ ]
+ : []),
+ ...(permissions.canComment
+ ? [
+ {
+ id: "add-comment",
+ title: "Add comment",
+ icon: "plus.bubble",
+ onPress: () =>
+ navigation.navigate("PullRequestReview", { ...params, mode: "comment" }),
+ },
+ ]
+ : []),
+ ...(permissions.canEditChangeRequest
+ ? [
+ {
+ id: "edit-title",
+ title: "Edit title",
+ icon: "pencil",
+ onPress: () =>
+ navigation.navigate("PullRequestEdit", { ...params, field: "title" }),
+ },
+ {
+ id: "edit-description",
+ title: "Edit description",
+ icon: "doc.text",
+ disabled: description.pending,
+ subtitle: description.pending ? "Saving…" : undefined,
+ onPress: () =>
+ navigation.navigate("PullRequestEdit", { ...params, field: "body" }),
+ },
+ ]
+ : []),
+ ...(maintainerEdits.visible
+ ? [
+ {
+ id: "maintainer-edits",
+ title: "Allow edits from maintainers",
+ icon: "pencil",
+ selected: maintainerEdits.value,
+ disabled: maintainerEdits.saving,
+ subtitle: maintainerEdits.subtitle,
+ onPress: maintainerEdits.toggle,
+ },
+ ]
+ : []),
+ ...(identity
+ ? [
+ {
+ id: "open-on-provider",
+ title: openOnProviderLabel(identity.provider),
+ icon: "arrow.up.right",
+ onPress: () => void Linking.openURL(identity.url),
+ },
+ {
+ id: "copy-link",
+ title: "Copy link",
+ icon: "link",
+ onPress: () => copyPullRequestLink(identity),
+ },
+ {
+ id: "share",
+ title: "Share…",
+ icon: "square.and.arrow.up",
+ onPress: () => sharePullRequestLink(identity),
+ },
+ ]
+ : []),
+ ...(stateAction
+ ? [
+ {
+ id: "state",
+ title: pullRequestActionLabel(stateAction, terminology),
+ icon: PR_ACTION_ICONS[stateAction],
+ destructive: stateAction === "close",
+ onPress: runStateAction,
+ },
+ ]
+ : []),
+ ...(showsDeleteBranch
+ ? [
+ {
+ id: "delete-branch",
+ title: pullRequestActionLabel("delete-branch", terminology),
+ icon: PR_ACTION_ICONS["delete-branch"],
+ destructive: true,
+ disabled: !action.available("delete-branch"),
+ subtitle: action.busy
+ ? "Deleting…"
+ : connected
+ ? pr.headBranch
+ : "Reconnect to delete this branch.",
+ onPress: confirmDeleteBranch,
+ },
+ ]
+ : []),
+ ],
+ },
+ ]}
/>
- {Platform.OS === "android" ? (
- <AppBar
- embedded
- title={`#${params.number}${connected ? "" : " · Offline"}`}
- subtitle={params.repository}
- onBack={layout.usesSplitView ? undefined : returnToList}
- actions={[
- ...(permissions.verdicts.length
- ? [
- {
- accessibilityLabel: "Submit review",
- icon: "text.bubble" as const,
- onPress: () =>
- navigation.navigate("PullRequestReview", { ...params, mode: "review" }),
- },
- ]
- : []),
- ...(permissions.canComment
- ? [
- {
- accessibilityLabel: "Add comment",
- icon: "plus.bubble" as const,
- onPress: () =>
- navigation.navigate("PullRequestReview", { ...params, mode: "comment" }),
- },
- ]
- : []),
- ...(permissions.canEditChangeRequest
- ? [
- {
- accessibilityLabel: "Edit title",
- icon: "pencil" as const,
- overflowOnly: true,
- onPress: () =>
- navigation.navigate("PullRequestEdit", { ...params, field: "title" }),
- },
- {
- accessibilityLabel: "Edit description",
- icon: "doc.text" as const,
- disabled: description.pending,
- subtitle: description.pending ? "Saving…" : undefined,
- overflowOnly: true,
- onPress: () =>
- navigation.navigate("PullRequestEdit", { ...params, field: "body" }),
- },
- ]
- : []),
- ...(maintainerEdits.visible
- ? [
- {
- accessibilityLabel: "Allow edits from maintainers",
- icon: "pencil" as const,
- selected: maintainerEdits.value,
- disabled: maintainerEdits.saving,
- subtitle: maintainerEdits.subtitle,
- overflowOnly: true,
- onPress: maintainerEdits.toggle,
- },
- ]
- : []),
- ...(identity
- ? [
- {
- accessibilityLabel: openOnProviderLabel(identity.provider),
- icon: "arrow.up.right" as const,
- onPress: () => void Linking.openURL(identity.url),
- },
- {
- accessibilityLabel: "Copy link",
- icon: "link" as const,
- overflowOnly: true,
- onPress: () => copyPullRequestLink(identity),
- },
- {
- accessibilityLabel: "Share…",
- icon: "square.and.arrow.up" as const,
- overflowOnly: true,
- onPress: () => sharePullRequestLink(identity),
- },
- ]
- : []),
- ...(stateAction
- ? [
- {
- accessibilityLabel: pullRequestActionLabel(stateAction, terminology),
- icon: PR_ACTION_ICONS[stateAction],
- destructive: stateAction === "close",
- overflowOnly: true,
- onPress: runStateAction,
- },
- ]
- : []),
- ...(showsDeleteBranch
- ? [
- {
- accessibilityLabel: pullRequestActionLabel("delete-branch", terminology),
- icon: PR_ACTION_ICONS["delete-branch"],
- disabled: !action.available("delete-branch"),
- destructive: true,
- overflowOnly: true,
- onPress: confirmDeleteBranch,
- },
- ]
- : []),
- ]}
- />
- ) : null}
- <Toolbar placement="right">
- <Toolbar.Menu
- title={capitalizeTerm(terminology.singular)}
- accessibilityLabel={`${capitalizeTerm(terminology.singular)} actions`}
- icon="ellipsis"
- >
- {permissions.verdicts.length ? (
- <Toolbar.MenuAction
- icon="text.bubble"
- onPress={() =>
- navigation.navigate("PullRequestReview", { ...params, mode: "review" })
- }
- >
- <Toolbar.Label>Submit review</Toolbar.Label>
- </Toolbar.MenuAction>
- ) : null}
- {permissions.canComment ? (
- <Toolbar.MenuAction
- icon="plus.bubble"
- onPress={() =>
- navigation.navigate("PullRequestReview", { ...params, mode: "comment" })
- }
- >
- <Toolbar.Label>Add comment</Toolbar.Label>
- </Toolbar.MenuAction>
- ) : null}
- {permissions.canEditChangeRequest ? (
- <Toolbar.MenuAction
- icon="pencil"
- onPress={() =>
- navigation.navigate("PullRequestEdit", { ...params, field: "title" })
- }
- >
- <Toolbar.Label>Edit title</Toolbar.Label>
- </Toolbar.MenuAction>
- ) : null}
- {permissions.canEditChangeRequest ? (
- <Toolbar.MenuAction
- icon="doc.text"
- disabled={description.pending}
- subtitle={description.pending ? "Saving…" : undefined}
- onPress={() => navigation.navigate("PullRequestEdit", { ...params, field: "body" })}
- >
- <Toolbar.Label>Edit description</Toolbar.Label>
- </Toolbar.MenuAction>
- ) : null}
- {maintainerEdits.visible ? (
- <Toolbar.MenuAction
- icon="pencil"
- isOn={maintainerEdits.value}
- disabled={maintainerEdits.saving}
- subtitle={maintainerEdits.subtitle}
- onPress={maintainerEdits.toggle}
- >
- <Toolbar.Label>Allow edits from maintainers</Toolbar.Label>
- </Toolbar.MenuAction>
- ) : null}
- {identity ? (
- <Toolbar.MenuAction
- icon="arrow.up.right"
- onPress={() => void Linking.openURL(identity.url)}
- >
- <Toolbar.Label>{openOnProviderLabel(identity.provider)}</Toolbar.Label>
- </Toolbar.MenuAction>
- ) : null}
- {identity ? (
- <Toolbar.MenuAction icon="link" onPress={() => copyPullRequestLink(identity)}>
- <Toolbar.Label>Copy link</Toolbar.Label>
- </Toolbar.MenuAction>
- ) : null}
- {identity ? (
- <Toolbar.MenuAction
- icon="square.and.arrow.up"
- onPress={() => sharePullRequestLink(identity)}
- >
- <Toolbar.Label>Share…</Toolbar.Label>
- </Toolbar.MenuAction>
- ) : null}
- {stateAction ? (
- <Toolbar.MenuAction
- icon={PR_ACTION_ICONS[stateAction]}
- destructive={stateAction === "close"}
- onPress={runStateAction}
- >
- <Toolbar.Label>{pullRequestActionLabel(stateAction, terminology)}</Toolbar.Label>
- </Toolbar.MenuAction>
- ) : null}
- {showsDeleteBranch ? (
- <Toolbar.MenuAction
- icon={PR_ACTION_ICONS["delete-branch"]}
- destructive
- disabled={!action.available("delete-branch")}
- subtitle={
- action.busy
- ? "Deleting…"
- : connected
- ? pr.headBranch
- : "Reconnect to delete this branch."
- }
- onPress={confirmDeleteBranch}
- >
- <Toolbar.Label>
- {pullRequestActionLabel("delete-branch", terminology)}
- </Toolbar.Label>
- </Toolbar.MenuAction>
- ) : null}
- </Toolbar.Menu>
- </Toolbar>
- <ScreenContent
- insetHorizontal={layout.usesSplitView}
- onLayout={(event) => setViewportHeight(event.nativeEvent.layout.height)}
- >
+ <ScreenContent onLayout={(event) => setViewportHeight(event.nativeEvent.layout.height)}>
{(["overview", "guide", "activity"] as const)
.filter((tab) => tab !== "guide" || guidesEnabled)
.map((tab) => (
@@ -734,13 +602,11 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
currentScrollOffset.current = { tab, offset };
}}
className="flex-1"
- renderScrollComponent={
- Platform.OS === "ios" ? PullRequestTabScrollView : undefined
- }
+ renderScrollComponent={NativeScrollView}
// UIKit owns the bar's inset, so a minimizing bar and a resized column
// move the list in the same frame as the bar.
contentInsetAdjustmentBehavior="automatic"
- contentInsetStartAdjustment={barInsets.top}
+ contentInsetStartAdjustment={contentTopInset}
// RN scrollTo clamps against raw insets and ignores the automatic bar inset.
scrollToOverflowEnabled
refreshControl={
@@ -761,7 +627,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
pendingDescriptionJump.current = false;
// Collapse changes the scroll range; restore the heading after that layout commits.
scrollViews.current.overview?.scrollToOffset({
- offset: bodyY.current + descriptionY.current - barInsets.top,
+ offset: bodyY.current + descriptionY.current - contentTopInset,
animated: false,
});
}}
@@ -772,7 +638,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
// Short tabs must still be tall enough to preserve the collapsed header.
minHeight: Math.max(
0,
- viewportHeight + headerHeight - barInsets.top - barInsets.bottom,
+ viewportHeight + headerHeight - contentTopInset - contentBottomInset,
),
}}
data={[
@@ -960,10 +826,7 @@ export function PullRequestFileRouteScreen(props: PullRequestFileRouteProps) {
const title = props.route.params.commit ? "Commit changes" : "Changes";
return (
<View className="flex-1 bg-screen">
- <NativeStackScreenOptions options={{ title, headerTitle: title }} />
- {Platform.OS === "android" ? (
- <AppBar embedded title={title} onBack={() => navigation.goBack()} />
- ) : null}
+ <AppBar title={title} onBack={() => navigation.goBack()} />
<View className="flex-1 items-center justify-center">
<AppActivityIndicator accessibilityLabel="Loading changes" />
</View>
@@ -972,9 +835,9 @@ export function PullRequestFileRouteScreen(props: PullRequestFileRouteProps) {
}
function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
- const { layout } = useAdaptiveWorkspaceLayout();
const navigation = useNavigation();
const insets = useSafeAreaInsets();
+ const contentTopInset = useContentTopInset();
const [toolbarHeight, setToolbarHeight] = usePullRequestToolbarHeight(insets.bottom);
const commit = route.params.commit;
const detail = useEnvironmentQuery(composerPullRequests.detail(requestTarget(route.params)));
@@ -1150,122 +1013,84 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
const seekingFile = !targetFile && result.nextCursor !== null;
const loadingDiff = (result.isPending && !data.rows.length) || (seekingFile && !result.error);
return (
- <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
- <NativeStackScreenOptions
- options={{
- title,
- headerTitle: title,
- unstable_headerSubtitle: `${commit ? commit.slice(0, 7) : `#${route.params.number}`} · ${data.files.length} ${data.files.length === 1 ? "file" : "files"}${filter.hideTestFiles && filter.hiddenCount ? ` · ${filter.hiddenCount} ${filter.hiddenCount === 1 ? "test" : "tests"} hidden` : ""}`,
- }}
+ <View className="flex-1 android:bg-header ios:bg-screen">
+ <AppBar
+ title={title}
+ subtitle={`${commit ? commit.slice(0, 7) : `#${route.params.number}`} · ${data.files.length} ${data.files.length === 1 ? "file" : "files"}${filter.hideTestFiles && filter.hiddenCount ? ` · ${filter.hiddenCount} ${filter.hiddenCount === 1 ? "test" : "tests"} hidden` : ""}`}
+ onBack={() => navigation.goBack()}
+ menus={[
+ {
+ title: "Diff options",
+ icon: "ellipsis",
+ items: [
+ ...(permissions.verdicts.length
+ ? [
+ {
+ id: "submit-review",
+ title: "Submit review",
+ icon: "text.bubble",
+ onPress: () =>
+ navigation.navigate("PullRequestReview", {
+ ...route.params,
+ mode: "review",
+ }),
+ },
+ ]
+ : []),
+ ...(permissions.canComment
+ ? [
+ {
+ id: "comment-on-pr",
+ title: "Add comment",
+ icon: "plus.bubble",
+ onPress: () =>
+ navigation.navigate("PullRequestReview", {
+ ...route.params,
+ mode: "comment",
+ }),
+ },
+ ]
+ : []),
+ {
+ id: "word-wrap",
+ title: "Word wrap",
+ icon: "text.alignleft",
+ selected: appearance.codeWordBreak,
+ onPress: () => setCodeWordBreak(!appearance.codeWordBreak),
+ },
+ {
+ id: "hide-tests",
+ title: "Hide test files",
+ icon: "line.3.horizontal.decrease",
+ selected: filter.hideTestFiles,
+ onPress: toggleTestFiles,
+ },
+ ...(selectedRow && selectedFile && canCommentOnDiff
+ ? [
+ {
+ id: "comment",
+ title: route.params.replacingDraftId
+ ? "Move draft to this line"
+ : "Add review comment",
+ icon: "bubble.left",
+ onPress: () => commentOnLine(),
+ },
+ ]
+ : []),
+ ...(selectedRow && selectedFile
+ ? [
+ {
+ id: "copy",
+ title: "Copy line",
+ icon: "document.on.document",
+ onPress: () => void Clipboard.setStringAsync(selectedRow.content ?? ""),
+ },
+ ]
+ : []),
+ ],
+ },
+ ]}
/>
- {Platform.OS === "android" ? (
- <AppBar
- embedded
- title={title}
- onBack={() => navigation.goBack()}
- trailing={
- <Menu
- actions={[
- {
- id: "word-wrap",
- title: "Word wrap",
- image: "text.alignleft",
- state: appearance.codeWordBreak ? "on" : "off",
- },
- {
- id: "hide-tests",
- title: "Hide test files",
- image: "line.3.horizontal.decrease",
- state: filter.hideTestFiles ? "on" : "off",
- },
- ...(permissions.verdicts.length
- ? [{ id: "submit-review", title: "Submit review", image: "text.bubble" }]
- : []),
- ...(permissions.canComment
- ? [{ id: "comment-on-pr", title: "Add comment", image: "plus.bubble" }]
- : []),
- ...(selectedRow && selectedFile
- ? [
- ...(canCommentOnDiff ? [{ id: "comment", title: "Add review comment" }] : []),
- { id: "copy", title: "Copy line" },
- ]
- : []),
- ]}
- onPressAction={({ nativeEvent }) => {
- if (nativeEvent.event === "word-wrap") setCodeWordBreak(!appearance.codeWordBreak);
- else if (nativeEvent.event === "hide-tests") toggleTestFiles();
- else if (
- nativeEvent.event === "submit-review" ||
- nativeEvent.event === "comment-on-pr"
- )
- navigation.navigate("PullRequestReview", {
- ...route.params,
- mode: nativeEvent.event === "submit-review" ? "review" : "comment",
- });
- else if (nativeEvent.event === "comment") commentOnLine();
- else void Clipboard.setStringAsync(selectedRow?.content ?? "");
- }}
- >
- <View pointerEvents="none">
- <IconButton icon="ellipsis" accessibilityLabel="Diff options" />
- </View>
- </Menu>
- }
- />
- ) : null}
- <Toolbar placement="right">
- <Toolbar.Menu title="Diff options" accessibilityLabel="Diff options" icon="ellipsis">
- {permissions.verdicts.length ? (
- <Toolbar.MenuAction
- icon="text.bubble"
- onPress={() =>
- navigation.navigate("PullRequestReview", { ...route.params, mode: "review" })
- }
- >
- <Toolbar.Label>Submit review</Toolbar.Label>
- </Toolbar.MenuAction>
- ) : null}
- {permissions.canComment ? (
- <Toolbar.MenuAction
- icon="plus.bubble"
- onPress={() =>
- navigation.navigate("PullRequestReview", { ...route.params, mode: "comment" })
- }
- >
- <Toolbar.Label>Add comment</Toolbar.Label>
- </Toolbar.MenuAction>
- ) : null}
- <Toolbar.MenuAction
- icon="text.alignleft"
- isOn={appearance.codeWordBreak}
- onPress={() => setCodeWordBreak(!appearance.codeWordBreak)}
- >
- <Toolbar.Label>Word wrap</Toolbar.Label>
- </Toolbar.MenuAction>
- <Toolbar.MenuAction
- icon="line.3.horizontal.decrease"
- isOn={filter.hideTestFiles}
- onPress={toggleTestFiles}
- >
- <Toolbar.Label>Hide test files</Toolbar.Label>
- </Toolbar.MenuAction>
- {selectedRow && selectedFile && canCommentOnDiff ? (
- <Toolbar.MenuAction icon="bubble.left" onPress={() => commentOnLine()}>
- <Toolbar.Label>
- {route.params.replacingDraftId ? "Move draft to this line" : "Add review comment"}
- </Toolbar.Label>
- </Toolbar.MenuAction>
- ) : null}
- {selectedRow && selectedFile ? (
- <Toolbar.MenuAction
- icon="document.on.document"
- onPress={() => void Clipboard.setStringAsync(selectedRow.content ?? "")}
- >
- <Toolbar.Label>Copy line</Toolbar.Label>
- </Toolbar.MenuAction>
- ) : null}
- </Toolbar.Menu>
- </Toolbar>
{route.params.replacingDraftId ? (
<Text className="px-4 py-2 text-xs text-foreground-muted">
Select a current line, then choose “Move draft to this line” from its menu.
@@ -1277,7 +1102,7 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
{staleDiff ? (
<View
className="flex-row items-center gap-2 px-4 py-2"
- style={{ paddingTop: Platform.OS === "ios" ? insets.top + 8 : 8 }}
+ style={{ paddingTop: contentTopInset + 8 }}
>
<Text className="min-w-0 flex-1 text-xs text-foreground-muted">
The branch changed. Reload before adding line comments.
@@ -1294,10 +1119,10 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
/>
</View>
) : null}
- <ScreenContent insetHorizontal={layout.usesSplitView}>
+ <ScreenContent>
<View className="flex-1" collapsable={false}>
{loadingDiff || result.error ? (
- <View style={{ paddingTop: Platform.OS === "ios" && !staleDiff ? insets.top : 0 }}>
+ <View style={{ paddingTop: staleDiff ? 0 : contentTopInset }}>
<PullRequestReadStatus
pending={loadingDiff}
error={result.error}
@@ -1373,7 +1198,7 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
appearanceScheme={themeAppearance}
rowHeight={nativeReviewDiffStyle.rowHeight}
contentWidth={NATIVE_REVIEW_DIFF_CONTENT_WIDTH}
- contentInsetTop={Platform.OS === "ios" ? (staleDiff ? 0 : insets.top) : undefined}
+ contentInsetTop={staleDiff ? 0 : contentTopInset}
contentInsetBottom={Platform.OS === "android" ? toolbarHeight : insets.bottom}
contentResetKey={`pull-request:${route.params.environmentId}:${route.params.repository}:${route.params.number}:${commit ?? "all"}`}
/>
@@ -1383,7 +1208,7 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
!result.isPending &&
!result.error &&
!seekingFile ? (
- <View style={{ paddingTop: Platform.OS === "ios" ? insets.top : 0 }}>
+ <View style={{ paddingTop: contentTopInset }}>
<EmptyState
title="Only test files changed"
detail="Test files are hidden from this review."
diff --git a/apps/mobile/src/features/pull-requests/PullRequestSearchSheet.tsx b/apps/mobile/src/features/pull-requests/PullRequestSearchSheet.tsx
index b7020c684f0..860de90f275 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestSearchSheet.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestSearchSheet.tsx
@@ -1,95 +1,44 @@
import { useNavigation } from "@react-navigation/native";
-import { useRef, type ReactNode } from "react";
-import { Platform, View, type TextInputInstance } from "react-native";
+import type { ReactNode } from "react";
+import { View } from "react-native";
import { AppBar } from "../../components/ui/AppBar";
-import { SearchField } from "../../components/ui/SearchField";
-import { SheetHeader } from "../../components/ui/SheetHeader";
-import { Toolbar } from "../../components/ui/Toolbar";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
-import {
- createNativeMailSearchToolbarItem,
- NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET,
-} from "../layout/native-mail-search-toolbar";
+import { NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET } from "../layout/native-mail-search-toolbar";
-/**
- * A searchable picker over a pull request list or a pull request: a pushed card with a search
- * field on Android, a sheet with the native search toolbar on iOS.
- */
+/** A searchable picker over a pull request list or a pull request. */
export function PullRequestSearchSheet(props: {
readonly title: string;
readonly placeholder: string;
readonly closeAccessibilityLabel: string;
readonly clearAccessibilityLabel: string;
- readonly searchTextChangeId: string;
readonly query: string;
readonly onQueryChange: (query: string) => void;
/** Renders the list, given the bottom padding that keeps its end clear of the search bar. */
readonly children: (list: { readonly paddingBottom: number }) => ReactNode;
}) {
const navigation = useNavigation();
- const integratedSearch = useNativeMailSearchToolbar();
- const searchRef = useRef<TextInputInstance>(null);
- const list = props.children({
- paddingBottom: integratedSearch ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 16 : 16,
- });
- if (Platform.OS === "android") {
- return (
- <View className="flex-1 bg-sheet" collapsable={false}>
- <AppBar embedded title={props.title} hideBottomBorder onBack={() => navigation.goBack()} />
- <View className="bg-header px-4 pb-3 pt-1">
- <SearchField
- inputRef={searchRef}
- accessibilityLabel={props.placeholder}
- clearAccessibilityLabel={props.clearAccessibilityLabel}
- onChangeText={props.onQueryChange}
- placeholder={props.placeholder}
- value={props.query}
- />
- </View>
- {list}
- </View>
- );
- }
+ // The compact search toolbar floats over the end of the list.
+ const bottomSearch = useNativeMailSearchToolbar();
return (
- <View className="flex-1 bg-sheet">
- <SheetHeader
+ <View className="flex-1 bg-sheet" collapsable={false}>
+ <AppBar
title={props.title}
onClose={() => navigation.goBack()}
- accessibilityLabel={props.closeAccessibilityLabel}
- />
- <NativeStackScreenOptions
- options={{
- unstable_headerToolbarItems: integratedSearch
- ? () => [
- createNativeMailSearchToolbarItem({
- placeholder: props.placeholder,
- onSearchTextChange: props.onQueryChange,
- showsSearchDismissButton: true,
- searchTextChangeId: props.searchTextChangeId,
- }),
- ]
- : undefined,
- headerSearchBarOptions: integratedSearch
- ? undefined
- : {
- placeholder: props.placeholder,
- allowToolbarIntegration: true,
- autoCapitalize: "none",
- hideNavigationBar: false,
- obscureBackground: false,
- onChangeText: (event) => props.onQueryChange(event.nativeEvent.text),
- onCancelButtonPress: () => props.onQueryChange(""),
- },
+ closeAccessibilityLabel={props.closeAccessibilityLabel}
+ hideBottomBorder
+ search={{
+ mode: "inline",
+ compactToolbar: true,
+ value: props.query,
+ onChangeText: props.onQueryChange,
+ placeholder: props.placeholder,
+ clearAccessibilityLabel: props.clearAccessibilityLabel,
}}
/>
- {integratedSearch ? null : (
- <Toolbar placement="bottom">
- <Toolbar.SearchBarSlot />
- </Toolbar>
- )}
- {list}
+ {props.children({
+ paddingBottom: bottomSearch ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 16 : 16,
+ })}
</View>
);
}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestSheetContent.tsx b/apps/mobile/src/features/pull-requests/PullRequestSheetContent.tsx
index d3830ea82ab..7990a7fdd2f 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestSheetContent.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestSheetContent.tsx
@@ -34,7 +34,6 @@ export function PullRequestSheetContent(props: {
style={android ? { maxHeight: windowHeight * 0.92 } : undefined}
>
<SheetHeader
- presentation={android ? "inline" : "native"}
title={props.title}
subtitle={props.subtitle}
onCancel={() => navigation.goBack()}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestStackCard.tsx b/apps/mobile/src/features/pull-requests/PullRequestStackCard.tsx
index bdf4399f1e6..0b2637b7c6b 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestStackCard.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestStackCard.tsx
@@ -1,7 +1,6 @@
-import { StackActions, useNavigation } from "@react-navigation/native";
import { useState } from "react";
-import { Platform, View } from "react-native";
-import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";
+import { View } from "react-native";
+import { useOpenWorkspaceDetail } from "../layout/useOpenWorkspaceDetail";
import { AppText as Text } from "../../components/ui/AppText";
import { PullRequestCardGroup, PullRequestCardRow } from "./PullRequestControls";
import { pullRequestLayerParams } from "./pullRequestStack";
@@ -15,8 +14,7 @@ export function PullRequestStackCard(props: {
readonly params: PullRequestParams;
readonly state: PullRequestStackState;
}) {
- const navigation = useNavigation();
- const selectDetail = useSelectWorkspaceDetail();
+ const openDetail = useOpenWorkspaceDetail();
const [expanded, setExpanded] = useState(false);
const stack = props.state.stack;
if (!stack) {
@@ -67,14 +65,13 @@ export function PullRequestStackCard(props: {
onPress={
selected
? undefined
- : () => {
- const params = withKnownPullRequestSummary(
- pullRequestLayerParams(props.params, layer.number),
- );
- if (Platform.OS === "android")
- selectDetail({ name: "PullRequest", params });
- else navigation.dispatch(StackActions.push("PullRequest", params));
- }
+ : () =>
+ openDetail({
+ name: "PullRequest",
+ params: withKnownPullRequestSummary(
+ pullRequestLayerParams(props.params, layer.number),
+ ),
+ })
}
last={index === stack.layers.length - 1}
/>
diff --git a/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx
index 14ea14036a5..3e84e665257 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx
@@ -9,19 +9,12 @@ import { LegendList, type LegendListRef } from "@legendapp/list/react-native";
import { useNavigation } from "@react-navigation/native";
import { use, useMemo, useRef, useState, type ReactNode } from "react";
import { useAtomValue } from "@effect/atom-react";
-import {
- Keyboard,
- Platform,
- Pressable,
- RefreshControl,
- ScrollView,
- View,
- type ScrollViewProps,
-} from "react-native";
-import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
+import { Keyboard, Platform, Pressable, RefreshControl, View } from "react-native";
+import { NativeScrollView } from "../../native/NativeScrollViewMarker";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppText as Text } from "../../components/ui/AppText";
+import { useContentTopInset } from "../../components/ui/useBarInset";
import { SymbolView } from "../../components/ui/AppSymbol";
import { EmptyState } from "../../components/ui/EmptyState";
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
@@ -53,14 +46,6 @@ import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
import { useSearchScrollRestoration } from "../workspace/useSearchScrollRestoration";
import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";
-function PullRequestScrollView(props: ScrollViewProps) {
- return (
- <ScrollViewMarker style={{ flex: 1 }}>
- <ScrollView {...props} />
- </ScrollViewMarker>
- );
-}
-
function PullRequestListError(props: { readonly message: string }) {
const [expanded, setExpanded] = useState(false);
return (
@@ -113,6 +98,7 @@ export function PullRequestsScreen(
const { environments } = useWorkspaceState();
const configs = useAtomValue(environmentServerConfigsAtom);
const insets = useSafeAreaInsets();
+ const contentTopInset = useContentTopInset();
// UIKit insets the list by its column's safe area, which this context can report as 0.
const columnSafeBottom = useNativeColumnLayoutMetrics()?.safeArea.bottom;
const bottomSafeArea =
@@ -122,7 +108,7 @@ export function PullRequestsScreen(
const [initialScrollOffset] = useState(() => workspace.getScrollOffset("pullRequests"));
useSearchScrollRestoration(tab.searchMode, () => {
void listRef.current?.scrollToOffset({
- offset: tab.scrollOffset - (Platform.OS === "ios" ? insets.top : 0),
+ offset: tab.scrollOffset - contentTopInset,
animated: false,
});
});
@@ -253,7 +239,7 @@ export function PullRequestsScreen(
if (update.query !== typedQuery)
workspace.dispatch({ type: "query", tab: "pullRequests", query: update.query });
void listRef.current?.scrollToOffset({
- offset: Platform.OS === "ios" ? -insets.top : 0,
+ offset: -contentTopInset,
animated: false,
});
},
@@ -308,18 +294,16 @@ export function PullRequestsScreen(
// to this tab. The thread list shows none either.
showsVerticalScrollIndicator={Platform.OS !== "android"}
recycleItems
- renderScrollComponent={Platform.OS === "ios" ? PullRequestScrollView : undefined}
+ renderScrollComponent={NativeScrollView}
// UIKit owns the bar's inset, so a minimizing bar and a resized column move
// the list in the same frame as the bar.
contentInsetAdjustmentBehavior="automatic"
// A plain offset: LegendList adds the list header to an index-based restore, which
// landed every return one header lower.
initialScrollOffset={
- initialScrollOffset > 0
- ? initialScrollOffset - (Platform.OS === "ios" ? insets.top : 0)
- : undefined
+ initialScrollOffset > 0 ? initialScrollOffset - contentTopInset : undefined
}
- contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
+ contentInsetStartAdjustment={contentTopInset}
contentContainerStyle={{
paddingBottom:
Math.max(bottomSafeArea, workspace.bottomClearance) -
@@ -328,10 +312,7 @@ export function PullRequestsScreen(
onScroll={(event) => {
workspace.recordScrollOffset(
"pullRequests",
- Math.max(
- 0,
- event.nativeEvent.contentOffset.y + (Platform.OS === "ios" ? insets.top : 0),
- ),
+ Math.max(0, event.nativeEvent.contentOffset.y + contentTopInset),
);
}}
keyboardDismissMode="on-drag"
diff --git a/apps/mobile/src/features/pull-requests/guide/PullRequestGuideScreen.tsx b/apps/mobile/src/features/pull-requests/guide/PullRequestGuideScreen.tsx
index 22447892795..542700dc691 100644
--- a/apps/mobile/src/features/pull-requests/guide/PullRequestGuideScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/guide/PullRequestGuideScreen.tsx
@@ -1,10 +1,9 @@
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
-import { Toolbar } from "../../../components/ui/Toolbar";
import { parsePatchFiles } from "@pierre/diffs/utils/parsePatchFiles";
import type { FileDiffMetadata } from "@pierre/diffs";
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
import { useEffect } from "react";
-import { Platform, Pressable, View } from "react-native";
+import { Pressable, View } from "react-native";
import { AppBar } from "../../../components/ui/AppBar";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import {
@@ -16,10 +15,7 @@ import { SymbolView } from "../../../components/ui/AppSymbol";
import { GuideOutline } from "./GuideOutline";
import { AppText as Text } from "../../../components/ui/AppText";
import { ScreenScrollView } from "../../../components/ui/ScreenScrollView";
-import { Menu } from "../../../components/ui/Menu";
-import { IconButton } from "../../../components/ui/IconButton";
import { useAppearancePreferences } from "../../settings/appearance/AppearancePreferencesProvider";
-import { NativeStackScreenOptions } from "../../../native/StackHeader";
import { PullRequestCardGroup, PullRequestCardRow } from "../PullRequestControls";
import { PullRequestMarkdown, PullRequestMarkdownRepository } from "../PullRequestMarkdown";
import { usePullRequestDiff, type PullRequestParams } from "../usePullRequestDiff";
@@ -132,47 +128,25 @@ export function PullRequestGuideStopScreen({ route }: StaticScreenProps<GuideSto
const notes = stop ? letterStopNotes(stop).lettered : [];
return (
<View className="flex-1 bg-screen">
- <NativeStackScreenOptions
- options={{
- title: `Stop ${route.params.position + 1}`,
- headerTitle: `Stop ${route.params.position + 1} of ${guide?.stops.length ?? "…"}`,
- }}
+ <AppBar
+ title={`Stop ${route.params.position + 1} of ${guide?.stops.length ?? "…"}`}
+ onBack={() => navigation.goBack()}
+ menus={[
+ {
+ title: "Guide options",
+ icon: "ellipsis",
+ items: [
+ {
+ id: "word-wrap",
+ title: "Word wrap",
+ icon: "text.alignleft",
+ selected: appearance.codeWordBreak,
+ onPress: () => setCodeWordBreak(!appearance.codeWordBreak),
+ },
+ ],
+ },
+ ]}
/>
- {Platform.OS === "android" ? (
- <AppBar
- embedded
- title={`Stop ${route.params.position + 1}`}
- onBack={() => navigation.goBack()}
- trailing={
- <Menu
- actions={[
- {
- id: "word-wrap",
- title: "Word wrap",
- image: "text.alignleft",
- state: appearance.codeWordBreak ? "on" : "off",
- },
- ]}
- onPressAction={() => setCodeWordBreak(!appearance.codeWordBreak)}
- >
- <View pointerEvents="none">
- <IconButton icon="ellipsis" accessibilityLabel="Guide options" />
- </View>
- </Menu>
- }
- />
- ) : null}
- <Toolbar placement="right">
- <Toolbar.Menu title="Guide options" accessibilityLabel="Guide options" icon="ellipsis">
- <Toolbar.MenuAction
- icon="text.alignleft"
- isOn={appearance.codeWordBreak}
- onPress={() => setCodeWordBreak(!appearance.codeWordBreak)}
- >
- <Toolbar.Label>Word wrap</Toolbar.Label>
- </Toolbar.MenuAction>
- </Toolbar.Menu>
- </Toolbar>
<PullRequestMarkdownRepository params={route.params} changeRequest={detail.data}>
<ScreenScrollView
contentInsetAdjustmentBehavior="automatic"
diff --git a/apps/mobile/src/features/pull-requests/usePullRequestListActions.ts b/apps/mobile/src/features/pull-requests/usePullRequestListActions.ts
index 8a81ef6d73c..e8b52cec58c 100644
--- a/apps/mobile/src/features/pull-requests/usePullRequestListActions.ts
+++ b/apps/mobile/src/features/pull-requests/usePullRequestListActions.ts
@@ -1,6 +1,5 @@
import * as Dialog from "../../components/ui/Dialog";
import { RegistryContext, useAtomValue } from "@effect/atom-react";
-import { useNavigation } from "@react-navigation/native";
import {
executeAtomQuery,
settlePromise,
@@ -23,6 +22,7 @@ import { scopedPullRequestListKey, type EnvironmentPullRequestListEntry } from "
import { copyPullRequestLink, sharePullRequestLink } from "./pullRequestLink";
import { pullRequestTarget } from "./usePullRequestDiff";
import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";
+import { useOpenWorkspaceDetail } from "../layout/useOpenWorkspaceDetail";
export function usePullRequestListActions(
environmentIds: readonly EnvironmentId[],
@@ -32,8 +32,8 @@ export function usePullRequestListActions(
) => void,
) {
const registry = use(RegistryContext);
- const navigation = useNavigation();
const selectDetail = useSelectWorkspaceDetail();
+ const openDetail = useOpenWorkspaceDetail();
const permissionKey = JSON.stringify(environmentIds);
const permissionAtom = (() => {
const ids: readonly EnvironmentId[] = JSON.parse(permissionKey);
@@ -79,12 +79,10 @@ export function usePullRequestListActions(
!pr.viewerPermissions.requestReviewers
)
throw new Error(`Review requests aren't available for this ${terminology.singular}.`);
- if (Platform.OS === "android") {
- selectDetail(
- { name: "PullRequest", params: params(entry) },
- { name: "PullRequestReviewers", params: params(entry) },
- );
- } else navigation.navigate("PullRequestReviewers", params(entry));
+ openDetail(
+ { name: "PullRequest", params: params(entry) },
+ { name: "PullRequestReviewers", params: params(entry) },
+ );
return;
}
if (
diff --git a/apps/mobile/src/features/pull-requests/usePullRequestThreads.ts b/apps/mobile/src/features/pull-requests/usePullRequestThreads.ts
index e19dc333f2e..85a77a25496 100644
--- a/apps/mobile/src/features/pull-requests/usePullRequestThreads.ts
+++ b/apps/mobile/src/features/pull-requests/usePullRequestThreads.ts
@@ -3,12 +3,7 @@ import { visibleLinkedThreads } from "@t3tools/client-runtime/state/threads";
import { AsyncResult } from "effect/reactivity";
import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
import * as Dialog from "../../components/ui/Dialog";
-import {
- StackActions,
- useNavigation,
- useNavigationState,
- useRoute,
-} from "@react-navigation/native";
+import { useNavigationState, useRoute } from "@react-navigation/native";
import { threadPullRequestLinkMode } from "@t3tools/client-runtime/thread-pull-request-compatibility";
import {
AuthOrchestrationOperateScope,
@@ -21,8 +16,7 @@ import { formatComposerContextReference } from "@t3tools/shared/composerContextR
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
import { normalizeThreadPullRequestKey } from "@t3tools/client-runtime/thread-pull-requests";
import { useRef, useState } from "react";
-import { Platform } from "react-native";
-import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";
+import { useOpenWorkspaceDetail } from "../layout/useOpenWorkspaceDetail";
import { pullRequestComposerContext } from "../../lib/composerContext";
import { scopedThreadKey } from "../../lib/scopedEntities";
import { uuidv4 } from "../../lib/uuid";
@@ -88,18 +82,14 @@ export function usePullRequestThreads(
const canOperate = useEnvironmentScope(target.environmentId, AuthOrchestrationOperateScope);
const canAsk = !connected || canOperate;
const canCheckout = useEnvironmentScope(target.environmentId, AuthSourceControlWriteScope);
- const navigation = useNavigation();
- const selectDetail = useSelectWorkspaceDetail();
+ const openDetail = useOpenWorkspaceDetail();
const pending = useRef(false);
const previousPrompts = useRef(new Map<string, string>());
const openThread = (thread: LinkedThread) => {
openThreadRoute({ environmentId: params.environmentId, threadId: thread.id });
};
- // Android shows one page at a time; iOS opens the thread over the pull request, so Back returns.
- const openThreadRoute = (destination: ReactNavigation.RootParamList["Thread"]) => {
- if (Platform.OS === "android") selectDetail({ name: "Thread", params: destination });
- else navigation.dispatch(StackActions.push("Thread", destination));
- };
+ const openThreadRoute = (destination: ReactNavigation.RootParamList["Thread"]) =>
+ openDetail({ name: "Thread", params: destination });
const [busy, setBusy] = useState(false);
const ask = async (thread?: LinkedThread, task: PullRequestAgentTask = "ask") => {
if (!pr || !canAsk || pending.current) return;
diff --git a/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx b/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx
index a98d88a152e..e290f7ea498 100644
--- a/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx
+++ b/apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx
@@ -2,13 +2,13 @@ import { useNavigation, type StaticScreenProps } from "@react-navigation/native"
import { TextInputWrapper } from "expo-paste-input";
import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
import { useMemo, useState } from "react";
-import { Platform, Pressable, ScrollView, View, useWindowDimensions } from "react-native";
+import { Platform, ScrollView, View, useWindowDimensions } from "react-native";
import { KeyboardAvoidingView, KeyboardStickyView } from "react-native-keyboard-controller";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText";
-import { SymbolView } from "../../components/ui/AppSymbol";
+import { SheetHeader } from "../../components/ui/SheetHeader";
import { ComposerAttachmentStrip } from "../../components/ComposerAttachmentStrip";
import { ControlPill } from "../../components/ui/ControlPill";
import { cn } from "../../lib/cn";
@@ -129,32 +129,15 @@ export function ReviewCommentComposerSheet(props: ReviewCommentComposerSheetProp
return (
<View className="flex-1 bg-sheet">
+ <SheetHeader title="Add Comment" onClose={dismissComposer} />
<KeyboardAvoidingView automaticOffset behavior="padding" className="flex-1">
<View
className="flex-1 px-5"
style={{
- paddingTop: isAndroid ? insets.top + 8 : 8,
+ paddingTop: 8,
paddingBottom: target ? (isAndroid ? 72 : 0) : Math.max(insets.bottom, 18),
}}
>
- <View className="flex-row items-center justify-between py-2">
- <Pressable
- className="bg-subtle h-12 w-12 items-center justify-center rounded-full"
- onPress={dismissComposer}
- >
- <SymbolView
- name="xmark"
- size={18}
- tintColorClassName={"accent-icon"}
- type="monochrome"
- />
- </Pressable>
-
- <Text className="text-lg font-t3-bold text-foreground">Add Comment</Text>
-
- <View className="h-12 w-12" />
- </View>
-
{!target ? (
<View className="rounded-[22px] border border-border bg-card px-4 py-5">
<Text className="text-base font-t3-bold text-foreground">No selection</Text>
diff --git a/apps/mobile/src/features/review/ReviewSheet.tsx b/apps/mobile/src/features/review/ReviewSheet.tsx
index b53d6129480..00ea54db3f5 100644
--- a/apps/mobile/src/features/review/ReviewSheet.tsx
+++ b/apps/mobile/src/features/review/ReviewSheet.tsx
@@ -22,6 +22,7 @@ import {
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useReduceMotionEnabled } from "../../lib/appState";
import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
+import { useContentTopInset } from "../../components/ui/useBarInset";
import { NativeScrollView } from "../../native/NativeScrollViewMarker";
import { AppText as Text } from "../../components/ui/AppText";
@@ -31,7 +32,6 @@ import { cn } from "../../lib/cn";
import { environmentCatalog } from "../../connection/catalog";
import { useEnvironmentPresentation } from "../../state/presentation";
import { useAtomCommand } from "../../state/use-atom-command";
-import { useUniwindTheme } from "../../lib/useUniwindTheme";
import { useThreadDraftForThread } from "../../state/use-thread-composer-state";
import { EnvironmentConnectionNotice } from "../connection/EnvironmentConnectionNotice";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
@@ -59,7 +59,6 @@ import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail"
function ReviewHeader(
props: Parameters<typeof useReviewHeaderPresentation>[0] & {
- readonly iconColor: string;
readonly sectionMenu: ReturnType<typeof buildReviewSectionMenu>;
readonly showSectionToolbar: boolean;
readonly showChangedFilesToggle: boolean;
@@ -84,7 +83,6 @@ function ReviewHeader(
subtitle={presentation.subtitle}
onBack={props.onReturnToThread}
hideBottomBorder
- options={{ headerTintColor: props.iconColor, headerTitle: props.title }}
backInSplitView={{ accessibilityLabel: "Back to chat", icon: "chevron.left" }}
actions={
props.showChangedFilesToggle
@@ -335,15 +333,15 @@ function ReviewFileNavigator({ files, sectionId, onSelectFile, ref }: ReviewFile
<AppBar
title="Changed files"
subtitle={`${files.length} ${files.length === 1 ? "file" : "files"}`}
- hideBottomBorder={Platform.OS === "android"}
+ hideBottomBorder
/>
<ScreenContent insetHorizontal>
<FlatList
- renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
+ renderScrollComponent={NativeScrollView}
data={files}
extraData={selectedFileId}
keyExtractor={(file) => file.id}
- contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
+ contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={{ paddingHorizontal: 8, paddingVertical: 8 }}
renderItem={renderFile}
/>
@@ -365,7 +363,6 @@ export function ReviewSheet(props: ReviewSheetProps) {
const selectDetail = useSelectWorkspaceDetail();
const insets = useSafeAreaInsets();
const { themeAppearance: selectedTheme } = useAppearancePreferences();
- const headerIcon = String(useUniwindTheme()["--color-icon"]);
const { environmentId, threadId } = props.route.params;
const environment = useEnvironmentPresentation(environmentId);
const retryEnvironment = useAtomCommand(environmentCatalog.retryNow, "environment retry");
@@ -375,7 +372,7 @@ export function ReviewSheet(props: ReviewSheetProps) {
const { selectedThreadCwd } = useSelectedThreadWorktree();
const columnMetrics = useNativeColumnLayoutMetrics();
const safeArea = columnMetrics?.safeArea ?? insets;
- const topContentInset = Platform.OS === "ios" ? safeArea.top : 0;
+ const topContentInset = useContentTopInset();
const bottomContentInset =
Platform.OS === "ios" ? safeArea.bottom + 8 : Math.max(insets.bottom, 18) + 18;
@@ -620,7 +617,6 @@ export function ReviewSheet(props: ReviewSheetProps) {
title={headerTitleText}
subtitle={headerSubtitle}
androidSubtitle={androidHeaderSubtitle}
- iconColor={headerIcon}
selectedThreadCwd={selectedThreadCwd}
sectionMenu={sectionMenu}
selectedSection={selectedSection}
diff --git a/apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx
index 478520ea87a..75b0cd4e916 100644
--- a/apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx
@@ -4,12 +4,10 @@ import { useAtomValue } from "@effect/atom-react";
import { managedRelaySessionAtom } from "@t3tools/client-runtime/relay";
import type { EnvironmentId } from "@t3tools/contracts";
import { useRef, useState } from "react";
-import { Platform, RefreshControl } from "react-native";
+import { RefreshControl } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { SettingsScreen } from "./components/SettingsScreen";
-import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
-import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
import { CloudEnvironmentRows } from "../connection/CloudEnvironmentRows";
import { LocalEnvironmentList } from "../connection/LocalEnvironmentList";
import { PullRequestRoutingSettings } from "../connection/PullRequestRoutingSettings";
@@ -94,30 +92,14 @@ export function SettingsEnvironmentsRouteScreen() {
return (
<SettingsScreen
title="Environments"
- trailing={
- Platform.OS === "android" && relaySession ? (
- <AndroidAnchoredMenu
- title="Environment options"
- actions={[
- {
- id: "refresh",
- title: "Refresh cloud environments",
- attributes: { disabled: isRefreshingCloud },
- },
- ]}
- onPressAction={({ nativeEvent }) => {
- if (nativeEvent.event === "refresh") void refreshCloudEnvironments();
- }}
- >
- {(open) => (
- <AndroidHeaderIconButton
- accessibilityLabel="Environment options"
- icon="ellipsis"
- onPress={open}
- />
- )}
- </AndroidAnchoredMenu>
- ) : undefined
+ refresh={
+ relaySession
+ ? {
+ accessibilityLabel: "Refresh cloud environments",
+ disabled: isRefreshingCloud,
+ onPress: () => void refreshCloudEnvironments(),
+ }
+ : undefined
}
actions={[
{
diff --git a/apps/mobile/src/features/settings/SettingsFollowUpRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsFollowUpRouteScreen.tsx
index 29b47a9ddd4..bdaab6c3ea4 100644
--- a/apps/mobile/src/features/settings/SettingsFollowUpRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsFollowUpRouteScreen.tsx
@@ -1,7 +1,6 @@
import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
import { useAtomSet, useAtomValue } from "@effect/atom-react";
import { AsyncResult } from "effect/reactivity";
-import { Platform, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppText as Text } from "../../components/ui/AppText";
@@ -65,11 +64,5 @@ export function SettingsFollowUpRouteScreen() {
</ScrollView>
);
- return Platform.OS === "android" ? (
- <SettingsScreen title="Chat">{content}</SettingsScreen>
- ) : (
- <View collapsable={false} className="flex-1 bg-sheet">
- {content}
- </View>
- );
+ return <SettingsScreen title="Chat">{content}</SettingsScreen>;
}
diff --git a/apps/mobile/src/features/settings/SettingsOpenSourceLicensesRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsOpenSourceLicensesRouteScreen.tsx
index 7c16fc16be2..b6e354a00e1 100644
--- a/apps/mobile/src/features/settings/SettingsOpenSourceLicensesRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsOpenSourceLicensesRouteScreen.tsx
@@ -1,6 +1,5 @@
import { NativeScrollView } from "../../native/NativeScrollViewMarker";
-import { SearchField } from "../../components/ui/SearchField";
-import { Toolbar } from "../../components/ui/Toolbar";
+import { useSearchToolbarInset } from "../../components/ui/useBarInset";
import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
import { LegendList } from "@legendapp/list/react-native";
import { type StaticScreenProps, useNavigation } from "@react-navigation/native";
@@ -11,20 +10,14 @@ import {
thirdPartyLicenseEntryKey,
type ThirdPartyLicenseEntry,
} from "@t3tools/shared/thirdPartyLicenses";
-import { useMemo, useRef, useState } from "react";
-import { Linking, Platform, Pressable, type TextInputInstance, View } from "react-native";
+import { useMemo, useState } from "react";
+import { Linking, Platform, Pressable, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { SymbolView } from "../../components/ui/AppSymbol";
import { AppText as Text } from "../../components/ui/AppText";
import { ListRow } from "../../components/ui/ListRow";
import { SettingsScreen } from "./components/SettingsScreen";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
-import {
- createNativeMailSearchToolbarItem,
- NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET,
-} from "../layout/native-mail-search-toolbar";
-import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
import { getMobileThirdPartyLicenses } from "./mobileThirdPartyLicenses";
@@ -54,11 +47,17 @@ function LicenseRow(props: {
}
export function SettingsOpenSourceLicensesRouteScreen() {
- const searchRef = useRef<TextInputInstance>(null);
const navigation = useNavigation();
const insets = useSafeAreaInsets();
const [query, setQuery] = useState("");
- const usesNativeMailSearchToolbar = useNativeMailSearchToolbar();
+ const search = {
+ value: query,
+ onChangeText: setQuery,
+ placeholder: "Search packages",
+ accessibilityLabel: "Search open-source licenses",
+ clearAccessibilityLabel: "Clear package search",
+ };
+ const searchInset = useSearchToolbarInset(search);
const manifest = useMobileThirdPartyLicenses();
const entries = manifest?.entries ?? [];
const filteredEntries = filterThirdPartyLicenseEntries(entries, query);
@@ -86,50 +85,13 @@ export function SettingsOpenSourceLicensesRouteScreen() {
}
return (
- <SettingsScreen title="Open source licenses">
- {Platform.OS === "ios" ? (
- <NativeStackScreenOptions
- options={{
- unstable_headerToolbarItems: usesNativeMailSearchToolbar
- ? () => [
- createNativeMailSearchToolbarItem({
- onSearchTextChange: setQuery,
- placeholder: "Search packages",
- searchTextChangeId: "open-source-licenses-search-text",
- showsSearchDismissButton: true,
- }),
- ]
- : undefined,
- headerSearchBarOptions: usesNativeMailSearchToolbar
- ? undefined
- : {
- allowToolbarIntegration: true,
- autoCapitalize: "none",
- hideNavigationBar: false,
- hideWhenScrolling: false,
- obscureBackground: false,
- onCancelButtonPress: () => setQuery(""),
- onChangeText: (event) => setQuery(event.nativeEvent.text),
- placeholder: "Search packages",
- },
- }}
- />
- ) : null}
- {Platform.OS === "ios" && !usesNativeMailSearchToolbar ? (
- <Toolbar placement="bottom">
- <Toolbar.SearchBarSlot />
- </Toolbar>
- ) : null}
-
+ <SettingsScreen title="Open source licenses" search={search}>
<LegendList
- renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
+ renderScrollComponent={NativeScrollView}
className="flex-1"
contentContainerStyle={{
- paddingBottom: usesNativeMailSearchToolbar
- ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 18
- : Platform.OS === "ios"
- ? 18
- : Math.max(insets.bottom, 18) + 18,
+ paddingBottom:
+ searchInset + (Platform.OS === "ios" ? 18 : Math.max(insets.bottom, 18) + 18),
}}
contentInsetAdjustmentBehavior="automatic"
data={filteredEntries}
@@ -144,21 +106,6 @@ export function SettingsOpenSourceLicensesRouteScreen() {
</Text>
</View>
}
- ListHeaderComponent={
- Platform.OS !== "ios" ? (
- <View className="px-5 pt-4 pb-5">
- <SearchField
- inputRef={searchRef}
- autoFocus={false}
- accessibilityLabel="Search open-source licenses"
- clearAccessibilityLabel="Clear package search"
- onChangeText={setQuery}
- placeholder="Search packages"
- value={query}
- />
- </View>
- ) : null
- }
renderItem={renderItem}
showsVerticalScrollIndicator={false}
/>
diff --git a/apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx
index d68578961c1..8492f9b9e03 100644
--- a/apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx
@@ -38,10 +38,7 @@ import { SettingsScreen } from "./components/SettingsScreen";
import { SettingsSection } from "./components/SettingsSection";
import { ListActionRow as SettingsActionRow } from "../../components/ui/ListActionRow";
import { SettingsSwitchRow } from "./components/SettingsSwitchRow";
-import {
- useSettingsEnvironmentMenu,
- SettingsEnvironmentFilterHeader,
-} from "./components/SettingsEnvironmentFilterHeader";
+import { useSettingsEnvironmentMenu } from "./components/SettingsEnvironmentFilterHeader";
import { useSettingsEnvironmentFilter, type SettingsTarget } from "./settings-environment-filter";
import { leaveSettingsPage } from "./settings-navigation";
import { workspaceHasColumns } from "../workspace/workspace-selection-store";
@@ -87,44 +84,41 @@ export function SettingsProjectOverviewRouteScreen() {
.filter((project) => selectedEnvironmentIds.has(project.environmentId)) ?? [];
return (
- <>
- <SettingsEnvironmentFilterHeader />
- <SettingsScreen title="Projects" menus={[environmentMenu]}>
- <ScrollView
- contentInsetAdjustmentBehavior="automatic"
- showsVerticalScrollIndicator={false}
- className="flex-1"
- contentContainerClassName="gap-6 px-5 pt-4"
- contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
- >
- {selectedProjectKey === null ? (
- <Text className="px-2 text-base text-foreground-muted">
- Choose a project with the filter above to manage its name, checkouts and removal.
- </Text>
- ) : !group || members.length === 0 ? (
- <Text className="px-2 text-base text-foreground-muted">
- This project has no checkout on the selected connected environments. Change the filter
- above.
- </Text>
- ) : (
- <ProjectOverviewContent
- key={`${selectedProjectKey}:${members.map((member) => member.id).join(",")}`}
- members={members}
- group={group}
- connectedTargets={availableTargets}
- environments={selectedTargets}
- hasOtherMembers={members.length < (group?.members.length ?? 0)}
- isRemoving={isRemoving}
- setIsRemoving={setIsRemoving}
- startRemoval={startRemoval}
- finishRemoval={finishRemoval}
- projectKey={selectedProjectKey}
- onProjectRemoved={finishProjectRemoval}
- />
- )}
- </ScrollView>
- </SettingsScreen>
- </>
+ <SettingsScreen title="Projects" menus={[environmentMenu]}>
+ <ScrollView
+ contentInsetAdjustmentBehavior="automatic"
+ showsVerticalScrollIndicator={false}
+ className="flex-1"
+ contentContainerClassName="gap-6 px-5 pt-4"
+ contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
+ >
+ {selectedProjectKey === null ? (
+ <Text className="px-2 text-base text-foreground-muted">
+ Choose a project with the filter above to manage its name, checkouts and removal.
+ </Text>
+ ) : !group || members.length === 0 ? (
+ <Text className="px-2 text-base text-foreground-muted">
+ This project has no checkout on the selected connected environments. Change the filter
+ above.
+ </Text>
+ ) : (
+ <ProjectOverviewContent
+ key={`${selectedProjectKey}:${members.map((member) => member.id).join(",")}`}
+ members={members}
+ group={group}
+ connectedTargets={availableTargets}
+ environments={selectedTargets}
+ hasOtherMembers={members.length < (group?.members.length ?? 0)}
+ isRemoving={isRemoving}
+ setIsRemoving={setIsRemoving}
+ startRemoval={startRemoval}
+ finishRemoval={finishRemoval}
+ projectKey={selectedProjectKey}
+ onProjectRemoved={finishProjectRemoval}
+ />
+ )}
+ </ScrollView>
+ </SettingsScreen>
);
}
diff --git a/apps/mobile/src/features/settings/SettingsProviderAccountsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsProviderAccountsRouteScreen.tsx
index 2d7e639d8b9..ff4d44fcaa7 100644
--- a/apps/mobile/src/features/settings/SettingsProviderAccountsRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsProviderAccountsRouteScreen.tsx
@@ -28,10 +28,7 @@ import { serverEnvironment } from "../../state/server";
import { useEnvironmentsWithScope } from "../../state/session";
import { useAtomCommand } from "../../state/use-atom-command";
import { ListActionRow as SettingsActionRow } from "../../components/ui/ListActionRow";
-import {
- useSettingsEnvironmentMenu,
- SettingsEnvironmentFilterHeader,
-} from "./components/SettingsEnvironmentFilterHeader";
+import { useSettingsEnvironmentMenu } from "./components/SettingsEnvironmentFilterHeader";
import { SettingsScreen } from "./components/SettingsScreen";
import { SettingsSection } from "./components/SettingsSection";
import { AddClaudeAccount, ClaudeAccount } from "./ClaudeAccounts";
@@ -45,39 +42,36 @@ export function SettingsProviderAccountsRouteScreen() {
const providersByEnvironment = useAtomValue(environmentPresentations.providersByEnvironmentAtom);
const insets = useSafeAreaInsets();
return (
- <>
- <SettingsEnvironmentFilterHeader />
- <SettingsScreen title="Providers" menus={[environmentMenu]}>
- <ScreenScrollView
- className="flex-1"
- contentInsetAdjustmentBehavior="automatic"
- contentContainerClassName="gap-6 px-5 pt-4"
- contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
- >
- {selectedTargets.length === 0 ? (
- <Text className="text-foreground-muted">Select a connected environment.</Text>
- ) : (
- selectedTargets.map((environment) => (
- <SettingsSection key={environment.environmentId} title={environment.label}>
- {!permittedEnvironments.has(environment.environmentId) ? (
- <View className="gap-1 p-4">
- <Text className="text-base text-foreground">Limited permissions</Text>
- <Text className="text-sm text-foreground-muted">
- {`This session can view ${environment.label}'s providers but can't change their settings.`}
- </Text>
- </View>
- ) : (
- <EnvironmentProviders
- environment={environment}
- providers={managedProviders(environment, providersByEnvironment)}
- />
- )}
- </SettingsSection>
- ))
- )}
- </ScreenScrollView>
- </SettingsScreen>
- </>
+ <SettingsScreen title="Providers" menus={[environmentMenu]}>
+ <ScreenScrollView
+ className="flex-1"
+ contentInsetAdjustmentBehavior="automatic"
+ contentContainerClassName="gap-6 px-5 pt-4"
+ contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
+ >
+ {selectedTargets.length === 0 ? (
+ <Text className="text-foreground-muted">Select a connected environment.</Text>
+ ) : (
+ selectedTargets.map((environment) => (
+ <SettingsSection key={environment.environmentId} title={environment.label}>
+ {!permittedEnvironments.has(environment.environmentId) ? (
+ <View className="gap-1 p-4">
+ <Text className="text-base text-foreground">Limited permissions</Text>
+ <Text className="text-sm text-foreground-muted">
+ {`This session can view ${environment.label}'s providers but can't change their settings.`}
+ </Text>
+ </View>
+ ) : (
+ <EnvironmentProviders
+ environment={environment}
+ providers={managedProviders(environment, providersByEnvironment)}
+ />
+ )}
+ </SettingsSection>
+ ))
+ )}
+ </ScreenScrollView>
+ </SettingsScreen>
);
}
diff --git a/apps/mobile/src/features/settings/SettingsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsRouteScreen.tsx
index a8576efc54a..f43219865f1 100644
--- a/apps/mobile/src/features/settings/SettingsRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsRouteScreen.tsx
@@ -29,17 +29,30 @@ import { SettingsRow } from "./components/SettingsRow";
import { SettingsSection, SettingsSidebarContext } from "./components/SettingsSection";
import { SettingsScreen } from "./components/SettingsScreen";
import type { SettingsPageTarget } from "./components/settings-page-targets";
-import {
- useSettingsEnvironmentMenu,
- SettingsEnvironmentFilterHeader,
-} from "./components/SettingsEnvironmentFilterHeader";
+import { useSettingsEnvironmentMenu } from "./components/SettingsEnvironmentFilterHeader";
import { useSettingsEnvironmentFilter } from "./settings-environment-filter";
import { filterSettingsSections } from "./settings-search";
-import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
+import { usePaneRole } from "../../components/ui/Pane";
export function SettingsRouteScreen() {
- const { layout } = useAdaptiveWorkspaceLayout();
- const inSidebar = use(NativePrimaryColumnContext) !== null && layout.usesSplitView;
+ const list = useSettingsListPlacement();
+ return <SettingsListScreen sidebar={list.sidebar} selected={list.selected} />;
+}
+
+/** The Settings list inside a workspace shell that draws its bar, title and search itself. */
+export function WorkspaceSettingsList() {
+ const list = useSettingsListPlacement();
+ return (
+ <SettingsSidebarContext value={list.sidebar ? { selected: list.selected } : null}>
+ <View className="flex-1 bg-screen">
+ <SettingsListContent />
+ </View>
+ </SettingsSidebarContext>
+ );
+}
+
+function useSettingsListPlacement() {
+ const sidebar = usePaneRole() === "sidebar";
// The page open beside the list: the route right above the Settings tab's route. While
// another tab is open this list stays mounted, hidden, and must keep showing the page Settings
// reopens on; otherwise returning shows it unselected for a frame before the page arrives.
@@ -49,7 +62,11 @@ export function SettingsRouteScreen() {
? rememberedSettingsPage(currentWorkspaceSelections())
: (state.routes[list + 1]?.name ?? null);
});
- return <SettingsListScreen sidebar={inSidebar} selected={selected} />;
+ return { sidebar, selected };
+}
+
+function SettingsListContent() {
+ return hasCloudPublicConfig() ? <ConfiguredSettingsRouteScreen /> : <LocalSettingsRouteScreen />;
}
export function SettingsListScreen(props: {
@@ -58,40 +75,26 @@ export function SettingsListScreen(props: {
}) {
const workspace = useWorkspaceTabs();
const environmentMenu = useSettingsEnvironmentMenu();
- const inSidebar = props.sidebar;
- const selected = props.selected;
- const sidebar = inSidebar ? { selected } : null;
- const content = hasCloudPublicConfig() ? (
- <ConfiguredSettingsRouteScreen />
- ) : (
- <LocalSettingsRouteScreen />
- );
-
return (
- <SettingsSidebarContext value={sidebar}>
+ <SettingsSidebarContext value={props.sidebar ? { selected: props.selected } : null}>
<View className="flex-1 bg-screen">
- <SettingsEnvironmentFilterHeader />
- {Platform.OS === "android" ? (
- <SettingsScreen
- title="Settings"
- workspaceRoot={inSidebar}
- menus={[environmentMenu]}
- search={
- workspace
- ? {
- value: workspace.state.tabs.settings.query,
- onChangeText: (query) =>
- workspace.dispatch({ type: "query", tab: "settings", query }),
- placeholder: "Search settings",
- }
- : undefined
- }
- >
- {content}
- </SettingsScreen>
- ) : (
- content
- )}
+ <SettingsScreen
+ title="Settings"
+ workspaceRoot={props.sidebar}
+ menus={[environmentMenu]}
+ search={
+ workspace
+ ? {
+ value: workspace.state.tabs.settings.query,
+ onChangeText: (query) =>
+ workspace.dispatch({ type: "query", tab: "settings", query }),
+ placeholder: "Search settings",
+ }
+ : undefined
+ }
+ >
+ <SettingsListContent />
+ </SettingsScreen>
</View>
</SettingsSidebarContext>
);
diff --git a/apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx
index 888ad2fb1d7..34dd75e7500 100644
--- a/apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx
@@ -62,14 +62,10 @@ import { useProjects, useEnvironmentServerConfig } from "../../state/entities";
import { useEnvironmentQuery } from "../../state/query";
import { serverEnvironment } from "../../state/server";
import { useAtomCommand } from "../../state/use-atom-command";
-import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
import { resolveNewTaskBranchLabel } from "../threads/new-task-context-presentation";
import { useVoiceInputController } from "../voice-input/useVoiceInputController";
import { ScheduledTaskPromptField } from "./components/ScheduledTaskPromptField";
-import {
- useSettingsEnvironmentMenu,
- SettingsEnvironmentFilterHeader,
-} from "./components/SettingsEnvironmentFilterHeader";
+import { useSettingsEnvironmentMenu } from "./components/SettingsEnvironmentFilterHeader";
import { SettingsScreen } from "./components/SettingsScreen";
import { SettingsSection } from "./components/SettingsSection";
import { useSettingsEnvironmentFilter, type SettingsTarget } from "./settings-environment-filter";
@@ -414,79 +410,61 @@ export function SettingsScheduledTasksRouteScreen() {
};
return (
- <>
- <SettingsEnvironmentFilterHeader
- trailingItems={[
- withNativeGlassHeaderItem({
- type: "button",
- label: "",
- accessibilityLabel: "New task",
- icon: { type: "sfSymbol", name: "plus" } as const,
- disabled: visibleEnvironments.length === 0,
- onPress: newTask,
- }),
- ]}
- />
- <SettingsScreen
- title="Scheduled tasks"
- actions={
- Platform.OS === "android"
- ? [
- {
- accessibilityLabel: "New task",
- icon: "plus",
- disabled: visibleEnvironments.length === 0,
- onPress: newTask,
- },
- ]
- : undefined
- }
- menus={[environmentMenu]}
+ <SettingsScreen
+ title="Scheduled tasks"
+ actions={[
+ {
+ accessibilityLabel: "New task",
+ icon: "plus",
+ disabled: visibleEnvironments.length === 0,
+ onPress: newTask,
+ },
+ ]}
+ menus={[environmentMenu]}
+ >
+ <ScrollView
+ keyboardShouldPersistTaps="handled"
+ keyboardDismissMode="on-drag"
+ contentInsetAdjustmentBehavior="automatic"
+ showsVerticalScrollIndicator={false}
+ className="flex-1"
+ contentContainerClassName="gap-5 px-5 pt-4"
+ contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
>
- <ScrollView
- keyboardShouldPersistTaps="handled"
- keyboardDismissMode="on-drag"
- contentInsetAdjustmentBehavior="automatic"
- showsVerticalScrollIndicator={false}
- className="flex-1"
- contentContainerClassName="gap-5 px-5 pt-4"
- contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
- >
- {visibleEnvironments.length > 0 ? (
- visibleEnvironments.map((environment) => (
- <EnvironmentTasks
- key={environment.environmentId}
- environment={environment}
- now={now}
- projectIds={
- selectedProjectKey === null
- ? null
- : (selectedGroup?.members
- .filter(
- (member) => member.project.environmentId === environment.environmentId,
- )
- .map((member) => member.project.id) ?? [])
- }
- onEdit={(task) => {
- startEditor({
- environmentId: environment.environmentId,
- environmentLabel: environment.label,
- draft: editDraft(task),
- });
- navigation.navigate("SettingsScheduledTaskEdit");
- }}
- />
- ))
- ) : (
- <Text className="px-2 text-base text-foreground-muted">
- {availableTargets.length === 0
- ? "Connect an environment to view and create scheduled tasks."
- : "No environments match these filters. Change the filter above."}
- </Text>
- )}
- </ScrollView>
- </SettingsScreen>
- </>
+ {visibleEnvironments.length > 0 ? (
+ visibleEnvironments.map((environment) => (
+ <EnvironmentTasks
+ key={environment.environmentId}
+ environment={environment}
+ now={now}
+ projectIds={
+ selectedProjectKey === null
+ ? null
+ : (selectedGroup?.members
+ .filter(
+ (member) => member.project.environmentId === environment.environmentId,
+ )
+ .map((member) => member.project.id) ?? [])
+ }
+ onEdit={(task) => {
+ startEditor({
+ environmentId: environment.environmentId,
+ environmentLabel: environment.label,
+ draft: editDraft(task),
+ });
+ navigation.navigate("SettingsScheduledTaskEdit");
+ }}
+ />
+ ))
+ ) : (
+ <Text className="px-2 text-base text-foreground-muted">
+ {availableTargets.length === 0
+ ? "Connect an environment to view and create scheduled tasks."
+ : "No environments match these filters. Change the filter above."}
+ </Text>
+ )}
+ </ScrollView>
+ </SettingsScreen>
);
}
@@ -574,23 +552,7 @@ function SettingsScheduledTaskEditorScreen({ title }: { readonly title: string }
<SettingsScreen
title={title}
// Native Back pops before removal guards; a bar action lets the guard run first.
- options={
- Platform.OS === "ios"
- ? {
- headerBackVisible: false,
- gestureEnabled: !preventRemove,
- unstable_headerLeftItems: () => [
- withNativeGlassHeaderItem({
- type: "button",
- label: "",
- accessibilityLabel: "Back",
- icon: { type: "sfSymbol", name: "chevron.backward" },
- onPress: () => navigation.goBack(),
- }),
- ],
- }
- : undefined
- }
+ guardBack={preventRemove}
>
<ScrollView
keyboardShouldPersistTaps="handled"
diff --git a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx
index bae80ff3279..7d22b2e27ea 100644
--- a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx
+++ b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx
@@ -92,7 +92,6 @@ vi.mock("./components/SettingsEnvironmentFilterHeader", () => ({
icon: "line.3.horizontal.decrease.circle",
items: [],
}),
- SettingsEnvironmentFilterHeader: () => null,
}));
vi.mock("./components/DatabaseStorageNotice", () => ({ DatabaseStorageNotice: () => null }));
vi.mock("./components/SettingsSection", () => ({ SettingsSection: Children }));
diff --git a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx
index fc36729d672..793e3ae7541 100644
--- a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx
@@ -22,10 +22,7 @@ import {
withManagedRuntimeModeLimits,
} from "../threads/thread-settings-options";
import { SettingsScreen } from "./components/SettingsScreen";
-import {
- useSettingsEnvironmentMenu,
- SettingsEnvironmentFilterHeader,
-} from "./components/SettingsEnvironmentFilterHeader";
+import { useSettingsEnvironmentMenu } from "./components/SettingsEnvironmentFilterHeader";
import { BranchNamingSettings } from "./components/BranchNamingSettings";
import { DatabaseStorageNotice } from "./components/DatabaseStorageNotice";
import { ListChoiceRow as SettingsChoiceRow } from "../../components/ui/ListChoiceRow";
@@ -284,292 +281,287 @@ function ServerSettingsDetail(props: { readonly page: SettingsPage }) {
));
return (
- <>
- <SettingsEnvironmentFilterHeader />
- <SettingsScreen title={PAGE_TITLES[props.page]} menus={[environmentMenu]}>
- <ScrollView
- contentInsetAdjustmentBehavior="automatic"
- showsVerticalScrollIndicator={false}
- className="flex-1"
- contentContainerClassName="gap-6 px-5 pt-4"
- contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
- >
- {!hasConnectedSelection || reference === null ? (
- <Text className="px-2 text-base text-foreground-muted">
- {projectSelected
- ? "Select a project with a checkout on a connected environment."
- : "Use the filter above to select a connected environment."}
- </Text>
- ) : (
- <>
- <ManagedPolicyNotice targets={targets} />
- {projectSelected ? (
- <SettingsProjectOverridesSection
- projectLabel={selectedProject?.label ?? "Unavailable project"}
- hasOverrides={targets.some((target) =>
- PAGE_PROJECT_KEYS[props.page].some((key) => target.sources[key] === "project"),
- )}
- pending={pendingWrites > 0}
- disabled={!canWriteSettings}
- onClear={clearProjectOverrides}
- />
- ) : null}
- {props.page === "threads" ? (
- <>
- <SettingsSection
- title="Default workspace"
- footer={managed("defaultThreadEnvMode")}
- trailing={
- pendingWrites === 0 && isMixed("defaultThreadEnvMode") ? (
- <MixedValuesLabel projectSelected={projectSelected} />
- ) : null
- }
- >
- {WORKSPACE_CHOICES.filter(
- (choice) => choice.mode !== null || !projectSelected,
- ).map((choice, index) => (
- <SettingsChoiceRow
- key={choice.mode ?? "inherit"}
- label={choice.label}
- description={choice.description}
- selected={
- !isMixed("defaultThreadEnvMode") &&
- uniform("defaultThreadEnvMode") === choice.mode
- }
- separated={index > 0}
- disabled={disabledFor("defaultThreadEnvMode")}
- onPress={() => write({ defaultThreadEnvMode: choice.mode })}
- />
- ))}
- </SettingsSection>
- <SettingsSection
- title="Default permissions"
- footer={managed("defaultRuntimeMode")}
- trailing={
- pendingWrites === 0 && uniform("defaultRuntimeMode") === null ? (
- <MixedValuesLabel projectSelected={projectSelected} />
- ) : null
- }
- >
- {runtimeModeChoices.map((choice, index) => (
- <SettingsChoiceRow
- key={choice.mode}
- label={choice.label}
- description={choice.disabledReason ?? choice.description}
- selected={uniform("defaultRuntimeMode") === choice.mode}
- separated={index > 0}
- disabled={
- disabledFor("defaultRuntimeMode") || choice.disabledReason !== undefined
- }
- onPress={() => write({ defaultRuntimeMode: choice.mode })}
- />
- ))}
- </SettingsSection>
- <SettingsSection
- title="Response streaming"
- footer={managed("responseStreamingMode")}
- trailing={
- pendingWrites === 0 && uniform("responseStreamingMode") === null ? (
- <MixedValuesLabel projectSelected={projectSelected} />
- ) : null
- }
- >
- {STREAMING_CHOICES.map((choice, index) => (
- <SettingsChoiceRow
- key={choice.mode}
- label={choice.label}
- description={choice.description}
- selected={uniform("responseStreamingMode") === choice.mode}
- separated={index > 0}
- disabled={disabledFor("responseStreamingMode")}
- onPress={() => write({ responseStreamingMode: choice.mode })}
- />
- ))}
- </SettingsSection>
- <SettingsSection title="Preview browser">
- <SettingsSwitchRow
- icon="globe"
- label="Agent browser access"
- subtitle={managedSubtitle(
- "enableAgentBrowserAccess",
- "Allow agents to use the in-app preview browser.",
- )}
- value={uniform("enableAgentBrowserAccess")}
- disabled={disabledFor("enableAgentBrowserAccess")}
- onValueChange={(value) => write({ enableAgentBrowserAccess: value })}
- />
- </SettingsSection>
- <AutoSettleSettingsRows write={write} pending={pendingWrites > 0} />
- </>
- ) : null}
-
- {props.page === "source-control" ? (
- <>
- {projectSelected ? null : (
- <SourceControlSignInSection
- environments={selectedTargets}
- canWrite={(environmentId) => writableEnvironments.has(environmentId)}
+ <SettingsScreen title={PAGE_TITLES[props.page]} menus={[environmentMenu]}>
+ <ScrollView
+ contentInsetAdjustmentBehavior="automatic"
+ showsVerticalScrollIndicator={false}
+ className="flex-1"
+ contentContainerClassName="gap-6 px-5 pt-4"
+ contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
+ >
+ {!hasConnectedSelection || reference === null ? (
+ <Text className="px-2 text-base text-foreground-muted">
+ {projectSelected
+ ? "Select a project with a checkout on a connected environment."
+ : "Use the filter above to select a connected environment."}
+ </Text>
+ ) : (
+ <>
+ <ManagedPolicyNotice targets={targets} />
+ {projectSelected ? (
+ <SettingsProjectOverridesSection
+ projectLabel={selectedProject?.label ?? "Unavailable project"}
+ hasOverrides={targets.some((target) =>
+ PAGE_PROJECT_KEYS[props.page].some((key) => target.sources[key] === "project"),
+ )}
+ pending={pendingWrites > 0}
+ disabled={!canWriteSettings}
+ onClear={clearProjectOverrides}
+ />
+ ) : null}
+ {props.page === "threads" ? (
+ <>
+ <SettingsSection
+ title="Default workspace"
+ footer={managed("defaultThreadEnvMode")}
+ trailing={
+ pendingWrites === 0 && isMixed("defaultThreadEnvMode") ? (
+ <MixedValuesLabel projectSelected={projectSelected} />
+ ) : null
+ }
+ >
+ {WORKSPACE_CHOICES.filter(
+ (choice) => choice.mode !== null || !projectSelected,
+ ).map((choice, index) => (
+ <SettingsChoiceRow
+ key={choice.mode ?? "inherit"}
+ label={choice.label}
+ description={choice.description}
+ selected={
+ !isMixed("defaultThreadEnvMode") &&
+ uniform("defaultThreadEnvMode") === choice.mode
+ }
+ separated={index > 0}
+ disabled={disabledFor("defaultThreadEnvMode")}
+ onPress={() => write({ defaultThreadEnvMode: choice.mode })}
/>
- )}
- <SettingsSection title="Pull requests">
- <SettingsSwitchRow
- icon={PullRequestGlyph.merged}
- label="Remove agent credits when merging"
- subtitle={managedSubtitle(
- "removeAgentCreditsOnMerge",
- "Remove recognized agent credits from merge and squash messages on hosts that support it, keeping human co-authors. Includes auto-merge. Excludes merge queues, stack merges, and existing commits.",
- )}
- value={uniform("removeAgentCreditsOnMerge")}
- disabled={disabledFor("removeAgentCreditsOnMerge")}
- onValueChange={(value) => write({ removeAgentCreditsOnMerge: value })}
- />
- </SettingsSection>
- <SettingsSection title="Default branch">
- <SettingsSwitchRow
- icon="arrow.down.circle"
- label="Automatically pull"
- subtitle={managedSubtitle(
- "defaultAutoPull",
- "Keep the default branch current when there are no local changes.",
- )}
- value={uniform("defaultAutoPull")}
- disabled={disabledFor("defaultAutoPull")}
- onValueChange={(value) => write({ defaultAutoPull: value })}
+ ))}
+ </SettingsSection>
+ <SettingsSection
+ title="Default permissions"
+ footer={managed("defaultRuntimeMode")}
+ trailing={
+ pendingWrites === 0 && uniform("defaultRuntimeMode") === null ? (
+ <MixedValuesLabel projectSelected={projectSelected} />
+ ) : null
+ }
+ >
+ {runtimeModeChoices.map((choice, index) => (
+ <SettingsChoiceRow
+ key={choice.mode}
+ label={choice.label}
+ description={choice.disabledReason ?? choice.description}
+ selected={uniform("defaultRuntimeMode") === choice.mode}
+ separated={index > 0}
+ disabled={
+ disabledFor("defaultRuntimeMode") || choice.disabledReason !== undefined
+ }
+ onPress={() => write({ defaultRuntimeMode: choice.mode })}
/>
- </SettingsSection>
- <SettingsSection title="Clones">
- <SettingsSwitchRow
- icon="folder"
- label="Clone into host folders"
- subtitle="Clones go to github.com/owner/repo under the Add project folder, like ghq."
- value={uniform("ghqCloneLayout")}
- disabled={disabledFor("ghqCloneLayout")}
- onValueChange={(value) => write({ ghqCloneLayout: value })}
+ ))}
+ </SettingsSection>
+ <SettingsSection
+ title="Response streaming"
+ footer={managed("responseStreamingMode")}
+ trailing={
+ pendingWrites === 0 && uniform("responseStreamingMode") === null ? (
+ <MixedValuesLabel projectSelected={projectSelected} />
+ ) : null
+ }
+ >
+ {STREAMING_CHOICES.map((choice, index) => (
+ <SettingsChoiceRow
+ key={choice.mode}
+ label={choice.label}
+ description={choice.description}
+ selected={uniform("responseStreamingMode") === choice.mode}
+ separated={index > 0}
+ disabled={disabledFor("responseStreamingMode")}
+ onPress={() => write({ responseStreamingMode: choice.mode })}
/>
- </SettingsSection>
- </>
- ) : null}
+ ))}
+ </SettingsSection>
+ <SettingsSection title="Preview browser">
+ <SettingsSwitchRow
+ icon="globe"
+ label="Agent browser access"
+ subtitle={managedSubtitle(
+ "enableAgentBrowserAccess",
+ "Allow agents to use the in-app preview browser.",
+ )}
+ value={uniform("enableAgentBrowserAccess")}
+ disabled={disabledFor("enableAgentBrowserAccess")}
+ onValueChange={(value) => write({ enableAgentBrowserAccess: value })}
+ />
+ </SettingsSection>
+ <AutoSettleSettingsRows write={write} pending={pendingWrites > 0} />
+ </>
+ ) : null}
- {props.page === "worktrees" ? (
- <>
- <SettingsSection title="New worktrees">
- <SettingsSwitchRow
- icon="arrow.triangle.branch"
- label="Start from remote"
- subtitle={managedSubtitle(
- "newWorktreesStartFromOrigin",
- "Uses the latest commit of the base branch’s tracked remote branch, even if its name differs. Otherwise uses the same-named branch on origin. Uses your local branch if that remote branch is missing.",
- )}
- value={uniform("newWorktreesStartFromOrigin")}
- disabled={disabledFor("newWorktreesStartFromOrigin")}
- onValueChange={(value) => write({ newWorktreesStartFromOrigin: value })}
+ {props.page === "source-control" ? (
+ <>
+ {projectSelected ? null : (
+ <SourceControlSignInSection
+ environments={selectedTargets}
+ canWrite={(environmentId) => writableEnvironments.has(environmentId)}
+ />
+ )}
+ <SettingsSection title="Pull requests">
+ <SettingsSwitchRow
+ icon={PullRequestGlyph.merged}
+ label="Remove agent credits when merging"
+ subtitle={managedSubtitle(
+ "removeAgentCreditsOnMerge",
+ "Remove recognized agent credits from merge and squash messages on hosts that support it, keeping human co-authors. Includes auto-merge. Excludes merge queues, stack merges, and existing commits.",
+ )}
+ value={uniform("removeAgentCreditsOnMerge")}
+ disabled={disabledFor("removeAgentCreditsOnMerge")}
+ onValueChange={(value) => write({ removeAgentCreditsOnMerge: value })}
+ />
+ </SettingsSection>
+ <SettingsSection title="Default branch">
+ <SettingsSwitchRow
+ icon="arrow.down.circle"
+ label="Automatically pull"
+ subtitle={managedSubtitle(
+ "defaultAutoPull",
+ "Keep the default branch current when there are no local changes.",
+ )}
+ value={uniform("defaultAutoPull")}
+ disabled={disabledFor("defaultAutoPull")}
+ onValueChange={(value) => write({ defaultAutoPull: value })}
+ />
+ </SettingsSection>
+ <SettingsSection title="Clones">
+ <SettingsSwitchRow
+ icon="folder"
+ label="Clone into host folders"
+ subtitle="Clones go to github.com/owner/repo under the Add project folder, like ghq."
+ value={uniform("ghqCloneLayout")}
+ disabled={disabledFor("ghqCloneLayout")}
+ onValueChange={(value) => write({ ghqCloneLayout: value })}
+ />
+ </SettingsSection>
+ </>
+ ) : null}
+
+ {props.page === "worktrees" ? (
+ <>
+ <SettingsSection title="New worktrees">
+ <SettingsSwitchRow
+ icon="arrow.triangle.branch"
+ label="Start from remote"
+ subtitle={managedSubtitle(
+ "newWorktreesStartFromOrigin",
+ "Uses the latest commit of the base branch’s tracked remote branch, even if its name differs. Otherwise uses the same-named branch on origin. Uses your local branch if that remote branch is missing.",
+ )}
+ value={uniform("newWorktreesStartFromOrigin")}
+ disabled={disabledFor("newWorktreesStartFromOrigin")}
+ onValueChange={(value) => write({ newWorktreesStartFromOrigin: value })}
+ />
+ </SettingsSection>
+ <SettingsSection
+ title="Worktree submodules"
+ footer={managed("worktreeSubmodules")}
+ trailing={
+ pendingWrites === 0 && isMixed("worktreeSubmodules") ? (
+ <MixedValuesLabel projectSelected={projectSelected} />
+ ) : null
+ }
+ >
+ {SUBMODULE_CHOICES.filter(
+ (choice) => choice.mode !== null || !projectSelected,
+ ).map((choice, index) => (
+ <SettingsChoiceRow
+ key={choice.mode ?? "inherit"}
+ label={choice.label}
+ description={choice.description}
+ selected={
+ !isMixed("worktreeSubmodules") &&
+ uniform("worktreeSubmodules") === choice.mode
+ }
+ separated={index > 0}
+ disabled={disabledFor("worktreeSubmodules")}
+ onPress={() => write({ worktreeSubmodules: choice.mode })}
/>
- </SettingsSection>
- <SettingsSection
- title="Worktree submodules"
- footer={managed("worktreeSubmodules")}
- trailing={
- pendingWrites === 0 && isMixed("worktreeSubmodules") ? (
- <MixedValuesLabel projectSelected={projectSelected} />
- ) : null
- }
- >
- {SUBMODULE_CHOICES.filter(
- (choice) => choice.mode !== null || !projectSelected,
- ).map((choice, index) => (
- <SettingsChoiceRow
- key={choice.mode ?? "inherit"}
- label={choice.label}
- description={choice.description}
- selected={
- !isMixed("worktreeSubmodules") &&
- uniform("worktreeSubmodules") === choice.mode
+ ))}
+ </SettingsSection>
+ <BranchNamingSettings
+ key={targetsKey}
+ mode={uniform("branchNamingMode")}
+ prefix={uniform("branchNamePrefix")}
+ instructions={uniform("branchNameInstructions")}
+ disabled={{
+ mode: disabledFor("branchNamingMode"),
+ prefix: disabledFor("branchNamePrefix"),
+ instructions: disabledFor("branchNameInstructions"),
+ }}
+ onChange={write}
+ />
+ </>
+ ) : null}
+
+ {props.page === "maintenance" ? (
+ <>
+ {!projectSelected ? (
+ <DatabaseStorageNotice
+ targets={selectedTargets.filter(
+ (target) =>
+ target.serverConfig.environment.capabilities.databaseStorage === true,
+ )}
+ />
+ ) : null}
+ {!projectSelected ? (
+ <SettingsSection title="Manage environments">
+ {selectedTargets.map((target) => (
+ <SettingsRow
+ key={target.environmentId}
+ icon="server.rack"
+ label={target.label}
+ value="Server and provider updates"
+ onPress={() =>
+ navigation.navigate("SettingsEnvironmentDetail", {
+ environmentId: target.environmentId,
+ })
}
- separated={index > 0}
- disabled={disabledFor("worktreeSubmodules")}
- onPress={() => write({ worktreeSubmodules: choice.mode })}
/>
))}
</SettingsSection>
- <BranchNamingSettings
- key={targetsKey}
- mode={uniform("branchNamingMode")}
- prefix={uniform("branchNamePrefix")}
- instructions={uniform("branchNameInstructions")}
- disabled={{
- mode: disabledFor("branchNamingMode"),
- prefix: disabledFor("branchNamePrefix"),
- instructions: disabledFor("branchNameInstructions"),
- }}
- onChange={write}
+ ) : null}
+ <SettingsSection title="Updates">
+ <SettingsSwitchRow
+ icon="arrow.clockwise"
+ label="Check provider updates"
+ subtitle={managedSubtitle(
+ "enableProviderUpdateChecks",
+ projectSelected
+ ? "Environment-wide setting. Select All projects to change it."
+ : "Check installed provider CLIs for newer versions and fetch model catalog updates. When off, new models may not appear.",
+ )}
+ value={uniform("enableProviderUpdateChecks")}
+ disabled={disabledFor("enableProviderUpdateChecks")}
+ onValueChange={(value) => write({ enableProviderUpdateChecks: value })}
/>
- </>
- ) : null}
-
- {props.page === "maintenance" ? (
- <>
- {!projectSelected ? (
- <DatabaseStorageNotice
- targets={selectedTargets.filter(
- (target) =>
- target.serverConfig.environment.capabilities.databaseStorage === true,
- )}
- />
- ) : null}
- {!projectSelected ? (
- <SettingsSection title="Manage environments">
- {selectedTargets.map((target) => (
- <SettingsRow
- key={target.environmentId}
- icon="server.rack"
- label={target.label}
- value="Server and provider updates"
- onPress={() =>
- navigation.navigate("SettingsEnvironmentDetail", {
- environmentId: target.environmentId,
- })
- }
- />
- ))}
- </SettingsSection>
- ) : null}
- <SettingsSection title="Updates">
+ <View className="border-t border-border-subtle">
<SettingsSwitchRow
- icon="arrow.clockwise"
- label="Check provider updates"
+ icon="arrow.uturn.forward"
+ label="Continue after restart"
subtitle={managedSubtitle(
- "enableProviderUpdateChecks",
- projectSelected
- ? "Environment-wide setting. Select All projects to change it."
- : "Check installed provider CLIs for newer versions and fetch model catalog updates. When off, new models may not appear.",
+ "continueThreadsAfterServerUpdate",
+ "Resume interrupted threads after an update or restart.",
)}
- value={uniform("enableProviderUpdateChecks")}
- disabled={disabledFor("enableProviderUpdateChecks")}
- onValueChange={(value) => write({ enableProviderUpdateChecks: value })}
+ value={uniform("continueThreadsAfterServerUpdate")}
+ disabled={disabledFor("continueThreadsAfterServerUpdate")}
+ onValueChange={(value) => write({ continueThreadsAfterServerUpdate: value })}
/>
- <View className="border-t border-border-subtle">
- <SettingsSwitchRow
- icon="arrow.uturn.forward"
- label="Continue after restart"
- subtitle={managedSubtitle(
- "continueThreadsAfterServerUpdate",
- "Resume interrupted threads after an update or restart.",
- )}
- value={uniform("continueThreadsAfterServerUpdate")}
- disabled={disabledFor("continueThreadsAfterServerUpdate")}
- onValueChange={(value) =>
- write({ continueThreadsAfterServerUpdate: value })
- }
- />
- </View>
- </SettingsSection>
- </>
- ) : null}
- </>
- )}
- </ScrollView>
- </SettingsScreen>
- </>
+ </View>
+ </SettingsSection>
+ </>
+ ) : null}
+ </>
+ )}
+ </ScrollView>
+ </SettingsScreen>
);
}
diff --git a/apps/mobile/src/features/settings/components/SettingsEnvironmentFilterHeader.tsx b/apps/mobile/src/features/settings/components/SettingsEnvironmentFilterHeader.tsx
index 2ec1982167a..29eafff4ab6 100644
--- a/apps/mobile/src/features/settings/components/SettingsEnvironmentFilterHeader.tsx
+++ b/apps/mobile/src/features/settings/components/SettingsEnvironmentFilterHeader.tsx
@@ -1,124 +1,14 @@
-import type { NativeStackHeaderItem } from "@react-navigation/native-stack";
import { resolveEnvironmentMachineKind } from "@t3tools/contracts";
-import { Platform } from "react-native";
import type { AppBarMenu } from "../../../components/ui/AppBar.types";
import { ENVIRONMENT_MACHINE_SYMBOLS } from "../../../components/EnvironmentMachineSymbol";
-import { NativeStackScreenOptions } from "../../../native/StackHeader";
-import { withNativeGlassHeaderItem } from "../../layout/native-glass-header-items";
import { useSettingsEnvironmentFilter } from "../settings-environment-filter";
-export function SettingsEnvironmentFilterHeader(props: {
- readonly trailingItems?: readonly NativeStackHeaderItem[];
-}) {
- const {
- availableTargets,
- selectedTargets,
- selectedIds,
- selectAll,
- toggleEnvironment,
- selectableProjectGroups,
- selectedProjectKey,
- selectProject,
- } = useSettingsEnvironmentFilter();
- if (Platform.OS !== "ios") return null;
-
- const filterIcon =
- selectedIds === null && selectedProjectKey === null
- ? "line.3.horizontal.decrease"
- : "line.3.horizontal.decrease.circle.fill";
- const filterVersion = JSON.stringify({
- selection: selectedIds === null ? null : [...selectedIds].sort(),
- targets: availableTargets.map((entry) => [
- entry.environmentId,
- entry.label,
- entry.displayUrl,
- resolveEnvironmentMachineKind(entry.serverConfig),
- ]),
- project: selectedProjectKey,
- projects: selectableProjectGroups.map((group) => [group.key, group.label]),
- trailingItems: props.trailingItems,
- });
-
- return (
- <NativeStackScreenOptions
- optionsVersion={filterVersion}
- options={{
- unstable_headerRightItems: () => [
- withNativeGlassHeaderItem({
- accessibilityLabel: "Filter settings environments and projects",
- icon: { name: filterIcon, type: "sfSymbol" },
- label: "",
- type: "menu",
- menu: {
- title: "Settings scope",
- items: [
- {
- type: "submenu",
- label:
- selectedIds === null
- ? "All environments"
- : `${selectedTargets.length} ${selectedTargets.length === 1 ? "environment" : "environments"}`,
- items: [
- {
- type: "action",
- label: "All connected environments",
- state: selectedIds === null ? "on" : undefined,
- onPress: selectAll,
- },
- ...availableTargets.map((entry) => ({
- type: "action" as const,
- label: entry.label,
- icon: {
- type: "sfSymbol" as const,
- name: ENVIRONMENT_MACHINE_SYMBOLS[
- resolveEnvironmentMachineKind(entry.serverConfig)
- ],
- },
- description: entry.displayUrl ?? undefined,
- state:
- selectedIds === null || selectedIds.has(entry.environmentId)
- ? ("on" as const)
- : undefined,
- onPress: () => toggleEnvironment(entry.environmentId),
- })),
- ],
- },
- {
- type: "submenu",
- label:
- selectableProjectGroups.find((group) => group.key === selectedProjectKey)
- ?.label ??
- (selectedProjectKey === null ? "All projects" : "Unavailable project"),
- items: [
- {
- type: "action",
- label: "All projects",
- state: selectedProjectKey === null ? "on" : undefined,
- onPress: () => selectProject(null),
- },
- ...selectableProjectGroups.map((group) => ({
- type: "action" as const,
- label: projectMenuLabel(group),
- state: selectedProjectKey === group.key ? ("on" as const) : undefined,
- onPress: () => selectProject(group.key),
- })),
- ],
- },
- ],
- },
- }),
- ...(props.trailingItems ?? []),
- ],
- }}
- />
- );
-}
-
-/** Android's settings scope filter, as an `AppBar` menu. */
+/** The settings scope filter, as an `AppBar` menu. */
export function useSettingsEnvironmentMenu(): AppBarMenu {
const {
availableTargets,
+ selectedTargets,
selectedIds,
selectAll,
toggleEnvironment,
@@ -130,35 +20,52 @@ export function useSettingsEnvironmentMenu(): AppBarMenu {
title: "Filter settings environments and projects",
icon:
selectedIds === null && selectedProjectKey === null
- ? "line.3.horizontal.decrease.circle"
+ ? "line.3.horizontal.decrease"
: "line.3.horizontal.decrease.circle.fill",
items: [
{
- id: "all",
- title: "All connected environments",
- selected: selectedIds === null,
- onPress: selectAll,
+ id: "environments",
+ title:
+ selectedIds === null
+ ? "All environments"
+ : `${selectedTargets.length} ${selectedTargets.length === 1 ? "environment" : "environments"}`,
+ items: [
+ {
+ id: "all",
+ title: "All connected environments",
+ selected: selectedIds === null,
+ onPress: selectAll,
+ },
+ ...availableTargets.map((entry) => ({
+ id: `environment:${entry.environmentId}`,
+ title: entry.label,
+ icon: ENVIRONMENT_MACHINE_SYMBOLS[resolveEnvironmentMachineKind(entry.serverConfig)],
+ subtitle: entry.displayUrl ?? undefined,
+ selected: selectedIds === null || selectedIds.has(entry.environmentId),
+ onPress: () => toggleEnvironment(entry.environmentId),
+ })),
+ ],
},
- ...availableTargets.map((entry) => ({
- id: `environment:${entry.environmentId}`,
- title: `Environment · ${entry.label}`,
- icon: ENVIRONMENT_MACHINE_SYMBOLS[resolveEnvironmentMachineKind(entry.serverConfig)],
- subtitle: entry.displayUrl ?? undefined,
- selected: selectedIds === null || selectedIds.has(entry.environmentId),
- onPress: () => toggleEnvironment(entry.environmentId),
- })),
{
- id: "project:all",
- title: "All projects",
- selected: selectedProjectKey === null,
- onPress: () => selectProject(null),
+ id: "projects",
+ title:
+ selectableProjectGroups.find((group) => group.key === selectedProjectKey)?.label ??
+ (selectedProjectKey === null ? "All projects" : "Unavailable project"),
+ items: [
+ {
+ id: "project:all",
+ title: "All projects",
+ selected: selectedProjectKey === null,
+ onPress: () => selectProject(null),
+ },
+ ...selectableProjectGroups.map((group) => ({
+ id: `project:${group.key}`,
+ title: projectMenuLabel(group),
+ selected: selectedProjectKey === group.key,
+ onPress: () => selectProject(group.key),
+ })),
+ ],
},
- ...selectableProjectGroups.map((group) => ({
- id: `project:${group.key}`,
- title: `Project · ${projectMenuLabel(group)}`,
- selected: selectedProjectKey === group.key,
- onPress: () => selectProject(group.key),
- })),
],
};
}
diff --git a/apps/mobile/src/features/settings/components/SettingsScreen.tsx b/apps/mobile/src/features/settings/components/SettingsScreen.tsx
index a18ae1c1566..8cd478c7040 100644
--- a/apps/mobile/src/features/settings/components/SettingsScreen.tsx
+++ b/apps/mobile/src/features/settings/components/SettingsScreen.tsx
@@ -1,6 +1,6 @@
import { useRoute } from "@react-navigation/native";
import type { ReactNode } from "react";
-import { Platform, View } from "react-native";
+import { View } from "react-native";
import type { AppBarProps } from "../../../components/ui/AppBar.types";
import { AppBar } from "../../../components/ui/AppBar";
@@ -8,7 +8,6 @@ import { ScreenContent as SettingsScreenContent } from "../../../components/ui/S
import { useWorkspaceTabs } from "../../workspace/WorkspaceTabsContext";
import { useDeviceType } from "../../../native/native-layout-metrics";
import { useCompactWorkspaceTabs } from "../../workspace/useSystemWorkspaceTabBar";
-import { useAdaptiveWorkspaceLayout } from "../../layout/adaptive-workspace-context";
import { useSettingsPageBack } from "../useSettingsPageBack";
import {
ScreenScrollViewBottomInset,
@@ -18,9 +17,11 @@ import {
export { SettingsScreenContent };
export function SettingsScreen(
- props: Pick<AppBarProps, "title" | "actions" | "trailing" | "search" | "menus" | "options"> & {
+ props: Pick<
+ AppBarProps,
+ "title" | "actions" | "refresh" | "trailing" | "search" | "menus" | "guardBack"
+ > & {
readonly children: ReactNode;
- readonly formSheet?: boolean;
readonly workspaceRoot?: boolean;
},
) {
@@ -28,13 +29,10 @@ export function SettingsScreen(
const workspace = useWorkspaceTabs();
const deviceType = useDeviceType();
const compactTabs = useCompactWorkspaceTabs();
- const { layout } = useAdaptiveWorkspaceLayout();
const back = useSettingsPageBack();
const cover = deviceType === "duo-folded";
- // Android opens Settings as a workspace tab; its root page has nothing to go back to.
- const workspaceRoot =
- props.workspaceRoot ||
- (Platform.OS === "android" && workspace !== null && route.name === "Settings");
+ // Opened as a workspace tab, the Settings list has nothing to go back to.
+ const workspaceRoot = props.workspaceRoot || (workspace !== null && route.name === "Settings");
const surfaceClassName = workspaceRoot || cover ? "bg-screen" : "bg-sheet";
@@ -43,26 +41,17 @@ export function SettingsScreen(
<AppBar
title={props.title}
actions={props.actions}
+ refresh={props.refresh}
search={props.search}
- trailing={Platform.OS === "android" ? props.trailing : undefined}
- // iOS screens put their filter menus in native header items themselves.
- menus={Platform.OS === "android" ? props.menus : undefined}
- sheet={Platform.OS === "android" && props.formSheet}
+ trailing={props.trailing}
+ menus={props.menus}
onBack={workspaceRoot ? undefined : back}
- hideBottomBorder={!props.formSheet || Platform.OS === "android"}
- options={props.options}
+ guardBack={props.guardBack}
+ hideBottomBorder
/>
<ScreenScrollViewBottomInset value={deviceType === "pad" || compactTabs ? 80 : 0}>
<ScreenScrollViewSurface value={surfaceClassName}>
- {props.formSheet && Platform.OS !== "android" ? (
- props.children
- ) : (
- <SettingsScreenContent
- insetHorizontal={Platform.OS === "android" && layout.usesSplitView}
- >
- {props.children}
- </SettingsScreenContent>
- )}
+ <SettingsScreenContent>{props.children}</SettingsScreenContent>
</ScreenScrollViewSurface>
</ScreenScrollViewBottomInset>
</View>
diff --git a/apps/mobile/src/features/terminal/TerminalContextSheet.tsx b/apps/mobile/src/features/terminal/TerminalContextSheet.tsx
index 99e445d483c..0e0a8785979 100644
--- a/apps/mobile/src/features/terminal/TerminalContextSheet.tsx
+++ b/apps/mobile/src/features/terminal/TerminalContextSheet.tsx
@@ -7,7 +7,7 @@ import {
} from "@t3tools/contracts";
import { formatComposerContextReference } from "@t3tools/shared/composerContextReferences";
import { useState } from "react";
-import { Platform, Pressable, ScrollView, View } from "react-native";
+import { Pressable, ScrollView, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { REVIEW_MONO_FONT_FAMILY } from "../review/reviewDiffRendering";
import { AppText as Text } from "../../components/ui/AppText";
@@ -60,7 +60,7 @@ export function TerminalContextSheet(props: {
<ScrollView
nestedScrollEnabled
className="flex-1"
- contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
+ contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={{ paddingHorizontal: 20, paddingTop: 12, paddingBottom: 20 }}
>
<Text className="pb-4 text-sm text-foreground-muted">
diff --git a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx
index 82ede662bba..19a8685fe36 100644
--- a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx
+++ b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx
@@ -11,6 +11,7 @@ import { type KnownTerminalSession } from "@t3tools/client-runtime/state/termina
import { SymbolView } from "../../components/ui/AppSymbol";
import { AppBar } from "../../components/ui/AppBar";
import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
+import { useContentTopInset } from "../../components/ui/useBarInset";
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
import { useAtomMount } from "@effect/atom-react";
import { useMemo, useRef, useState } from "react";
@@ -377,6 +378,7 @@ function ThreadTerminal(props: {
} = props.knownSessions;
const insets = useSafeAreaInsets();
const nativeColumnMetrics = useNativeColumnLayoutMetrics();
+ const contentTopInset = useContentTopInset();
const navigation = useNavigation();
const writeTerminal = useAtomCommand(terminalEnvironment.write, "terminal write");
const clearTerminal = useAtomCommand(terminalEnvironment.clear, "terminal clear");
@@ -839,8 +841,7 @@ function ThreadTerminal(props: {
? themeVariables["--color-card-alt"]
: terminalTheme.background,
// Measured top reservation is zero when UIKit already inset the body or moved the bar.
- paddingTop:
- Platform.OS === "ios" ? (nativeColumnMetrics?.safeArea.top ?? insets.top) : 0,
+ paddingTop: contentTopInset,
paddingBottom:
Platform.OS === "android" && !keyboardState.isVisible ? insets.bottom : 0,
}}
diff --git a/apps/mobile/src/features/threads/DraftThreadHeader.tsx b/apps/mobile/src/features/threads/DraftThreadHeader.tsx
index 5c3d758f455..773ffc76c27 100644
--- a/apps/mobile/src/features/threads/DraftThreadHeader.tsx
+++ b/apps/mobile/src/features/threads/DraftThreadHeader.tsx
@@ -8,8 +8,6 @@ import type {
EnvironmentProject,
EnvironmentThreadShell,
} from "@t3tools/client-runtime/state/shell";
-import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
-import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
import { useEnvironmentQuery } from "../../state/query";
import { useEnvironmentScope } from "../../state/session";
import { useAtomCommand } from "../../state/use-atom-command";
@@ -23,7 +21,6 @@ export function DraftThreadHeader(props: {
readonly cwd: string | null;
}) {
const navigation = useNavigation();
- const { themeVariables } = useAppearancePreferences();
const environmentId = props.thread.environmentId;
const canReadFiles = useEnvironmentScope(environmentId, AuthFilesystemReadScope);
const canWriteGit = useEnvironmentScope(environmentId, AuthSourceControlWriteScope);
@@ -51,15 +48,11 @@ export function DraftThreadHeader(props: {
draft
title="New thread"
subtitle=""
- headerColor={themeVariables["--color-header"]}
- usesNativeHeaderGlass={NATIVE_LIQUID_GLASS_SUPPORTED}
hasThreadCwd={props.cwd !== null}
- hasWorkspaceRoot={Boolean(props.project.workspaceRoot)}
fileInspectorSupported={false}
inspectorMode={null}
onToggleInspector={openFiles}
onOpenFilesInspector={openFiles}
- onOpenGitInspector={requiresThread}
gitControls={{
environmentId,
threadId: props.thread.id,
diff --git a/apps/mobile/src/features/threads/GitActionProgressOverlay.tsx b/apps/mobile/src/features/threads/GitActionProgressOverlay.tsx
index 17475f9e33d..47f83d1a23f 100644
--- a/apps/mobile/src/features/threads/GitActionProgressOverlay.tsx
+++ b/apps/mobile/src/features/threads/GitActionProgressOverlay.tsx
@@ -1,13 +1,8 @@
import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
-import { HeaderHeightContext } from "@react-navigation/elements";
-import { useContext } from "react";
-import { Platform } from "react-native";
import Animated, { FadeIn, FadeOut, ReduceMotion } from "react-native-reanimated";
-import { useSafeAreaInsets } from "react-native-safe-area-context";
import { Toast } from "../../components/ui/Toast";
-import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
+import { useBarInset } from "../../components/ui/useBarInset";
import { MOBILE_MOTION } from "../../lib/designTokens";
-import { APP_BAR_HEIGHT } from "../../lib/layoutMetrics";
import type { GitActionProgress } from "../../state/use-vcs-action-state";
export function GitActionProgressOverlay(props: {
@@ -17,14 +12,7 @@ export function GitActionProgressOverlay(props: {
}) {
const { progress, onDismiss } = props;
const openPullRequest = props.onOpenPullRequest;
- const insets = useSafeAreaInsets();
- // Keyboard-copy feedback sits outside the screen's native header context.
- const headerHeight = useContext(HeaderHeightContext) ?? insets.top + APP_BAR_HEIGHT;
- const toolbar = useToolbarLayout();
- const top =
- Platform.OS === "android"
- ? toolbar.paddingTop + toolbar.height + toolbar.paddingBottom + 8
- : headerHeight + 8;
+ const top = useBarInset() + 8;
const handlePress = () => {
if (progress.prUrl) {
void (openPullRequest
diff --git a/apps/mobile/src/features/threads/LinkRequestCard.tsx b/apps/mobile/src/features/threads/LinkRequestCard.tsx
index 4150c96a34e..53c5408b6d5 100644
--- a/apps/mobile/src/features/threads/LinkRequestCard.tsx
+++ b/apps/mobile/src/features/threads/LinkRequestCard.tsx
@@ -24,7 +24,7 @@ import {
import * as Option from "effect/Option";
import * as Result from "effect/Result";
import { useMemo, useRef, useState } from "react";
-import { Modal, Platform, Pressable, ScrollView, View, type ColorValue } from "react-native";
+import { Pressable, ScrollView, View, type ColorValue } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";
@@ -37,6 +37,7 @@ import { useAtomCommand } from "../../state/use-atom-command";
import { ListChoiceRow as SettingsChoiceRow } from "../../components/ui/ListChoiceRow";
import { SettingsSection } from "../settings/components/SettingsSection";
import { Button } from "../../components/ui/Button";
+import { Sheet } from "../../components/ui/Sheet";
import { RUNTIME_MODE_CHOICES } from "./thread-settings-options";
/** The same five levels as web's access picker: read-only, then the runtime modes. */
@@ -316,24 +317,20 @@ function LinkRequestSheet(props: {
};
return (
- <Modal
- animationType="slide"
- presentationStyle={Platform.OS === "ios" ? "pageSheet" : "fullScreen"}
+ <Sheet
+ title={pickMachine ? "Link a machine" : `Link ${targetName}`}
+ onClose={props.onClose}
// An answer that lands after a close would still link, and would close a reopened sheet.
- onRequestClose={() => {
- if (!busy) props.onClose();
- }}
+ dismissDisabled={busy}
>
<ScrollView
className="flex-1 bg-sheet-solid"
+ contentInsetAdjustmentBehavior="automatic"
contentContainerClassName="gap-5 p-5"
contentContainerStyle={{ paddingBottom: insets.bottom + 20 }}
keyboardShouldPersistTaps="handled"
>
<View className="gap-1">
- <Text className="font-t3-bold text-lg text-foreground">
- {pickMachine ? "Link a machine" : `Link ${targetName}`}
- </Text>
<Text className="font-sans text-sm leading-5 text-foreground-muted">
Agents here can then launch, message and wait on threads there. It appears in that
machine's Connections, where it can be revoked.
@@ -457,7 +454,7 @@ function LinkRequestSheet(props: {
/>
<Button label="Cancel" tone="secondary" disabled={busy} onPress={props.onClose} fullWidth />
</ScrollView>
- </Modal>
+ </Sheet>
);
}
diff --git a/apps/mobile/src/features/threads/McpAppFullscreenScreen.tsx b/apps/mobile/src/features/threads/McpAppFullscreenScreen.tsx
index 95d111f4333..de3041c06b5 100644
--- a/apps/mobile/src/features/threads/McpAppFullscreenScreen.tsx
+++ b/apps/mobile/src/features/threads/McpAppFullscreenScreen.tsx
@@ -4,11 +4,11 @@ import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell
import { turnItemDetailRevision } from "@t3tools/client-runtime/work-log/item-detail";
import { mcpAppFromToolItem } from "@t3tools/shared/toolOutput";
import { useEffect, useRef, useState } from "react";
-import { Pressable, View } from "react-native";
+import { View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppText as Text } from "../../components/ui/AppText";
-import { SymbolView } from "../../components/ui/AppSymbol";
+import { AppBar } from "../../components/ui/AppBar";
import { orchestrationEnvironment } from "../../state/orchestration";
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
import { useThreadShell, useThreadShells } from "../../state/entities";
@@ -108,20 +108,12 @@ export function McpAppFullscreenScreen({ route }: McpAppFullscreenScreenProps) {
}, [awaitingUser, focused, navigation]);
return (
- <View className="flex-1 bg-screen" style={{ paddingTop: insets.top }}>
- <View className="h-11 flex-row items-center justify-between px-3">
- <Text className="text-base font-semibold text-foreground" numberOfLines={1}>
- {app?.server ?? "App"}
- </Text>
- <Pressable
- accessibilityRole="button"
- accessibilityLabel="Exit full screen"
- hitSlop={8}
- onPress={onClose}
- >
- <SymbolView name="xmark" size={18} tintColor="gray" />
- </Pressable>
- </View>
+ <View className="flex-1 bg-screen">
+ <AppBar
+ title={app?.server ?? "App"}
+ onClose={onClose}
+ closeAccessibilityLabel="Exit full screen"
+ />
<View
className="flex-1"
style={{ paddingBottom: insets.bottom }}
diff --git a/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx b/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx
index fe109c5f9d4..88ec0c06e43 100644
--- a/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx
+++ b/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx
@@ -1,7 +1,5 @@
import { NativeScrollView } from "../../native/NativeScrollViewMarker";
-import { SearchField } from "../../components/ui/SearchField";
import { Button } from "../../components/ui/Button";
-import { Toolbar } from "../../components/ui/Toolbar";
import * as Dialog from "../../components/ui/Dialog";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import { SelectionRow } from "../../components/ui/SelectionRow";
@@ -32,15 +30,11 @@ import { AppText as Text } from "../../components/ui/AppText";
import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
import { ThemedSwitch } from "../../components/ui/ThemedSwitch";
import { cn } from "../../lib/cn";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
import { useEnvironmentScope } from "../../state/session";
import { useAtomCommand } from "../../state/use-atom-command";
import { vcsEnvironment } from "../../state/vcs";
-import {
- createNativeMailSearchToolbarItem,
- NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET,
-} from "../layout/native-mail-search-toolbar";
-import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
+import { useSearchToolbarInset } from "../../components/ui/useBarInset";
+import type { AppBarSearch } from "../../components/ui/AppBar";
import { branchBadgeLabel, useNewTaskFlow } from "./new-task-flow-provider";
import { checkoutNewTaskBranch } from "./checkout-new-task-branch";
import { filterNewTaskBranches } from "./new-task-context-presentation";
@@ -188,15 +182,7 @@ export function NewTaskEnvironmentPickerRouteScreen() {
const insets = useSafeAreaInsets();
return (
<View className="flex-1 bg-sheet" collapsable={false}>
- <NativeStackScreenOptions
- options={{
- headerShown: Platform.OS !== "android",
- title: "Environment",
- }}
- />
- {Platform.OS === "android" ? (
- <AppBar embedded title="Environment" hideBottomBorder onBack={() => navigation.goBack()} />
- ) : null}
+ <AppBar title="Environment" hideBottomBorder onBack={() => navigation.goBack()} />
<ScreenContent>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
@@ -365,18 +351,25 @@ export function BranchPickerScreen(props: {
readonly onChangeStartFromOrigin: (value: boolean) => void;
};
}) {
- const searchRef = useRef<import("react-native").TextInputInstance>(null);
const navigation = useNavigation();
const insets = useSafeAreaInsets();
- const usesNativeMailSearchToolbar = useNativeMailSearchToolbar();
+ const search: AppBarSearch = {
+ value: props.query,
+ onChangeText: props.onQueryChange,
+ placeholder: "Find a branch",
+ clearAccessibilityLabel: "Clear branch search",
+ mode: "inline",
+ compactToolbar: true,
+ };
+ const searchToolbarInset = useSearchToolbarInset(search);
const selectedBranchName =
props.selectedBranchName ??
props.branches.find((branch) => branch.current)?.name ??
props.branches.find((branch) => branch.isDefault)?.name ??
null;
const branchListContentStyle = {
- paddingBottom: usesNativeMailSearchToolbar
- ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 16
+ paddingBottom: searchToolbarInset
+ ? searchToolbarInset + 16
: Platform.OS === "ios"
? 16
: Math.max(insets.bottom, 16) + 16,
@@ -425,9 +418,7 @@ export function BranchPickerScreen(props: {
<View
className="flex-1 items-center justify-center gap-3 px-4"
style={{
- marginBottom: usesNativeMailSearchToolbar
- ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET
- : 0,
+ marginBottom: searchToolbarInset,
}}
>
{props.loading ? <AppActivityIndicator /> : null}
@@ -449,7 +440,7 @@ export function BranchPickerScreen(props: {
</ScrollView>
) : (
<LegendList
- renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
+ renderScrollComponent={NativeScrollView}
alwaysBounceVertical={false}
automaticallyAdjustsScrollIndicatorInsets
automaticallyAdjustKeyboardInsets={Platform.OS === "ios"}
@@ -477,66 +468,15 @@ export function BranchPickerScreen(props: {
/>
);
- if (Platform.OS === "android") {
- return (
- <View className="flex-1 bg-sheet" collapsable={false}>
- <NativeStackScreenOptions options={{ headerShown: false }} />
- <AppBar embedded title={props.title} hideBottomBorder onBack={() => navigation.goBack()} />
- <View className="bg-header px-4 pb-3 pt-1">
- <SearchField
- inputRef={searchRef}
- autoFocus={false}
- accessibilityLabel="Find a branch"
- clearAccessibilityLabel="Clear branch search"
- onChangeText={props.onQueryChange}
- placeholder="Find a branch"
- value={props.query}
- />
- </View>
- <ScreenContent>{branchContent}</ScreenContent>
- </View>
- );
- }
-
return (
- <>
- <NativeStackScreenOptions
- options={{
- headerShown: true,
- title: props.title,
- unstable_headerToolbarItems: usesNativeMailSearchToolbar
- ? () => [
- createNativeMailSearchToolbarItem({
- onSearchTextChange: props.onQueryChange,
- placeholder: "Find a branch",
- searchTextChangeId: "new-task-branch-search-text",
- showsSearchDismissButton: true,
- }),
- ]
- : undefined,
- headerSearchBarOptions: usesNativeMailSearchToolbar
- ? undefined
- : {
- allowToolbarIntegration: true,
- autoCapitalize: "none",
- hideNavigationBar: false,
- obscureBackground: false,
- placeholder: "Find a branch",
- onChangeText: (event) => {
- props.onQueryChange(event.nativeEvent.text);
- },
- onCancelButtonPress: () => {
- props.onQueryChange("");
- },
- },
- }}
+ <View className="flex-1 bg-sheet" collapsable={false}>
+ <AppBar
+ title={props.title}
+ hideBottomBorder
+ onBack={() => navigation.goBack()}
+ search={search}
/>
- {usesNativeMailSearchToolbar ? null : (
- <Toolbar placement="bottom">
- <Toolbar.SearchBarSlot />
- </Toolbar>
- )}
- {branchContent}
- </>
+ <ScreenContent>{branchContent}</ScreenContent>
+ </View>
);
}
diff --git a/apps/mobile/src/features/threads/NewTaskDraftRouteScreen.test.tsx b/apps/mobile/src/features/threads/NewTaskDraftRouteScreen.test.tsx
index ca955b2cd37..636e6658c3d 100644
--- a/apps/mobile/src/features/threads/NewTaskDraftRouteScreen.test.tsx
+++ b/apps/mobile/src/features/threads/NewTaskDraftRouteScreen.test.tsx
@@ -54,7 +54,10 @@ vi.mock("../../components/ui/AppText", () => ({
AppText: ({ children }: { children: ReactNode }) => <span>{children}</span>,
}));
vi.mock("../../components/ui/Dialog", () => ({ alert: vi.fn() }));
-vi.mock("../../native/StackHeader", () => ({ NativeStackScreenOptions: () => null }));
+vi.mock("../../components/ui/AppBar", () => ({ AppBar: () => null }));
+vi.mock("../workspace/useAndroidWorkspaceNavigation", () => ({
+ useWorkspaceBackNavigation: () => () => undefined,
+}));
vi.mock("./ThreadScreenHost", () => ({
ThreadScreenFallback: ({ children }: { children: ReactNode }) => <>{children}</>,
}));
diff --git a/apps/mobile/src/features/threads/NewTaskDraftRouteScreen.tsx b/apps/mobile/src/features/threads/NewTaskDraftRouteScreen.tsx
index 75ba59f2225..02165d01fdc 100644
--- a/apps/mobile/src/features/threads/NewTaskDraftRouteScreen.tsx
+++ b/apps/mobile/src/features/threads/NewTaskDraftRouteScreen.tsx
@@ -30,7 +30,8 @@ import {
makeNewTaskBranchCheckouts,
} from "./new-task-branch-checkout";
import { liveNewTaskFlowKeys, newTaskFlowKey } from "./new-task-flow-state";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
+import { AppBar } from "../../components/ui/AppBar";
+import { useWorkspaceBackNavigation } from "../workspace/useAndroidWorkspaceNavigation";
import { ThreadScreenFallback } from "./ThreadScreenHost";
import { NewTaskDraftScreen } from "./NewTaskDraftScreen";
@@ -89,6 +90,7 @@ const idleBranchCheckoutAtom = Atom.make(AsyncResult.initial<BranchCheckoutResul
export function NewTaskDraftRouteScreen({ route }: StaticScreenProps<NewTaskDraftRouteParams>) {
const currentRoute = useRoute();
+ const goBack = useWorkspaceBackNavigation("threads");
const params = route.params ?? {};
const draftId = Array.isArray(params.draftId) ? params.draftId[0] : params.draftId;
const projects = useProjects();
@@ -197,8 +199,7 @@ export function NewTaskDraftRouteScreen({ route }: StaticScreenProps<NewTaskDraf
return (
<>
{preparingBranch ? (
- <ThreadScreenFallback>
- <NativeStackScreenOptions options={{ title: "New thread" }} />
+ <ThreadScreenFallback header={<AppBar title="New thread" onBack={goBack} />}>
<View className="flex-1 items-center justify-center bg-screen">
<Text className="text-foreground">Switching branch...</Text>
</View>
diff --git a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
index fd0ea7e1e48..b5274b73fae 100644
--- a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
+++ b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
@@ -1,8 +1,6 @@
import { DraftEnvironmentControl } from "./DraftEnvironmentControl";
import { NativeScrollEdgeEffectsContext } from "../../native/NativeScrollViewMarker";
import { DraftThreadHeader } from "./DraftThreadHeader";
-import { threadHeaderAppearance } from "./thread-header-appearance";
-import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
import { useComposerAttachmentActions } from "../../state/use-composer-attachment-actions";
import { useWorkspaceBackNavigation } from "../workspace/useAndroidWorkspaceNavigation";
import { submittedThreadParams } from "./thread-route-state";
@@ -851,20 +849,7 @@ export function NewTaskDraftScreen(props: {
if (!flow.selectedModel) {
return (
- <ThreadScreenFallback
- header={
- <AppBar
- title="New thread"
- onBack={goBack}
- options={{
- ...threadHeaderAppearance(NATIVE_LIQUID_GLASS_SUPPORTED),
- unstable_headerSubtitle: undefined,
- unstable_headerRightItems: () => [],
- unstable_headerToolbarItems: () => [],
- }}
- />
- }
- >
+ <ThreadScreenFallback header={<AppBar title="New thread" onBack={goBack} />}>
<View className="flex-1 justify-end gap-3 p-4">
{environmentControl}
<Text className="text-foreground-muted">
diff --git a/apps/mobile/src/features/threads/NewTaskRouteScreen.tsx b/apps/mobile/src/features/threads/NewTaskRouteScreen.tsx
index cd7bdc77d67..de9ae4ba626 100644
--- a/apps/mobile/src/features/threads/NewTaskRouteScreen.tsx
+++ b/apps/mobile/src/features/threads/NewTaskRouteScreen.tsx
@@ -127,7 +127,6 @@ function NewTaskHeader(props: {
<AppBar
title={props.title}
subtitle={props.subtitle ?? undefined}
- options={{ headerBackVisible: true }}
hideBottomBorder
onBack={goBack}
actions={
diff --git a/apps/mobile/src/features/threads/ThreadAgentsSheet.tsx b/apps/mobile/src/features/threads/ThreadAgentsSheet.tsx
index c4c5fa58e22..e78239955e4 100644
--- a/apps/mobile/src/features/threads/ThreadAgentsSheet.tsx
+++ b/apps/mobile/src/features/threads/ThreadAgentsSheet.tsx
@@ -28,7 +28,6 @@ import { useVisibleSecondClock } from "./use-visible-second-clock";
import { SubagentStopButton } from "./SubagentStopButton";
import { ThreadWorkflowGroup } from "./ThreadWorkflowGroup";
import { ScreenContent } from "../../components/ui/ScreenContent";
-import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import { subagentThreadTarget } from "./threadAgentsPresentation";
import { useOpenThreadInspector } from "./thread-inspector-navigation";
@@ -48,7 +47,6 @@ export function useThreadTurnSubagents(target: AgentsTarget | null): ThreadTurnS
}
export function ThreadAgentsSheet({ route }: StaticScreenProps<AgentsTarget>) {
- const { layout } = useAdaptiveWorkspaceLayout();
const target = route.params;
const navigation = useNavigation();
const openInspector = useOpenThreadInspector();
@@ -130,7 +128,7 @@ export function ThreadAgentsSheet({ route }: StaticScreenProps<AgentsTarget>) {
return (
<View collapsable={false} className="flex-1 bg-sheet">
<SheetHeader title="Agents" onClose={() => navigation.goBack()} />
- <ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
+ <ScreenContent>{content}</ScreenContent>
</View>
);
}
diff --git a/apps/mobile/src/features/threads/ThreadBackgroundWorkSheet.tsx b/apps/mobile/src/features/threads/ThreadBackgroundWorkSheet.tsx
index 123b2611bce..87730e41381 100644
--- a/apps/mobile/src/features/threads/ThreadBackgroundWorkSheet.tsx
+++ b/apps/mobile/src/features/threads/ThreadBackgroundWorkSheet.tsx
@@ -15,7 +15,6 @@ import { SymbolView } from "../../components/ui/AppSymbol";
import { AppText as Text } from "../../components/ui/AppText";
import { ScreenContent } from "../../components/ui/ScreenContent";
import { environmentThreadShells } from "../../state/threads";
-import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
const KIND_LABELS = {
subagent: "Subagent",
@@ -27,7 +26,6 @@ const KIND_LABELS = {
type BackgroundWorkTarget = { readonly environmentId: EnvironmentId; readonly threadId: ThreadId };
export function ThreadBackgroundWorkSheet({ route }: StaticScreenProps<BackgroundWorkTarget>) {
- const { layout } = useAdaptiveWorkspaceLayout();
const navigation = useNavigation();
const insets = useSafeAreaInsets();
const target = route.params;
@@ -64,7 +62,7 @@ export function ThreadBackgroundWorkSheet({ route }: StaticScreenProps<Backgroun
return (
<View collapsable={false} className="flex-1 bg-sheet">
<SheetHeader title="Background work" onClose={() => navigation.goBack()} />
- <ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
+ <ScreenContent>{content}</ScreenContent>
</View>
);
}
diff --git a/apps/mobile/src/features/threads/ThreadComposer.tsx b/apps/mobile/src/features/threads/ThreadComposer.tsx
index f588dcfa388..08ae2486e46 100644
--- a/apps/mobile/src/features/threads/ThreadComposer.tsx
+++ b/apps/mobile/src/features/threads/ThreadComposer.tsx
@@ -2,6 +2,7 @@ import { useSidebarWorkspaceTabs } from "../workspace/useSystemWorkspaceTabBar";
import { Button } from "../../components/ui/Button";
import * as Dialog from "../../components/ui/Dialog";
import type { ComposerTextPaste } from "../../native/T3ComposerEditor.types";
+import { useDeviceType } from "../../native/native-layout-metrics";
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import {
useAppearancePreferences,
@@ -586,8 +587,9 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
const isExpanded = isFocused || settingsSheetPresentation.keepsComposerExpanded;
const { layout, setComposerEditing } = useAdaptiveWorkspaceLayout();
const floatingSidebarComposer = useAndroidFloatingTabs() && layout.usesSplitView;
- const usesLargeControls =
- useSidebarWorkspaceTabs() === "picker" || (Platform.OS === "ios" && Platform.isPad);
+ const sidebarWorkspaceTabs = useSidebarWorkspaceTabs();
+ const deviceType = useDeviceType();
+ const usesLargeControls = sidebarWorkspaceTabs === "picker" || deviceType === "pad";
const surfacePaddingVertical = usesLargeControls ? 9 : floatingSidebarComposer ? 6 : 2;
const [compactRowWidth, setCompactRowWidth] = useState(0);
const compactAttachmentLimit = compactRowWidth >= 500 ? 3 : 1;
diff --git a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx
index 255724094aa..d222ba8e9ea 100644
--- a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx
+++ b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx
@@ -35,7 +35,6 @@ import {
import { useKeyboardChatComposerInset, useKeyboardScrollToEnd } from "@legendapp/list/keyboard";
import { resolveProviderSkillsForCwd } from "@t3tools/client-runtime/providerSkills";
import type { LegendListRef } from "@legendapp/list/react-native";
-import { HeaderHeightContext } from "@react-navigation/elements";
import { NativeLayoutObserver } from "../../native/NativeLayoutObserver";
import { deriveBottomControlInsets, type NativeLayoutMetrics } from "../../lib/reserved-regions";
import type {
@@ -79,7 +78,6 @@ import type { ActiveTurnComposerAction } from "@t3tools/client-runtime/state/com
import * as Haptics from "expo-haptics";
import {
useCallback,
- useContext,
useEffect,
useEffectEvent,
useRef,
@@ -116,6 +114,7 @@ import Animated, {
withTiming,
} from "react-native-reanimated";
import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { useBarOverlap } from "../../components/ui/useBarInset";
import { useWorkspaceContentWidth } from "../layout/workspace-content-width";
import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";
@@ -468,7 +467,7 @@ function ThreadDetailBody(
}
};
const windowHeight = useWindowDimensions().height;
- const navigationHeaderHeight = useContext(HeaderHeightContext) ?? insets.top + 44;
+ const navigationHeaderHeight = useBarOverlap();
const [screenMetrics, setScreenMetrics] = useState<NativeLayoutMetrics | null>(null);
const columnMetrics = useNativeColumnLayoutMetrics();
const windowMetrics = useNativeLayoutMetrics();
diff --git a/apps/mobile/src/features/threads/ThreadFeed.tsx b/apps/mobile/src/features/threads/ThreadFeed.tsx
index d5def4f2939..b561231b805 100644
--- a/apps/mobile/src/features/threads/ThreadFeed.tsx
+++ b/apps/mobile/src/features/threads/ThreadFeed.tsx
@@ -95,7 +95,6 @@ import { CHAT_LIST_ANCHOR_OFFSET, resolveChatListAnchoredEndSpace } from "@t3too
import { imageMimeType } from "@t3tools/shared/image";
import { videoMimeType } from "@t3tools/shared/video";
import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";
-import { HeaderHeightContext } from "@react-navigation/elements";
import { useFocusEffect, useNavigation } from "@react-navigation/native";
import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";
import { useDeviceType } from "../../native/native-layout-metrics";
@@ -103,7 +102,6 @@ import { isDuoDevice } from "../../lib/device-type";
import {
memo,
useCallback,
- useContext,
useEffect,
useEffectEvent,
useImperativeHandle,
@@ -150,7 +148,6 @@ import { NativeScrollViewMarker } from "../../native/NativeScrollViewMarker";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import Animated, { FadeIn, FadeInDown, type SharedValue } from "react-native-reanimated";
import { useUniwindTheme } from "../../lib/useUniwindTheme";
-import { IOS_NAV_BAR_HEIGHT } from "../../lib/layoutMetrics";
import { FONT_FAMILIES } from "../../lib/fontFamilies";
import { scopedThreadKey } from "../../lib/scopedEntities";
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
@@ -176,6 +173,7 @@ import { getReviewSectionIdForCheckpoint } from "../review/reviewModel";
import { setReviewSelectedSectionId } from "../review/reviewState";
import { Menu } from "../../components/ui/Menu";
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
+import { useBarInset } from "../../components/ui/useBarInset";
import { copyPromptLink } from "../prompt-links/prompt-link-actions";
import { parseReviewCommentMessageSegments } from "../review/reviewCommentSelection";
import {
@@ -2802,7 +2800,8 @@ export const ThreadFeed = memo(function ThreadFeed({
const markdownContentWidth = Math.max(0, contentWidth - ASSISTANT_ROW_HORIZONTAL_PADDING * 2);
const reviewCommentBubbleWidth = Math.min(Math.max(280, contentWidth * 0.85), contentWidth);
const insets = useSafeAreaInsets();
- const topContentInset = props.contentTopInset ?? insets.top + IOS_NAV_BAR_HEIGHT;
+ const barInset = useBarInset();
+ const topContentInset = props.contentTopInset ?? barInset;
const bottomContentInset = props.contentBottomInset ?? 18;
const usesNativeAutomaticInsets =
props.usesAutomaticContentInsets === true && Platform.OS === "ios";
@@ -2812,10 +2811,7 @@ export const ThreadFeed = memo(function ThreadFeed({
bottomContentInset,
});
// LegendList cannot see UIKit's adjustedContentInset; include header height in anchor offsets.
- const navigationHeaderHeight = useContext(HeaderHeightContext);
- const anchorTopInset = usesNativeAutomaticInsets
- ? (navigationHeaderHeight ?? insets.top + IOS_NAV_BAR_HEIGHT)
- : topContentInset;
+ const anchorTopInset = usesNativeAutomaticInsets ? barInset : topContentInset;
const theme = useUniwindTheme();
const iconSubtleColor = theme["--color-icon-subtle"];
diff --git a/apps/mobile/src/features/threads/ThreadGitControls.android.tsx b/apps/mobile/src/features/threads/ThreadGitControls.android.tsx
deleted file mode 100644
index 4ec85db2eeb..00000000000
--- a/apps/mobile/src/features/threads/ThreadGitControls.android.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import type {
- ThreadGitControls as IosThreadGitControls,
- ThreadGitMenu as IosThreadGitMenu,
- useThreadGitRightHeaderItems as useIosThreadGitRightHeaderItems,
-} from "./ThreadGitControls";
-
-export type { ThreadGitMenuProps } from "./ThreadGitControls";
-
-type ThreadGitControlsProps = Parameters<typeof IosThreadGitControls>[0];
-const EMPTY_HEADER_ITEMS: ReturnType<typeof useIosThreadGitRightHeaderItems> = [];
-
-// oxlint-disable-next-line t3code/no-hookless-use-function -- Android stub of a hook; the iOS file calls hooks.
-export function useThreadGitRightHeaderItems(_props: ThreadGitControlsProps) {
- return EMPTY_HEADER_ITEMS;
-}
-
-// oxlint-disable-next-line t3code/no-hookless-use-function -- Android stub of a hook; the iOS file calls hooks.
-export function useThreadGitCenterHeaderItems(_props: ThreadGitControlsProps) {
- return EMPTY_HEADER_ITEMS;
-}
-
-export function ThreadGitControls(_props: ThreadGitControlsProps) {
- return null;
-}
-
-export function ThreadGitMenu(_props: Parameters<typeof IosThreadGitMenu>[0]) {
- return null;
-}
-
-// oxlint-disable-next-line t3code/no-hookless-use-function -- Android stub of a hook; the iOS file calls hooks.
-export function useThreadGitMenuDefinition(_props: Parameters<typeof IosThreadGitMenu>[0]) {
- return null;
-}
diff --git a/apps/mobile/src/features/threads/ThreadGitControls.tsx b/apps/mobile/src/features/threads/ThreadGitControls.tsx
index 3aa5a8df67e..57d26e3b65d 100644
--- a/apps/mobile/src/features/threads/ThreadGitControls.tsx
+++ b/apps/mobile/src/features/threads/ThreadGitControls.tsx
@@ -1,7 +1,5 @@
-import { Toolbar } from "../../components/ui/Toolbar";
import * as Dialog from "../../components/ui/Dialog";
import { useOpenPullRequest } from "../../native/useOpenPullRequest";
-import { createNativeHeaderMenu } from "../../components/ui/nativeHeaderMenu.ios";
import type { AppBarMenu } from "../../components/ui/AppBar.types";
import {
AuthSourceControlWriteScope,
@@ -73,13 +71,6 @@ function compactMenuStatus(gitStatus: VcsStatusResult | null): string {
return parts.join(" · ");
}
-type HeaderItem = Record<string, unknown>;
-type HeaderItems = HeaderItem[];
-type ThreadGitHeaderActionItems = {
- readonly terminal: HeaderItem;
- readonly files: HeaderItem;
- readonly git: HeaderItem;
-};
type QuickActionIcon =
| "arrow.down.circle"
| "arrow.up.right.circle"
@@ -100,18 +91,12 @@ export type ThreadGitMenuProps = {
readonly onRunAction: (input: GitActionRequestInput) => Promise<GitRunStackedActionResult | null>;
};
-type ThreadGitControlsProps = ThreadGitMenuProps & {
- readonly auxiliaryPaneControl?: {
- readonly accessibilityLabel: string;
- readonly onPress: () => void;
- };
+export type ThreadGitControlsProps = ThreadGitMenuProps & {
readonly canOpenTerminal: boolean;
readonly canOperateTerminal: boolean;
readonly canOpenFiles: boolean;
readonly projectScripts: ReadonlyArray<ProjectScript>;
readonly terminalSessions: ReadonlyArray<TerminalMenuSession>;
- readonly showActionControls?: boolean;
- readonly showDirectFileControl?: boolean;
readonly onOpenTerminal: (terminalId?: string | null) => void;
readonly onOpenNewTerminal: () => void;
readonly onRunProjectScript: (script: ProjectScript) => Promise<void>;
@@ -233,17 +218,6 @@ function useThreadGitControlModel(props: ThreadGitMenuProps) {
}
};
- const openFiles = () => {
- if (props.onOpenFilesInspector) {
- props.onOpenFilesInspector();
- return;
- }
- navigation.navigate("ThreadFiles", {
- environmentId: String(environmentId),
- threadId: String(threadId),
- });
- };
-
const openReview = () => {
navigation.navigate("ThreadReview", {
environmentId: EnvironmentId.make(String(environmentId)),
@@ -265,7 +239,6 @@ function useThreadGitControlModel(props: ThreadGitMenuProps) {
return {
currentBranchLabel,
isRepo,
- openFiles,
openGitInspector,
openReview,
quickAction,
@@ -275,261 +248,62 @@ function useThreadGitControlModel(props: ThreadGitMenuProps) {
};
}
-function useThreadGitHeaderActionItems(props: ThreadGitControlsProps): ThreadGitHeaderActionItems {
- const model = useThreadGitControlModel(props);
-
+export function threadTerminalMenu(props: ThreadGitControlsProps): AppBarMenu | null {
+ if (!props.canOpenTerminal) return null;
return {
- terminal: {
- accessibilityLabel: "Open terminal",
- disabled: !props.canOpenTerminal,
- icon: { name: "terminal", type: "sfSymbol" },
- identifier: "thread-right-terminal",
- label: "Terminal",
- menu: {
- items: [
- ...props.projectScripts.map((script) => ({
- description: script.command,
+ title: "Terminal",
+ icon: "terminal",
+ separateBackground: false,
+ items: [
+ ...(props.projectScripts.length > 0
+ ? props.projectScripts.map((script) => ({
+ id: `script-${script.id}`,
+ title: projectScriptMenuLabel(script),
+ icon: projectScriptMenuIcon(script.icon),
+ subtitle: script.command,
disabled: !props.canOperateTerminal,
- icon: { name: projectScriptMenuIcon(script.icon), type: "sfSymbol" as const },
- label: projectScriptMenuLabel(script),
onPress: () => void props.onRunProjectScript(script),
- type: "action" as const,
- })),
- ...(props.projectScripts.length === 0
- ? [
- {
- description: "This project has no saved scripts yet",
- disabled: true,
- icon: { name: "play", type: "sfSymbol" as const },
- label: "No project scripts",
- onPress: () => {},
- type: "action" as const,
- },
- ]
- : []),
- ...props.terminalSessions.map((session) => ({
- description: [
- getTerminalStatusLabel({
- status: session.status,
- hasRunningSubprocess: session.hasRunningSubprocess,
- }),
- basename(session.cwd),
- ]
- .filter(Boolean)
- .join(" · "),
- icon: { name: "terminal", type: "sfSymbol" as const },
- label: session.displayLabel,
- onPress: () => props.onOpenTerminal(session.terminalId),
- type: "action" as const,
- })),
- {
- description: "Start another shell for this thread",
- disabled: !props.canOperateTerminal,
- icon: { name: "plus", type: "sfSymbol" },
- label: "Open new terminal",
- onPress: props.onOpenNewTerminal,
- type: "action",
- },
- ],
- title: "Terminal",
- },
- sharesBackground: true,
- type: "menu",
- variant: "plain",
- },
- files: {
- accessibilityLabel: "Open files",
- disabled: !props.canOpenFiles,
- icon: { name: "folder", type: "sfSymbol" },
- identifier: "thread-right-files",
- label: "Files",
- onPress: model.openFiles,
- sharesBackground: true,
- type: "button",
- variant: "plain",
- },
- git: {
- accessibilityLabel: "Git actions",
- icon: { name: "point.topleft.down.curvedto.point.bottomright.up", type: "sfSymbol" },
- identifier: "thread-right-git",
- label: "Git",
- menu: {
- items: [
- {
- description: compactMenuStatus(props.gitStatus),
- disabled: true,
- icon: {
- name: "point.topleft.down.curvedto.point.bottomright.up",
- type: "sfSymbol",
+ }))
+ : [
+ {
+ id: "script-none",
+ title: "No project scripts",
+ icon: "play",
+ subtitle: "This project has no saved scripts yet",
+ disabled: true,
+ onPress: () => {},
},
- label: compactMenuBranchLabel(model.currentBranchLabel),
- onPress: (): void => {},
- type: "action",
- },
- {
- description: model.quickActionHint ?? undefined,
- disabled: model.quickAction.disabled,
- icon: { name: model.quickActionIcon, type: "sfSymbol" },
- label: model.quickAction.label,
- onPress: (): void => void model.runQuickAction(),
- type: "action",
- },
- {
- description:
- props.hasThread === false
- ? "Available after the first message"
- : "Turn diffs and worktree changes",
- disabled: !model.isRepo || props.hasThread === false,
- icon: { name: "text.bubble", type: "sfSymbol" },
- label: "Review changes",
- onPress: model.openReview,
- type: "action",
- },
- ...(props.onMergeBack
- ? [
- {
- description: "Bring this thread's latest turn into its source",
- icon: { name: PullRequestGlyph.merged, type: "sfSymbol" as const },
- label: "Merge back to source",
- onPress: props.onMergeBack,
- type: "action" as const,
- },
- ]
- : []),
- {
- description:
- props.hasThread === false
- ? "Available after the first message"
- : "Commit, files, branches",
- disabled: props.hasThread === false,
- icon: { name: "ellipsis", type: "sfSymbol" },
- label: "More",
- onPress: model.openGitInspector,
- type: "action",
- },
- ],
- title: "Git",
+ ]),
+ ...props.terminalSessions.map((session) => ({
+ id: `terminal-${session.terminalId}`,
+ title: session.displayLabel,
+ icon: "terminal",
+ subtitle: [
+ getTerminalStatusLabel({
+ status: session.status,
+ hasRunningSubprocess: session.hasRunningSubprocess,
+ }),
+ basename(session.cwd),
+ ]
+ .filter(Boolean)
+ .join(" · "),
+ onPress: () => props.onOpenTerminal(session.terminalId),
+ })),
+ {
+ id: "terminal-new",
+ title: "Open new terminal",
+ icon: "plus",
+ subtitle: "Start another shell for this thread",
+ disabled: !props.canOperateTerminal,
+ onPress: props.onOpenNewTerminal,
},
- sharesBackground: true,
- type: "menu",
- variant: "plain",
- },
+ ],
};
}
-export function useThreadGitRightHeaderItems(props: ThreadGitControlsProps): HeaderItems {
- const actionItems = useThreadGitHeaderActionItems(props);
- return [actionItems.git, actionItems.files, actionItems.terminal] as HeaderItems;
-}
-
-export function useThreadGitCenterHeaderItems(props: ThreadGitControlsProps): HeaderItems {
- const actionItems = useThreadGitHeaderActionItems(props);
- return [actionItems.files, actionItems.git, actionItems.terminal] as HeaderItems;
-}
-
-export function ThreadGitControls(props: ThreadGitControlsProps) {
- const model = useThreadGitControlModel(props);
- const showActionControls = props.showActionControls ?? true;
-
- if (!showActionControls) {
- return null;
- }
-
- return (
- <Toolbar placement="right">
- {showActionControls && props.auxiliaryPaneControl ? (
- <Toolbar.Button
- accessibilityLabel={props.auxiliaryPaneControl.accessibilityLabel}
- icon="sidebar.right"
- onPress={props.auxiliaryPaneControl.onPress}
- separateBackground
- />
- ) : null}
- {showActionControls ? (
- <Toolbar.Menu
- accessibilityLabel="Open terminal"
- icon="terminal"
- disabled={!props.canOpenTerminal}
- separateBackground
- >
- {props.projectScripts.length > 0 ? (
- props.projectScripts.map((script) => (
- <Toolbar.MenuAction
- key={script.id}
- icon={projectScriptMenuIcon(script.icon)}
- disabled={!props.canOperateTerminal}
- onPress={() => void props.onRunProjectScript(script)}
- subtitle={script.command}
- >
- <Toolbar.Label>{projectScriptMenuLabel(script)}</Toolbar.Label>
- </Toolbar.MenuAction>
- ))
- ) : (
- <Toolbar.MenuAction
- icon="play"
- disabled
- onPress={() => {}}
- subtitle="This project has no saved scripts yet"
- >
- <Toolbar.Label>No project scripts</Toolbar.Label>
- </Toolbar.MenuAction>
- )}
- {props.terminalSessions.map((session) => (
- <Toolbar.MenuAction
- key={session.terminalId}
- icon="terminal"
- onPress={() => props.onOpenTerminal(session.terminalId)}
- subtitle={[
- getTerminalStatusLabel({
- status: session.status,
- hasRunningSubprocess: session.hasRunningSubprocess,
- }),
- basename(session.cwd),
- ]
- .filter(Boolean)
- .join(" · ")}
- >
- <Toolbar.Label>{session.displayLabel}</Toolbar.Label>
- </Toolbar.MenuAction>
- ))}
- <Toolbar.MenuAction
- icon="plus"
- disabled={!props.canOperateTerminal}
- onPress={props.onOpenNewTerminal}
- subtitle="Start another shell for this thread"
- >
- <Toolbar.Label>Open new terminal</Toolbar.Label>
- </Toolbar.MenuAction>
- </Toolbar.Menu>
- ) : null}
- {showActionControls && props.showDirectFileControl ? (
- <Toolbar.Button
- accessibilityLabel="Open files"
- disabled={!props.canOpenFiles}
- icon="folder"
- onPress={model.openFiles}
- separateBackground
- />
- ) : null}
- {showActionControls ? createNativeHeaderMenu(threadGitMenuDefinition(props, model)) : null}
- </Toolbar>
- );
-}
-
-export function ThreadGitMenu(props: ThreadGitMenuProps) {
- const menu = useThreadGitMenuDefinition(props);
- return menu ? createNativeHeaderMenu(menu) : null;
-}
-
-/** Returns menu data because native toolbars serialize direct items rather than rendering component children. */
+/** The thread's git menu, shared by the thread bar and Review. */
export function useThreadGitMenuDefinition(props: ThreadGitMenuProps): AppBarMenu | null {
- return threadGitMenuDefinition(props, useThreadGitControlModel(props));
-}
-
-function threadGitMenuDefinition(
- props: ThreadGitMenuProps,
- model: ReturnType<typeof useThreadGitControlModel>,
-): AppBarMenu {
+ const model = useThreadGitControlModel(props);
return {
title: "Git controls",
icon: "point.topleft.down.curvedto.point.bottomright.up",
@@ -564,6 +338,17 @@ function threadGitMenuDefinition(
: "Turn diffs and worktree changes",
onPress: model.openReview,
},
+ ...(props.onMergeBack
+ ? [
+ {
+ id: "git-merge-back",
+ title: "Merge back to source",
+ icon: PullRequestGlyph.merged,
+ subtitle: "Bring this thread's latest turn into its source",
+ onPress: props.onMergeBack,
+ },
+ ]
+ : []),
{
id: "git-more",
title: "More",
diff --git a/apps/mobile/src/features/threads/ThreadHeader.tsx b/apps/mobile/src/features/threads/ThreadHeader.tsx
index 065e643a4bf..d4b13246c4b 100644
--- a/apps/mobile/src/features/threads/ThreadHeader.tsx
+++ b/apps/mobile/src/features/threads/ThreadHeader.tsx
@@ -1,108 +1,77 @@
-import { useMemo } from "react";
import { AppBar } from "../../components/ui/AppBar";
import { ScreenHeaderButton } from "../../components/ui/ScreenHeaderButton";
-import type { AppBarAction } from "../../components/ui/AppBar.types";
+import type { AppBarAction, AppBarMenu } from "../../components/ui/AppBar.types";
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import type { ThreadInspectorMode } from "./thread-inspector-navigation";
-import { useThreadHeaderOptions } from "./useThreadHeaderOptions";
import { useWorkspaceBackNavigation } from "../workspace/useAndroidWorkspaceNavigation";
-import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
+import {
+ threadTerminalMenu,
+ useThreadGitMenuDefinition,
+ type ThreadGitControlsProps,
+} from "./ThreadGitControls";
-export function ThreadHeader(
- props: Parameters<typeof useThreadHeaderOptions>[0] & {
- readonly hasThreadCwd: boolean;
- readonly hasWorkspaceRoot: boolean;
- readonly fileInspectorSupported: boolean;
- readonly inspectorMode: ThreadInspectorMode | null;
- readonly onToggleInspector: () => void;
- readonly onOpenGitInspector: () => void;
- readonly onOpenFilesInspector: () => void;
- },
-) {
+export function ThreadHeader(props: {
+ readonly title: string;
+ readonly subtitle: string;
+ readonly gitControls: ThreadGitControlsProps;
+ readonly onReturnToThread?: () => void;
+ readonly draft?: boolean;
+ readonly hasThreadCwd: boolean;
+ readonly fileInspectorSupported: boolean;
+ readonly inspectorMode: ThreadInspectorMode | null;
+ readonly onToggleInspector: () => void;
+ readonly onOpenFilesInspector: () => void;
+}) {
const goBack = useWorkspaceBackNavigation("threads");
- const { layout, panes, toggleAuxiliaryPane, composerKeyboardActive } =
+ const { panes, toggleAuxiliaryPane, composerKeyboardActive, startNewTask } =
useAdaptiveWorkspaceLayout();
- const { onOpenTerminal, onMergeBack } = props.gitControls;
- const native = useThreadHeaderOptions(props);
- const androidHeaderActions = useMemo<ReadonlyArray<AppBarAction>>(() => {
- const actions: AppBarAction[] = [];
- if (props.onReturnToThread) {
- actions.push({
- accessibilityLabel: "Return to chat",
- icon: "chevron.left",
- onPress: props.onReturnToThread,
- });
- }
- if (props.hasThreadCwd) {
- const filesVisible = props.inspectorMode === "files" && panes.auxiliaryPaneVisible;
- actions.push({
- accessibilityLabel: filesVisible ? "Close files" : "Open files",
- selected: filesVisible,
- icon: "folder",
- onPress: filesVisible ? toggleAuxiliaryPane : props.onOpenFilesInspector,
- });
- }
- if (props.hasWorkspaceRoot && props.gitControls.canOpenTerminal) {
- actions.push({
- accessibilityLabel: "Open terminal",
- icon: "terminal",
- onPress: () => onOpenTerminal(null),
- });
- }
- actions.push({
- accessibilityLabel: "Open git controls",
- icon: "point.topleft.down.curvedto.point.bottomright.up",
- onPress: props.onOpenGitInspector,
- });
- if (onMergeBack) {
- actions.push({
- accessibilityLabel: "Merge back to source",
- icon: PullRequestGlyph.merged,
- onPress: onMergeBack,
- });
- }
- return actions;
- }, [
- props.inspectorMode,
- panes.auxiliaryPaneVisible,
- props.onOpenFilesInspector,
- onOpenTerminal,
- onMergeBack,
- props.onOpenGitInspector,
- toggleAuxiliaryPane,
- props.onReturnToThread,
- props.hasThreadCwd,
- props.hasWorkspaceRoot,
- props.gitControls.canOpenTerminal,
- ]);
+ const gitMenu = useThreadGitMenuDefinition(props.gitControls);
+ const terminalMenu = threadTerminalMenu(props.gitControls);
+ const filesVisible = props.inspectorMode === "files" && panes.auxiliaryPaneVisible;
+ const inspectorVisible = props.inspectorMode !== null && panes.auxiliaryPaneVisible;
+ const actions: AppBarAction[] = props.hasThreadCwd
+ ? [
+ {
+ accessibilityLabel: filesVisible ? "Close files" : "Open files",
+ icon: "folder",
+ selected: filesVisible,
+ disabled: !props.gitControls.canOpenFiles,
+ separateBackground: false,
+ onPress: filesVisible ? toggleAuxiliaryPane : props.onOpenFilesInspector,
+ },
+ ]
+ : [];
+ const menus = [gitMenu, terminalMenu].filter((menu): menu is AppBarMenu => menu !== null);
return (
- <>
- <AppBar
- title={props.title}
- subtitle={props.subtitle}
- options={native.options}
- optionsVersion={native.optionsVersion}
- trailing={
- props.fileInspectorSupported && props.hasThreadCwd ? (
- <ScreenHeaderButton
- accessibilityLabel={
- props.inspectorMode !== null && panes.auxiliaryPaneVisible
- ? "Hide inspector"
- : "Show inspector"
- }
- icon="sidebar.right"
- selected={props.inspectorMode !== null && panes.auxiliaryPaneVisible}
- onPress={props.onToggleInspector}
- />
- ) : null
- }
- onBack={layout.usesSplitView ? undefined : goBack}
- actions={androidHeaderActions}
- hideBottomBorder
- compact={composerKeyboardActive}
- />
- {native.fallback}
- </>
+ <AppBar
+ title={props.title}
+ subtitle={props.subtitle}
+ onBackToList={goBack}
+ onCompose={props.draft ? undefined : startNewTask}
+ backInSplitView={
+ props.onReturnToThread
+ ? {
+ accessibilityLabel: "Return to chat",
+ icon: "chevron.left",
+ onPress: props.onReturnToThread,
+ }
+ : undefined
+ }
+ actions={actions}
+ menus={menus}
+ trailing={
+ props.fileInspectorSupported && props.hasThreadCwd ? (
+ <ScreenHeaderButton
+ accessibilityLabel={inspectorVisible ? "Hide inspector" : "Show inspector"}
+ icon="sidebar.right"
+ selected={inspectorVisible}
+ onPress={props.onToggleInspector}
+ />
+ ) : null
+ }
+ hideBottomBorder
+ compact={composerKeyboardActive}
+ />
);
}
diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
index 6e8c4fa251e..5fc720e607a 100644
--- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
@@ -19,8 +19,7 @@ import { THREAD_SIDEBAR_ROW_LAYOUT } from "./threadListAnimations";
import type { MenuAction } from "@react-native-menu/menu";
import { useAtomValue } from "@effect/atom-react";
import { useMemo, useRef, useState } from "react";
-import type { LayoutChangeEvent, TextInputInstance } from "react-native";
-import { Platform, StyleSheet, TextInput, View } from "react-native";
+import { Platform, StyleSheet, View } from "react-native";
import { GestureDetector, useNativeGesture } from "react-native-gesture-handler";
import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
import { FLOATING_TABS } from "../workspace/floating-workspace-tabs";
@@ -28,9 +27,6 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
import type { SearchBarCommands } from "react-native-screens";
import { AppText as Text } from "../../components/ui/AppText";
-import { CompactBrandTitle } from "../../components/CompactBrandTitle";
-import { Menu } from "../../components/ui/Menu";
-import { SymbolView } from "../../components/ui/AppSymbol";
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
import { NativeStackScreenOptions } from "../../native/StackHeader";
import { scopedProjectKey, scopedThreadKey } from "../../lib/scopedEntities";
@@ -55,14 +51,9 @@ import { buildHomeProjectScopes } from "../home/homeThreadList";
import { SwipeableScrollGateProvider, useSwipeableScrollGate } from "../home/thread-swipe-actions";
import { usePendingTaskListActions } from "../home/usePendingTaskListActions";
import { useThreadListActions } from "../home/useThreadListActions";
-import {
- getConnectionAwareBrandHeaderOptions,
- WorkspaceConnectionTitle,
-} from "../home/WorkspaceConnectionTitle";
-import { SidebarHeaderActions } from "./sidebar-header-actions";
+import { getConnectionAwareBrandHeaderOptions } from "../home/WorkspaceConnectionTitle";
import { ThreadListToolbar } from "../home/ThreadListToolbar";
import { useFabScroll } from "../home/FabScrollContext";
-import { SidebarFilterButton } from "./sidebar-filter-button";
import { createSidebarHeaderItems } from "./sidebar-native-header-items";
import { getCompactBrandHeaderOptions } from "../../components/CompactBrandTitle";
import { StandaloneStack } from "../layout/nested-stacks";
@@ -97,8 +88,6 @@ type SidebarListItem =
readonly state?: "loading" | "failed";
};
-const SIDEBAR_STICKY_HEADER_HEIGHT = 106;
-
interface ThreadNavigationSidebarProps {
readonly width: number;
readonly visible: boolean;
@@ -163,7 +152,6 @@ function ThreadNavigationSidebarPane(
const threads = useNavigationThreadShells();
const { environments: workspaceEnvironments, state: catalogState } = useWorkspaceState();
const { savedConnectionsById } = useSavedRemoteConnections();
- const searchInputRef = useRef<TextInputInstance>(null);
const searchBarRef = useRef<SearchBarCommands>(null);
const openSwipeableRef = useRef<SwipeableMethods | null>(null);
const sidebarScrollGesture = useNativeGesture();
@@ -420,13 +408,6 @@ function ThreadNavigationSidebarPane(
}
};
- const [measuredHeaderHeight, setMeasuredHeaderHeight] = useState<number | null>(null);
- const stickyHeaderHeight = measuredHeaderHeight ?? insets.top + SIDEBAR_STICKY_HEADER_HEIGHT;
- const topListInset = stickyHeaderHeight + 6;
- const handleStickyHeaderLayout = (event: LayoutChangeEvent) => {
- const nextHeight = event.nativeEvent.layout.height;
- setMeasuredHeaderHeight((current) => (current === nextHeight ? current : nextHeight));
- };
const handleSwipeableWillOpen = (methods: SwipeableMethods) => {
if (openSwipeableRef.current !== methods) {
openSwipeableRef.current?.close();
@@ -490,14 +471,8 @@ function ThreadNavigationSidebarPane(
return false;
};
const focusSearch = () => {
- if (Platform.OS === "android") return false;
- const focus = () => {
- if (props.nativeChrome) {
- searchBarRef.current?.focus();
- return;
- }
- searchInputRef.current?.focus();
- };
+ if (!props.nativeChrome) return false;
+ const focus = () => searchBarRef.current?.focus();
if (!props.visible) {
props.onRequestVisibility();
setTimeout(focus, 240);
@@ -738,7 +713,7 @@ function ThreadNavigationSidebarPane(
<SwipeableScrollGateProvider enabled={swipeEnabled}>
<GestureDetector gesture={sidebarScrollGesture}>
<AnimatedLegendList
- renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
+ renderScrollComponent={NativeScrollView}
itemLayoutAnimation={THREAD_SIDEBAR_ROW_LAYOUT}
data={listItems}
drawDistance={500}
@@ -754,7 +729,6 @@ function ThreadNavigationSidebarPane(
}
contentContainerStyle={[
styles.threadListContent,
- Platform.OS === "android" ? { paddingHorizontal: 0 } : null,
{
paddingBottom: Math.max(insets.bottom, 16) + 16,
paddingTop: 6,
@@ -777,36 +751,26 @@ function ThreadNavigationSidebarPane(
);
}
+ // Android: the bar is the floating ThreadListToolbar below the list.
return (
- <View
- testID="thread-navigation-sidebar"
- className={
- Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 border-r border-border bg-drawer"
- }
- // Android fills its pane, which animates its width while a hinge resizes the split.
- style={Platform.OS === "android" ? undefined : { width: props.width }}
- >
+ <View testID="thread-navigation-sidebar" className="flex-1 bg-header">
<View
className="flex-1"
- style={
- Platform.OS === "android"
- ? {
- marginHorizontal: 4,
- paddingBottom: insets.bottom,
- backgroundColor: drawerColor,
- borderTopLeftRadius: 28,
- borderTopRightRadius: 28,
- overflow: "hidden",
- }
- : { paddingBottom: insets.bottom }
- }
+ style={{
+ marginHorizontal: 4,
+ paddingBottom: insets.bottom,
+ backgroundColor: drawerColor,
+ borderTopLeftRadius: 28,
+ borderTopRightRadius: 28,
+ overflow: "hidden",
+ }}
>
- {Platform.OS === "android" && listItems.length === 0 ? (
+ {listItems.length === 0 ? (
<View className="flex-1 items-center justify-center">{listEmpty}</View>
) : (
<SwipeableScrollGateProvider enabled={swipeEnabled}>
<GestureDetector gesture={sidebarScrollGesture}>
- {/* oxlint-disable-next-line t3code/require-registered-list-scroll -- Only the non-native workspace layout (Android and the fallback) renders this sidebar, which has no native header to register with. */}
+ {/* oxlint-disable-next-line t3code/require-registered-list-scroll -- The Android sidebar has no native header to register with. */}
<AnimatedLegendList
itemLayoutAnimation={THREAD_SIDEBAR_ROW_LAYOUT}
data={listItems}
@@ -817,19 +781,12 @@ function ThreadNavigationSidebarPane(
itemsAreEqual={sidebarItemsAreEqual}
keyExtractor={(item) => item.key}
renderItem={renderListItem}
- contentContainerStyle={[
- styles.threadListContent,
- Platform.OS === "android" ? { paddingHorizontal: 0 } : null,
- {
- paddingBottom:
- Platform.OS === "android"
- ? floatingTabsEnabled
- ? FLOATING_TABS.bottom + FLOATING_TABS.edge + fabSize
- : Math.max(insets.bottom, 16) + fabClearance - insets.bottom
- : 16 + insets.bottom,
- paddingTop: Platform.OS === "android" ? 6 : topListInset,
- },
- ]}
+ contentContainerStyle={{
+ paddingBottom: floatingTabsEnabled
+ ? FLOATING_TABS.bottom + FLOATING_TABS.edge + fabSize
+ : Math.max(insets.bottom, 16) + fabClearance - insets.bottom,
+ paddingTop: 6,
+ }}
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps="handled"
{...scrollGateHandlers}
@@ -843,70 +800,15 @@ function ThreadNavigationSidebarPane(
</SwipeableScrollGateProvider>
)}
</View>
-
- {Platform.OS === "android" ? (
- <ThreadListToolbar
- searchQuery={props.searchQuery}
- onSearchQueryChange={props.onSearchQueryChange}
- filterActions={listMenuActions}
- filterCustomized={filterCustomized}
- onFilterSelect={(event) => handleListMenuAction({ nativeEvent: { event } })}
- onOpenEnvironments={props.onOpenEnvironmentSettings}
- onRequestVisibility={props.onRequestVisibility}
- />
- ) : (
- <View
- className="absolute inset-x-0 top-0 z-[4] bg-drawer"
- collapsable={false}
- onLayout={handleStickyHeaderLayout}
- pointerEvents="auto"
- style={{ paddingTop: insets.top }}
- >
- <View className="h-[50px] flex-row items-end gap-0.5 pr-2 pl-5">
- <WorkspaceConnectionTitle
- grow
- onPress={props.onOpenEnvironmentSettings}
- size="pageTitle"
- brand={
- <View className="h-11 flex-1 justify-center">
- <CompactBrandTitle allowFontScaling={false} />
- </View>
- }
- />
- <View className="flex-row items-center gap-2.5">
- <Menu actions={listMenuActions} onPressAction={handleListMenuAction}>
- <SidebarFilterButton accessibilityLabel="Filter threads" icon={filterIcon} />
- </Menu>
- <SidebarHeaderActions onOpenSettings={props.onOpenSettings} />
- </View>
- </View>
-
- <View className="mx-4 mt-[9px] h-[38px] flex-row items-center gap-1.5 rounded-xl bg-sidebar-search pr-2.5 pl-[11px]">
- <SymbolView
- name="magnifyingglass"
- size={15}
- tintColorClassName="accent-drawer-foreground-muted"
- type="monochrome"
- />
- <TextInput
- ref={searchInputRef}
- accessibilityLabel="Search threads"
- autoCapitalize="none"
- autoCorrect={false}
- clearButtonMode="while-editing"
- onChangeText={props.onSearchQueryChange}
- placeholder="Search"
- placeholderTextColorClassName="accent-placeholder"
- selectionColorClassName={undefined}
- cursorColorClassName={undefined}
- selectionHandleColorClassName={undefined}
- returnKeyType="search"
- className="h-[34px] flex-1 px-0 py-0 font-sans text-base text-drawer-foreground"
- value={props.searchQuery}
- />
- </View>
- </View>
- )}
+ <ThreadListToolbar
+ searchQuery={props.searchQuery}
+ onSearchQueryChange={props.onSearchQueryChange}
+ filterActions={listMenuActions}
+ filterCustomized={filterCustomized}
+ onFilterSelect={(event) => handleListMenuAction({ nativeEvent: { event } })}
+ onOpenEnvironments={props.onOpenEnvironmentSettings}
+ onRequestVisibility={props.onRequestVisibility}
+ />
<ThreadUndoNotice visible={props.visible} />
</View>
);
diff --git a/apps/mobile/src/features/threads/ThreadPullRequestsSheet.tsx b/apps/mobile/src/features/threads/ThreadPullRequestsSheet.tsx
index 0c801eb7601..dd20c0a162f 100644
--- a/apps/mobile/src/features/threads/ThreadPullRequestsSheet.tsx
+++ b/apps/mobile/src/features/threads/ThreadPullRequestsSheet.tsx
@@ -4,14 +4,11 @@ import { useMemo } from "react";
import { Platform, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
-import { AppBar } from "../../components/ui/AppBar";
import { AppText as Text } from "../../components/ui/AppText";
import { ScreenContent } from "../../components/ui/ScreenContent";
import { SheetHeader } from "../../components/ui/SheetHeader";
-import { Toolbar } from "../../components/ui/Toolbar";
import { useOpenPullRequest } from "../../native/useOpenPullRequest";
import { useThreadSelection } from "../../state/use-thread-selection";
-import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import {
LinkedPullRequestRow,
linkedPullRequestKey,
@@ -22,7 +19,6 @@ import { useLinkedPullRequestActions } from "./useLinkedPullRequestActions";
export function ThreadPullRequestsSheet(
_props: StaticScreenProps<{ readonly environmentId: string; readonly threadId: string }>,
) {
- const { layout } = useAdaptiveWorkspaceLayout();
const navigation = useNavigation();
const insets = useSafeAreaInsets();
const { selectedThread, selectedThreadProject, selectedEnvironmentRuntime } =
@@ -67,7 +63,7 @@ export function ThreadPullRequestsSheet(
recycleItems
alwaysBounceVertical
style={{ flex: 1 }}
- contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
+ contentInsetAdjustmentBehavior="automatic"
showsVerticalScrollIndicator={false}
contentContainerStyle={{
paddingBottom: Math.max(insets.bottom, 18) + 18,
@@ -89,31 +85,11 @@ export function ThreadPullRequestsSheet(
</View>
);
- if (Platform.OS === "ios") {
- return (
- <View collapsable={false} className="flex-1 bg-sheet">
- <SheetHeader presentation="native" title={title} onClose={() => navigation.goBack()} />
- {actions.canLink ? (
- <Toolbar placement="right">
- <Toolbar.Button
- icon="plus"
- accessibilityLabel={`Link ${singular}`}
- onPress={actions.promptLink}
- />
- </Toolbar>
- ) : null}
- {content}
- </View>
- );
- }
-
return (
- <View collapsable={false} className="flex-1 bg-header">
- <AppBar
- sheet
+ <View collapsable={false} className="flex-1 bg-sheet">
+ <SheetHeader
title={title}
- hideBottomBorder
- onBack={() => navigation.goBack()}
+ onClose={() => navigation.goBack()}
actions={
actions.canLink
? [
@@ -126,7 +102,7 @@ export function ThreadPullRequestsSheet(
: undefined
}
/>
- <ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
+ <ScreenContent>{content}</ScreenContent>
</View>
);
}
diff --git a/apps/mobile/src/features/threads/ThreadQueueControl.tsx b/apps/mobile/src/features/threads/ThreadQueueControl.tsx
index 6ee507918f8..e2c6f33f220 100644
--- a/apps/mobile/src/features/threads/ThreadQueueControl.tsx
+++ b/apps/mobile/src/features/threads/ThreadQueueControl.tsx
@@ -34,7 +34,6 @@ import { assetImageSource } from "../../lib/assetImageSource";
import { beginQueuedRunEdit, useQueuedRunEdit } from "../../state/queued-run-edit";
import { environmentThreadDetails, threadEnvironment } from "../../state/threads";
import { useAtomCommand } from "../../state/use-atom-command";
-import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import {
REMOVE_QUEUED_MESSAGE_ACCESSIBILITY_LABEL,
buildCancelQueuedRunCommand,
@@ -117,7 +116,6 @@ function QueuedRunSender(props: {
}
export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
- const { layout } = useAdaptiveWorkspaceLayout();
const theme = useUniwindTheme();
const target = route.params;
const navigation = useNavigation();
@@ -362,7 +360,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
<GestureHandlerRootView style={{ flex: 1 }}>
<View collapsable={false} className="flex-1 bg-sheet">
<SheetHeader title="Queued" onClose={() => navigation.goBack()} />
- <ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
+ <ScreenContent>{content}</ScreenContent>
</View>
</GestureHandlerRootView>
);
diff --git a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx
index 53c06fe6733..4f13a57a8fb 100644
--- a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+++ b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx
@@ -12,7 +12,15 @@ import {
useRoute,
type StaticScreenProps,
} from "@react-navigation/native";
-import { useEffect, useEffectEvent, useRef, useState, type ReactNode } from "react";
+import {
+ createContext,
+ use,
+ useEffect,
+ useEffectEvent,
+ useRef,
+ useState,
+ type ReactNode,
+} from "react";
import * as Option from "effect/Option";
import {
AuthOrchestrationOperateScope,
@@ -30,7 +38,6 @@ import {
projectScriptTerminalInput,
resolveProjectScripts,
} from "@t3tools/shared/projectScripts";
-import { Platform } from "react-native";
import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
import { useConnectionsReady } from "../../state/workspace";
import { useEnvironmentShellReadiness } from "../../state/shell";
@@ -88,7 +95,6 @@ import { threadEnvironment } from "../../state/threads";
import { EMPTY_ENVIRONMENT_THREAD_STATE } from "@t3tools/client-runtime/state/threads";
import { useProjects } from "../../state/entities";
import { projectThreadContentPresentation } from "./threadContentPresentation";
-import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
import { Inspector, useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import { ThreadFileNavigatorPane } from "../files/thread-file-navigator-pane";
import { InspectorSheetContext } from "../layout/workspace-inspector-sheet";
@@ -120,34 +126,29 @@ function firstRouteParam(value: string | string[] | undefined): string | null {
return first === undefined || first.trim().length === 0 ? null : first;
}
+// The inspector pane's bar belongs to ThreadInspectorHeader; the fallback must not draw its own.
+const InspectorHeaderShownContext = createContext(false);
+
function ThreadRouteFallbackLayout(props: { readonly children: ReactNode }) {
const goBack = useWorkspaceBackNavigation("threads");
- const { layout } = useAdaptiveWorkspaceLayout();
- const { themeVariables } = useAppearancePreferences();
- if (Platform.OS !== "android")
- return <ThreadScreenFallback>{props.children}</ThreadScreenFallback>;
-
+ const inspectorHeaderShown = use(InspectorHeaderShownContext);
return (
- <>
- <AppBar
- title="Thread"
- options={{ contentStyle: { backgroundColor: themeVariables["--color-header"] } }}
- onBack={layout.usesSplitView ? undefined : goBack}
- hideBottomBorder
- />
- <ThreadScreenFallback>{props.children}</ThreadScreenFallback>
- </>
+ <ThreadScreenFallback
+ header={
+ inspectorHeaderShown ? undefined : (
+ <AppBar title="Thread" onBackToList={goBack} hideBottomBorder />
+ )
+ }
+ >
+ {props.children}
+ </ThreadScreenFallback>
);
}
function OpeningThreadLoadingScreen() {
return (
<ThreadRouteFallbackLayout>
- <LoadingScreen
- message="Opening thread…"
- messagePlacement="above-spinner"
- embedded={Platform.OS === "android"}
- />
+ <LoadingScreen message="Opening thread…" messagePlacement="above-spinner" embedded />
</ThreadRouteFallbackLayout>
);
}
@@ -265,17 +266,18 @@ function LiveThreadRouteController(props: ThreadRouteScreenProps) {
if (routeConnectionState !== "connected" && errorBeforeConnected !== detailError) {
setErrorBeforeConnected(detailError);
}
- const withInspectorHeader = (content: ReactNode) => (
- <>
- {props.inspectorPresentation ? (
+ const withInspectorHeader = (content: ReactNode) =>
+ props.inspectorPresentation ? (
+ <InspectorHeaderShownContext value>
<ThreadInspectorHeader
title={selectedThread?.title ?? "Thread"}
{...props.inspectorPresentation}
/>
- ) : null}
- {content}
- </>
- );
+ {content}
+ </InspectorHeaderShownContext>
+ ) : (
+ content
+ );
if (environmentId === null || threadIdRaw === null) {
return withInspectorHeader(<OpeningThreadLoadingScreen />);
@@ -340,8 +342,6 @@ function ThreadRouteContent(
readonly selectedThreadDetailState: ReturnType<typeof useSelectedThreadDetailState>;
},
) {
- const { themeVariables } = useAppearancePreferences();
- const headerColor = themeVariables["--color-header"];
const { fileInspector, layout, panes, showInspector, toggleAuxiliaryPane } =
useAdaptiveWorkspaceLayout();
const { connectionState } = useRemoteConnectionStatus();
@@ -779,13 +779,6 @@ function ThreadRouteContent(
const threadGitControlProps = {
environmentId: environmentIdRaw ?? "",
threadId: threadId ?? "",
- auxiliaryPaneControl:
- !layout.usesSplitView && fileInspector.supported && selectedThreadCwd !== null
- ? {
- accessibilityLabel: "Toggle inspector",
- onPress: handleToggleInspector,
- }
- : undefined,
onOpenFilesInspector: selectedThreadCwd !== null ? handleOpenFilesInspector : undefined,
onOpenGitInspector: handleOpenGitInspector,
onMergeBack:
@@ -806,7 +799,6 @@ function ThreadRouteContent(
)
: [],
terminalSessions: terminalMenuSessions,
- showDirectFileControl: layout.usesSplitView,
onOpenTerminal: handleOpenTerminal,
onOpenNewTerminal: handleOpenNewTerminal,
onRunProjectScript: handleRunProjectScript,
@@ -969,15 +961,11 @@ function ThreadRouteContent(
<ThreadHeader
title={selectedThread.title}
subtitle={headerSubtitle}
- headerColor={headerColor}
- usesNativeHeaderGlass={usesNativeHeaderGlass}
gitControls={threadGitControlProps}
hasThreadCwd={selectedThreadCwd !== null}
- hasWorkspaceRoot={Boolean(selectedThreadProject?.workspaceRoot)}
fileInspectorSupported={fileInspector.supported}
inspectorMode={inspectorMode}
onToggleInspector={handleToggleInspector}
- onOpenGitInspector={handleOpenGitInspector}
onOpenFilesInspector={handleOpenFilesInspector}
onReturnToThread={props.onReturnToThread}
/>
diff --git a/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx b/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
index 8c6c7998fe7..7aafc20d085 100644
--- a/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
+++ b/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
@@ -2,8 +2,6 @@ import {
getPromptControlledTraits,
getTraitSelectChange,
} from "@t3tools/client-runtime/model-traits";
-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";
@@ -49,7 +47,7 @@ import {
useState,
type ReactNode,
} from "react";
-import { Platform, Pressable, RefreshControl, ScrollView, TextInput, View } from "react-native";
+import { Platform, Pressable, RefreshControl, ScrollView, View } from "react-native";
import Animated, {
FadeIn,
FadeOut,
@@ -61,8 +59,6 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
import { SymbolView } from "../../components/ui/AppSymbol";
import { AppText as Text } from "../../components/ui/AppText";
import { AppBar } from "../../components/ui/AppBar";
-import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
-import { IconButton } from "../../components/ui/IconButton";
import { ProviderIcon } from "../../components/ProviderIcon";
import { ThemedSwitch } from "../../components/ui/ThemedSwitch";
import { cn } from "../../lib/cn";
@@ -79,7 +75,6 @@ import {
rememberModelOptions,
withRememberedModelOptions,
} from "../../state/use-model-option-memory";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
import { ChatGptSharingStatus } from "./ChatGptSharingStatus";
import { environmentCatalog } from "../../connection/catalog";
import { useEnvironmentQuery } from "../../state/query";
@@ -105,12 +100,8 @@ import {
createProviderCatalogRefreshRunner,
providerCatalogRefreshError,
} from "./provider-catalog-refresh";
-import {
- createNativeMailSearchToolbarItem,
- NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET,
-} from "../layout/native-mail-search-toolbar";
-import { useNativeLayoutMetrics } from "../../native/native-layout-metrics";
-import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
+import { useSearchToolbarInset } from "../../components/ui/useBarInset";
+import type { AppBarSearch } from "../../components/ui/AppBar";
import { ModelRow, ChoiceRow } from "./ThreadSettingsRows";
import {
compatibleRuntimeModeForChoices,
@@ -824,6 +815,7 @@ function buildThreadSettingsCatalogItems(
function ThreadSettingsOptionsItem(props: {
readonly animationsReady: boolean;
+ readonly bottomInset: number;
readonly onOpenSubmenu: (submenu: ThreadSettingsSubmenuPage) => void;
}) {
const insets = useSafeAreaInsets();
@@ -834,11 +826,9 @@ function ThreadSettingsOptionsItem(props: {
.get(session.environmentId)
?.providers.find((provider) => provider.instanceId === session.providerInstanceId) ?? null)
: null;
- // Both iOS search layouts float a bottom toolbar over the list's last rows.
- const bottomToolbarInset = Platform.OS === "ios" ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET : 0;
return (
- <View style={{ paddingBottom: insets.bottom + bottomToolbarInset + 12 }}>
+ <View style={{ paddingBottom: insets.bottom + props.bottomInset + 12 }}>
<ChatGptSharingStatus provider={selectedProvider} />
<Text className="px-5 pb-2 pt-2 text-sm font-t3-medium text-foreground-muted">Options</Text>
<Animated.View
@@ -907,22 +897,15 @@ function ThreadSettingsOptionsItem(props: {
label="Manage hidden models"
value={session.manageHidden}
onValueChange={session.setManageHidden}
- isLast={Platform.OS === "ios" || !session.hasLegacyModels}
+ isLast
/>
- {Platform.OS !== "ios" && session.hasLegacyModels ? (
- <SwitchRow
- isLast
- label="Legacy models"
- onValueChange={session.setShowLegacy}
- value={session.showLegacy}
- />
- ) : null}
</View>
</View>
);
}
function ThreadSettingsMainContent(props: {
+ readonly bottomInset: number;
readonly onOpenSubmenu: (submenu: ThreadSettingsSubmenuPage) => void;
}) {
const session = useThreadSettingsSession();
@@ -985,6 +968,7 @@ function ThreadSettingsMainContent(props: {
content = (
<ThreadSettingsOptionsItem
animationsReady={animationsReady}
+ bottomInset={props.bottomInset}
onOpenSubmenu={props.onOpenSubmenu}
/>
);
@@ -1023,47 +1007,6 @@ function ThreadSettingsMainContent(props: {
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps="handled"
maintainVisibleContentPosition={THREAD_SETTINGS_MAINTAIN_VISIBLE_CONTENT_POSITION}
- ListHeaderComponent={
- <>
- {Platform.OS === "android" ? (
- <View className="px-4 pb-2 pt-3">
- <View
- className="flex-row items-center rounded-full bg-input px-2"
- style={{ minHeight: 56 }}
- >
- <View pointerEvents="none" className="px-2">
- <SymbolView
- name="magnifyingglass"
- size={24}
- tintColorClassName="accent-icon-subtle"
- />
- </View>
- <TextInput
- accessibilityLabel="Find a model"
- autoCapitalize="none"
- autoCorrect={false}
- className="min-w-0 flex-1 px-2 py-0 text-base text-foreground"
- style={{ minHeight: 56, includeFontPadding: false, textAlignVertical: "center" }}
- onChangeText={session.setSearchQuery}
- placeholder="Find a model"
- placeholderTextColorClassName="accent-placeholder"
- selectionColorClassName="accent-focus/32"
- cursorColorClassName="accent-focus"
- selectionHandleColorClassName="accent-focus"
- value={session.searchQuery}
- />
- {session.searchQuery.length > 0 ? (
- <IconButton
- accessibilityLabel="Clear model search"
- icon="xmark"
- onPress={() => session.setSearchQuery("")}
- />
- ) : null}
- </View>
- </View>
- ) : null}
- </>
- }
recycleItems
refreshControl={
session.environmentId ? (
@@ -1204,22 +1147,24 @@ function useThreadSettingsPickerPresentation() {
return value;
}
-// With a Duo vertical bar, filter and search join cancel and confirm in the rail.
-function useThreadSettingsMailSearchToolbar() {
- const metrics = useNativeLayoutMetrics();
- return useNativeMailSearchToolbar() && (metrics?.verticalBarEdge ?? "none") === "none";
-}
-
function ThreadSettingsModelsScreen() {
const session = useThreadSettingsSession();
const presentation = useThreadSettingsPickerPresentation();
const navigation = useNavigation<NativeStackNavigationProp<ThreadSettingsPickerStackParams>>();
- const usesNativeMailSearchToolbar = useThreadSettingsMailSearchToolbar();
const hasCustomCatalogFilter = session.providerFilter !== null || session.showLegacy;
const commitAndClose = useEffectEvent(() => {
if (!session.commitPendingModel()) return;
presentation.onClose();
});
+ const search: AppBarSearch = {
+ value: session.searchQuery,
+ onChangeText: session.setSearchQuery,
+ placeholder: "Find a model",
+ clearAccessibilityLabel: "Clear model search",
+ mode: "inline",
+ compactToolbar: true,
+ };
+ const searchToolbarInset = useSearchToolbarInset(search);
const providerFilters = [
{ id: "all-providers", title: "All providers", value: null },
{ id: "favorites", title: "Favorites", value: FAVORITES_PROVIDER_FILTER },
@@ -1229,124 +1174,59 @@ function ThreadSettingsModelsScreen() {
value: group.providerKey,
})),
];
- const filterMenu = {
- title: "Model filters",
- items: [
- {
- type: "submenu" as const,
- title: "Provider",
- items: providerFilters.map((filter) => ({
- type: "action" as const,
- title: filter.title,
- state: session.providerFilter === filter.value ? ("on" as const) : ("off" as const),
- onPress: () => session.setProviderFilter(filter.value),
- })),
- },
- ...(session.hasLegacyModels
- ? [
- {
- type: "action" as const,
- title: "Show legacy models",
- state: session.showLegacy ? ("on" as const) : ("off" as const),
- onPress: () => session.setShowLegacy(!session.showLegacy),
- },
- ]
- : []),
- ],
- };
return (
<>
- {Platform.OS === "android" ? (
- <SheetHeader
- trailing={
- <View className="flex-row items-center">
- <AndroidAnchoredMenu
- title="Model filters"
- actions={[
- {
- title: "Provider",
- subactions: providerFilters.map((filter) => ({
- id: filter.id,
- title: filter.title,
- state: session.providerFilter === filter.value ? "on" : "off",
- })),
- },
- ...(session.hasLegacyModels
- ? [
- {
- id: "show-legacy",
- title: "Show legacy models",
- state: session.showLegacy ? ("on" as const) : ("off" as const),
- },
- ]
- : []),
- ]}
- onPressAction={({ nativeEvent }) => {
- if (nativeEvent.event === "show-legacy") {
- session.setShowLegacy(!session.showLegacy);
- } else {
- const filter = providerFilters.find((item) => item.id === nativeEvent.event);
- if (filter) session.setProviderFilter(filter.value);
- }
- }}
- >
- {(open) => (
- <IconButton
- accessibilityLabel="Filter models"
- icon="line.3.horizontal.decrease"
- selected={hasCustomCatalogFilter}
- variant={hasCustomCatalogFilter ? "tonal" : "standard"}
- onPress={open}
- />
- )}
- </AndroidAnchoredMenu>
- </View>
- }
- onCancel={presentation.onClose}
- title="Thread settings"
- confirm={session.pendingModel ? { label: "Save", onPress: commitAndClose } : undefined}
- />
- ) : null}
- <NativeStackScreenOptions
+ <AppBar
+ title="Thread settings"
+ onClose={presentation.onClose}
+ closeAccessibilityLabel="Cancel thread settings"
+ search={search}
+ menus={[
+ {
+ title: "Model filters",
+ icon: hasCustomCatalogFilter
+ ? "line.3.horizontal.decrease.circle.fill"
+ : "line.3.horizontal.decrease",
+ items: [
+ {
+ id: "provider",
+ title: "Provider",
+ items: providerFilters.map((filter) => ({
+ id: filter.id,
+ title: filter.title,
+ selected: session.providerFilter === filter.value,
+ onPress: () => session.setProviderFilter(filter.value),
+ })),
+ },
+ ...(session.hasLegacyModels
+ ? [
+ {
+ id: "show-legacy",
+ title: "Show legacy models",
+ selected: session.showLegacy,
+ onPress: () => session.setShowLegacy(!session.showLegacy),
+ },
+ ]
+ : []),
+ ],
+ },
+ ]}
optionsVersion={[
session.providerFilter,
session.providerGroups.map((group) => group.providerKey),
session.showLegacy,
+ session.hasLegacyModels,
]}
- options={{
- unstable_headerToolbarItems: usesNativeMailSearchToolbar
- ? () => [
- createNativeMailSearchToolbarItem({
- filterButtonId: "thread-settings-model-filter",
- filterMenu,
- filterSystemImageName: hasCustomCatalogFilter
- ? "line.3.horizontal.decrease.circle.fill"
- : "line.3.horizontal.decrease",
- onSearchTextChange: session.setSearchQuery,
- placeholder: "Find a model",
- searchTextChangeId: "thread-settings-model-search-text",
- showsSearchDismissButton: true,
- }),
- ]
- : undefined,
- headerShown: Platform.OS !== "android",
- headerSearchBarOptions:
- Platform.OS === "ios" && !usesNativeMailSearchToolbar
- ? {
- allowToolbarIntegration: true,
- autoCapitalize: "none",
- hideNavigationBar: false,
- obscureBackground: false,
- onCancelButtonPress: () => session.setSearchQuery(""),
- onChangeText: (event) => session.setSearchQuery(event.nativeEvent.text),
- placeholder: "Find a model",
- }
- : undefined,
+ confirm={{
+ label: session.pendingModel ? "Save thread settings" : "Done",
+ onPress: commitAndClose,
}}
+ hideBottomBorder
/>
<ScreenContent>
<ThreadSettingsMainContent
+ bottomInset={searchToolbarInset}
onOpenSubmenu={(submenu) => {
const title =
submenu.kind === "runtime"
@@ -1358,64 +1238,6 @@ function ThreadSettingsModelsScreen() {
}}
/>
</ScreenContent>
- {Platform.OS === "ios" ? (
- <SheetHeader
- title="Thread settings"
- onCancel={presentation.onClose}
- accessibilityLabel="Cancel thread settings"
- confirm={{
- label: session.pendingModel ? "Save thread settings" : "Done",
- onPress: commitAndClose,
- }}
- />
- ) : null}
- {Platform.OS === "ios" && !usesNativeMailSearchToolbar ? (
- <Toolbar placement="bottom">
- <Toolbar.Menu
- accessibilityLabel="Filter models"
- icon={
- hasCustomCatalogFilter
- ? "line.3.horizontal.decrease.circle.fill"
- : "line.3.horizontal.decrease.circle"
- }
- title="Model filters"
- >
- <Toolbar.Menu title="Provider">
- <Toolbar.Label>Provider</Toolbar.Label>
- <Toolbar.MenuAction
- isOn={session.providerFilter === null}
- onPress={() => session.setProviderFilter(null)}
- >
- All providers
- </Toolbar.MenuAction>
- <Toolbar.MenuAction
- isOn={session.providerFilter === FAVORITES_PROVIDER_FILTER}
- onPress={() => session.setProviderFilter(FAVORITES_PROVIDER_FILTER)}
- >
- Favorites
- </Toolbar.MenuAction>
- {session.providerGroups.map((group) => (
- <Toolbar.MenuAction
- key={group.providerKey}
- isOn={session.providerFilter === group.providerKey}
- onPress={() => session.setProviderFilter(group.providerKey)}
- >
- {group.providerLabel}
- </Toolbar.MenuAction>
- ))}
- </Toolbar.Menu>
- {session.hasLegacyModels ? (
- <Toolbar.MenuAction
- isOn={session.showLegacy}
- onPress={() => session.setShowLegacy(!session.showLegacy)}
- >
- Show legacy models
- </Toolbar.MenuAction>
- ) : null}
- </Toolbar.Menu>
- <Toolbar.SearchBarSlot />
- </Toolbar>
- ) : null}
</>
);
}
diff --git a/apps/mobile/src/features/threads/git/GitBranchesSheet.occupancy.test.tsx b/apps/mobile/src/features/threads/git/GitBranchesSheet.occupancy.test.tsx
index 87aca82de51..26337e8be75 100644
--- a/apps/mobile/src/features/threads/git/GitBranchesSheet.occupancy.test.tsx
+++ b/apps/mobile/src/features/threads/git/GitBranchesSheet.occupancy.test.tsx
@@ -19,7 +19,6 @@ vi.mock("react-native", () => ({
}));
vi.mock("@react-navigation/native", () => ({ useNavigation: () => ({}) }));
vi.mock("react-native-safe-area-context", () => ({ useSafeAreaInsets: () => ({ bottom: 0 }) }));
-vi.mock("../../../components/ui/AppBar", () => ({ AppBar: () => null }));
vi.mock("../../../components/ui/SheetHeader", () => ({ SheetHeader: () => null }));
vi.mock("../../../components/ui/ScreenContent", () => ({
ScreenContent: ({ children }: { children: ReactNode }) => <div>{children}</div>,
diff --git a/apps/mobile/src/features/threads/git/GitBranchesSheet.test.tsx b/apps/mobile/src/features/threads/git/GitBranchesSheet.test.tsx
index 22b750fca72..509dd512402 100644
--- a/apps/mobile/src/features/threads/git/GitBranchesSheet.test.tsx
+++ b/apps/mobile/src/features/threads/git/GitBranchesSheet.test.tsx
@@ -27,7 +27,6 @@ vi.mock("react-native", () => ({
vi.mock("react-native-safe-area-context", () => ({
useSafeAreaInsets: () => ({ bottom: 0 }),
}));
-vi.mock("../../../components/ui/AppBar", () => ({ AppBar: () => null }));
vi.mock("../../../components/ui/SheetHeader", () => ({ SheetHeader: () => null }));
vi.mock("../../../components/ui/ScreenContent", () => ({
ScreenContent: ({ children }: { children: ReactNode }) => children,
diff --git a/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx b/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx
index d2298c64ab8..f8ddd8d7498 100644
--- a/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx
+++ b/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx
@@ -4,7 +4,6 @@ import { useState } from "react";
import { Platform, Pressable, ScrollView, useWindowDimensions, 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 { ScreenContent } from "../../../components/ui/ScreenContent";
import { AppText as Text, AppTextInput as TextInput } from "../../../components/ui/AppText";
@@ -65,28 +64,14 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {
return (
<View
collapsable={false}
- className="bg-sheet ios:flex-1"
+ className="bg-sheet ios:flex-1 android:flex-col-reverse"
style={Platform.OS === "android" ? { maxHeight: windowHeight * 0.92 } : undefined}
>
- {Platform.OS === "android" ? (
- <AppBar
- sheet
- title="Branches & worktrees"
- onBack={() => navigation.goBack()}
- hideBottomBorder
- />
- ) : (
- <SheetHeader
- presentation="native"
- title="Branches & worktrees"
- onClose={() => navigation.goBack()}
- />
- )}
<ScreenContent fitToContents>
<ScrollView
nestedScrollEnabled
className="android:shrink android:grow-0 ios:flex-1"
- contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
+ contentInsetAdjustmentBehavior="automatic"
keyboardShouldPersistTaps="handled"
showsVerticalScrollIndicator={false}
contentInset={{ bottom: Math.max(insets.bottom, 18) + 18 }}
@@ -230,6 +215,7 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {
</View>
</ScrollView>
</ScreenContent>
+ <SheetHeader title="Branches & worktrees" onClose={() => navigation.goBack()} />
</View>
);
}
diff --git a/apps/mobile/src/features/threads/git/GitCommitSheet.tsx b/apps/mobile/src/features/threads/git/GitCommitSheet.tsx
index 6612bf0a5a2..637dab6768c 100644
--- a/apps/mobile/src/features/threads/git/GitCommitSheet.tsx
+++ b/apps/mobile/src/features/threads/git/GitCommitSheet.tsx
@@ -69,7 +69,6 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {
const android = Platform.OS === "android";
const header = (
<SheetHeader
- presentation={android ? "inline" : "native"}
title="Commit changes"
subtitle={gitStatus.data?.refName ?? "(detached HEAD)"}
onCancel={() => navigation.goBack()}
@@ -85,7 +84,6 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {
className="bg-sheet ios:flex-1 android:flex-col-reverse"
style={android ? { maxHeight: windowHeight * 0.92 } : undefined}
>
- {android ? null : header}
<ScreenContent fitToContents>
<ScrollView
nestedScrollEnabled
@@ -229,7 +227,7 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {
</View>
</ScrollView>
</ScreenContent>
- {android ? header : null}
+ {header}
</View>
);
}
diff --git a/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx b/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx
index fe7df8aa2b3..ae840b63ad2 100644
--- a/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx
+++ b/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx
@@ -9,7 +9,7 @@ import { Platform, ScrollView, useWindowDimensions, 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 { ScreenContent } from "../../../components/ui/ScreenContent";
import { AppText as Text } from "../../../components/ui/AppText";
import { useSelectedThreadGitActions } from "../../../state/use-selected-thread-git-actions";
@@ -117,15 +117,9 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {
return (
<View
collapsable={false}
- className="bg-sheet ios:flex-1"
+ className="bg-sheet ios:flex-1 android:flex-col-reverse"
style={Platform.OS === "android" ? { maxHeight: windowHeight * 0.92 } : undefined}
>
- {Platform.OS === "android" ? (
- <AppBar sheet title="Confirm action" onBack={() => navigation.goBack()} hideBottomBorder />
- ) : (
- <View className="min-h-4 pt-2" />
- )}
-
<ScreenContent fitToContents>
<ScrollView
nestedScrollEnabled
@@ -176,6 +170,7 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {
</View>
</ScrollView>
</ScreenContent>
+ <SheetHeader title="Confirm action" onClose={() => navigation.goBack()} />
</View>
);
}
diff --git a/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx b/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx
index 98e63c96b33..43e54108368 100644
--- a/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx
+++ b/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx
@@ -1,5 +1,5 @@
import * as Dialog from "../../../components/ui/Dialog";
-import { SheetHeader } from "../../../components/ui/SheetHeader";
+import { cn } from "../../../lib/cn";
import { useOpenPullRequest } from "../../../native/useOpenPullRequest";
import {
type GitActionRequestInput,
@@ -24,7 +24,6 @@ import { AppBar } from "../../../components/ui/AppBar";
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 { useEnvironmentQuery } from "../../../state/query";
@@ -61,7 +60,6 @@ export function GitOverviewSheet(props: GitOverviewSheetProps) {
}
function GitOverviewSheetContent(props: GitOverviewSheetProps) {
- const { layout } = useAdaptiveWorkspaceLayout();
const navigation = useNavigation();
const insets = useSafeAreaInsets();
const presentation = props.presentation ?? "sheet";
@@ -234,7 +232,7 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
nestedScrollEnabled
alwaysBounceVertical
className="flex-1 android:bg-sheet-solid ios:bg-screen"
- contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
+ contentInsetAdjustmentBehavior="automatic"
showsVerticalScrollIndicator={false}
contentInset={{ bottom: Math.max(insets.bottom, 18) + 18 }}
contentContainerStyle={{
@@ -243,9 +241,7 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
gap: Platform.OS === "android" ? 8 : 14,
}}
refreshControl={
- Platform.OS === "ios" || isInspector ? (
- <RefreshControl refreshing={isRefreshing} onRefresh={() => void handleRefresh()} />
- ) : undefined
+ <RefreshControl refreshing={isRefreshing} onRefresh={() => void handleRefresh()} />
}
>
<ListSection>
@@ -347,44 +343,19 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
onPress: () => void handleRefresh(),
};
- if (isInspector) {
- return (
- <View collapsable={false} className="flex-1 ios:bg-screen android:bg-header">
- <AppBar title={currentBranchLabel} subtitle={currentStatusSummary} refresh={refresh} />
- <ScreenContent insetHorizontal>{content}</ScreenContent>
- </View>
- );
- }
-
- if (Platform.OS === "ios") {
- return (
- <View collapsable={false} className="flex-1 bg-sheet">
- <SheetHeader
- presentation="native"
- title={currentBranchLabel}
- subtitle={currentStatusSummary}
- onClose={() => navigation.goBack()}
- />
- {content}
- </View>
- );
- }
-
return (
<View
collapsable={false}
- className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-sheet"}
+ className={cn("flex-1 android:bg-header", isInspector ? "ios:bg-screen" : "ios:bg-sheet")}
>
<AppBar
- sheet
title={currentBranchLabel}
- hideBottomBorder={Platform.OS === "android"}
subtitle={currentStatusSummary}
- onBack={() => navigation.goBack()}
+ hideBottomBorder={!isInspector}
+ onClose={isInspector ? undefined : () => navigation.goBack()}
refresh={refresh}
/>
-
- <ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
+ <ScreenContent insetHorizontal={isInspector ? true : undefined}>{content}</ScreenContent>
</View>
);
}
diff --git a/apps/mobile/src/features/threads/sidebar-filter-button.tsx b/apps/mobile/src/features/threads/sidebar-filter-button.tsx
deleted file mode 100644
index ee8ecf3207a..00000000000
--- a/apps/mobile/src/features/threads/sidebar-filter-button.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { SymbolView } from "../../components/ui/AppSymbol";
-import { Pressable } from "react-native";
-
-export type SidebarFilterButtonIcon =
- | "line.3.horizontal.decrease.circle"
- | "line.3.horizontal.decrease.circle.fill";
-
-export function SidebarFilterButton(props: {
- readonly accessibilityLabel: string;
- readonly icon: SidebarFilterButtonIcon;
-}) {
- return (
- <Pressable
- className="size-11 cursor-pointer items-center justify-center rounded-full bg-subtle active:opacity-70"
- accessibilityLabel={props.accessibilityLabel}
- accessibilityRole="button"
- hitSlop={4}
- >
- <SymbolView
- name={props.icon}
- size={16}
- tintColorClassName="accent-foreground"
- type="monochrome"
- />
- </Pressable>
- );
-}
diff --git a/apps/mobile/src/features/threads/sidebar-header-actions.tsx b/apps/mobile/src/features/threads/sidebar-header-actions.tsx
deleted file mode 100644
index febc0345183..00000000000
--- a/apps/mobile/src/features/threads/sidebar-header-actions.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { SymbolView } from "../../components/ui/AppSymbol";
-import { Pressable, View } from "react-native";
-
-export interface SidebarHeaderActionsProps {
- readonly onOpenSettings: () => void;
-}
-
-function FallbackHeaderButton(props: {
- readonly accessibilityLabel: string;
- readonly icon: "gearshape" | "square.and.pencil";
- readonly onPress: () => void;
-}) {
- return (
- <Pressable
- className="size-11 items-center justify-center rounded-full bg-subtle active:opacity-70"
- accessibilityLabel={props.accessibilityLabel}
- accessibilityRole="button"
- hitSlop={4}
- onPress={props.onPress}
- >
- <SymbolView
- name={props.icon}
- size={18}
- tintColorClassName="accent-foreground"
- type="monochrome"
- />
- </Pressable>
- );
-}
-
-export function SidebarHeaderActions(props: SidebarHeaderActionsProps) {
- return (
- <View className="flex-row items-center gap-0.5">
- <FallbackHeaderButton
- accessibilityLabel="Open settings"
- icon="gearshape"
- onPress={props.onOpenSettings}
- />
- </View>
- );
-}
diff --git a/apps/mobile/src/features/threads/thread-header-appearance.ts b/apps/mobile/src/features/threads/thread-header-appearance.ts
deleted file mode 100644
index 9cbbf01c799..00000000000
--- a/apps/mobile/src/features/threads/thread-header-appearance.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { Platform } from "react-native";
-import {
- nativeHeaderScrollEdgeEffects,
- type AppNativeStackNavigationOptions,
-} from "../../native/StackHeader";
-
-export function threadHeaderAppearance(
- usesNativeHeaderGlass: boolean,
-): AppNativeStackNavigationOptions {
- return {
- headerShown: true,
- headerTransparent: usesNativeHeaderGlass,
- headerStyle: usesNativeHeaderGlass ? { backgroundColor: "transparent" } : undefined,
- headerShadowVisible: false,
- scrollEdgeEffects: usesNativeHeaderGlass
- ? nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version)
- : undefined,
- headerTitleStyle: usesNativeHeaderGlass ? { fontSize: 17, fontWeight: "800" } : undefined,
- contentStyle: undefined,
- };
-}
diff --git a/apps/mobile/src/features/threads/useThreadHeaderOptions.android.ts b/apps/mobile/src/features/threads/useThreadHeaderOptions.android.ts
deleted file mode 100644
index 262a869f041..00000000000
--- a/apps/mobile/src/features/threads/useThreadHeaderOptions.android.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import type { useThreadHeaderOptions as useIosThreadHeaderOptions } from "./useThreadHeaderOptions";
-
-// oxlint-disable-next-line t3code/no-hookless-use-function -- Android stub of a hook; the iOS file calls hooks.
-export function useThreadHeaderOptions(
- props: Parameters<typeof useIosThreadHeaderOptions>[0],
-): ReturnType<typeof useIosThreadHeaderOptions> {
- return {
- options: { contentStyle: { backgroundColor: props.headerColor } },
- // Android renders header actions as children, not native item factories.
- optionsVersion: [],
- fallback: null,
- };
-}
diff --git a/apps/mobile/src/features/threads/useThreadHeaderOptions.tsx b/apps/mobile/src/features/threads/useThreadHeaderOptions.tsx
deleted file mode 100644
index a4327457fe2..00000000000
--- a/apps/mobile/src/features/threads/useThreadHeaderOptions.tsx
+++ /dev/null
@@ -1,117 +0,0 @@
-import { useWorkspaceSidebarHeaderItem } from "../layout/useWorkspaceSidebarHeaderItem";
-import { StackActions, useNavigation } from "@react-navigation/native";
-import { threadHeaderAppearance } from "./thread-header-appearance";
-import { isDuoDevice } from "../../lib/device-type";
-import type { AppNativeStackNavigationOptions } from "../../native/StackHeader";
-import { useDeviceType } from "../../native/native-layout-metrics";
-import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";
-import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
-import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
-import {
- ThreadGitControls,
- useThreadGitCenterHeaderItems,
- useThreadGitRightHeaderItems,
-} from "./ThreadGitControls";
-
-type NativeHeaderItems = ReadonlyArray<Record<string, unknown>>;
-
-export function useThreadHeaderOptions(props: {
- readonly title: string;
- readonly subtitle: string;
- readonly headerColor: string;
- readonly usesNativeHeaderGlass: boolean;
- readonly gitControls: Parameters<typeof ThreadGitControls>[0];
- readonly onReturnToThread?: () => void;
- readonly draft?: boolean;
-}) {
- const usesNativeWorkspaceColumns = useNativeWorkspaceColumnsSupported();
- const deviceType = useDeviceType();
- const usesDuoHeader = usesNativeWorkspaceColumns && isDuoDevice(deviceType);
- const navigation = useNavigation();
- const { layout, startNewTask } = useAdaptiveWorkspaceLayout();
- const sidebarHeaderItem = useWorkspaceSidebarHeaderItem();
- const threadCenterHeaderItems = useThreadGitCenterHeaderItems(props.gitControls);
- const compactRightHeaderItems = useThreadGitRightHeaderItems(props.gitControls);
- const splitLeftHeaderItems: NativeHeaderItems = [
- ...(!usesDuoHeader
- ? [
- {
- spacing: 18,
- type: "spacing" as const,
- },
- ]
- : []),
- ...(props.onReturnToThread
- ? [
- withNativeGlassHeaderItem({
- accessibilityLabel: "Return to chat",
- icon: { name: "chevron.left", type: "sfSymbol" as const },
- identifier: "thread-left-return",
- onPress: props.onReturnToThread,
- type: "button" as const,
- }),
- ]
- : []),
- ...(sidebarHeaderItem ? [sidebarHeaderItem] : []),
- ...(!usesDuoHeader && !props.draft
- ? [
- withNativeGlassHeaderItem({
- accessibilityLabel: "New task",
- icon: { name: "square.and.pencil", type: "sfSymbol" as const },
- identifier: "thread-left-new-task",
- label: "New task",
- onPress: startNewTask,
- type: "button" as const,
- }),
- ]
- : []),
- ];
- const canGoBack = navigation.canGoBack();
- const compactHomeHeaderItems: NativeHeaderItems = [
- withNativeGlassHeaderItem({
- accessibilityLabel: "Go to threads list",
- icon: { name: "list.bullet", type: "sfSymbol" as const },
- identifier: "thread-left-home",
- onPress: () => navigation.dispatch(StackActions.replace("Home")),
- type: "button" as const,
- }),
- ];
-
- const options: AppNativeStackNavigationOptions = {
- ...threadHeaderAppearance(props.usesNativeHeaderGlass),
- headerTitle: props.title,
- title: props.title,
- headerBackVisible: !layout.usesSplitView,
- unstable_headerLeftItems: layout.usesSplitView
- ? () => splitLeftHeaderItems
- : canGoBack
- ? undefined
- : () => compactHomeHeaderItems,
- // The workspace navigator adds compose to the Duo detail column's bar.
- unstable_headerRightItems: () =>
- usesDuoHeader || layout.usesSplitView ? threadCenterHeaderItems : compactRightHeaderItems,
- unstable_headerToolbarItems: () => [],
- unstable_headerSubtitle: props.usesNativeHeaderGlass ? props.subtitle : undefined,
- contentStyle: undefined,
- };
- const { environmentId, threadId, gitStatus } = props.gitControls;
- return {
- options,
- // Factories re-read only on version changes; include displayed items and hidden callback state such as default refs.
- optionsVersion: [
- splitLeftHeaderItems,
- threadCenterHeaderItems,
- compactRightHeaderItems,
- usesDuoHeader,
- environmentId,
- threadId,
- gitStatus?.isDefaultRef,
- gitStatus?.refName,
- gitStatus?.pr?.url,
- ],
- fallback:
- !layout.usesSplitView && !props.usesNativeHeaderGlass ? (
- <ThreadGitControls {...props.gitControls} showActionControls />
- ) : null,
- };
-}
diff --git a/apps/mobile/src/features/threads/worktree-setup-card.tsx b/apps/mobile/src/features/threads/worktree-setup-card.tsx
index 7495399edd2..ce2fd4abc0b 100644
--- a/apps/mobile/src/features/threads/worktree-setup-card.tsx
+++ b/apps/mobile/src/features/threads/worktree-setup-card.tsx
@@ -12,7 +12,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import { AppText as Text } from "../../components/ui/AppText";
import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";
-import { WorktreeSetupSheet } from "./worktree-setup-sheet";
+import { Sheet } from "../../components/ui/Sheet";
import { ShimmeringWorkContent } from "./thread-work-log";
import { useVisibleSecondClock } from "./use-visible-second-clock";
@@ -198,14 +198,12 @@ function SetupDetailsSheet({
now,
}: WorktreeSetupCardProps & { onClose: () => void; now: number }) {
const insets = useSafeAreaInsets();
- const [bodyHeight, setBodyHeight] = useState(0);
const canCancel = snapshot.phase === "running" && !turnStarted;
return (
- <WorktreeSetupSheet height={bodyHeight} onClose={onClose}>
+ <Sheet title="Worktree setup" onClose={onClose}>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
bounces={false}
- onContentSizeChange={(_width, height) => setBodyHeight(height)}
contentContainerStyle={{
paddingHorizontal: 20,
paddingTop: 12,
@@ -252,7 +250,7 @@ function SetupDetailsSheet({
</View>
) : null}
</ScrollView>
- </WorktreeSetupSheet>
+ </Sheet>
);
}
diff --git a/apps/mobile/src/features/threads/worktree-setup-sheet.android.tsx b/apps/mobile/src/features/threads/worktree-setup-sheet.android.tsx
deleted file mode 100644
index ecd4d5a54d1..00000000000
--- a/apps/mobile/src/features/threads/worktree-setup-sheet.android.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Host, ModalBottomSheet, RNHostView } from "@expo/ui/jetpack-compose";
-import { View, useWindowDimensions } from "react-native";
-import { withUniwind } from "uniwind";
-import { AppBar } from "../../components/ui/AppBar";
-import type { WorktreeSetupSheetProps } from "./worktree-setup-sheet";
-
-const NativeBottomSheet = withUniwind(ModalBottomSheet, {
- containerColor: { fromClassName: "containerColorClassName", styleProperty: "accentColor" },
-});
-
-export function WorktreeSetupSheet({ children, height, onClose }: WorktreeSetupSheetProps) {
- const window = useWindowDimensions();
- return (
- <Host style={{ position: "absolute", width: 0, height: 0 }}>
- <NativeBottomSheet
- onDismissRequest={onClose}
- skipPartiallyExpanded
- containerColorClassName="accent-sheet-solid"
- >
- <RNHostView matchContents>
- <View
- style={{
- width: Math.min(window.width, 640),
- height: Math.min((height || 360) + 64, window.height * 0.85),
- }}
- >
- <AppBar
- sheet
- title="Worktree setup"
- actions={[
- { accessibilityLabel: "Close setup details", icon: "xmark", onPress: onClose },
- ]}
- />
- {children}
- </View>
- </RNHostView>
- </NativeBottomSheet>
- </Host>
- );
-}
diff --git a/apps/mobile/src/features/threads/worktree-setup-sheet.tsx b/apps/mobile/src/features/threads/worktree-setup-sheet.tsx
deleted file mode 100644
index a7429419ac1..00000000000
--- a/apps/mobile/src/features/threads/worktree-setup-sheet.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import type { ReactElement } from "react";
-import { Sheet } from "../../components/ui/Sheet";
-
-export interface WorktreeSetupSheetProps {
- children: ReactElement;
- height: number;
- onClose: () => void;
-}
-
-export function WorktreeSetupSheet({ children, onClose }: WorktreeSetupSheetProps) {
- return (
- <Sheet title="Worktree setup" onClose={onClose}>
- {children}
- </Sheet>
- );
-}
diff --git a/apps/mobile/src/features/usage/UsageRouteScreen.tsx b/apps/mobile/src/features/usage/UsageRouteScreen.tsx
index f21b46bc9ff..032ab7e23fb 100644
--- a/apps/mobile/src/features/usage/UsageRouteScreen.tsx
+++ b/apps/mobile/src/features/usage/UsageRouteScreen.tsx
@@ -30,7 +30,7 @@ import {
usageSourceMessages,
} from "@t3tools/shared/usageFormat";
import { useRef, useState, type ReactNode } from "react";
-import { Platform, RefreshControl, View } from "react-native";
+import { RefreshControl, View } from "react-native";
import Animated, { FadeIn, ReduceMotion } from "react-native-reanimated";
import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -49,8 +49,6 @@ import { UsageDailyChart } from "./UsageDailyChart";
import { toggleUsageEnvironment } from "./usageEnvironmentSelection";
import { useRefreshLimits } from "./UsageLimitsSection";
import { UsageLimitsSection } from "./UsageLimitsPooled";
-import { NativeStackScreenOptions } from "../../native/StackHeader";
-import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
import type { UsageChartMetric } from "./usageChartData";
import { PROVIDER_LABEL, useProviderColors, useUsageMixColors } from "./usageProviders";
@@ -197,27 +195,6 @@ function UsageScreen(props: {
);
const showEnvironmentFilter = environments.length > 0 || selectedEnvironmentIds !== null;
- const filterIcon =
- selectedEnvironmentIds === null
- ? "line.3.horizontal.decrease"
- : "line.3.horizontal.decrease.circle.fill";
- const environmentActions = [
- {
- id: "all",
- title: "All environments",
- subtitle: undefined,
- state: selectedEnvironmentIds === null ? ("on" as const) : ("off" as const),
- },
- ...environments.map((environment) => ({
- id: environment.environmentId,
- title: environment.label,
- subtitle: usageEnvironmentStatus(environment, refreshingUsage),
- state:
- selectedEnvironmentIds === null || selectedEnvironmentIds.has(environment.environmentId)
- ? ("on" as const)
- : ("off" as const),
- })),
- ];
const selectEnvironment = (value: string) => {
if (value === "all") {
setSelectedEnvironmentIds(null);
@@ -230,15 +207,24 @@ function UsageScreen(props: {
title: "Filter usage environments",
icon:
selectedEnvironmentIds === null
- ? ("line.3.horizontal.decrease.circle" as const)
+ ? ("line.3.horizontal.decrease" as const)
: ("line.3.horizontal.decrease.circle.fill" as const),
- items: environmentActions.map((action) => ({
- id: action.id,
- title: action.title,
- subtitle: action.subtitle,
- selected: action.state === "on",
- onPress: () => selectEnvironment(action.id),
- })),
+ items: [
+ {
+ id: "all",
+ title: "All environments",
+ selected: selectedEnvironmentIds === null,
+ onPress: () => selectEnvironment("all"),
+ },
+ ...environments.map((environment) => ({
+ id: environment.environmentId,
+ title: environment.label,
+ subtitle: usageEnvironmentStatus(environment, refreshingUsage),
+ selected:
+ selectedEnvironmentIds === null || selectedEnvironmentIds.has(environment.environmentId),
+ onPress: () => selectEnvironment(environment.environmentId),
+ })),
+ ],
};
return (
@@ -247,35 +233,6 @@ function UsageScreen(props: {
menus={showEnvironmentFilter ? [environmentMenu] : undefined}
workspaceRoot={props.workspace}
>
- {Platform.OS === "ios" ? (
- <NativeStackScreenOptions
- optionsVersion={JSON.stringify({ showEnvironmentFilter, filterIcon, environmentActions })}
- options={{
- // A native menu item, unlike a custom view, moves into the Duo's vertical bar.
- unstable_headerRightItems: () =>
- showEnvironmentFilter
- ? [
- withNativeGlassHeaderItem({
- accessibilityLabel: "Filter usage environments",
- icon: { name: filterIcon, type: "sfSymbol" },
- label: "",
- type: "menu",
- menu: {
- title: "Environments",
- items: environmentActions.map((action) => ({
- type: "action" as const,
- label: action.title,
- description: action.subtitle,
- state: action.state === "on" ? ("on" as const) : undefined,
- onPress: () => selectEnvironment(action.id),
- })),
- },
- }),
- ]
- : [],
- }}
- />
- ) : null}
<ScrollView
contentInsetAdjustmentBehavior="automatic"
showsVerticalScrollIndicator={false}
diff --git a/apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx b/apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
index bed075eea31..20778dc657a 100644
--- a/apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
+++ b/apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
@@ -1,16 +1,15 @@
import { WorkspaceNoTabs } from "./WorkspaceNoTabs";
import { WORKSPACE_TAB_LABELS, useEnabledNavigationTabs } from "./navigation-tabs";
import { WorkspaceExtraTab } from "./WorkspaceExtraTab";
-import { SettingsRouteScreen } from "../settings/SettingsRouteScreen";
+import { WorkspaceSettingsList } from "../settings/SettingsRouteScreen";
import { WorkspaceSectionToolbar } from "./WorkspaceSectionToolbar";
import { useNavigation } from "@react-navigation/native";
import { use } from "react";
-import { Platform, View, useWindowDimensions } from "react-native";
+import { View, useWindowDimensions } from "react-native";
import { useKeyboardState } from "react-native-keyboard-controller";
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
import { CompactBrandTitle } from "../../components/CompactBrandTitle";
-import { AppBar } from "../../components/ui/AppBar";
import { HeaderItemsWidthContext } from "../../native/header-items-width";
import { NativeStackScreenOptions } from "../../native/StackHeader";
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
@@ -22,7 +21,6 @@ import {
useNativeLayoutMetrics,
} from "../../native/native-layout-metrics";
import { HomeRouteScreen } from "../home/HomeRouteScreen";
-import { dispatchHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
import { WorkspaceConnectionTitle } from "../home/WorkspaceConnectionTitle";
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import { PullRequestsScreen } from "../pull-requests/PullRequestsScreen";
@@ -32,11 +30,7 @@ import {
useWorkspaceTabs,
} from "./WorkspaceTabsContext";
import { WorkspaceToolbar } from "./WorkspaceToolbar";
-import {
- WORKSPACE_DOCK,
- workspaceDockBottomClearance,
- workspaceToolbarHeight,
-} from "./workspace-tabs-state";
+import { WORKSPACE_DOCK, workspaceDockBottomClearance } from "./workspace-tabs-state";
import { WorkspaceSidebarTabs } from "./WorkspaceSidebarTabs";
import {
useCompactWorkspaceTabs,
@@ -44,7 +38,6 @@ import {
useSystemWorkspaceTabBar,
} from "./useSystemWorkspaceTabBar";
import { openSettings } from "../settings/settings-navigation";
-import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab";
const TAB_TITLES = WORKSPACE_TAB_LABELS;
@@ -73,7 +66,6 @@ function WorkspaceRootTitle(props: {
function WorkspaceRootContent() {
const navigation = useNavigation();
- const selectTab = useSelectWorkspaceTab();
const { width: windowWidth } = useWindowDimensions();
const { layout, startNewTask } = useAdaptiveWorkspaceLayout();
const primaryColumn = use(NativePrimaryColumnContext);
@@ -107,89 +99,58 @@ function WorkspaceRootContent() {
const bottomClearance =
layout.variant === "medium" && state.selectedTab === "usage"
? workspaceDockBottomClearance({ bottomInset: insets.bottom, keyboardHeight })
- : Platform.OS === "ios" && isDuoDevice(deviceType)
+ : isDuoDevice(deviceType)
? // The column's safe area already holds the Duo's search toolbar and keyboard.
Math.max(insets.bottom, keyboardHeight) + 16
: compactTabs || deviceType === "pad"
? workspaceDockBottomClearance({ bottomInset: insets.bottom, keyboardHeight })
- : Platform.OS === "ios"
- ? Math.max(insets.bottom, keyboardHeight) +
- (systemTabBar || sidebarTabs || tab.searchMode !== "resting"
- ? sidebarPicker
- ? 80
- : 16
- : WORKSPACE_DOCK.height + WORKSPACE_DOCK.bottomGap + 16)
- : keyboardHeight > 0 && tab.searchMode !== "resting"
- ? keyboardHeight + 64
- : Math.max(insets.bottom, 12) + workspaceToolbarHeight(tab.searchMode) + 16;
+ : Math.max(insets.bottom, keyboardHeight) +
+ (systemTabBar || sidebarTabs || tab.searchMode !== "resting"
+ ? sidebarPicker
+ ? 80
+ : 16
+ : WORKSPACE_DOCK.height + WORKSPACE_DOCK.bottomGap + 16);
const context = { ...workspace, bottomClearance };
return (
<WorkspaceTabsContext value={context}>
<View className={sidebarPicker ? "flex-1 bg-drawer" : "flex-1 bg-screen"}>
- {Platform.OS === "ios" ? (
- <NativeStackScreenOptions
- optionsVersion={[
- settingsOpen,
- state.selectedTab,
- state.selectionRevision,
- width,
- sidebarNavigation,
- enabled.length,
- ]}
- options={{
- title: settingsOpen
- ? "Settings"
- : enabled.length
- ? TAB_TITLES[state.selectedTab]
- : "Navigation",
- headerShown: true,
- headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,
- headerStyle: NATIVE_LIQUID_GLASS_SUPPORTED
- ? { backgroundColor: "transparent" }
+ <NativeStackScreenOptions
+ optionsVersion={[
+ settingsOpen,
+ state.selectedTab,
+ state.selectionRevision,
+ width,
+ sidebarNavigation,
+ enabled.length,
+ ]}
+ options={{
+ title: settingsOpen
+ ? "Settings"
+ : enabled.length
+ ? TAB_TITLES[state.selectedTab]
+ : "Navigation",
+ headerShown: true,
+ headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,
+ headerStyle: NATIVE_LIQUID_GLASS_SUPPORTED
+ ? { backgroundColor: "transparent" }
+ : undefined,
+ contentStyle: undefined,
+ ...(enabled.length === 0
+ ? { headerSearchBarOptions: undefined, unstable_headerRightItems: () => [] }
+ : {}),
+ unstable_headerLeftItems: () => [],
+ // Beside a detail column the tab bar names the tab and the detail header the page,
+ // so the sidebar keeps the brand.
+ headerTitle:
+ sidebarNavigation || (!settingsOpen && state.selectedTab !== "usage")
+ ? renderHeaderTitle
: undefined,
- contentStyle: undefined,
- ...(enabled.length === 0
- ? { headerSearchBarOptions: undefined, unstable_headerRightItems: () => [] }
- : {}),
- unstable_headerLeftItems: () => [],
- // Beside a detail column the tab bar names the tab and the detail header the page,
- // so the sidebar keeps the brand.
- headerTitle:
- sidebarNavigation || (!settingsOpen && state.selectedTab !== "usage")
- ? renderHeaderTitle
- : undefined,
- }}
- />
- ) : (
- <AppBar
- embedded
- title="T3 Code"
- titleContent={renderHeaderTitle()}
- actions={[
- ...(state.selectedTab === "threads" || state.selectedTab === "pullRequests"
- ? [
- {
- accessibilityLabel:
- state.selectedTab === "threads" ? "Search threads" : "Search pull requests",
- icon: "magnifyingglass" as const,
- onPress: () => {
- dispatchHardwareKeyboardCommand("focusSearch");
- },
- },
- ]
- : []),
- {
- accessibilityLabel: "Settings",
- icon: "gearshape",
- onPress: () => selectTab("settings"),
- },
- ]}
- />
- )}
+ }}
+ />
<SafeAreaInsetsContext value={compactTabs ? { ...insets, bottom: 0 } : insets}>
{settingsOpen ? (
- <SettingsRouteScreen />
+ <WorkspaceSettingsList />
) : enabled.length === 0 ? (
<WorkspaceNoTabs />
) : state.selectedTab === "threads" ? (
@@ -203,12 +164,9 @@ function WorkspaceRootContent() {
{deviceType !== "pad" && deviceType !== "phone" && sidebarPicker ? (
<WorkspaceSidebarTabs />
) : null}
- {/* Android's Settings list carries its own search in its app bar. */}
- {enabled.length === 0 && !settingsOpen ? null : (
- settingsOpen
- ? Platform.OS === "ios"
- : state.selectedTab === "threads" || state.selectedTab === "pullRequests"
- ) ? (
+ {enabled.length === 0 && !settingsOpen ? null : settingsOpen ||
+ state.selectedTab === "threads" ||
+ state.selectedTab === "pullRequests" ? (
<WorkspaceToolbar sidebar={sidebarNavigation} onNewTask={startNewTask} />
) : (
<WorkspaceSectionToolbar onNewTask={startNewTask} showCompose={false} />
@@ -219,11 +177,8 @@ function WorkspaceRootContent() {
}
export function WorkspaceRootScreen() {
- const { layout } = useAdaptiveWorkspaceLayout();
const workspace = useWorkspaceTabs();
- return Platform.OS === "android" && layout.usesSplitView ? (
- <HomeRouteScreen />
- ) : workspace ? (
+ return workspace ? (
<WorkspaceRootContent />
) : (
<WorkspaceTabsProvider>
diff --git a/apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx b/apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx
index 00da5083cb3..f2961b7904a 100644
--- a/apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx
+++ b/apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx
@@ -2,9 +2,10 @@ import { useActiveNewTask } from "../../state/active-new-task";
import { Toolbar } from "../../components/ui/Toolbar";
import { useFocusEffect, useIsFocused } from "@react-navigation/native";
import { use, useCallback, useEffect, useRef } from "react";
-import { Platform } from "react-native";
import { isDuoDevice } from "../../lib/device-type";
import { useDeviceType } from "../../native/native-layout-metrics";
+import { createNativeHeaderMenu } from "../../components/ui/nativeHeaderMenu.ios";
+import { useSettingsEnvironmentMenu } from "../settings/components/SettingsEnvironmentFilterHeader";
import type { SearchBarCommands } from "react-native-screens";
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
@@ -39,7 +40,6 @@ export function WorkspaceToolbar(props: {
const bottomSearch = duoSearch && sidebarTabs !== "picker";
// On the Duo, compose belongs to the threads tab, in the detail column's bar when unfolded.
const nativeToolbarCompose =
- Platform.OS === "ios" &&
deviceType === "duo-folded" &&
!workspace.settingsOpen &&
workspace.state.selectedTab === "threads" &&
@@ -48,6 +48,7 @@ export function WorkspaceToolbar(props: {
const focused = useIsFocused();
const { layout, panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
const searchRef = useRef<SearchBarCommands>(null);
+ const settingsMenu = useSettingsEnvironmentMenu();
// The Settings list takes the selected tab's place, so search follows it.
const selectedTab = workspace.settingsOpen ? "settings" : workspace.state.selectedTab;
const tab = workspace.state.tabs[selectedTab];
@@ -181,9 +182,13 @@ export function WorkspaceToolbar(props: {
: undefined,
}}
/>
- {/* UIKit lays trailing items out from the edge inward. A trailing toolbar replaces the
- header's own items, so an empty one would hide the Settings scope filter. */}
- {workspace.settingsOpen && !foldedSearch ? null : (
+ {/* UIKit lays trailing items out from the edge inward. */}
+ {workspace.settingsOpen ? (
+ <Toolbar placement="right">
+ {searchButton}
+ {createNativeHeaderMenu(settingsMenu)}
+ </Toolbar>
+ ) : (
<Toolbar placement="right">
{searchButton}
{nativeToolbarCompose && foldedSearch ? <Toolbar.Spacer width={8} /> : null}
diff --git a/apps/mobile/src/lib/filePreview.test.ts b/apps/mobile/src/lib/filePreview.test.ts
index dbc60045adc..5dee41b54c1 100644
--- a/apps/mobile/src/lib/filePreview.test.ts
+++ b/apps/mobile/src/lib/filePreview.test.ts
@@ -257,7 +257,10 @@ vi.mock("../native/NativeScrollViewMarker", () => ({
vi.mock("../native/NativeWorkspaceColumns", () => ({
useNativeWorkspaceColumnsSupported: () => false,
}));
-vi.mock("../native/native-layout-metrics", () => ({ useDeviceType: () => "phone" }));
+vi.mock("../native/native-layout-metrics", () => ({
+ useDeviceType: () => "phone",
+ useNativeColumnLayoutMetrics: () => null,
+}));
vi.mock("../features/layout/workspace-content-width", () => ({
useWorkspaceSettledContentWidth: () => null,
}));