@devries-cameron20 / t3code Mirror · read-only / commits / 162f81fd05
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 03:15 UTC

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

About 50 feature screens wrote their bar twice (iOS header options or Toolbar items, plus an Android-only embedded AppBar), branched on Platform.OS and liquid-glass support for chrome, and guessed the bar height four different ways. - AppBar loses its `options` escape hatch and gains onClose, confirm, guardBack, onBackToList and onCompose; menu items can be destructive. Search sheets, form sheets and modals use the same AppBar as pages. - useBarInset, useBarOverlap, useContentTopInset and useSearchToolbarInset replace HeaderHeightContext and insets.top + 44/48/72 math in features. - ScreenContent keeps the Android split-view edge gap by default. - The thread bar is one AppBar with one git menu; the three copies disagreed about "Merge back". - Settings filter menus, Usage, Files, ZIP and attachment viewers, PR detail, discussion and guide screens, git sheets, search sheets and thread settings each declare actions, menus and search once. - useOpenWorkspaceDetail replaces Android selectDetail vs iOS push branches. - Fixes: Files error states had no bar; GitConfirm had no bar on iOS; Android never showed "Move draft to this line"; thread settings Save/Done differed between platforms; "Switching branch" had no back button on Android. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 4, 2026 at 20:51 UTC 162f81fd05f080db1d8acd61b27c01680fd418ce
101 files changed +1827 -3486
apps/mobile/src/Stack.tsx
+3 -3
@@ -629,7 +629,7 @@ const RootStackConfig = createWorkspaceStackNavigator({
629 ThreadReviewComment: createNativeStackScreen({
630 screen: ReviewCommentComposerSheet,
631 linking: `${THREAD_LINKING_PREFIX}/review-comment`,
632 - options: sheetRoute({ detent: 0.55, header: "none", android: "fullScreen" }),
632 + options: sheetRoute({ detent: 0.55, android: "fullScreen" }),
633 }),
634 ThreadFiles: createNativeStackScreen({
635 screen: ThreadFilesTreeScreen,
@@ -644,7 +644,7 @@ const RootStackConfig = createWorkspaceStackNavigator({
644 ThreadMcpApp: createNativeStackScreen({
645 screen: McpAppFullscreenScreen,
646 linking: `${THREAD_LINKING_PREFIX}/apps/:itemId`,
647 - options: immersiveRoute(),
647 + options: { ...modalRoute({ header: "solid" }), gestureEnabled: false },
648 }),
649 ThreadAttachment: createNativeStackScreen({
650 screen: AttachmentFileScreen,
@@ -690,7 +690,7 @@ const RootStackConfig = createWorkspaceStackNavigator({
690 GitConfirm: createNativeStackScreen({
691 screen: GitConfirmSheet,
692 linking: `${THREAD_LINKING_PREFIX}/git-confirm`,
693 - options: sheetRoute({ detent: 0.55, maxDetent: 0.7, header: "none", androidFit: true }),
693 + options: sheetRoute({ detent: 0.55, maxDetent: 0.7, androidFit: true }),
694 }),
695 ...SETTINGS_SCREENS,
696 SettingsLegal: createNativeStackScreen({
apps/mobile/src/components/ComposerContextSheet.tsx
+2 -2
@@ -13,7 +13,7 @@ import type {
13 import { formatAttachmentSize } from "@t3tools/client-runtime/state/attachments";
14 import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
15 import { videoMimeType } from "@t3tools/shared/video";
16 -import { Platform, Pressable, ScrollView, View } from "react-native";
16 +import { Pressable, ScrollView, View } from "react-native";
17 import { useSafeAreaInsets } from "react-native-safe-area-context";
18 import { REVIEW_MONO_FONT_FAMILY } from "../features/review/reviewDiffRendering";
19 import { ReviewCommentCard, useReviewCommentColors } from "../features/review/ReviewCommentCard";
@@ -193,7 +193,7 @@ export function ComposerContextSheet(props: {
193 <ScrollView
194 nestedScrollEnabled
195 className="flex-1"
196 - contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
196 + contentInsetAdjustmentBehavior="automatic"
197 contentContainerStyle={{
198 paddingHorizontal: 20,
199 paddingTop: 12,
apps/mobile/src/components/FilePreview.tsx
+6 -7
@@ -12,7 +12,7 @@ import type {
12 } from "./FilePreviewModal.types";
13 import { imageViewingProps, MediaImagePreview } from "./MediaImagePreview";
14 import { PdfPreview } from "./PdfPreview";
15 -import { ControlPill } from "./ui/ControlPill";
15 +import { SheetHeader } from "./ui/SheetHeader";
16 import { AppText as Text } from "./ui/AppText";
17
18 function PdfDocumentPreview(props: {
@@ -31,12 +31,11 @@ function PdfDocumentPreview(props: {
31 className="flex-1 bg-card"
32 style={{ paddingTop: insets.top, paddingBottom: insets.bottom }}
33 >
34 - <View className="flex-row items-center gap-3 border-b border-border px-4 py-2">
35 - <Text className="flex-1 font-t3-semibold text-foreground" numberOfLines={1}>
36 - {props.source.name ?? "PDF"}
37 - </Text>
38 - <ControlPill label="Close" variant="pill" onPress={props.onRequestClose} />
39 - </View>
34 + <SheetHeader
35 + presentation="inline"
36 + title={props.source.name ?? "PDF"}
37 + onClose={props.onRequestClose}
38 + />
39 <PdfPreview uri={props.source.uri} />
40 </View>
41 </Modal>
apps/mobile/src/components/MediaImagePreview.tsx
+8 -20
@@ -1,14 +1,11 @@
1 import { createContext, useContext } from "react";
2 -import { Pressable, View } from "react-native";
2 +import { View } from "react-native";
3 import ImageViewing from "react-native-image-viewing";
4 import { useSafeAreaInsets } from "react-native-safe-area-context";
5
6 import { useMediaActions } from "../state/mediaActions";
7 -import { AppText } from "./ui/AppText";
8 -import { SymbolView } from "./ui/AppSymbol";
7 import type { FilePreviewImages } from "./FilePreviewModal.types";
10 -import { MediaActionsMenu } from "./MediaActionsMenu";
11 -import { MediaSourceCaption } from "./MediaSourceCaption";
8 +import { MediaPreviewHeader } from "./MediaPreviewHeader";
9
10 type MediaImagePreviewProps = {
11 readonly source: FilePreviewImages;
@@ -24,21 +21,12 @@ function ImagePreviewHeader(header: { readonly imageIndex: number }) {
21 const mediaActions = useMediaActions(source?.actionsSource, props.onRequestClose);
22 return (
23 <View className="bg-black/70" style={{ paddingTop: insets.top }}>
27 - <View className="flex-row items-center gap-2 px-3">
28 - <AppText className="flex-1 text-base text-white" numberOfLines={2}>
29 - {source?.name ?? "Image"}
30 - </AppText>
31 - <MediaActionsMenu media={mediaActions} inModal />
32 - <Pressable
33 - accessibilityRole="button"
34 - accessibilityLabel="Close image"
35 - onPress={props.onRequestClose}
36 - className="min-h-11 min-w-11 items-center justify-center"
37 - >
38 - <SymbolView name="xmark" size={20} tintColor="#ffffff" type="monochrome" />
39 - </Pressable>
40 - </View>
41 - <MediaSourceCaption source={mediaActions.title} />
24 + <MediaPreviewHeader
25 + title={source?.name ?? "Image"}
26 + media={mediaActions}
27 + closeAccessibilityLabel="Close image"
28 + onClose={props.onRequestClose}
29 + />
30 </View>
31 );
32 }
apps/mobile/src/components/MediaPreviewHeader.tsx new
+35
@@ -0,0 +1,35 @@
1 +import { Pressable, View } from "react-native";
2 +
3 +import type { useMediaActions } from "../state/mediaActions";
4 +import { SymbolView } from "./ui/AppSymbol";
5 +import { AppText } from "./ui/AppText";
6 +import { MediaActionsMenu } from "./MediaActionsMenu";
7 +import { MediaSourceCaption } from "./MediaSourceCaption";
8 +
9 +/** The bar over a full-screen image or video: always dark, whatever the app theme. */
10 +export function MediaPreviewHeader(props: {
11 + readonly title: string;
12 + readonly media: ReturnType<typeof useMediaActions>;
13 + readonly closeAccessibilityLabel: string;
14 + readonly onClose: () => void;
15 +}) {
16 + return (
17 + <>
18 + <View className="min-h-14 flex-row items-center gap-3 pl-4 pr-2">
19 + <AppText className="flex-1 font-t3-medium text-base text-white" numberOfLines={2}>
20 + {props.title}
21 + </AppText>
22 + <MediaActionsMenu media={props.media} inModal />
23 + <Pressable
24 + accessibilityRole="button"
25 + accessibilityLabel={props.closeAccessibilityLabel}
26 + onPress={props.onClose}
27 + className="size-12 items-center justify-center"
28 + >
29 + <SymbolView name="xmark" size={20} tintColor="#ffffff" type="monochrome" />
30 + </Pressable>
31 + </View>
32 + <MediaSourceCaption source={props.media.title} />
33 + </>
34 + );
35 +}
apps/mobile/src/components/VideoPreviewModal.tsx
+7 -18
@@ -17,9 +17,7 @@ import {
17 import { useAssetUrlState, useRefreshAssetUrl } from "../state/assets";
18 import { usePreparedConnection } from "../state/session";
19 import { AppText } from "./ui/AppText";
20 -import { SymbolView } from "./ui/AppSymbol";
21 -import { MediaActionsMenu } from "./MediaActionsMenu";
22 -import { MediaSourceCaption } from "./MediaSourceCaption";
20 +import { MediaPreviewHeader } from "./MediaPreviewHeader";
21 import { MediaVideoPlayer } from "./MediaVideoPlayer";
22
23 export type { VideoPreviewSource } from "../lib/videoPreviewSource";
@@ -118,21 +116,12 @@ function OpenVideoPreviewModal(props: {
116 className="flex-1 bg-black"
117 style={{ paddingTop: insets.top, paddingBottom: insets.bottom }}
118 >
121 - <View className="min-h-14 flex-row items-center gap-3 pl-4 pr-2">
122 - <AppText className="flex-1 font-t3-medium text-base text-white" numberOfLines={2}>
123 - {props.name}
124 - </AppText>
125 - <MediaActionsMenu media={mediaActions} inModal />
126 - <Pressable
127 - accessibilityRole="button"
128 - accessibilityLabel="Close video"
129 - onPress={props.onRequestClose}
130 - className="size-12 items-center justify-center"
131 - >
132 - <SymbolView name="xmark" size={20} tintColor="#ffffff" type="monochrome" />
133 - </Pressable>
134 - </View>
135 - <MediaSourceCaption source={mediaActions.title} />
119 + <MediaPreviewHeader
120 + title={props.name}
121 + media={mediaActions}
122 + closeAccessibilityLabel="Close video"
123 + onClose={props.onRequestClose}
124 + />
125 {playback.uri === null && !playback.unavailable ? (
126 <View className="flex-1 items-center justify-center gap-3 px-6">
127 <AppActivityIndicator color="#ffffff" />
apps/mobile/src/components/ui/AppBar.android.test.tsx
+4
@@ -23,6 +23,10 @@ vi.mock("./WorkspaceAppBar.android", () => ({
23 vi.mock("./Menu", () => ({ Menu: (props: { readonly children?: ReactNode }) => props.children }));
24 vi.mock("./ScreenHeaderButton.android", () => ({ ScreenHeaderButton: () => null }));
25 vi.mock("./SearchField", () => ({ SearchField: () => null }));
26 +vi.mock("./Button", () => ({ Button: () => null }));
27 +vi.mock("../../features/layout/adaptive-workspace-context", () => ({
28 + useAdaptiveWorkspaceLayout: () => ({ layout: { usesSplitView: false } }),
29 +}));
30 vi.mock("./useToolbarLayout", () => ({
31 useToolbarLayout: () => ({ height: 48, paddingTop: 0, paddingBottom: 0 }),
32 }));
apps/mobile/src/components/ui/AppBar.android.tsx
+40 -6
@@ -2,13 +2,16 @@ import { type RefObject, use, useRef, useState } from "react";
2 import { Keyboard, type TextInputInstance, View } from "react-native";
3 import { useHardwareBack } from "../../lib/backHandler";
4 import { useToolbarLayout } from "./useToolbarLayout";
5 +import { RoutedFormSheetContext } from "./RoutedFormSheetContext";
6 import { NativeStackScreenOptions } from "../../native/StackHeader";
7 import { useSidebarToggle } from "../../features/layout/useSidebarToggle";
8 +import { useAdaptiveWorkspaceLayout } from "../../features/layout/adaptive-workspace-context";
9 import { InspectorCloseContext } from "../../features/layout/inspector-bar-store";
10 import { useAppearancePreferences } from "../../features/settings/appearance/AppearancePreferencesProvider";
11 import { AndroidHeaderIconButton, AndroidScreenHeader } from "./AndroidScreenHeader";
12 import { ScreenHeaderButton } from "./ScreenHeaderButton.android";
13 import { Menu } from "./Menu";
14 +import { Button } from "./Button";
15 import { SearchField } from "./SearchField";
16 import { androidHeaderMenuActions, findHeaderMenuAction } from "./headerMenu.android";
17 import type { AppBarMenuItem, AppBarProps, AppBarSearch } from "./AppBar.types";
@@ -26,7 +29,14 @@ interface SearchState {
29 readonly inputRef: RefObject<TextInputInstance | null>;
30 }
31
29 -export function AppBar(props: AppBarProps) {
32 +export function AppBar(barProps: AppBarProps) {
33 + const { layout } = useAdaptiveWorkspaceLayout();
34 + const props = {
35 + ...barProps,
36 + onBack:
37 + barProps.onBack ??
38 + (layout.usesSplitView ? barProps.backInSplitView?.onPress : barProps.onBackToList),
39 + };
40 return props.search ? (
41 <SearchableAppBar {...props} search={props.search} />
42 ) : (
@@ -66,7 +76,8 @@ function SearchableAppBar(props: AppBarProps & { readonly search: AppBarSearch }
76
77 function AppBarView(props: AppBarProps & { readonly searchState?: SearchState }) {
78 const { search, searchState } = props;
69 - const { paddingTop, paddingBottom } = useToolbarLayout(props.sheet);
79 + const inFormSheet = use(RoutedFormSheetContext);
80 + const { paddingTop, paddingBottom } = useToolbarLayout(props.sheet || inFormSheet);
81 const { themeVariables } = useAppearancePreferences();
82 const inWorkspace = useHasWorkspaceAppBar();
83 const sidebarToggle = useSidebarToggle();
@@ -143,11 +154,19 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
154 <ScreenHeaderButton accessibilityLabel={menu.title} icon={menu.icon} />
155 </Menu>
156 ));
157 + const confirmButton = props.confirm ? (
158 + <Button
159 + label={props.confirm.label}
160 + tone="text"
161 + loading={props.confirm.loading}
162 + disabled={props.confirm.disabled}
163 + onPress={props.confirm.onPress}
164 + />
165 + ) : null;
166 const options =
167 props.embedded || props.sheet ? null : (
168 <NativeStackScreenOptions
169 options={{
150 - ...props.options,
170 ...(props.matchSearchSurface
171 ? { contentStyle: { backgroundColor: themeVariables["--color-header"] } }
172 : undefined),
@@ -162,8 +181,15 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
181 title={props.title}
182 titleContent={props.titleContent}
183 subtitle={props.subtitle}
165 - onBack={props.onBack}
184 + onBack={props.onClose ? undefined : props.onBack}
185 leading={
186 + (props.onClose ? (
187 + <AndroidHeaderIconButton
188 + accessibilityLabel={props.closeAccessibilityLabel ?? "Close"}
189 + icon="xmark"
190 + onPress={props.onClose}
191 + />
192 + ) : undefined) ??
193 props.leading ??
194 // Only a real button: any leading content takes the bar's navigation slot.
195 (sidebarToggle && !props.sheet ? (
@@ -190,10 +216,11 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
216 : actions
217 }
218 trailing={
193 - menuView?.length || props.trailing || closeInspector ? (
219 + menuView?.length || props.trailing || props.confirm || closeInspector ? (
220 <>
221 {menuView}
222 {props.trailing}
223 + {confirmButton}
224 {closeInspector ? (
225 <AndroidHeaderIconButton
226 accessibilityLabel="Close inspector"
@@ -234,7 +261,13 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
261 >
262 <View className="flex-1 flex-row items-center gap-1">
263 {inline ? (
237 - props.onBack ? (
264 + props.onClose ? (
265 + <ScreenHeaderButton
266 + accessibilityLabel={props.closeAccessibilityLabel ?? "Close"}
267 + icon="xmark"
268 + onPress={props.onClose}
269 + />
270 + ) : props.onBack ? (
271 <ScreenHeaderButton
272 accessibilityLabel="Navigate up"
273 icon="arrow.left"
@@ -250,6 +283,7 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
283 )}
284 {searchField}
285 {inline ? menuView : null}
286 + {inline ? confirmButton : null}
287 </View>
288 </View>
289 ) : null}
apps/mobile/src/components/ui/AppBar.tsx
+75 -7
@@ -1,6 +1,7 @@
1 import { Toolbar } from "./Toolbar";
2 import { AppActivityIndicator } from "./AppActivityIndicator";
3 import type { HeaderBarButtonMailSearchToolbarItem } from "react-native-screens";
4 +import { NavigationContext } from "@react-navigation/native";
5 import { use, useId, useLayoutEffect } from "react";
6 import { View } from "react-native";
7 import { createNativeHeaderMenu } from "./nativeHeaderMenu.ios";
@@ -20,6 +21,7 @@ import { useAppearancePreferences } from "../../features/settings/appearance/App
21 import type { AppBarMenuItem, AppBarProps } from "./AppBar.types";
22 import type { AppSymbolName } from "./AppSymbol";
23 import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
24 +import { useControlTheme } from "./useControlTheme";
25
26 function iosIcon(icon: AppSymbolName) {
27 return typeof icon === "string" ? icon : icon.ios;
@@ -64,7 +66,19 @@ export function AppBar(props: AppBarProps) {
66 layout.usesSplitView && props.backInSplitView && splitBackPress
67 ? { ...props.backInSplitView, onPress: splitBackPress }
68 : null;
69 + const navigation = use(NavigationContext);
70 + const rootBack =
71 + !layout.usesSplitView && props.onBackToList && navigation?.canGoBack() === false
72 + ? props.onBackToList
73 + : props.guardBack && props.onBack
74 + ? props.onBack
75 + : null;
76 + const compose =
77 + layout.usesSplitView && !(usesNativeWorkspaceColumns && isDuoDevice(deviceType))
78 + ? props.onCompose
79 + : undefined;
80 const { themeVariables } = useAppearancePreferences();
81 + const { colors } = useControlTheme();
82 const usesNativeMailSearchToolbar = useNativeMailSearchToolbar();
83 const { search, menus } = props;
84 const menu = menus?.[0];
@@ -87,7 +101,12 @@ export function AppBar(props: AppBarProps) {
101 optionsVersion={[props.optionsVersion, compactSearch ? menu : undefined]}
102 options={{
103 headerShown: true,
90 - headerBackVisible: splitBack === null,
104 + headerBackVisible:
105 + props.onClose === undefined &&
106 + splitBack === null &&
107 + !(layout.usesSplitView && props.onBackToList) &&
108 + !(props.guardBack && props.onBack),
109 + ...(props.guardBack ? { gestureEnabled: false } : undefined),
110 title: props.title,
111 unstable_headerSubtitle: props.subtitle || undefined,
112 ...(props.matchSearchSurface
@@ -132,12 +151,26 @@ export function AppBar(props: AppBarProps) {
151 },
152 }
153 : undefined),
135 - ...props.options,
154 }}
155 />
138 - {(splitBack || showsSidebarToggle) &&
139 - props.options?.unstable_headerLeftItems === undefined ? (
156 + {props.onClose ? (
157 <Toolbar placement="left">
158 + <Toolbar.Button
159 + icon="xmark"
160 + accessibilityLabel={props.closeAccessibilityLabel ?? "Close"}
161 + onPress={props.onClose}
162 + />
163 + </Toolbar>
164 + ) : rootBack || splitBack || showsSidebarToggle || compose ? (
165 + <Toolbar placement="left">
166 + {rootBack ? (
167 + <ScreenHeaderButton
168 + accessibilityLabel="Back"
169 + icon="chevron.left"
170 + onPress={rootBack}
171 + separateBackground
172 + />
173 + ) : null}
174 {splitBack ? <ScreenHeaderButton {...splitBack} /> : null}
175 {showsSidebarToggle ? (
176 <ScreenHeaderButton
@@ -148,10 +181,22 @@ export function AppBar(props: AppBarProps) {
181 separateBackground={splitBack ? splitBack.separateBackground : true}
182 />
183 ) : null}
184 + {compose ? (
185 + <ScreenHeaderButton
186 + accessibilityLabel="New task"
187 + label="New task"
188 + icon="square.and.pencil"
189 + onPress={compose}
190 + separateBackground
191 + />
192 + ) : null}
193 </Toolbar>
194 ) : null}
153 - {(props.actions?.length || visibleMenus.length || props.trailing || closeInspector) &&
154 - props.options?.unstable_headerRightItems === undefined ? (
195 + {props.actions?.length ||
196 + visibleMenus.length ||
197 + props.trailing ||
198 + props.confirm ||
199 + closeInspector ? (
200 <Toolbar placement="right">
201 {props.actions?.map(({ loading, ...action }) =>
202 loading ? (
@@ -168,12 +213,34 @@ export function AppBar(props: AppBarProps) {
213 key={action.accessibilityLabel}
214 {...action}
215 icon={iosIcon(action.icon)}
171 - separateBackground
216 + separateBackground={action.separateBackground ?? true}
217 />
218 ),
219 )}
220 {visibleMenus.map(createNativeHeaderMenu)}
221 {props.trailing}
222 + {props.confirm?.loading ? (
223 + <Toolbar.Custom>
224 + <View
225 + className="size-11 items-center justify-center"
226 + accessible
227 + accessibilityLabel={props.confirm.label}
228 + accessibilityState={{ busy: true }}
229 + >
230 + <AppActivityIndicator colorClassName="accent-prominent-action" />
231 + </View>
232 + </Toolbar.Custom>
233 + ) : props.confirm ? (
234 + <Toolbar.Button
235 + icon="checkmark"
236 + variant="prominent"
237 + visibilityPriority="high"
238 + tintColor={colors["--color-prominent-action"]}
239 + accessibilityLabel={props.confirm.label}
240 + disabled={props.confirm.disabled}
241 + onPress={props.confirm.onPress}
242 + />
243 + ) : null}
244 {closeInspector ? (
245 <ScreenHeaderButton
246 accessibilityLabel="Close inspector"
@@ -195,6 +262,7 @@ export function AppBar(props: AppBarProps) {
262
263 export type {
264 AppBarAction,
265 + AppBarConfirm,
266 AppBarMenu,
267 AppBarMenuItem,
268 AppBarProps,
apps/mobile/src/components/ui/AppBar.types.ts
+36 -4
@@ -1,6 +1,5 @@
1 import type { ReactNode } from "react";
2 import type { ColorValue } from "react-native";
3 -import type { AppNativeStackNavigationOptions } from "../../native/StackHeader";
3 import type { AppSymbolName } from "./AppSymbol";
4
5 export interface AppBarAction {
@@ -16,6 +15,8 @@ export interface AppBarAction {
15 readonly destructive?: boolean;
16 /** Android: always in the overflow menu, never a toolbar button. */
17 readonly overflowOnly?: boolean;
18 + /** iOS: false shares one glass capsule with neighbouring items. Defaults to true. */
19 + readonly separateBackground?: boolean;
20 }
21
22 export type AppBarMenuItem =
@@ -28,6 +29,7 @@ export type AppBarMenuItem =
29 readonly subtitle?: string;
30 readonly disabled?: boolean;
31 readonly selected?: boolean;
32 + readonly destructive?: boolean;
33 readonly onPress: () => void;
34 }
35 | {
@@ -46,6 +48,13 @@ export interface AppBarMenu {
48 readonly items: ReadonlyArray<AppBarMenuItem>;
49 }
50
51 +export interface AppBarConfirm {
52 + readonly label: string;
53 + readonly onPress: () => void;
54 + readonly disabled?: boolean;
55 + readonly loading?: boolean;
56 +}
57 +
58 export interface AppBarSearch {
59 readonly value: string;
60 readonly onChangeText: (value: string) => void;
@@ -74,11 +83,35 @@ export interface AppBarProps {
83 readonly menus?: ReadonlyArray<AppBarMenu>;
84 readonly search?: AppBarSearch;
85 readonly onBack?: () => void;
86 + /** Back runs `onBack` and swipe-back is off, so a `usePreventRemove` guard sees it first. */
87 + readonly guardBack?: boolean;
88 + /**
89 + * Back for a page whose parent is the workspace list. Hidden in split view, where the list is
90 + * beside the page; shown even when the page opened with nothing beneath it.
91 + */
92 + readonly onBackToList?: () => void;
93 + /**
94 + * iOS: a labelled compose button beside the sidebar button in split view. The Duo's column bar
95 + * and Android's sidebar compose on their own, so they ignore it.
96 + */
97 + readonly onCompose?: () => void;
98 + /**
99 + * The bar of a sheet or modal: a close button leads the bar in place of Back and the sidebar
100 + * button, on both platforms.
101 + */
102 + readonly onClose?: () => void;
103 + /** Defaults to "Close". */
104 + readonly closeAccessibilityLabel?: string;
105 + /** A sheet's confirm button, last in the bar. */
106 + readonly confirm?: AppBarConfirm;
107 /** Android: replaces the sidebar button at the start of the bar. */
108 readonly leading?: ReactNode;
79 - /** Leaves route options to the screen: in-screen bars, and screens that set their own. iOS draws nothing. */
109 + /**
110 + * Workspace shell only: a second bar inside a route whose own bar is drawn elsewhere, such as
111 + * a workspace tab pane. Leaves route options alone; iOS draws nothing. Screens never set it.
112 + */
113 readonly embedded?: boolean;
81 - /** An embedded bar at the top of a sheet. */
114 + /** A bar at the top of a sheet that is not a route (routed sheets are detected). */
115 readonly sheet?: boolean;
116 readonly backInSplitView?: {
117 readonly accessibilityLabel: string;
@@ -91,6 +124,5 @@ export interface AppBarProps {
124 readonly compact?: boolean;
125 readonly trailing?: ReactNode;
126 readonly matchSearchSurface?: boolean;
94 - readonly options?: AppNativeStackNavigationOptions;
127 readonly optionsVersion?: unknown;
128 }
apps/mobile/src/components/ui/ScreenContent.tsx
+6 -2
@@ -1,6 +1,8 @@
1 import type { ReactNode } from "react";
2 import { Platform, View, type LayoutChangeEvent } from "react-native";
3
4 +import { useAdaptiveWorkspaceLayout } from "../../features/layout/adaptive-workspace-context";
5 +
6 const SURFACE_CLASS_NAMES = {
7 sheet: "bg-sheet-solid",
8 screen: "bg-screen",
@@ -15,16 +17,18 @@ const SURFACE_CLASS_NAMES = {
17 export function ScreenContent({
18 children,
19 surface = "sheet",
18 - insetHorizontal = false,
20 + insetHorizontal,
21 fitToContents = false,
22 onLayout,
23 }: {
24 readonly children: ReactNode;
25 readonly surface?: keyof typeof SURFACE_CLASS_NAMES;
26 + /** Keeps the card off the window edge. Defaults to on wherever the workspace is split. */
27 readonly insetHorizontal?: boolean;
28 readonly fitToContents?: boolean;
29 readonly onLayout?: (event: LayoutChangeEvent) => void;
30 }) {
31 + const { layout } = useAdaptiveWorkspaceLayout();
32 if (Platform.OS !== "android") {
33 return onLayout ? (
34 <View className="flex-1" onLayout={onLayout}>
@@ -45,7 +49,7 @@ export function ScreenContent({
49 flexShrink: 1,
50 flexGrow: fitToContents ? 0 : 1,
51 flexBasis: fitToContents ? "auto" : 0,
48 - marginHorizontal: insetHorizontal ? 4 : 0,
52 + marginHorizontal: (insetHorizontal ?? layout.usesSplitView) ? 4 : 0,
53 }}
54 >
55 {children}
apps/mobile/src/components/ui/Sheet.android.tsx
+7 -1
@@ -16,6 +16,7 @@ export function Sheet(props: SheetProps) {
16 isOpen={isOpen}
17 detents={[0.5, 0.9]}
18 prefersGrabberVisible={false}
19 + preventNativeDismiss={props.dismissDisabled}
20 nativeContainerStyle={containerStyle}
21 onDismiss={props.onClose}
22 onNativeDismiss={props.onClose}
@@ -24,7 +25,12 @@ export function Sheet(props: SheetProps) {
25 {/* Android FormSheet does not bound flex children. Material drags target the first scroll view, so place content before the header. */}
26 <View collapsable={false} className="absolute inset-0 flex-col-reverse bg-header">
27 <ScreenContent>{props.children}</ScreenContent>
27 - <AppBar sheet title={props.title} onBack={() => setIsOpen(false)} hideBottomBorder />
28 + <AppBar
29 + sheet
30 + title={props.title}
31 + onBack={props.dismissDisabled ? undefined : () => setIsOpen(false)}
32 + hideBottomBorder
33 + />
34 <View
35 pointerEvents="none"
36 className="absolute top-1 h-1 w-8 self-center rounded-full bg-header-foreground/40"
apps/mobile/src/components/ui/Sheet.tsx
+5 -1
@@ -17,13 +17,16 @@ export function Sheet(props: SheetProps) {
17 const containerStyle = useResolveClassNames("bg-sheet");
18 const screenId = useId();
19 const [isOpen, setIsOpen] = useState(true);
20 - const close = () => setIsOpen(false);
20 + const close = () => {
21 + if (!props.dismissDisabled) setIsOpen(false);
22 + };
23
24 return (
25 <FormSheet
26 isOpen={isOpen}
27 detents={formSheetDetents(0.5, 0.9)}
28 prefersGrabberVisible
29 + preventNativeDismiss={props.dismissDisabled}
30 // The header holds the close button, so the Duo needs no rail inside this sheet.
31 prefersHorizontalBars
32 nativeContainerStyle={containerStyle}
@@ -57,6 +60,7 @@ export function Sheet(props: SheetProps) {
60 icon: { name: "xmark", type: "sfSymbol" },
61 accessibilityLabel: `Close ${props.title}`,
62 identifier: `app-sheet-close-${screenId}`,
63 + disabled: props.dismissDisabled,
64 onPress: close,
65 },
66 ]}
apps/mobile/src/components/ui/Sheet.types.ts
+2
@@ -4,4 +4,6 @@ export interface SheetProps {
4 readonly title: string;
5 readonly children: ReactNode;
6 readonly onClose: () => void;
7 + /** Blocks the close button and the swipe, such as while a submit is in flight. */
8 + readonly dismissDisabled?: boolean;
9 }
apps/mobile/src/components/ui/headerMenu.android.ts
+4 -1
@@ -22,7 +22,10 @@ export function androidHeaderMenuActions(items: ReadonlyArray<AppBarMenuItem>):
22 image: item.icon,
23 imageColor: item.iconColor,
24 state: item.selected ? "on" : undefined,
25 - attributes: item.disabled ? { disabled: true } : undefined,
25 + attributes:
26 + item.disabled || item.destructive
27 + ? { disabled: item.disabled, destructive: item.destructive }
28 + : undefined,
29 },
30 ],
31 );
apps/mobile/src/components/ui/nativeHeaderMenu.ios.tsx
+1
@@ -14,6 +14,7 @@ function renderMenuItems(items: ReadonlyArray<AppBarMenuItem>) {
14 icon={item.icon}
15 subtitle={item.subtitle}
16 disabled={item.disabled}
17 + destructive={item.destructive}
18 isOn={item.selected}
19 onPress={item.onPress}
20 >
apps/mobile/src/components/ui/useBarInset.ts new
+60
@@ -0,0 +1,60 @@
1 +import { HeaderHeightContext } from "@react-navigation/elements";
2 +import { use } from "react";
3 +import { Platform } from "react-native";
4 +
5 +import { useAdaptiveWorkspaceLayout } from "../../features/layout/adaptive-workspace-context";
6 +import { NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET } from "../../features/layout/native-mail-search-toolbar";
7 +import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
8 +import type { AppBarSearch } from "./AppBar.types";
9 +import { useSafeAreaInsets } from "react-native-safe-area-context";
10 +
11 +import { IOS_NAV_BAR_HEIGHT } from "../../lib/layoutMetrics";
12 +import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
13 +import { useToolbarLayout } from "./useToolbarLayout";
14 +
15 +/**
16 + * How far below the screen's top edge its AppBar ends: where content that scrolls under a
17 + * translucent bar starts, and where an overlay pinned under the bar goes. Measured by the native
18 + * column or stack on iOS; Android draws the bar in-tree from the toolbar geometry.
19 + */
20 +export function useBarInset(): number {
21 + const headerHeight = use(HeaderHeightContext);
22 + const columnMetrics = useNativeColumnLayoutMetrics();
23 + const insets = useSafeAreaInsets();
24 + const toolbar = useToolbarLayout();
25 + if (Platform.OS === "android") {
26 + return toolbar.paddingTop + toolbar.height + toolbar.paddingBottom;
27 + }
28 + return headerHeight ?? columnMetrics?.safeArea.top ?? insets.top + IOS_NAV_BAR_HEIGHT;
29 +}
30 +
31 +/**
32 + * How far the bar covers the top of the body below it: the bar inset where the body runs under
33 + * the iOS bar, 0 on Android, where the bar sits above the body in flow.
34 + */
35 +export function useBarOverlap(): number {
36 + const barInset = useBarInset();
37 + return Platform.OS === "android" ? 0 : barInset;
38 +}
39 +
40 +/**
41 + * The content's top safe area under the AppBar: a translucent bar's height, zero under a solid
42 + * one or on Android, where the bar sits in flow. For scroll content insets, which must not
43 + * double-count a solid bar.
44 + */
45 +export function useContentTopInset(): number {
46 + const insets = useSafeAreaInsets();
47 + const columnMetrics = useNativeColumnLayoutMetrics();
48 + return Platform.OS === "ios" ? (columnMetrics?.safeArea.top ?? insets.top) : 0;
49 +}
50 +
51 +/** How much of the screen's bottom edge an AppBar `search` covers: iOS's bottom search toolbar. */
52 +export function useSearchToolbarInset(search: AppBarSearch | undefined): number {
53 + const { layout } = useAdaptiveWorkspaceLayout();
54 + const usesNativeMailSearchToolbar = useNativeMailSearchToolbar();
55 + return search !== undefined &&
56 + (search.compactToolbar ?? !layout.usesSplitView) &&
57 + usesNativeMailSearchToolbar
58 + ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET
59 + : 0;
60 +}
apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx
+7 -11
@@ -16,7 +16,7 @@ import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
16 import { AppBar } from "../../components/ui/AppBar";
17 import { SymbolView } from "../../components/ui/AppSymbol";
18 import { useMemo, useRef, type ComponentProps } from "react";
19 -import { Platform, RefreshControl, useWindowDimensions, View } from "react-native";
19 +import { RefreshControl, useWindowDimensions, View } from "react-native";
20 import { GestureDetector, useNativeGesture } from "react-native-gesture-handler";
21 import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
22
@@ -105,15 +105,11 @@ function ArchivedThreadsHeader(props: {
105 },
106 ],
107 },
108 - ...(Platform.OS === "android"
109 - ? [
110 - {
111 - id: "refresh",
112 - title: "Refresh archived threads",
113 - onPress: props.onRefresh,
114 - },
115 - ]
116 - : []),
108 + {
109 + id: "refresh",
110 + title: "Refresh archived threads",
111 + onPress: props.onRefresh,
112 + },
113 ],
114 },
115 ]}
@@ -418,7 +414,7 @@ export function ArchivedThreadsScreen(props: {
414 <SettingsScreenContent>
415 <GestureDetector gesture={archiveScrollGesture}>
416 <LegendList
421 - renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
417 + renderScrollComponent={NativeScrollView}
418 className="flex-1"
419 contentContainerStyle={{
420 paddingBottom: 32,
apps/mobile/src/features/cloud/ConnectOnboardingRouteScreen.tsx
+9 -31
@@ -1,13 +1,11 @@
1 -import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
2 -import { SheetHeader } from "../../components/ui/SheetHeader";
3 -import { IconButton } from "../../components/ui/IconButton";
1 +import { AppBar } from "../../components/ui/AppBar";
2 import { Button } from "../../components/ui/Button";
3 import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
4
5 import { useAuth } from "@clerk/expo";
6 import { useNavigation } from "@react-navigation/native";
7 import { useState } from "react";
10 -import { Platform, RefreshControl, View } from "react-native";
8 +import { RefreshControl, View } from "react-native";
9 import { useSafeAreaInsets } from "react-native-safe-area-context";
10
11 import { reportAtomCommandResult, settlePromise } from "@t3tools/client-runtime/state/runtime";
@@ -60,30 +58,14 @@ function ConfiguredConnectOnboardingRouteScreen() {
58
59 return (
60 <View collapsable={false} className="flex-1 bg-sheet">
63 - <SheetHeader
64 - presentation={Platform.OS === "android" ? "inline" : "native"}
61 + <AppBar
62 title="Set up T3 Connect"
63 onClose={handleClose}
67 - trailing={
68 - Platform.OS === "android" ? (
69 - isRefreshing ? (
70 - <View
71 - className="size-12 items-center justify-center"
72 - accessible
73 - accessibilityLabel="Refreshing environments"
74 - accessibilityState={{ busy: true }}
75 - >
76 - <AppActivityIndicator />
77 - </View>
78 - ) : (
79 - <IconButton
80 - accessibilityLabel="Refresh environments"
81 - icon="arrow.clockwise"
82 - onPress={handleRefresh}
83 - />
84 - )
85 - ) : undefined
86 - }
64 + refresh={{
65 + accessibilityLabel: "Refresh environments",
66 + disabled: isRefreshing,
67 + onPress: handleRefresh,
68 + }}
69 />
70 <ScrollView
71 nestedScrollEnabled
@@ -97,11 +79,7 @@ function ConfiguredConnectOnboardingRouteScreen() {
79 paddingHorizontal: 20,
80 paddingTop: 16,
81 }}
100 - refreshControl={
101 - Platform.OS === "ios" ? (
102 - <RefreshControl refreshing={isRefreshing} onRefresh={handleRefresh} />
103 - ) : undefined
104 - }
82 + refreshControl={<RefreshControl refreshing={isRefreshing} onRefresh={handleRefresh} />}
83 >
84 {isSignedIn ? (
85 <CloudEnvironmentRows
apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx
-3
@@ -8,7 +8,6 @@ import {
8 StackActions,
9 useIsFocused,
10 useNavigation,
11 - useRoute,
11 type StaticScreenProps,
12 } from "@react-navigation/native";
13 import type { EnvironmentId } from "@t3tools/contracts";
@@ -66,7 +65,6 @@ function PairingForm({
65 const { connectionPairingUrl, onChangeConnectionPairingUrl, onConnectPress } =
66 useRemoteConnections();
67 const navigation = useNavigation();
69 - const routeName = useRoute().name;
68 const insets = useSafeAreaInsets();
69 const [initialPairing] = useState(() => parsePairingUrl(routePairingUrl || connectionPairingUrl));
70 const [hostInput, setHostInput] = useState(initialPairing.host);
@@ -178,7 +176,6 @@ function PairingForm({
176
177 return (
178 <SettingsScreen
181 - formSheet={routeName === "ConnectionsNew"}
179 title="Add environment"
180 actions={[
181 {
apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx
+4 -4
@@ -9,8 +9,7 @@ import {
9 import { useIsFocused, useNavigation, type StaticScreenProps } from "@react-navigation/native";
10 import { EnvironmentId, ThreadId } from "@t3tools/contracts";
11 import * as Cause from "effect/Cause";
12 -import { use, useEffect, useRef, useState, type RefObject } from "react";
13 -import { HeaderHeightContext } from "@react-navigation/elements";
12 +import { useEffect, useRef, useState, type RefObject } from "react";
13 import * as Haptics from "expo-haptics";
14 import { Accelerometer } from "expo-sensors";
15 import { Pressable, StatusBar, View } from "react-native";
@@ -28,6 +27,7 @@ import {
27 findHeaderMenuAction,
28 } from "../../components/ui/headerMenu.android";
29 import { AppBar } from "../../components/ui/AppBar";
30 +import { useBarOverlap } from "../../components/ui/useBarInset";
31 import type { AppBarMenuItem } from "../../components/ui/AppBar.types";
32 import { useAppForeground } from "../../lib/appState";
33 import { useHardwareBack } from "../../lib/backHandler";
@@ -91,7 +91,7 @@ export function DevicePreviewScreen({
91 const embedded = onMaximize !== undefined;
92 const insets = useSafeAreaInsets();
93 // In a pane the stream sits below the pane's bar, which content otherwise slides under.
94 - const headerHeight = use(HeaderHeightContext) ?? 0;
94 + const barOverlap = useBarOverlap();
95 // NativeColumnContent already insets the sides, so only a book fold moves the hidden-controls pill.
96 const handleBounds = deriveBottomControlInsets(useNativeColumnLayoutMetrics());
97 const { themeVariables } = useAppearancePreferences();
@@ -280,7 +280,7 @@ export function DevicePreviewScreen({
280 },
281 ]}
282 />
283 - <View style={{ height: headerHeight }} />
283 + <View style={{ height: barOverlap }} />
284 </>
285 ) : null}
286 {preview && focused && foreground ? (
apps/mobile/src/features/files/AttachmentFileScreen.tsx
+34 -79
@@ -1,25 +1,19 @@
1 -import { Toolbar } from "../../components/ui/Toolbar";
1 import * as Dialog from "../../components/ui/Dialog";
3 -import { NativeStackScreenOptions } from "../../native/StackHeader";
2 import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
5 -import type { MenuAction } from "@react-native-menu/menu";
3 import { EnvironmentId, ThreadId } from "@t3tools/contracts";
4 import {
5 clampFileAttachmentUploadBytes,
6 formatAttachmentSize,
7 } from "@t3tools/client-runtime/state/attachments";
8 import { useRef, useState } from "react";
12 -import { Platform, View } from "react-native";
9 +import { View } from "react-native";
10
14 -import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
15 -import { AppBar } from "../../components/ui/AppBar";
16 -import { Menu } from "../../components/ui/Menu";
11 +import { AppBar, type AppBarMenu } from "../../components/ui/AppBar";
12 import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
13 import { useAttachmentDocument } from "../../lib/attachmentDocument";
14 import { nativeViewerErrorMessage } from "../../lib/attachmentDownload";
15 import { isFileBackedComposerAttachment } from "../../lib/composerImages";
16 import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
22 -import { useUniwindTheme } from "../../lib/useUniwindTheme";
17 import { removeComposerDraftAttachment, useComposerDraft } from "../../state/use-composer-drafts";
18 import { useEnvironmentServerConfig } from "../../state/entities";
19 import { useRefreshAssetUrl } from "../../state/assets";
@@ -44,8 +38,6 @@ type AttachmentFileScreenProps = StaticScreenProps<AttachmentFileRouteParams>;
38 export function AttachmentFileScreen(props: AttachmentFileScreenProps) {
39 const navigation = useNavigation();
40 const { appearance, setCodeWordBreak } = useAppearancePreferences();
47 - const iconColor = useUniwindTheme()["--color-icon"];
48 - const isAndroid = Platform.OS === "android";
41 const params = props.route.params;
42 const environmentId = params.environmentId?.trim()
43 ? EnvironmentId.make(params.environmentId)
@@ -185,15 +177,37 @@ export function AttachmentFileScreen(props: AttachmentFileScreenProps) {
177 : null,
178 ].filter((action) => action !== null);
179 const selectedAction = activeMode === "source" ? "source" : "preview";
188 - const androidMenuActions = menuActions.map((action) => ({
189 - id: action.id,
190 - title: action.title,
191 - image: action.icon,
192 - state: action.inline ? (action.id === selectedAction ? "on" : "off") : undefined,
193 - ...("destructive" in action ? { attributes: { destructive: true } } : {}),
194 - })) satisfies MenuAction[];
195 - const handleAndroidMenuAction = (event: { nativeEvent: { event: string } }) => {
196 - menuActions.find(({ id }) => id === event.nativeEvent.event)?.onPress();
180 + const fileMenu: AppBarMenu = {
181 + title: "File actions",
182 + icon: "ellipsis",
183 + items: [
184 + ...(renderedMode
185 + ? [
186 + {
187 + id: "modes",
188 + inline: true,
189 + items: menuActions
190 + .filter(({ inline }) => inline)
191 + .map((action) => ({
192 + id: action.id,
193 + title: action.title,
194 + icon: action.icon,
195 + selected: action.id === selectedAction,
196 + onPress: action.onPress,
197 + })),
198 + },
199 + ]
200 + : []),
201 + ...menuActions
202 + .filter(({ inline }) => !inline)
203 + .map((action) => ({
204 + id: action.id,
205 + title: action.title,
206 + icon: action.icon,
207 + destructive: "destructive" in action,
208 + onPress: action.onPress,
209 + })),
210 + ],
211 };
212 const subtitle = `${draftKey ? "Draft attachment" : "Attachment"}${sizeBytes > 0 ? ` · ${formatAttachmentSize(sizeBytes)}` : ""}`;
213 const refresh = useRefreshAssetUrl(environmentId, resource);
@@ -208,7 +222,6 @@ export function AttachmentFileScreen(props: AttachmentFileScreenProps) {
222 <ZipArchiveView
223 name={params.name}
224 subtitle={subtitle}
211 - tintColor={iconColor}
225 sizeBytes={sizeBytes}
226 uri={uri}
227 isLocal={localAttachment !== null}
@@ -229,65 +242,7 @@ export function AttachmentFileScreen(props: AttachmentFileScreenProps) {
242
243 return (
244 <View className="flex-1 bg-sheet">
232 - <NativeStackScreenOptions
233 - options={{
234 - headerShown: !isAndroid,
235 - headerTintColor: iconColor,
236 - headerTitle: params.name,
237 - title: params.name,
238 - unstable_headerSubtitle: Platform.OS === "ios" ? subtitle : undefined,
239 - }}
240 - />
241 - {isAndroid ? (
242 - <AppBar
243 - embedded
244 - title={params.name}
245 - subtitle={subtitle}
246 - onBack={handleBack}
247 - trailing={
248 - <Menu
249 - actions={androidMenuActions}
250 - isAnchoredToRight
251 - title="File actions"
252 - onPressAction={handleAndroidMenuAction}
253 - >
254 - <AndroidHeaderIconButton accessibilityLabel="File actions" icon="ellipsis" />
255 - </Menu>
256 - }
257 - />
258 - ) : null}
259 - <Toolbar placement="right">
260 - <Toolbar.Menu accessibilityLabel="File actions" icon="ellipsis">
261 - {renderedMode ? (
262 - <Toolbar.Menu inline>
263 - {menuActions
264 - .filter(({ inline }) => inline)
265 - .map((action) => (
266 - <Toolbar.MenuAction
267 - key={action.id}
268 - icon={action.icon}
269 - isOn={action.id === selectedAction}
270 - onPress={action.onPress}
271 - >
272 - {action.title}
273 - </Toolbar.MenuAction>
274 - ))}
275 - </Toolbar.Menu>
276 - ) : null}
277 - {menuActions
278 - .filter(({ inline }) => !inline)
279 - .map((action) => (
280 - <Toolbar.MenuAction
281 - key={action.id}
282 - icon={action.icon}
283 - destructive={"destructive" in action}
284 - onPress={action.onPress}
285 - >
286 - {action.title}
287 - </Toolbar.MenuAction>
288 - ))}
289 - </Toolbar.Menu>
290 - </Toolbar>
245 + <AppBar title={params.name} subtitle={subtitle} onBack={handleBack} menus={[fileMenu]} />
246 <AttachmentDocumentBody
247 document={document}
248 name={params.name}
apps/mobile/src/features/files/FileTreeBrowser.tsx
+6 -9
@@ -5,13 +5,12 @@ import type { ProjectEntry } from "@t3tools/contracts";
5 import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
6 import { SymbolView } from "../../components/ui/AppSymbol";
7 import { useEffect, useRef, useState } from "react";
8 -import { Platform, Pressable, RefreshControl, View } from "react-native";
9 -import { useSafeAreaInsets } from "react-native-safe-area-context";
8 +import { Pressable, RefreshControl, View } from "react-native";
9
10 import { AppText as Text } from "../../components/ui/AppText";
11 import { PierreEntryIcon } from "../../components/PierreEntryIcon";
12 import { cn } from "../../lib/cn";
14 -import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
13 +import { useContentTopInset } from "../../components/ui/useBarInset";
14 import {
15 buildFileTree,
16 flattenFileTree,
@@ -122,9 +121,7 @@ export function FileTreeBrowser(props: {
121 readonly path: string;
122 readonly selectedPathAtPress: string | null;
123 } | null>(null);
125 - const insets = useSafeAreaInsets();
126 - const columnMetrics = useNativeColumnLayoutMetrics();
127 - const headerInset = Platform.OS === "ios" ? (columnMetrics?.safeArea.top ?? insets.top) : 0;
124 + const headerInset = useContentTopInset();
125 const {
126 onLoadDirectory,
127 onPreviewFile,
@@ -216,14 +213,14 @@ export function FileTreeBrowser(props: {
213 // Keep the list as direct screen content so UIKit can apply header insets.
214 return (
215 <LegendList
219 - renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
216 + renderScrollComponent={NativeScrollView}
217 contentInsetStartAdjustment={headerInset}
218 alwaysBounceVertical
219 className="flex-1"
220 data={visibleNodes}
221 keyExtractor={(item) => item.node.path}
225 - contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
226 - automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
222 + contentInsetAdjustmentBehavior="automatic"
223 + automaticallyAdjustsScrollIndicatorInsets
224 keyboardDismissMode="on-drag"
225 keyboardShouldPersistTaps="handled"
226 estimatedItemSize={42}
apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx
+36 -41
@@ -2,11 +2,9 @@ import { formatFilePathForClipboard } from "@t3tools/client-runtime/media-action
2 import { resolvePathLinkTarget } from "@t3tools/shared/fileLinks";
3 import { resolveFilesystemReadAccess } from "@t3tools/client-runtime/state/filesystem";
4 import { environmentSession } from "../../state/session";
5 -import { NativeStackScreenOptions } from "../../native/StackHeader";
5 import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
6 import { type ReactNode, useId, useState } from "react";
7 import { Platform, View } from "react-native";
9 -import { useSafeAreaInsets } from "react-native-safe-area-context";
8 import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
9 import { EnvironmentId, type ProjectReadFileResult, ThreadId } from "@t3tools/contracts";
10 import { videoMimeType } from "@t3tools/shared/video";
@@ -46,9 +44,9 @@ import { FileTreeBrowser } from "./FileTreeBrowser";
44 import { useFileTreeEntries } from "./useFileTreeEntries";
45 import { preloadWorkspaceFileContents } from "./preload-workspace-file";
46 import { SourceFileSurface } from "./SourceFileSurface";
49 -import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
47 import { ThreadFileNavigatorPane } from "./thread-file-navigator-pane";
48 import { AppBar } from "../../components/ui/AppBar";
49 +import { useContentTopInset } from "../../components/ui/useBarInset";
50 import { WorkspaceFileImagePreview } from "./WorkspaceFileImagePreview";
51 import { WorkspaceFilePreviewError } from "./WorkspaceFilePreviewError";
52 import { WorkspaceFileVideoPreview } from "./WorkspaceFileVideoPreview";
@@ -88,17 +86,7 @@ function FilesBrowserHeader(props: {
86 closeAccessibilityLabel: "Close file search",
87 clearAccessibilityLabel: "Clear file search",
88 }}
91 - menus={
92 - Platform.OS === "android"
93 - ? [
94 - {
95 - title: "File options",
96 - icon: "ellipsis",
97 - items: [{ id: "refresh", title: "Refresh files", onPress: props.onRefresh }],
98 - },
99 - ]
100 - : undefined
101 - }
89 + refresh={{ accessibilityLabel: "Refresh files", onPress: props.onRefresh }}
90 />
91 );
92 }
@@ -106,7 +94,6 @@ function FilesBrowserHeader(props: {
94 function FileHeader(props: {
95 readonly title: string;
96 readonly subtitle: string;
109 - readonly iconColor: string;
97 readonly activeMode: string;
98 readonly fileInspectorSupported: boolean;
99 readonly onBack: () => void;
@@ -127,7 +114,6 @@ function FileHeader(props: {
114 subtitle={props.subtitle}
115 onBack={props.onBack}
116 hideBottomBorder
130 - options={{ headerTintColor: props.iconColor, headerTitle: props.title }}
117 backInSplitView={
118 props.fileInspectorSupported
119 ? {
@@ -231,10 +217,8 @@ function FileContent(props: {
217 }) {
218 // Reopening a mutable host file must not reuse a poster from an earlier visit.
219 const thumbnailInstanceId = useId();
234 - const insets = useSafeAreaInsets();
235 - const columnMetrics = useNativeColumnLayoutMetrics();
236 - const reservedHeaderInset =
237 - Platform.OS === "ios" && props.truncated ? (columnMetrics?.safeArea.top ?? insets.top) : 0;
220 + const barOverlap = useContentTopInset();
221 + const reservedHeaderInset = props.truncated ? barOverlap : 0;
222 const isMarkdown = isMarkdownPreviewFile(props.relativePath);
223 const delimiter = filePreviewDelimiter({ name: props.relativePath });
224 const isBrowserFile = isWorkspaceBrowserPreviewPath(props.relativePath);
@@ -386,14 +370,22 @@ function useThreadFilesWorkspace(params: {
370 }
371
372 function FilesUnavailable({
373 + title = "Files unavailable",
374 detail = "This thread does not have an active workspace path.",
375 + onBack,
376 }: {
377 + title?: string;
378 detail?: string;
379 + onBack: () => void;
380 }) {
381 return (
394 - <View className="flex-1 items-center justify-center bg-sheet px-6">
395 - <NativeStackScreenOptions options={{ title: "Files" }} />
396 - <EmptyState title="Files unavailable" detail={detail} />
382 + <View className="flex-1 bg-sheet">
383 + <AppBar title="Files" onBack={onBack} onBackToList={onBack} hideBottomBorder />
384 + <ScreenContent>
385 + <View className="flex-1 items-center justify-center px-6">
386 + <EmptyState title={title} detail={detail} />
387 + </View>
388 + </ScreenContent>
389 </View>
390 );
391 }
@@ -428,7 +420,7 @@ function FilesToolbarBottomFade() {
420
421 export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
422 const navigation = useNavigation();
431 - const { fileInspector, layout } = useAdaptiveWorkspaceLayout();
423 + const { fileInspector } = useAdaptiveWorkspaceLayout();
424 const [searchQuery, setSearchQuery] = useState("");
425 const { themeAppearance: highlightTheme } = useAppearancePreferences();
426 const { cwd, environmentId, projectName, selectedThread, threadId } = useThreadFilesWorkspace(
@@ -524,11 +516,14 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
516 return <LoadingScreen message="Checking file access..." messagePlacement="above-spinner" />;
517 }
518 return (
527 - <FilesUnavailable detail={fileAccess.error ?? "This connection cannot read host files."} />
519 + <FilesUnavailable
520 + detail={fileAccess.error ?? "This connection cannot read host files."}
521 + onBack={handleReturnToThread}
522 + />
523 );
524 }
525 if (cwd === null) {
531 - return <FilesUnavailable />;
526 + return <FilesUnavailable onBack={handleReturnToThread} />;
527 }
528
529 if (hasFileInspector) {
@@ -541,8 +536,8 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
536 );
537 }
538
544 - const content = (
545 - <>
539 + return (
540 + <View className="flex-1">
541 <FilesBrowserHeader
542 projectName={projectName}
543 searchQuery={searchQuery}
@@ -550,7 +545,7 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
545 onRefresh={entriesQuery.refresh}
546 onBack={handleReturnToThread}
547 />
553 - <ScreenContent insetHorizontal={layout.usesSplitView}>
548 + <ScreenContent>
549 <FileTreeBrowser
550 key={JSON.stringify([environmentId, cwd])}
551 revealSelection={entriesQuery.revealSelection}
@@ -575,17 +570,14 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
570 />
571 <FilesToolbarBottomFade />
572 </ScreenContent>
578 - </>
573 + </View>
574 );
580 -
581 - return Platform.OS === "android" ? <View className="flex-1 bg-header">{content}</View> : content;
575 }
576
577 export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
578 const navigation = useNavigation();
579 const { fileInspector } = useAdaptiveWorkspaceLayout();
580 const { appearance, setCodeWordBreak } = useAppearancePreferences();
588 - const iconColor = useUniwindTheme()["--color-icon"];
581 const params = props.route.params;
582 const targetLine = normalizeRouteLine(firstRouteParam(params.line));
583 const { cwd, environmentId, projectName, relativePath, selectedThread, threadId } =
@@ -912,19 +904,23 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
904 );
905 }
906 return withInspector(
915 - <FilesUnavailable detail={fileAccess.error ?? "This connection cannot read host files."} />,
907 + <FilesUnavailable
908 + detail={fileAccess.error ?? "This connection cannot read host files."}
909 + onBack={handleBack}
910 + />,
911 );
912 }
913 if (cwd === null) {
919 - return withInspector(<FilesUnavailable />);
914 + return withInspector(<FilesUnavailable onBack={handleBack} />);
915 }
916
917 if (relativePath === null) {
918 return withInspector(
924 - <View className="flex-1 items-center justify-center bg-sheet px-6">
925 - <NativeStackScreenOptions options={{ title: "Files" }} />
926 - <EmptyState title="File unavailable" detail="This file path is invalid." />
927 - </View>,
919 + <FilesUnavailable
920 + title="File unavailable"
921 + detail="This file path is invalid."
922 + onBack={handleBack}
923 + />,
924 );
925 }
926
@@ -935,7 +931,7 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
931 }
932 if (directoryPath !== null) {
933 return withInspector(
938 - <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-sheet"}>
934 + <View className="flex-1 bg-sheet">
935 <FilesBrowserHeader
936 projectName={directoryPath}
937 searchQuery={searchQuery}
@@ -978,7 +974,6 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
974 <FileHeader
975 title={basename(relativePath)}
976 subtitle={headerSubtitle}
981 - iconColor={iconColor}
977 activeMode={resolvedActiveMode}
978 fileInspectorSupported={fileInspector.supported}
979 onBack={handleBack}
apps/mobile/src/features/files/WorkspaceFileWebPreview.tsx
+4 -7
@@ -1,7 +1,7 @@
1 import { useState } from "react";
2 -import { Platform, View } from "react-native";
2 +import { View } from "react-native";
3 import { WebView } from "react-native-webview";
4 -import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
4 +import { SafeAreaView } from "react-native-safe-area-context";
5
6 import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
7 import { AppText as Text } from "../../components/ui/AppText";
@@ -11,7 +11,7 @@ import { PdfPreview } from "../../components/PdfPreview";
11 import { ControlPill } from "../../components/ui/ControlPill";
12 import { useHardwareBack } from "../../lib/backHandler";
13 import { isPdfPreviewUri } from "../../lib/pdfPreview";
14 -import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
14 +import { useContentTopInset } from "../../components/ui/useBarInset";
15
16 export function WorkspaceFileWebPreview(props: { readonly uri: string | null }) {
17 if (props.uri === null) {
@@ -21,10 +21,7 @@ export function WorkspaceFileWebPreview(props: { readonly uri: string | null })
21 }
22
23 function DocumentWebPreview(props: { readonly uri: string }) {
24 - const insets = useSafeAreaInsets();
25 - const columnMetrics = useNativeColumnLayoutMetrics();
26 - // iOS headers float over this column, so content starts below them.
27 - const headerInset = Platform.OS === "ios" ? (columnMetrics?.safeArea.top ?? insets.top) : 0;
24 + const headerInset = useContentTopInset();
25 const [loadProgress, setLoadProgress] = useState(0);
26 const [loadError, setLoadError] = useState<string | null>(null);
27 const [linkedPdf, setLinkedPdf] = useState<string | null>(null);
apps/mobile/src/features/files/ZipArchiveView.test.tsx
+21 -22
@@ -102,32 +102,32 @@ vi.mock("@react-navigation/native", () => ({
102 navigation.remove = enabled ? remove : null;
103 },
104 }));
105 -vi.mock("react-native-safe-area-context", () => ({
106 - useSafeAreaInsets: () => ({ top: 0, right: 0, bottom: 0, left: 0 }),
107 -}));
105 vi.mock("../../native/NativeScrollViewMarker", () => ({ NativeScrollView: () => null }));
109 -vi.mock("../../native/StackHeader", () => ({ NativeStackScreenOptions: () => null }));
110 -vi.mock("../../components/ui/Toolbar", () => {
111 - const Slot = (props: { readonly children?: ReactNode }) => <div>{props.children}</div>;
112 - return {
113 - Toolbar: Object.assign(Slot, {
114 - Button: () => null,
115 - Menu: Slot,
116 - MenuAction: (props: {
117 - readonly children?: ReactNode;
118 - readonly disabled?: boolean;
119 - readonly onPress?: () => void;
120 - }) => (
121 - <button disabled={props.disabled} onClick={props.onPress}>
122 - {props.children}
106 +vi.mock("../../components/ui/AppBar", () => {
107 + interface Item {
108 + readonly id: string;
109 + readonly title?: string;
110 + readonly disabled?: boolean;
111 + readonly onPress?: () => void;
112 + readonly items?: ReadonlyArray<Item>;
113 + }
114 + const renderItems = (items: ReadonlyArray<Item>): ReactNode =>
115 + items.map((item) =>
116 + item.items ? (
117 + renderItems(item.items)
118 + ) : (
119 + <button key={item.id} disabled={item.disabled} onClick={item.onPress}>
120 + {item.title}
121 </button>
122 ),
125 - }),
123 + );
124 + return {
125 + AppBar: (props: {
126 + readonly menus?: ReadonlyArray<{ readonly items: ReadonlyArray<Item> }>;
127 + }) => <div>{props.menus?.map((menu) => renderItems(menu.items))}</div>,
128 };
129 });
128 -vi.mock("../../components/ui/AppBar", () => ({ AppBar: () => null }));
129 -vi.mock("../../components/ui/AndroidScreenHeader", () => ({ AndroidHeaderIconButton: () => null }));
130 -vi.mock("../../components/ui/Menu", () => ({ Menu: () => null }));
130 +vi.mock("../../components/ui/useBarInset", () => ({ useContentTopInset: () => 0 }));
131 vi.mock("../../components/ui/AppSymbol", () => ({ SymbolView: () => null }));
132 vi.mock("../../components/ui/Progress", () => ({ Progress: () => null }));
133 vi.mock("../../components/PierreEntryIcon", () => ({ PierreEntryIcon: () => null }));
@@ -182,7 +182,6 @@ function setup() {
182 const props: ComponentProps<typeof ZipArchiveView> = {
183 name: "archive.zip",
184 subtitle: "ZIP",
185 - tintColor: "#000000",
185 sizeBytes: 0,
186 uri: "file:///first.zip",
187 isLocal: true,
apps/mobile/src/features/files/ZipArchiveView.tsx
+67 -133
@@ -17,20 +17,17 @@ import { fetch } from "expo/fetch";
17 import { File } from "expo-file-system";
18 import { useNavigation, usePreventRemove } from "@react-navigation/native";
19 import { useEffect, useEffectEvent, useRef, useState } from "react";
20 -import { Keyboard, Platform, Pressable, ScrollView, TextInput, View } from "react-native";
21 -import { useSafeAreaInsets } from "react-native-safe-area-context";
20 +import { Keyboard, Pressable, ScrollView, TextInput, View } from "react-native";
21
22 import { PierreEntryIcon } from "../../components/PierreEntryIcon";
23 import { AppBar } from "../../components/ui/AppBar";
24 +import { useContentTopInset } from "../../components/ui/useBarInset";
25 import { SymbolView } from "../../components/ui/AppSymbol";
26 import { AppText as Text } from "../../components/ui/AppText";
27 import { Button } from "../../components/ui/Button";
28 import { EmptyState } from "../../components/ui/EmptyState";
29 import { Progress } from "../../components/ui/Progress";
30 -import { Toolbar } from "../../components/ui/Toolbar";
31 -import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
30 import { NativeScrollView } from "../../native/NativeScrollViewMarker";
33 -import { NativeStackScreenOptions } from "../../native/StackHeader";
31 import * as Dialog from "../../components/ui/Dialog";
32 import { FilePreviewModal } from "../../components/FilePreviewModal";
33 import {
@@ -296,67 +293,32 @@ function ZipTreeRowView(props: {
293 function ZipArchiveHeader(props: {
294 readonly name: string;
295 readonly subtitle: string;
299 - readonly tintColor: string;
296 readonly onSave: () => void;
297 readonly onRemove: (() => void) | null;
298 }) {
299 const navigation = useNavigation();
304 - const isAndroid = Platform.OS === "android";
300 return (
306 - <>
307 - <NativeStackScreenOptions
308 - options={{
309 - headerShown: !isAndroid,
310 - headerTintColor: props.tintColor,
311 - headerTitle: props.name,
312 - title: props.name,
313 - unstable_headerSubtitle: isAndroid ? undefined : props.subtitle,
314 - }}
315 - />
316 - {isAndroid ? (
317 - <AppBar
318 - embedded
319 - title={props.name}
320 - subtitle={props.subtitle}
321 - onBack={() => {
322 - if (navigation.canGoBack()) navigation.goBack();
323 - }}
324 - actions={[
325 - { accessibilityLabel: "Save ZIP", icon: "square.and.arrow.up", onPress: props.onSave },
326 - ...(props.onRemove
327 - ? [
328 - {
329 - accessibilityLabel: "Remove from draft",
330 - icon: "trash" as const,
331 - onPress: props.onRemove,
332 - destructive: true,
333 - overflowOnly: true,
334 - },
335 - ]
336 - : []),
337 - ]}
338 - />
339 - ) : (
340 - <Toolbar placement="right">
341 - {props.onRemove ? (
342 - <Toolbar.Menu accessibilityLabel="ZIP actions" icon="ellipsis">
343 - <Toolbar.MenuAction icon="square.and.arrow.up" onPress={props.onSave}>
344 - Save ZIP
345 - </Toolbar.MenuAction>
346 - <Toolbar.MenuAction icon="trash" destructive onPress={props.onRemove}>
347 - Remove from draft
348 - </Toolbar.MenuAction>
349 - </Toolbar.Menu>
350 - ) : (
351 - <Toolbar.Button
352 - accessibilityLabel="Save ZIP"
353 - icon="square.and.arrow.up"
354 - onPress={props.onSave}
355 - />
356 - )}
357 - </Toolbar>
358 - )}
359 - </>
301 + <AppBar
302 + title={props.name}
303 + subtitle={props.subtitle}
304 + onBack={() => {
305 + if (navigation.canGoBack()) navigation.goBack();
306 + }}
307 + actions={[
308 + { accessibilityLabel: "Save ZIP", icon: "square.and.arrow.up", onPress: props.onSave },
309 + ...(props.onRemove
310 + ? [
311 + {
312 + accessibilityLabel: "Remove from draft",
313 + icon: "trash" as const,
314 + onPress: props.onRemove,
315 + destructive: true,
316 + overflowOnly: true,
317 + },
318 + ]
319 + : []),
320 + ]}
321 + />
322 );
323 }
324
@@ -436,13 +398,13 @@ function ZipArchiveList(props: {
398 return (
399 <View className="flex-1 bg-sheet">
400 <LegendList
439 - renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
401 + renderScrollComponent={NativeScrollView}
402 contentInsetStartAdjustment={props.headerInset}
403 className="flex-1"
404 data={rows}
405 keyExtractor={(row) => `${row.node.entry ? "f" : "d"}:${row.node.path}`}
444 - contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
445 - automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
406 + contentInsetAdjustmentBehavior="automatic"
407 + automaticallyAdjustsScrollIndicatorInsets
408 estimatedItemSize={44}
409 recycleItems
410 keyboardDismissMode="on-drag"
@@ -509,7 +471,6 @@ function ZipArchiveList(props: {
471 export function ZipArchiveView(props: {
472 readonly name: string;
473 readonly subtitle: string;
512 - readonly tintColor: string;
474 readonly sizeBytes: number;
475 readonly uri: string | null;
476 readonly isLocal: boolean;
@@ -529,9 +490,7 @@ export function ZipArchiveView(props: {
490 const selected = selection && selection.archive === archive ? selection.entry : null;
491 const entryOpen = selected !== null;
492 usePreventRemove(entryOpen, () => setSelection(null));
532 - const insets = useSafeAreaInsets();
533 - const columnMetrics = useNativeColumnLayoutMetrics();
534 - const headerInset = Platform.OS === "ios" ? (columnMetrics?.safeArea.top ?? insets.top) : 0;
493 + const headerInset = useContentTopInset();
494 return (
495 <View className="flex-1 bg-sheet">
496 {entryOpen ? null : (
@@ -542,7 +501,6 @@ export function ZipArchiveView(props: {
501 ? `${archive.fileCount} ${archive.fileCount === 1 ? "file" : "files"}${props.sizeBytes > 0 ? ` · ${formatAttachmentSize(props.sizeBytes)}` : ""}`
502 : props.subtitle
503 }
545 - tintColor={props.tintColor}
504 onSave={props.onSave}
505 onRemove={props.onRemove}
506 />
@@ -753,73 +711,49 @@ function ZipEntryView(props: {
711 });
712 const folders = entry.path.split("/").slice(0, -1);
713 const subtitle = `${[props.archiveName, ...folders].join(" / ")} · ${formatAttachmentSize(entry.sizeBytes)}`;
756 - const isAndroid = Platform.OS === "android";
714 return (
715 <View className="flex-1 bg-sheet">
759 - <NativeStackScreenOptions
760 - options={{
761 - headerShown: !isAndroid,
762 - headerTitle: entry.name,
763 - title: entry.name,
764 - unstable_headerSubtitle: isAndroid ? undefined : subtitle,
765 - }}
716 + <AppBar
717 + title={entry.name}
718 + subtitle={subtitle}
719 + onBack={props.onBack}
720 + menus={[
721 + {
722 + title: "File actions",
723 + icon: "ellipsis",
724 + items: [
725 + ...(renderedMode
726 + ? [
727 + {
728 + id: "toggle-rendered",
729 + title: rendered ? "Show source" : "Show preview",
730 + icon: rendered ? "doc.text" : "eye",
731 + onPress: () => setRendered((value) => !value),
732 + },
733 + ]
734 + : []),
735 + ...(canAddToChat
736 + ? [
737 + {
738 + id: "add-to-chat",
739 + title: "Add to chat",
740 + icon: "plus.bubble",
741 + disabled: busy !== null,
742 + onPress: addToChat,
743 + },
744 + ]
745 + : []),
746 + {
747 + id: "save",
748 + title: "Save file",
749 + icon: "square.and.arrow.up",
750 + disabled: busy !== null,
751 + onPress: save,
752 + },
753 + ],
754 + },
755 + ]}
756 />
767 - {isAndroid ? (
768 - <AppBar
769 - embedded
770 - title={entry.name}
771 - subtitle={subtitle}
772 - onBack={props.onBack}
773 - actions={[
774 - ...(renderedMode
775 - ? [
776 - {
777 - accessibilityLabel: rendered ? "Show source" : "Show preview",
778 - icon: rendered ? ("doc.text" as const) : ("eye" as const),
779 - onPress: () => setRendered((value) => !value),
780 - },
781 - ]
782 - : []),
783 - ...(canAddToChat
784 - ? [
785 - {
786 - accessibilityLabel: "Add to chat",
787 - icon: "plus.bubble" as const,
788 - onPress: addToChat,
789 - disabled: busy !== null,
790 - },
791 - ]
792 - : []),
793 - {
794 - accessibilityLabel: "Save file",
795 - icon: "square.and.arrow.up",
796 - onPress: save,
797 - loading: busy === "save",
798 - },
799 - ]}
800 - />
801 - ) : (
802 - <Toolbar placement="right">
803 - <Toolbar.Menu accessibilityLabel="File actions" icon="ellipsis">
804 - {renderedMode ? (
805 - <Toolbar.MenuAction
806 - icon={rendered ? "doc.text" : "eye"}
807 - onPress={() => setRendered((value) => !value)}
808 - >
809 - {rendered ? "Show source" : "Show preview"}
810 - </Toolbar.MenuAction>
811 - ) : null}
812 - {canAddToChat ? (
813 - <Toolbar.MenuAction icon="plus.bubble" disabled={busy !== null} onPress={addToChat}>
814 - Add to chat
815 - </Toolbar.MenuAction>
816 - ) : null}
817 - <Toolbar.MenuAction icon="square.and.arrow.up" disabled={busy !== null} onPress={save}>
818 - Save file
819 - </Toolbar.MenuAction>
820 - </Toolbar.Menu>
821 - </Toolbar>
822 - )}
757 {content.status === "failed" ? (
758 <ScrollView contentContainerClassName="flex-grow items-center justify-center px-6">
759 <EmptyState
apps/mobile/src/features/files/useFileTreeEntries.test.tsx
+1
@@ -141,6 +141,7 @@ vi.mock("react-native", () => ({
141 vi.mock("react-native-safe-area-context", () => ({ useSafeAreaInsets: () => ({ top: 0 }) }));
142 vi.mock("../../native/NativeScrollViewMarker", () => ({ NativeScrollView: Nothing }));
143 vi.mock("../../native/native-layout-metrics", () => ({ useNativeColumnLayoutMetrics: () => null }));
144 +vi.mock("../../components/ui/useBarInset", () => ({ useContentTopInset: () => 0 }));
145 vi.mock("@legendapp/list/react-native", () => ({
146 LegendList: <T,>(props: {
147 data: ReadonlyArray<T>;
apps/mobile/src/features/home/HomeHeader.android.tsx
+8 -12
@@ -1,5 +1,4 @@
1 import type { MenuAction } from "@react-native-menu/menu";
2 -import { NativeStackScreenOptions } from "../../native/StackHeader";
2 import { ThreadListToolbar } from "./ThreadListToolbar";
3 import type { HomeHeaderProps } from "./HomeHeader.types";
4
@@ -83,16 +82,13 @@ export function HomeHeader(props: HomeHeaderProps) {
82 };
83
84 return (
86 - <>
87 - <NativeStackScreenOptions options={{ headerShown: false }} />
88 - <ThreadListToolbar
89 - searchQuery={props.searchQuery}
90 - onSearchQueryChange={props.onSearchQueryChange}
91 - filterActions={menuActions}
92 - filterCustomized={hasCustomListOptions}
93 - onFilterSelect={(event) => handleMenuAction({ nativeEvent: { event } })}
94 - onOpenEnvironments={props.onOpenEnvironments}
95 - />
96 - </>
85 + <ThreadListToolbar
86 + searchQuery={props.searchQuery}
87 + onSearchQueryChange={props.onSearchQueryChange}
88 + filterActions={menuActions}
89 + filterCustomized={hasCustomListOptions}
90 + onFilterSelect={(event) => handleMenuAction({ nativeEvent: { event } })}
91 + onOpenEnvironments={props.onOpenEnvironments}
92 + />
93 );
94 }
apps/mobile/src/features/home/HomeRouteScreen.tsx
+22 -31
@@ -163,29 +163,23 @@ export function HomeRouteScreen() {
163 return (
164 <>
165 <NativeStackScreenOptions
166 - options={
167 - Platform.OS === "android"
168 - ? { headerShown: false }
169 - : {
170 - title: "",
171 - headerTitle: "",
172 - unstable_headerLeftItems: () => [],
173 - headerSearchBarOptions: undefined,
174 - unstable_headerRightItems: () => [],
175 - unstable_headerToolbarItems: () => [],
176 - }
177 - }
166 + options={{
167 + title: "",
168 + headerTitle: "",
169 + unstable_headerLeftItems: () => [],
170 + headerSearchBarOptions: undefined,
171 + unstable_headerRightItems: () => [],
172 + unstable_headerToolbarItems: () => [],
173 + }}
174 />
179 - {Platform.OS === "ios" ? (
180 - <Toolbar placement="left">
181 - <Toolbar.Button
182 - accessibilityLabel="New task"
183 - icon="square.and.pencil"
184 - onPress={startNewTask}
185 - />
186 - </Toolbar>
187 - ) : null}
188 - {Platform.OS === "android" ? <AppBar embedded title="Threads" /> : null}
175 + <Toolbar placement="left">
176 + <Toolbar.Button
177 + accessibilityLabel="New task"
178 + icon="square.and.pencil"
179 + onPress={startNewTask}
180 + />
181 + </Toolbar>
182 + <AppBar embedded title="Threads" />
183 <WorkspaceEmptyDetail
184 onAddConnection={
185 Platform.OS === "android" && !catalogState.hasConnections
@@ -207,17 +201,14 @@ export function HomeRouteScreen() {
201 >
202 <>
203 {/* Screen options merge shallowly; restore the header after split view. */}
210 - {workspace !== null && Platform.OS === "ios" ? null : (
204 + {workspace !== null ? null : (
205 <NativeStackScreenOptions
206 optionsVersion={headerWidth}
213 - options={{
214 - ...getConnectionAwareBrandHeaderOptions({
215 - headerWidth,
216 - trailingItemCount: nativePrimaryColumn && deviceType === "pad" ? 2 : 1,
217 - onOpenEnvironments: () => openSettings(navigation, "SettingsEnvironments"),
218 - }),
219 - headerShown: Platform.OS !== "android",
220 - }}
207 + options={getConnectionAwareBrandHeaderOptions({
208 + headerWidth,
209 + trailingItemCount: nativePrimaryColumn && deviceType === "pad" ? 2 : 1,
210 + onOpenEnvironments: () => openSettings(navigation, "SettingsEnvironments"),
211 + })}
212 />
213 )}
214 <HomeHeader
apps/mobile/src/features/home/HomeScreen.tsx
+2 -2
@@ -797,7 +797,7 @@ export function HomeScreen(props: HomeScreenProps) {
797 onTouchStart={(event) => trackListTouches(event, true)}
798 onTouchEnd={(event) => trackListTouches(event, false)}
799 onTouchCancel={(event) => trackListTouches(event, false)}
800 - renderScrollComponent={Platform.OS === "ios" ? renderHomeScrollView : undefined}
800 + renderScrollComponent={renderHomeScrollView}
801 data={threadListV2Items}
802 renderItem={renderV2Item}
803 keyExtractor={v2KeyExtractor}
@@ -826,7 +826,7 @@ export function HomeScreen(props: HomeScreenProps) {
826 }
827 ListEmptyComponent={v2ListEmpty}
828 style={{ flex: 1 }}
829 - automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
829 + automaticallyAdjustsScrollIndicatorInsets
830 // UIKit owns the bar's inset, so a minimizing bar and a resized column move
831 // the list in the same frame as the bar.
832 contentInsetAdjustmentBehavior="automatic"
apps/mobile/src/features/layout/useOpenWorkspaceDetail.ts new
+23
@@ -0,0 +1,23 @@
1 +import { StackActions, useNavigation } from "@react-navigation/native";
2 +import { Platform } from "react-native";
3 +
4 +import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";
5 +import type {
6 + WorkspaceDetail,
7 + WorkspaceDetailSheet,
8 +} from "../workspace/workspace-detail-selection";
9 +
10 +/**
11 + * Opens a thread or pull request from another page. Android shows one detail page at a time, so
12 + * it selects the detail; iOS pushes it over the current page, so Back returns there. A `sheet`
13 + * opens over the detail on Android and on its own over the current page on iOS.
14 + */
15 +export function useOpenWorkspaceDetail() {
16 + const navigation = useNavigation();
17 + const selectDetail = useSelectWorkspaceDetail();
18 + return (detail: WorkspaceDetail, sheet?: WorkspaceDetailSheet) => {
19 + if (Platform.OS === "android") selectDetail(detail, sheet);
20 + else if (sheet) navigation.navigate(sheet.name, sheet.params);
21 + else navigation.dispatch(StackActions.push(detail.name, detail.params));
22 + };
23 +}
apps/mobile/src/features/projects/AddProjectRepositoryRoute.tsx
+1 -15
@@ -1,9 +1,4 @@
1 import type { StaticScreenProps } from "@react-navigation/native";
2 -import { NativeStackScreenOptions } from "../../native/StackHeader";
3 -import {
4 - addProjectRemoteSourceLabel,
5 - parseAddProjectRemoteSource,
6 -} from "@t3tools/client-runtime/operations/projects";
2
3 import { AddProjectRepositoryScreen } from "./AddProjectScreen";
4
@@ -15,14 +10,5 @@ type AddProjectRepositoryRouteParams = {
10 export function AddProjectRepositoryRoute({
11 route,
12 }: StaticScreenProps<AddProjectRepositoryRouteParams>) {
18 - const params = route.params ?? {};
19 - const source = Array.isArray(params.source) ? params.source[0] : params.source;
20 - const title = addProjectRemoteSourceLabel(parseAddProjectRemoteSource(source));
21 -
22 - return (
23 - <>
24 - <NativeStackScreenOptions options={{ title }} />
25 - <AddProjectRepositoryScreen {...params} />
26 - </>
27 - );
13 + return <AddProjectRepositoryScreen {...(route.params ?? {})} />;
14 }
apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
+17 -34
@@ -1,4 +1,3 @@
1 -import { Toolbar } from "../../components/ui/Toolbar";
1 import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
2 import { useAtomRefresh } from "@effect/atom-react";
3 import { useFocusEffect, useNavigation, type StaticScreenProps } from "@react-navigation/native";
@@ -9,7 +8,7 @@ import {
8 import { AsyncResult } from "effect/reactivity";
9 import type { PullRequestThreadComment } from "@t3tools/contracts";
10 import { useRef, useState } from "react";
12 -import { Platform, ScrollView, View } from "react-native";
11 +import { ScrollView, View } from "react-native";
12 import { KeyboardAvoidingView, useKeyboardState } from "react-native-keyboard-controller";
13 import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
14 import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -17,7 +16,6 @@ import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/
16 import { AppBar } from "../../components/ui/AppBar";
17 import { Button } from "../../components/ui/Button";
18 import { GlassSurface } from "../../components/ui/GlassSurface";
20 -import { NativeStackScreenOptions } from "../../native/StackHeader";
19 import { relativeTime } from "../../lib/time";
20 import { composerPullRequests } from "../../state/pull-requests";
21 import { useAtomCommand } from "../../state/use-atom-command";
@@ -136,38 +134,23 @@ function Discussion({ params }: { params: PullRequestParams & { readonly discuss
134 return (
135 <PullRequestMarkdownRepository params={params} changeRequest={detail.data}>
136 <KeyboardAvoidingView automaticOffset behavior="height" className="flex-1 bg-screen">
139 - <NativeStackScreenOptions
140 - options={{ title: "Discussion", unstable_headerSubtitle: `#${params.number}` }}
137 + <AppBar
138 + title="Discussion"
139 + subtitle={`#${params.number}`}
140 + onBack={() => navigation.goBack()}
141 + actions={
142 + permissions.canResolve && thread
143 + ? [
144 + {
145 + accessibilityLabel: resolveLabel,
146 + icon: thread.isResolved ? "arrow.uturn.backward" : "checkmark",
147 + disabled: busy || activity.isPending,
148 + onPress: () => void toggleResolved(),
149 + },
150 + ]
151 + : []
152 + }
153 />
142 - {Platform.OS === "android" ? (
143 - <AppBar
144 - embedded
145 - title="Discussion"
146 - subtitle={`#${params.number}`}
147 - onBack={() => navigation.goBack()}
148 - actions={
149 - permissions.canResolve && thread
150 - ? [
151 - {
152 - accessibilityLabel: resolveLabel,
153 - icon: thread.isResolved ? "arrow.uturn.backward" : "checkmark",
154 - disabled: busy || activity.isPending,
155 - onPress: () => void toggleResolved(),
156 - },
157 - ]
158 - : []
159 - }
160 - />
161 - ) : null}
162 - {permissions.canResolve && thread ? (
163 - <Toolbar placement="right">
164 - <Toolbar.Button
165 - label={resolveLabel}
166 - disabled={busy || activity.isPending}
167 - onPress={() => void toggleResolved()}
168 - />
169 - </Toolbar>
170 - ) : null}
154 <ScrollViewMarker style={{ flex: 1 }}>
155 <ScrollView
156 className="flex-1"
apps/mobile/src/features/pull-requests/PullRequestFiles.tsx
+17 -21
@@ -4,7 +4,7 @@ import { AnimatedLegendList } from "@legendapp/list/reanimated";
4 import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
5 import type { PullRequestChangeBreakdown } from "@t3tools/contracts";
6 import { useState } from "react";
7 -import { Platform, View } from "react-native";
7 +import { View } from "react-native";
8 import Animated from "react-native-reanimated";
9 import { PierreEntryIcon } from "../../components/PierreEntryIcon";
10 import { AppText as Text } from "../../components/ui/AppText";
@@ -16,7 +16,6 @@ import { Menu } from "../../components/ui/Menu";
16 import { RowPressable } from "../../components/ui/RowPressable";
17 import { ScreenContent } from "../../components/ui/ScreenContent";
18 import { SheetHeader } from "../../components/ui/SheetHeader";
19 -import { Toolbar } from "../../components/ui/Toolbar";
19 import { composerPullRequests } from "../../state/pull-requests";
20 import { useEnvironmentQuery } from "../../state/query";
21 import type { ReviewParsedDiff, ReviewRenderableFile } from "../review/reviewModel";
@@ -413,31 +412,28 @@ export function PullRequestFilesSheet({ route }: StaticScreenProps<PullRequestDi
412 return (
413 <View collapsable={false} className="flex-1 bg-sheet">
414 <SheetHeader
416 - presentation={Platform.OS === "android" ? "inline" : "native"}
415 title="Changed files"
416 subtitle={`#${params.number} · ${params.commit?.slice(0, 7) ?? params.repository}`}
417 onClose={() => navigation.goBack()}
420 - // iOS gets the native menu below; SheetHeader would render this as a custom bar item.
421 - trailing={Platform.OS === "android" ? <FileFilterMenu filter={filter} /> : undefined}
418 + menus={[
419 + {
420 + title: "Filter review files",
421 + icon: "line.3.horizontal.decrease",
422 + items: [
423 + {
424 + id: "hide-tests",
425 + title: "Hide test files",
426 + icon: "line.3.horizontal.decrease",
427 + selected: filter.hideTestFiles,
428 + onPress: filter.toggle,
429 + },
430 + ],
431 + },
432 + ]}
433 />
423 - <Toolbar placement="right">
424 - <Toolbar.Menu
425 - title="Review files"
426 - accessibilityLabel="Filter review files"
427 - icon="line.3.horizontal.decrease"
428 - >
429 - <Toolbar.MenuAction
430 - icon="line.3.horizontal.decrease"
431 - isOn={filter.hideTestFiles}
432 - onPress={filter.toggle}
433 - >
434 - <Toolbar.Label>Hide test files</Toolbar.Label>
435 - </Toolbar.MenuAction>
436 - </Toolbar.Menu>
437 - </Toolbar>
434 <ScreenContent>
435 <AnimatedLegendList
440 - renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
436 + renderScrollComponent={NativeScrollView}
437 className="flex-1"
438 data={parsed.kind === "files" ? groupByDirectory(parsed.files, collapsed) : []}
439 keyExtractor={(item) => item.key}
apps/mobile/src/features/pull-requests/PullRequestFilterSearchScreen.tsx
-1
@@ -117,7 +117,6 @@ export function PullRequestFilterSearchScreen({
117 placeholder={placeholder}
118 closeAccessibilityLabel={kind === "labels" ? "Close label filter" : "Close author filter"}
119 clearAccessibilityLabel={kind === "labels" ? "Clear label search" : "Clear author search"}
120 - searchTextChangeId="pr-filter-option-search"
120 query={query}
121 onQueryChange={setQuery}
122 >
apps/mobile/src/features/pull-requests/PullRequestLabelsScreen.tsx
-1
@@ -75,7 +75,6 @@ export function PullRequestLabelsScreen({ route }: StaticScreenProps<PullRequest
75 placeholder="Search labels"
76 closeAccessibilityLabel="Close labels"
77 clearAccessibilityLabel="Clear label search"
78 - searchTextChangeId="pr-label-search"
78 query={query}
79 onQueryChange={setQuery}
80 >
apps/mobile/src/features/pull-requests/PullRequestReviewersScreen.tsx
+22 -76
@@ -1,4 +1,4 @@
1 -import { SheetHeader } from "../../components/ui/SheetHeader";
1 +import { AppBar, type AppBarSearch } from "../../components/ui/AppBar";
2 import { AsyncResult } from "effect/reactivity";
3 import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
4 import { usePullRequestConnected } from "./usePullRequestConnected";
@@ -8,48 +8,23 @@ import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime"
8 import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
9 import type { PullRequestReviewerCandidate } from "@t3tools/contracts";
10 import { useRef, useState } from "react";
11 -import {
12 - FlatList,
13 - Platform,
14 - Pressable,
15 - ScrollView,
16 - View,
17 - type ScrollViewProps,
18 -} from "react-native";
19 -import { useSafeAreaInsets } from "react-native-safe-area-context";
20 -import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
11 +import { FlatList, Pressable, ScrollView, View } from "react-native";
12 +import { NativeScrollView } from "../../native/NativeScrollViewMarker";
13 +import { useContentTopInset, useSearchToolbarInset } from "../../components/ui/useBarInset";
14 import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText";
15 import { EmptyState } from "../../components/ui/EmptyState";
16 import { Button } from "../../components/ui/Button";
17 import { SymbolView } from "../../components/ui/AppSymbol";
25 -import { NativeStackScreenOptions } from "../../native/StackHeader";
26 -import { useNativeLayoutMetrics } from "../../native/native-layout-metrics";
18 import { composerPullRequests } from "../../state/pull-requests";
19 import { useEnvironmentQuery } from "../../state/query";
20 import { useAtomCommand } from "../../state/use-atom-command";
30 -import {
31 - createNativeMailSearchToolbarItem,
32 - NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED,
33 -} from "../layout/native-mail-search-toolbar";
21 import { PullRequestAvatar } from "./PullRequestPresentation";
22 import { pullRequestTarget, type PullRequestParams } from "./usePullRequestDiff";
23
37 -function ReviewerScrollView(props: ScrollViewProps) {
38 - return (
39 - <ScrollViewMarker style={{ flex: 1 }}>
40 - <ScrollView {...props} contentInsetAdjustmentBehavior="automatic" />
41 - </ScrollViewMarker>
42 - );
43 -}
44 -
24 export function PullRequestReviewersScreen({ route }: StaticScreenProps<PullRequestParams>) {
25 const navigation = useNavigation();
47 - const insets = useSafeAreaInsets();
26 + const contentTopInset = useContentTopInset();
27 const listRef = useRef<FlatList<PullRequestReviewerCandidate>>(null);
49 - const nativeMetrics = useNativeLayoutMetrics();
50 - const integratedSearch =
51 - NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED &&
52 - (!nativeMetrics || nativeMetrics.verticalBarEdge === "none");
28 const target = pullRequestTarget(route.params);
29 const detail = useEnvironmentQuery(composerPullRequests.detail(target));
30 const pr = detail.data;
@@ -90,7 +65,7 @@ export function PullRequestReviewersScreen({ route }: StaticScreenProps<PullRequ
65 const search = (next: string) => {
66 setQuery(next);
67 listRef.current?.scrollToOffset({
93 - offset: Platform.OS === "ios" ? -insets.top : 0,
68 + offset: -contentTopInset,
69 animated: false,
70 });
71 };
@@ -124,70 +99,41 @@ export function PullRequestReviewersScreen({ route }: StaticScreenProps<PullRequ
99 }
100 };
101 const listCandidates = pr?.capabilities.reviewers.listCandidates === true;
127 - const searchOptions = {
128 - placeholder: "Search reviewers",
129 - autoCapitalize: "none" as const,
130 - onChangeText: (event: { nativeEvent: { text: string } }) => search(event.nativeEvent.text),
131 - onCancelButtonPress: () => search(""),
132 - hideNavigationBar: false,
133 - hideWhenScrolling: false,
134 - obscureBackground: false,
135 - allowToolbarIntegration: integratedSearch,
136 - placement: integratedSearch ? ("automatic" as const) : ("stacked" as const),
137 - };
102 + const reviewerSearch: AppBarSearch | undefined = listCandidates
103 + ? {
104 + mode: "inline",
105 + compactToolbar: true,
106 + value: query,
107 + onChangeText: search,
108 + placeholder: "Search reviewers",
109 + }
110 + : undefined;
111 + const searchToolbarInset = useSearchToolbarInset(reviewerSearch);
112 return (
113 <View className="flex-1 bg-sheet">
140 - <SheetHeader
114 + <AppBar
115 title="Request review"
116 subtitle={`#${route.params.number} · ${route.params.repository}`}
117 onClose={() => navigation.goBack()}
144 - accessibilityLabel="Close request review"
145 - />
146 - <NativeStackScreenOptions
147 - options={{
148 - headerSearchBarOptions: listCandidates ? searchOptions : undefined,
149 - unstable_headerToolbarItems: () =>
150 - listCandidates && integratedSearch
151 - ? [
152 - createNativeMailSearchToolbarItem({
153 - placeholder: "Search reviewers",
154 - onSearchTextChange: search,
155 - showsSearchDismissButton: true,
156 - searchTextChangeId: "pr-reviewer-search",
157 - }),
158 - ]
159 - : [],
160 - }}
118 + closeAccessibilityLabel="Close request review"
119 + search={reviewerSearch}
120 />
121 {listCandidates ? (
122 <FlatList
123 ref={listRef}
124 data={candidates}
125 keyExtractor={(candidate) => `${candidate.kind}:${candidate.id}`}
167 - renderScrollComponent={
168 - Platform.OS === "ios" ? (props) => <ReviewerScrollView {...props} /> : undefined
169 - }
170 - contentInsetAdjustmentBehavior="never"
126 + renderScrollComponent={NativeScrollView}
127 + contentInsetAdjustmentBehavior="automatic"
128 automaticallyAdjustKeyboardInsets
129 keyboardDismissMode="on-drag"
130 keyboardShouldPersistTaps="handled"
174 - contentContainerStyle={{ paddingBottom: 24 }}
131 + contentContainerStyle={{ paddingBottom: 24 + searchToolbarInset }}
132 ListHeaderComponent={
133 <View className="gap-3 px-4 py-4">
134 <Text className="text-xs text-foreground-muted">
135 Tap someone to request a review. Tap a requested reviewer to remove the request.
136 </Text>
180 - {Platform.OS === "android" ? (
181 - <TextInput
182 - accessibilityLabel="Search reviewers"
183 - placeholder="Search reviewers"
184 - placeholderTextColorClassName="accent-foreground-muted"
185 - value={query}
186 - onChangeText={search}
187 - autoCapitalize="none"
188 - className="min-h-11 rounded-xl bg-grouped-card px-3 text-sm"
189 - />
190 - ) : null}
137 {!allowed ? (
138 <Text className="text-xs text-foreground-muted">
139 Requesting reviews requires write access and an open {singular}.
apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
+217 -392
@@ -1,4 +1,3 @@
1 -import { Toolbar } from "../../components/ui/Toolbar";
1 import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
2 import { Chip } from "../../components/ui/Chip";
3 import { pullRequestTabOffset } from "./pullRequestTabScroll";
@@ -27,8 +26,6 @@ import {
26 pullRequestActionLabel,
27 } from "./pullRequestActions";
28 import * as Clipboard from "expo-clipboard";
30 -import { Menu } from "../../components/ui/Menu";
31 -import { IconButton } from "../../components/ui/IconButton";
29 import { Button } from "../../components/ui/Button";
30 import { usePullRequestReviewDraft } from "./usePullRequestReviewDraft";
31 import { usePullRequestFilesViewed } from "./usePullRequestFilesViewed";
@@ -56,31 +53,21 @@ import { PullRequestOverviewLoading } from "./PullRequestOverviewLoading";
53 import { copyPullRequestLink, sharePullRequestLink } from "./pullRequestLink";
54 import { pullRequestStatus } from "./pullRequestStatus";
55 import { use, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
59 -import {
60 - Linking,
61 - Platform,
62 - Pressable,
63 - RefreshControl,
64 - ScrollView,
65 - type ScrollViewProps,
66 - StyleSheet,
67 - View,
68 -} from "react-native";
69 -import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
56 +import { Linking, Platform, Pressable, RefreshControl, StyleSheet, View } from "react-native";
57 +import { NativeScrollView } from "../../native/NativeScrollViewMarker";
58 import { useSafeAreaInsets } from "react-native-safe-area-context";
59
60 import { AppText as Text } from "../../components/ui/AppText";
61 import { AppBar } from "../../components/ui/AppBar";
62 +import { useContentTopInset } from "../../components/ui/useBarInset";
63 import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
64 import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
76 -import { useWorkspaceSidebarHeaderItem } from "../layout/useWorkspaceSidebarHeaderItem";
65 import { useAndroidWorkspaceBack } from "../workspace/useAndroidWorkspaceNavigation";
66 import { EmptyState } from "../../components/ui/EmptyState";
67 import { SegmentedControl } from "../../components/ui/SegmentedControl";
68 import { SymbolView } from "../../components/ui/AppSymbol";
69 import { ScreenContent } from "../../components/ui/ScreenContent";
70 import { RelativeTime } from "../../components/RelativeTime";
83 -import { NativeStackScreenOptions } from "../../native/StackHeader";
71 import { usePullRequestConnected } from "./usePullRequestConnected";
72 import { usePullRequestLiveChecks } from "./usePullRequestLiveChecks";
73 import { pullRequestLabelColor } from "./pullRequestList";
@@ -138,14 +125,6 @@ import {
125
126 const EMPTY_IDS: readonly string[] = [];
127
141 -function PullRequestTabScrollView(props: ScrollViewProps) {
142 - return (
143 - <ScrollViewMarker style={{ flex: 1 }}>
144 - <ScrollView {...props} />
145 - </ScrollViewMarker>
146 - );
147 -}
148 -
128 function usePullRequestActivityRows(params: PullRequestParams, filter: ActivityFilter) {
129 const navigation = useNavigation();
130 const result = useEnvironmentQuery(composerPullRequests.activity(requestTarget(params)));
@@ -346,12 +325,12 @@ function usePullRequestToolbarHeight(bottomInset: number) {
325 export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestParams>) {
326 const returnToList = useAndroidWorkspaceBack("pullRequests");
327 const { layout } = useAdaptiveWorkspaceLayout();
349 - const sidebarHeaderItem = useWorkspaceSidebarHeaderItem();
328 const navigation = useNavigation();
329 const insets = useSafeAreaInsets();
330 const [toolbarHeight, setToolbarHeight] = usePullRequestToolbarHeight(insets.bottom);
353 - // Only iOS lists run under the bars; Android lists start below the header.
354 - const barInsets = Platform.OS === "ios" ? insets : { top: 0, bottom: 0 };
331 + const contentTopInset = useContentTopInset();
332 + // Only iOS lists run under the bottom safe area; Android's floating toolbar pads its own.
333 + const contentBottomInset = Platform.OS === "ios" ? insets.bottom : 0;
334 const params = route.params;
335 usePullRequestEnvironmentFallback(params);
336 const connected = usePullRequestConnected(params.environmentId);
@@ -373,7 +352,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
352 // has its own offset, which only its next scroll would record here.
353 const currentScrollOffset = useRef<{ tab: typeof section; offset: number }>({
354 tab: "overview",
376 - offset: -barInsets.top,
355 + offset: -contentTopInset,
356 });
357 const bodyY = useRef(0);
358 const [headerHeight, setHeaderHeight] = useState(0);
@@ -397,9 +376,9 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
376 const current =
377 currentScrollOffset.current.tab === from
378 ? currentScrollOffset.current.offset
400 - : (scrollOffsets.current[from] ?? -barInsets.top);
379 + : (scrollOffsets.current[from] ?? -contentTopInset);
380 scrollOffsets.current[section] = current;
402 - const headerEnd = Math.max(-barInsets.top, bodyY.current - barInsets.top);
381 + const headerEnd = Math.max(-contentTopInset, bodyY.current - contentTopInset);
382 const offset = pullRequestTabOffset(current, scrollOffsets.current[next], headerEnd);
383 requestedSection.current = next;
384 scrollOffsets.current[next] = offset;
@@ -466,7 +445,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
445 });
446 const jumpToFiles = () => {
447 scrollViews.current.overview?.scrollToOffset({
469 - offset: bodyY.current + filesY.current - barInsets.top,
448 + offset: bodyY.current + filesY.current - contentTopInset,
449 animated: true,
450 });
451 pendingFilesJump.current = false;
@@ -481,237 +460,126 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
460 };
461 return (
462 <PullRequestMarkdownRepository params={params} changeRequest={pr}>
484 - <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
485 - <NativeStackScreenOptions
486 - options={{
487 - title: `#${params.number}`,
488 - headerTitle: `#${params.number}`,
489 - unstable_headerSubtitle: connected
490 - ? params.repository
491 - : `${params.repository} · Offline`,
492 - unstable_headerLeftItems: sidebarHeaderItem ? () => [sidebarHeaderItem] : undefined,
493 - }}
494 - optionsVersion={[sidebarHeaderItem]}
463 + <View className="flex-1 android:bg-header ios:bg-screen">
464 + <AppBar
465 + title={`#${params.number}`}
466 + subtitle={connected ? params.repository : `${params.repository} · Offline`}
467 + onBack={layout.usesSplitView ? undefined : returnToList}
468 + menus={[
469 + {
470 + title: `${capitalizeTerm(terminology.singular)} actions`,
471 + icon: "ellipsis",
472 + items: [
473 + ...(permissions.verdicts.length
474 + ? [
475 + {
476 + id: "submit-review",
477 + title: "Submit review",
478 + icon: "text.bubble",
479 + onPress: () =>
480 + navigation.navigate("PullRequestReview", { ...params, mode: "review" }),
481 + },
482 + ]
483 + : []),
484 + ...(permissions.canComment
485 + ? [
486 + {
487 + id: "add-comment",
488 + title: "Add comment",
489 + icon: "plus.bubble",
490 + onPress: () =>
491 + navigation.navigate("PullRequestReview", { ...params, mode: "comment" }),
492 + },
493 + ]
494 + : []),
495 + ...(permissions.canEditChangeRequest
496 + ? [
497 + {
498 + id: "edit-title",
499 + title: "Edit title",
500 + icon: "pencil",
501 + onPress: () =>
502 + navigation.navigate("PullRequestEdit", { ...params, field: "title" }),
503 + },
504 + {
505 + id: "edit-description",
506 + title: "Edit description",
507 + icon: "doc.text",
508 + disabled: description.pending,
509 + subtitle: description.pending ? "Saving…" : undefined,
510 + onPress: () =>
511 + navigation.navigate("PullRequestEdit", { ...params, field: "body" }),
512 + },
513 + ]
514 + : []),
515 + ...(maintainerEdits.visible
516 + ? [
517 + {
518 + id: "maintainer-edits",
519 + title: "Allow edits from maintainers",
520 + icon: "pencil",
521 + selected: maintainerEdits.value,
522 + disabled: maintainerEdits.saving,
523 + subtitle: maintainerEdits.subtitle,
524 + onPress: maintainerEdits.toggle,
525 + },
526 + ]
527 + : []),
528 + ...(identity
529 + ? [
530 + {
531 + id: "open-on-provider",
532 + title: openOnProviderLabel(identity.provider),
533 + icon: "arrow.up.right",
534 + onPress: () => void Linking.openURL(identity.url),
535 + },
536 + {
537 + id: "copy-link",
538 + title: "Copy link",
539 + icon: "link",
540 + onPress: () => copyPullRequestLink(identity),
541 + },
542 + {
543 + id: "share",
544 + title: "Share…",
545 + icon: "square.and.arrow.up",
546 + onPress: () => sharePullRequestLink(identity),
547 + },
548 + ]
549 + : []),
550 + ...(stateAction
551 + ? [
552 + {
553 + id: "state",
554 + title: pullRequestActionLabel(stateAction, terminology),
555 + icon: PR_ACTION_ICONS[stateAction],
556 + destructive: stateAction === "close",
557 + onPress: runStateAction,
558 + },
559 + ]
560 + : []),
561 + ...(showsDeleteBranch
562 + ? [
563 + {
564 + id: "delete-branch",
565 + title: pullRequestActionLabel("delete-branch", terminology),
566 + icon: PR_ACTION_ICONS["delete-branch"],
567 + destructive: true,
568 + disabled: !action.available("delete-branch"),
569 + subtitle: action.busy
570 + ? "Deleting…"
571 + : connected
572 + ? pr.headBranch
573 + : "Reconnect to delete this branch.",
574 + onPress: confirmDeleteBranch,
575 + },
576 + ]
577 + : []),
578 + ],
579 + },
580 + ]}
581 />
496 - {Platform.OS === "android" ? (
497 - <AppBar
498 - embedded
499 - title={`#${params.number}${connected ? "" : " · Offline"}`}
500 - subtitle={params.repository}
501 - onBack={layout.usesSplitView ? undefined : returnToList}
502 - actions={[
503 - ...(permissions.verdicts.length
504 - ? [
505 - {
506 - accessibilityLabel: "Submit review",
507 - icon: "text.bubble" as const,
508 - onPress: () =>
509 - navigation.navigate("PullRequestReview", { ...params, mode: "review" }),
510 - },
511 - ]
512 - : []),
513 - ...(permissions.canComment
514 - ? [
515 - {
516 - accessibilityLabel: "Add comment",
517 - icon: "plus.bubble" as const,
518 - onPress: () =>
519 - navigation.navigate("PullRequestReview", { ...params, mode: "comment" }),
520 - },
521 - ]
522 - : []),
523 - ...(permissions.canEditChangeRequest
524 - ? [
525 - {
526 - accessibilityLabel: "Edit title",
527 - icon: "pencil" as const,
528 - overflowOnly: true,
529 - onPress: () =>
530 - navigation.navigate("PullRequestEdit", { ...params, field: "title" }),
531 - },
532 - {
533 - accessibilityLabel: "Edit description",
534 - icon: "doc.text" as const,
535 - disabled: description.pending,
536 - subtitle: description.pending ? "Saving…" : undefined,
537 - overflowOnly: true,
538 - onPress: () =>
539 - navigation.navigate("PullRequestEdit", { ...params, field: "body" }),
540 - },
541 - ]
542 - : []),
543 - ...(maintainerEdits.visible
544 - ? [
545 - {
546 - accessibilityLabel: "Allow edits from maintainers",
547 - icon: "pencil" as const,
548 - selected: maintainerEdits.value,
549 - disabled: maintainerEdits.saving,
550 - subtitle: maintainerEdits.subtitle,
551 - overflowOnly: true,
552 - onPress: maintainerEdits.toggle,
553 - },
554 - ]
555 - : []),
556 - ...(identity
557 - ? [
558 - {
559 - accessibilityLabel: openOnProviderLabel(identity.provider),
560 - icon: "arrow.up.right" as const,
561 - onPress: () => void Linking.openURL(identity.url),
562 - },
563 - {
564 - accessibilityLabel: "Copy link",
565 - icon: "link" as const,
566 - overflowOnly: true,
567 - onPress: () => copyPullRequestLink(identity),
568 - },
569 - {
570 - accessibilityLabel: "Share…",
571 - icon: "square.and.arrow.up" as const,
572 - overflowOnly: true,
573 - onPress: () => sharePullRequestLink(identity),
574 - },
575 - ]
576 - : []),
577 - ...(stateAction
578 - ? [
579 - {
580 - accessibilityLabel: pullRequestActionLabel(stateAction, terminology),
581 - icon: PR_ACTION_ICONS[stateAction],
582 - destructive: stateAction === "close",
583 - overflowOnly: true,
584 - onPress: runStateAction,
585 - },
586 - ]
587 - : []),
588 - ...(showsDeleteBranch
589 - ? [
590 - {
591 - accessibilityLabel: pullRequestActionLabel("delete-branch", terminology),
592 - icon: PR_ACTION_ICONS["delete-branch"],
593 - disabled: !action.available("delete-branch"),
594 - destructive: true,
595 - overflowOnly: true,
596 - onPress: confirmDeleteBranch,
597 - },
598 - ]
599 - : []),
600 - ]}
601 - />
602 - ) : null}
603 - <Toolbar placement="right">
604 - <Toolbar.Menu
605 - title={capitalizeTerm(terminology.singular)}
606 - accessibilityLabel={`${capitalizeTerm(terminology.singular)} actions`}
607 - icon="ellipsis"
608 - >
609 - {permissions.verdicts.length ? (
610 - <Toolbar.MenuAction
611 - icon="text.bubble"
612 - onPress={() =>
613 - navigation.navigate("PullRequestReview", { ...params, mode: "review" })
614 - }
615 - >
616 - <Toolbar.Label>Submit review</Toolbar.Label>
617 - </Toolbar.MenuAction>
618 - ) : null}
619 - {permissions.canComment ? (
620 - <Toolbar.MenuAction
621 - icon="plus.bubble"
622 - onPress={() =>
623 - navigation.navigate("PullRequestReview", { ...params, mode: "comment" })
624 - }
625 - >
626 - <Toolbar.Label>Add comment</Toolbar.Label>
627 - </Toolbar.MenuAction>
628 - ) : null}
629 - {permissions.canEditChangeRequest ? (
630 - <Toolbar.MenuAction
631 - icon="pencil"
632 - onPress={() =>
633 - navigation.navigate("PullRequestEdit", { ...params, field: "title" })
634 - }
635 - >
636 - <Toolbar.Label>Edit title</Toolbar.Label>
637 - </Toolbar.MenuAction>
638 - ) : null}
639 - {permissions.canEditChangeRequest ? (
640 - <Toolbar.MenuAction
641 - icon="doc.text"
642 - disabled={description.pending}
643 - subtitle={description.pending ? "Saving…" : undefined}
644 - onPress={() => navigation.navigate("PullRequestEdit", { ...params, field: "body" })}
645 - >
646 - <Toolbar.Label>Edit description</Toolbar.Label>
647 - </Toolbar.MenuAction>
648 - ) : null}
649 - {maintainerEdits.visible ? (
650 - <Toolbar.MenuAction
651 - icon="pencil"
652 - isOn={maintainerEdits.value}
653 - disabled={maintainerEdits.saving}
654 - subtitle={maintainerEdits.subtitle}
655 - onPress={maintainerEdits.toggle}
656 - >
657 - <Toolbar.Label>Allow edits from maintainers</Toolbar.Label>
658 - </Toolbar.MenuAction>
659 - ) : null}
660 - {identity ? (
661 - <Toolbar.MenuAction
662 - icon="arrow.up.right"
663 - onPress={() => void Linking.openURL(identity.url)}
664 - >
665 - <Toolbar.Label>{openOnProviderLabel(identity.provider)}</Toolbar.Label>
666 - </Toolbar.MenuAction>
667 - ) : null}
668 - {identity ? (
669 - <Toolbar.MenuAction icon="link" onPress={() => copyPullRequestLink(identity)}>
670 - <Toolbar.Label>Copy link</Toolbar.Label>
671 - </Toolbar.MenuAction>
672 - ) : null}
673 - {identity ? (
674 - <Toolbar.MenuAction
675 - icon="square.and.arrow.up"
676 - onPress={() => sharePullRequestLink(identity)}
677 - >
678 - <Toolbar.Label>Share…</Toolbar.Label>
679 - </Toolbar.MenuAction>
680 - ) : null}
681 - {stateAction ? (
682 - <Toolbar.MenuAction
683 - icon={PR_ACTION_ICONS[stateAction]}
684 - destructive={stateAction === "close"}
685 - onPress={runStateAction}
686 - >
687 - <Toolbar.Label>{pullRequestActionLabel(stateAction, terminology)}</Toolbar.Label>
688 - </Toolbar.MenuAction>
689 - ) : null}
690 - {showsDeleteBranch ? (
691 - <Toolbar.MenuAction
692 - icon={PR_ACTION_ICONS["delete-branch"]}
693 - destructive
694 - disabled={!action.available("delete-branch")}
695 - subtitle={
696 - action.busy
697 - ? "Deleting…"
698 - : connected
699 - ? pr.headBranch
700 - : "Reconnect to delete this branch."
701 - }
702 - onPress={confirmDeleteBranch}
703 - >
704 - <Toolbar.Label>
705 - {pullRequestActionLabel("delete-branch", terminology)}
706 - </Toolbar.Label>
707 - </Toolbar.MenuAction>
708 - ) : null}
709 - </Toolbar.Menu>
710 - </Toolbar>
711 - <ScreenContent
712 - insetHorizontal={layout.usesSplitView}
713 - onLayout={(event) => setViewportHeight(event.nativeEvent.layout.height)}
714 - >
582 + <ScreenContent onLayout={(event) => setViewportHeight(event.nativeEvent.layout.height)}>
583 {(["overview", "guide", "activity"] as const)
584 .filter((tab) => tab !== "guide" || guidesEnabled)
585 .map((tab) => (
@@ -734,13 +602,11 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
602 currentScrollOffset.current = { tab, offset };
603 }}
604 className="flex-1"
737 - renderScrollComponent={
738 - Platform.OS === "ios" ? PullRequestTabScrollView : undefined
739 - }
605 + renderScrollComponent={NativeScrollView}
606 // UIKit owns the bar's inset, so a minimizing bar and a resized column
607 // move the list in the same frame as the bar.
608 contentInsetAdjustmentBehavior="automatic"
743 - contentInsetStartAdjustment={barInsets.top}
609 + contentInsetStartAdjustment={contentTopInset}
610 // RN scrollTo clamps against raw insets and ignores the automatic bar inset.
611 scrollToOverflowEnabled
612 refreshControl={
@@ -761,7 +627,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
627 pendingDescriptionJump.current = false;
628 // Collapse changes the scroll range; restore the heading after that layout commits.
629 scrollViews.current.overview?.scrollToOffset({
764 - offset: bodyY.current + descriptionY.current - barInsets.top,
630 + offset: bodyY.current + descriptionY.current - contentTopInset,
631 animated: false,
632 });
633 }}
@@ -772,7 +638,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
638 // Short tabs must still be tall enough to preserve the collapsed header.
639 minHeight: Math.max(
640 0,
775 - viewportHeight + headerHeight - barInsets.top - barInsets.bottom,
641 + viewportHeight + headerHeight - contentTopInset - contentBottomInset,
642 ),
643 }}
644 data={[
@@ -960,10 +826,7 @@ export function PullRequestFileRouteScreen(props: PullRequestFileRouteProps) {
826 const title = props.route.params.commit ? "Commit changes" : "Changes";
827 return (
828 <View className="flex-1 bg-screen">
963 - <NativeStackScreenOptions options={{ title, headerTitle: title }} />
964 - {Platform.OS === "android" ? (
965 - <AppBar embedded title={title} onBack={() => navigation.goBack()} />
966 - ) : null}
829 + <AppBar title={title} onBack={() => navigation.goBack()} />
830 <View className="flex-1 items-center justify-center">
831 <AppActivityIndicator accessibilityLabel="Loading changes" />
832 </View>
@@ -972,9 +835,9 @@ export function PullRequestFileRouteScreen(props: PullRequestFileRouteProps) {
835 }
836
837 function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
975 - const { layout } = useAdaptiveWorkspaceLayout();
838 const navigation = useNavigation();
839 const insets = useSafeAreaInsets();
840 + const contentTopInset = useContentTopInset();
841 const [toolbarHeight, setToolbarHeight] = usePullRequestToolbarHeight(insets.bottom);
842 const commit = route.params.commit;
843 const detail = useEnvironmentQuery(composerPullRequests.detail(requestTarget(route.params)));
@@ -1150,122 +1013,84 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
1013 const seekingFile = !targetFile && result.nextCursor !== null;
1014 const loadingDiff = (result.isPending && !data.rows.length) || (seekingFile && !result.error);
1015 return (
1153 - <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
1154 - <NativeStackScreenOptions
1155 - options={{
1156 - title,
1157 - headerTitle: title,
1158 - 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` : ""}`,
1159 - }}
1016 + <View className="flex-1 android:bg-header ios:bg-screen">
1017 + <AppBar
1018 + title={title}
1019 + 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` : ""}`}
1020 + onBack={() => navigation.goBack()}
1021 + menus={[
1022 + {
1023 + title: "Diff options",
1024 + icon: "ellipsis",
1025 + items: [
1026 + ...(permissions.verdicts.length
1027 + ? [
1028 + {
1029 + id: "submit-review",
1030 + title: "Submit review",
1031 + icon: "text.bubble",
1032 + onPress: () =>
1033 + navigation.navigate("PullRequestReview", {
1034 + ...route.params,
1035 + mode: "review",
1036 + }),
1037 + },
1038 + ]
1039 + : []),
1040 + ...(permissions.canComment
1041 + ? [
1042 + {
1043 + id: "comment-on-pr",
1044 + title: "Add comment",
1045 + icon: "plus.bubble",
1046 + onPress: () =>
1047 + navigation.navigate("PullRequestReview", {
1048 + ...route.params,
1049 + mode: "comment",
1050 + }),
1051 + },
1052 + ]
1053 + : []),
1054 + {
1055 + id: "word-wrap",
1056 + title: "Word wrap",
1057 + icon: "text.alignleft",
1058 + selected: appearance.codeWordBreak,
1059 + onPress: () => setCodeWordBreak(!appearance.codeWordBreak),
1060 + },
1061 + {
1062 + id: "hide-tests",
1063 + title: "Hide test files",
1064 + icon: "line.3.horizontal.decrease",
1065 + selected: filter.hideTestFiles,
1066 + onPress: toggleTestFiles,
1067 + },
1068 + ...(selectedRow && selectedFile && canCommentOnDiff
1069 + ? [
1070 + {
1071 + id: "comment",
1072 + title: route.params.replacingDraftId
1073 + ? "Move draft to this line"
1074 + : "Add review comment",
1075 + icon: "bubble.left",
1076 + onPress: () => commentOnLine(),
1077 + },
1078 + ]
1079 + : []),
1080 + ...(selectedRow && selectedFile
1081 + ? [
1082 + {
1083 + id: "copy",
1084 + title: "Copy line",
1085 + icon: "document.on.document",
1086 + onPress: () => void Clipboard.setStringAsync(selectedRow.content ?? ""),
1087 + },
1088 + ]
1089 + : []),
1090 + ],
1091 + },
1092 + ]}
1093 />
1161 - {Platform.OS === "android" ? (
1162 - <AppBar
1163 - embedded
1164 - title={title}
1165 - onBack={() => navigation.goBack()}
1166 - trailing={
1167 - <Menu
1168 - actions={[
1169 - {
1170 - id: "word-wrap",
1171 - title: "Word wrap",
1172 - image: "text.alignleft",
1173 - state: appearance.codeWordBreak ? "on" : "off",
1174 - },
1175 - {
1176 - id: "hide-tests",
1177 - title: "Hide test files",
1178 - image: "line.3.horizontal.decrease",
1179 - state: filter.hideTestFiles ? "on" : "off",
1180 - },
1181 - ...(permissions.verdicts.length
1182 - ? [{ id: "submit-review", title: "Submit review", image: "text.bubble" }]
1183 - : []),
1184 - ...(permissions.canComment
1185 - ? [{ id: "comment-on-pr", title: "Add comment", image: "plus.bubble" }]
1186 - : []),
1187 - ...(selectedRow && selectedFile
1188 - ? [
1189 - ...(canCommentOnDiff ? [{ id: "comment", title: "Add review comment" }] : []),
1190 - { id: "copy", title: "Copy line" },
1191 - ]
1192 - : []),
1193 - ]}
1194 - onPressAction={({ nativeEvent }) => {
1195 - if (nativeEvent.event === "word-wrap") setCodeWordBreak(!appearance.codeWordBreak);
1196 - else if (nativeEvent.event === "hide-tests") toggleTestFiles();
1197 - else if (
1198 - nativeEvent.event === "submit-review" ||
1199 - nativeEvent.event === "comment-on-pr"
1200 - )
1201 - navigation.navigate("PullRequestReview", {
1202 - ...route.params,
1203 - mode: nativeEvent.event === "submit-review" ? "review" : "comment",
1204 - });
1205 - else if (nativeEvent.event === "comment") commentOnLine();
1206 - else void Clipboard.setStringAsync(selectedRow?.content ?? "");
1207 - }}
1208 - >
1209 - <View pointerEvents="none">
1210 - <IconButton icon="ellipsis" accessibilityLabel="Diff options" />
1211 - </View>
1212 - </Menu>
1213 - }
1214 - />
1215 - ) : null}
1216 - <Toolbar placement="right">
1217 - <Toolbar.Menu title="Diff options" accessibilityLabel="Diff options" icon="ellipsis">
1218 - {permissions.verdicts.length ? (
1219 - <Toolbar.MenuAction
1220 - icon="text.bubble"
1221 - onPress={() =>
1222 - navigation.navigate("PullRequestReview", { ...route.params, mode: "review" })
1223 - }
1224 - >
1225 - <Toolbar.Label>Submit review</Toolbar.Label>
1226 - </Toolbar.MenuAction>
1227 - ) : null}
1228 - {permissions.canComment ? (
1229 - <Toolbar.MenuAction
1230 - icon="plus.bubble"
1231 - onPress={() =>
1232 - navigation.navigate("PullRequestReview", { ...route.params, mode: "comment" })
1233 - }
1234 - >
1235 - <Toolbar.Label>Add comment</Toolbar.Label>
1236 - </Toolbar.MenuAction>
1237 - ) : null}
1238 - <Toolbar.MenuAction
1239 - icon="text.alignleft"
1240 - isOn={appearance.codeWordBreak}
1241 - onPress={() => setCodeWordBreak(!appearance.codeWordBreak)}
1242 - >
1243 - <Toolbar.Label>Word wrap</Toolbar.Label>
1244 - </Toolbar.MenuAction>
1245 - <Toolbar.MenuAction
1246 - icon="line.3.horizontal.decrease"
1247 - isOn={filter.hideTestFiles}
1248 - onPress={toggleTestFiles}
1249 - >
1250 - <Toolbar.Label>Hide test files</Toolbar.Label>
1251 - </Toolbar.MenuAction>
1252 - {selectedRow && selectedFile && canCommentOnDiff ? (
1253 - <Toolbar.MenuAction icon="bubble.left" onPress={() => commentOnLine()}>
1254 - <Toolbar.Label>
1255 - {route.params.replacingDraftId ? "Move draft to this line" : "Add review comment"}
1256 - </Toolbar.Label>
1257 - </Toolbar.MenuAction>
1258 - ) : null}
1259 - {selectedRow && selectedFile ? (
1260 - <Toolbar.MenuAction
1261 - icon="document.on.document"
1262 - onPress={() => void Clipboard.setStringAsync(selectedRow.content ?? "")}
1263 - >
1264 - <Toolbar.Label>Copy line</Toolbar.Label>
1265 - </Toolbar.MenuAction>
1266 - ) : null}
1267 - </Toolbar.Menu>
1268 - </Toolbar>
1094 {route.params.replacingDraftId ? (
1095 <Text className="px-4 py-2 text-xs text-foreground-muted">
1096 Select a current line, then choose “Move draft to this line” from its menu.
@@ -1277,7 +1102,7 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
1102 {staleDiff ? (
1103 <View
1104 className="flex-row items-center gap-2 px-4 py-2"
1280 - style={{ paddingTop: Platform.OS === "ios" ? insets.top + 8 : 8 }}
1105 + style={{ paddingTop: contentTopInset + 8 }}
1106 >
1107 <Text className="min-w-0 flex-1 text-xs text-foreground-muted">
1108 The branch changed. Reload before adding line comments.
@@ -1294,10 +1119,10 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
1119 />
1120 </View>
1121 ) : null}
1297 - <ScreenContent insetHorizontal={layout.usesSplitView}>
1122 + <ScreenContent>
1123 <View className="flex-1" collapsable={false}>
1124 {loadingDiff || result.error ? (
1300 - <View style={{ paddingTop: Platform.OS === "ios" && !staleDiff ? insets.top : 0 }}>
1125 + <View style={{ paddingTop: staleDiff ? 0 : contentTopInset }}>
1126 <PullRequestReadStatus
1127 pending={loadingDiff}
1128 error={result.error}
@@ -1373,7 +1198,7 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
1198 appearanceScheme={themeAppearance}
1199 rowHeight={nativeReviewDiffStyle.rowHeight}
1200 contentWidth={NATIVE_REVIEW_DIFF_CONTENT_WIDTH}
1376 - contentInsetTop={Platform.OS === "ios" ? (staleDiff ? 0 : insets.top) : undefined}
1201 + contentInsetTop={staleDiff ? 0 : contentTopInset}
1202 contentInsetBottom={Platform.OS === "android" ? toolbarHeight : insets.bottom}
1203 contentResetKey={`pull-request:${route.params.environmentId}:${route.params.repository}:${route.params.number}:${commit ?? "all"}`}
1204 />
@@ -1383,7 +1208,7 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
1208 !result.isPending &&
1209 !result.error &&
1210 !seekingFile ? (
1386 - <View style={{ paddingTop: Platform.OS === "ios" ? insets.top : 0 }}>
1211 + <View style={{ paddingTop: contentTopInset }}>
1212 <EmptyState
1213 title="Only test files changed"
1214 detail="Test files are hidden from this review."
apps/mobile/src/features/pull-requests/PullRequestSearchSheet.tsx
+20 -71
@@ -1,95 +1,44 @@
1 import { useNavigation } from "@react-navigation/native";
2 -import { useRef, type ReactNode } from "react";
3 -import { Platform, View, type TextInputInstance } from "react-native";
2 +import type { ReactNode } from "react";
3 +import { View } from "react-native";
4
5 import { AppBar } from "../../components/ui/AppBar";
6 -import { SearchField } from "../../components/ui/SearchField";
7 -import { SheetHeader } from "../../components/ui/SheetHeader";
8 -import { Toolbar } from "../../components/ui/Toolbar";
9 -import { NativeStackScreenOptions } from "../../native/StackHeader";
6 import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
11 -import {
12 - createNativeMailSearchToolbarItem,
13 - NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET,
14 -} from "../layout/native-mail-search-toolbar";
7 +import { NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET } from "../layout/native-mail-search-toolbar";
8
16 -/**
17 - * A searchable picker over a pull request list or a pull request: a pushed card with a search
18 - * field on Android, a sheet with the native search toolbar on iOS.
19 - */
9 +/** A searchable picker over a pull request list or a pull request. */
10 export function PullRequestSearchSheet(props: {
11 readonly title: string;
12 readonly placeholder: string;
13 readonly closeAccessibilityLabel: string;
14 readonly clearAccessibilityLabel: string;
25 - readonly searchTextChangeId: string;
15 readonly query: string;
16 readonly onQueryChange: (query: string) => void;
17 /** Renders the list, given the bottom padding that keeps its end clear of the search bar. */
18 readonly children: (list: { readonly paddingBottom: number }) => ReactNode;
19 }) {
20 const navigation = useNavigation();
32 - const integratedSearch = useNativeMailSearchToolbar();
33 - const searchRef = useRef<TextInputInstance>(null);
34 - const list = props.children({
35 - paddingBottom: integratedSearch ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 16 : 16,
36 - });
37 - if (Platform.OS === "android") {
38 - return (
39 - <View className="flex-1 bg-sheet" collapsable={false}>
40 - <AppBar embedded title={props.title} hideBottomBorder onBack={() => navigation.goBack()} />
41 - <View className="bg-header px-4 pb-3 pt-1">
42 - <SearchField
43 - inputRef={searchRef}
44 - accessibilityLabel={props.placeholder}
45 - clearAccessibilityLabel={props.clearAccessibilityLabel}
46 - onChangeText={props.onQueryChange}
47 - placeholder={props.placeholder}
48 - value={props.query}
49 - />
50 - </View>
51 - {list}
52 - </View>
53 - );
54 - }
21 + // The compact search toolbar floats over the end of the list.
22 + const bottomSearch = useNativeMailSearchToolbar();
23 return (
56 - <View className="flex-1 bg-sheet">
57 - <SheetHeader
24 + <View className="flex-1 bg-sheet" collapsable={false}>
25 + <AppBar
26 title={props.title}
27 onClose={() => navigation.goBack()}
60 - accessibilityLabel={props.closeAccessibilityLabel}
61 - />
62 - <NativeStackScreenOptions
63 - options={{
64 - unstable_headerToolbarItems: integratedSearch
65 - ? () => [
66 - createNativeMailSearchToolbarItem({
67 - placeholder: props.placeholder,
68 - onSearchTextChange: props.onQueryChange,
69 - showsSearchDismissButton: true,
70 - searchTextChangeId: props.searchTextChangeId,
71 - }),
72 - ]
73 - : undefined,
74 - headerSearchBarOptions: integratedSearch
75 - ? undefined
76 - : {
77 - placeholder: props.placeholder,
78 - allowToolbarIntegration: true,
79 - autoCapitalize: "none",
80 - hideNavigationBar: false,
81 - obscureBackground: false,
82 - onChangeText: (event) => props.onQueryChange(event.nativeEvent.text),
83 - onCancelButtonPress: () => props.onQueryChange(""),
84 - },
28 + closeAccessibilityLabel={props.closeAccessibilityLabel}
29 + hideBottomBorder
30 + search={{
31 + mode: "inline",
32 + compactToolbar: true,
33 + value: props.query,
34 + onChangeText: props.onQueryChange,
35 + placeholder: props.placeholder,
36 + clearAccessibilityLabel: props.clearAccessibilityLabel,
37 }}
38 />
87 - {integratedSearch ? null : (
88 - <Toolbar placement="bottom">
89 - <Toolbar.SearchBarSlot />
90 - </Toolbar>
91 - )}
92 - {list}
39 + {props.children({
40 + paddingBottom: bottomSearch ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 16 : 16,
41 + })}
42 </View>
43 );
44 }
apps/mobile/src/features/pull-requests/PullRequestSheetContent.tsx
-1
@@ -34,7 +34,6 @@ export function PullRequestSheetContent(props: {
34 style={android ? { maxHeight: windowHeight * 0.92 } : undefined}
35 >
36 <SheetHeader
37 - presentation={android ? "inline" : "native"}
37 title={props.title}
38 subtitle={props.subtitle}
39 onCancel={() => navigation.goBack()}
apps/mobile/src/features/pull-requests/PullRequestStackCard.tsx
+10 -13
@@ -1,7 +1,6 @@
1 -import { StackActions, useNavigation } from "@react-navigation/native";
1 import { useState } from "react";
3 -import { Platform, View } from "react-native";
4 -import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";
2 +import { View } from "react-native";
3 +import { useOpenWorkspaceDetail } from "../layout/useOpenWorkspaceDetail";
4 import { AppText as Text } from "../../components/ui/AppText";
5 import { PullRequestCardGroup, PullRequestCardRow } from "./PullRequestControls";
6 import { pullRequestLayerParams } from "./pullRequestStack";
@@ -15,8 +14,7 @@ export function PullRequestStackCard(props: {
14 readonly params: PullRequestParams;
15 readonly state: PullRequestStackState;
16 }) {
18 - const navigation = useNavigation();
19 - const selectDetail = useSelectWorkspaceDetail();
17 + const openDetail = useOpenWorkspaceDetail();
18 const [expanded, setExpanded] = useState(false);
19 const stack = props.state.stack;
20 if (!stack) {
@@ -67,14 +65,13 @@ export function PullRequestStackCard(props: {
65 onPress={
66 selected
67 ? undefined
70 - : () => {
71 - const params = withKnownPullRequestSummary(
72 - pullRequestLayerParams(props.params, layer.number),
73 - );
74 - if (Platform.OS === "android")
75 - selectDetail({ name: "PullRequest", params });
76 - else navigation.dispatch(StackActions.push("PullRequest", params));
77 - }
68 + : () =>
69 + openDetail({
70 + name: "PullRequest",
71 + params: withKnownPullRequestSummary(
72 + pullRequestLayerParams(props.params, layer.number),
73 + ),
74 + })
75 }
76 last={index === stack.layers.length - 1}
77 />
apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx
+10 -29
@@ -9,19 +9,12 @@ import { LegendList, type LegendListRef } from "@legendapp/list/react-native";
9 import { useNavigation } from "@react-navigation/native";
10 import { use, useMemo, useRef, useState, type ReactNode } from "react";
11 import { useAtomValue } from "@effect/atom-react";
12 -import {
13 - Keyboard,
14 - Platform,
15 - Pressable,
16 - RefreshControl,
17 - ScrollView,
18 - View,
19 - type ScrollViewProps,
20 -} from "react-native";
21 -import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
12 +import { Keyboard, Platform, Pressable, RefreshControl, View } from "react-native";
13 +import { NativeScrollView } from "../../native/NativeScrollViewMarker";
14 import { useSafeAreaInsets } from "react-native-safe-area-context";
15
16 import { AppText as Text } from "../../components/ui/AppText";
17 +import { useContentTopInset } from "../../components/ui/useBarInset";
18 import { SymbolView } from "../../components/ui/AppSymbol";
19 import { EmptyState } from "../../components/ui/EmptyState";
20 import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
@@ -53,14 +46,6 @@ import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
46 import { useSearchScrollRestoration } from "../workspace/useSearchScrollRestoration";
47 import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";
48
56 -function PullRequestScrollView(props: ScrollViewProps) {
57 - return (
58 - <ScrollViewMarker style={{ flex: 1 }}>
59 - <ScrollView {...props} />
60 - </ScrollViewMarker>
61 - );
62 -}
63 -
49 function PullRequestListError(props: { readonly message: string }) {
50 const [expanded, setExpanded] = useState(false);
51 return (
@@ -113,6 +98,7 @@ export function PullRequestsScreen(
98 const { environments } = useWorkspaceState();
99 const configs = useAtomValue(environmentServerConfigsAtom);
100 const insets = useSafeAreaInsets();
101 + const contentTopInset = useContentTopInset();
102 // UIKit insets the list by its column's safe area, which this context can report as 0.
103 const columnSafeBottom = useNativeColumnLayoutMetrics()?.safeArea.bottom;
104 const bottomSafeArea =
@@ -122,7 +108,7 @@ export function PullRequestsScreen(
108 const [initialScrollOffset] = useState(() => workspace.getScrollOffset("pullRequests"));
109 useSearchScrollRestoration(tab.searchMode, () => {
110 void listRef.current?.scrollToOffset({
125 - offset: tab.scrollOffset - (Platform.OS === "ios" ? insets.top : 0),
111 + offset: tab.scrollOffset - contentTopInset,
112 animated: false,
113 });
114 });
@@ -253,7 +239,7 @@ export function PullRequestsScreen(
239 if (update.query !== typedQuery)
240 workspace.dispatch({ type: "query", tab: "pullRequests", query: update.query });
241 void listRef.current?.scrollToOffset({
256 - offset: Platform.OS === "ios" ? -insets.top : 0,
242 + offset: -contentTopInset,
243 animated: false,
244 });
245 },
@@ -308,18 +294,16 @@ export function PullRequestsScreen(
294 // to this tab. The thread list shows none either.
295 showsVerticalScrollIndicator={Platform.OS !== "android"}
296 recycleItems
311 - renderScrollComponent={Platform.OS === "ios" ? PullRequestScrollView : undefined}
297 + renderScrollComponent={NativeScrollView}
298 // UIKit owns the bar's inset, so a minimizing bar and a resized column move
299 // the list in the same frame as the bar.
300 contentInsetAdjustmentBehavior="automatic"
301 // A plain offset: LegendList adds the list header to an index-based restore, which
302 // landed every return one header lower.
303 initialScrollOffset={
318 - initialScrollOffset > 0
319 - ? initialScrollOffset - (Platform.OS === "ios" ? insets.top : 0)
320 - : undefined
304 + initialScrollOffset > 0 ? initialScrollOffset - contentTopInset : undefined
305 }
322 - contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
306 + contentInsetStartAdjustment={contentTopInset}
307 contentContainerStyle={{
308 paddingBottom:
309 Math.max(bottomSafeArea, workspace.bottomClearance) -
@@ -328,10 +312,7 @@ export function PullRequestsScreen(
312 onScroll={(event) => {
313 workspace.recordScrollOffset(
314 "pullRequests",
331 - Math.max(
332 - 0,
333 - event.nativeEvent.contentOffset.y + (Platform.OS === "ios" ? insets.top : 0),
334 - ),
315 + Math.max(0, event.nativeEvent.contentOffset.y + contentTopInset),
316 );
317 }}
318 keyboardDismissMode="on-drag"
apps/mobile/src/features/pull-requests/guide/PullRequestGuideScreen.tsx
+19 -45
@@ -1,10 +1,9 @@
1 import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
2 -import { Toolbar } from "../../../components/ui/Toolbar";
2 import { parsePatchFiles } from "@pierre/diffs/utils/parsePatchFiles";
3 import type { FileDiffMetadata } from "@pierre/diffs";
4 import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
5 import { useEffect } from "react";
7 -import { Platform, Pressable, View } from "react-native";
6 +import { Pressable, View } from "react-native";
7 import { AppBar } from "../../../components/ui/AppBar";
8 import { useSafeAreaInsets } from "react-native-safe-area-context";
9 import {
@@ -16,10 +15,7 @@ import { SymbolView } from "../../../components/ui/AppSymbol";
15 import { GuideOutline } from "./GuideOutline";
16 import { AppText as Text } from "../../../components/ui/AppText";
17 import { ScreenScrollView } from "../../../components/ui/ScreenScrollView";
19 -import { Menu } from "../../../components/ui/Menu";
20 -import { IconButton } from "../../../components/ui/IconButton";
18 import { useAppearancePreferences } from "../../settings/appearance/AppearancePreferencesProvider";
22 -import { NativeStackScreenOptions } from "../../../native/StackHeader";
19 import { PullRequestCardGroup, PullRequestCardRow } from "../PullRequestControls";
20 import { PullRequestMarkdown, PullRequestMarkdownRepository } from "../PullRequestMarkdown";
21 import { usePullRequestDiff, type PullRequestParams } from "../usePullRequestDiff";
@@ -132,47 +128,25 @@ export function PullRequestGuideStopScreen({ route }: StaticScreenProps<GuideSto
128 const notes = stop ? letterStopNotes(stop).lettered : [];
129 return (
130 <View className="flex-1 bg-screen">
135 - <NativeStackScreenOptions
136 - options={{
137 - title: `Stop ${route.params.position + 1}`,
138 - headerTitle: `Stop ${route.params.position + 1} of ${guide?.stops.length ?? "…"}`,
139 - }}
131 + <AppBar
132 + title={`Stop ${route.params.position + 1} of ${guide?.stops.length ?? "…"}`}
133 + onBack={() => navigation.goBack()}
134 + menus={[
135 + {
136 + title: "Guide options",
137 + icon: "ellipsis",
138 + items: [
139 + {
140 + id: "word-wrap",
141 + title: "Word wrap",
142 + icon: "text.alignleft",
143 + selected: appearance.codeWordBreak,
144 + onPress: () => setCodeWordBreak(!appearance.codeWordBreak),
145 + },
146 + ],
147 + },
148 + ]}
149 />
141 - {Platform.OS === "android" ? (
142 - <AppBar
143 - embedded
144 - title={`Stop ${route.params.position + 1}`}
145 - onBack={() => navigation.goBack()}
146 - trailing={
147 - <Menu
148 - actions={[
149 - {
150 - id: "word-wrap",
151 - title: "Word wrap",
152 - image: "text.alignleft",
153 - state: appearance.codeWordBreak ? "on" : "off",
154 - },
155 - ]}
156 - onPressAction={() => setCodeWordBreak(!appearance.codeWordBreak)}
157 - >
158 - <View pointerEvents="none">
159 - <IconButton icon="ellipsis" accessibilityLabel="Guide options" />
160 - </View>
161 - </Menu>
162 - }
163 - />
164 - ) : null}
165 - <Toolbar placement="right">
166 - <Toolbar.Menu title="Guide options" accessibilityLabel="Guide options" icon="ellipsis">
167 - <Toolbar.MenuAction
168 - icon="text.alignleft"
169 - isOn={appearance.codeWordBreak}
170 - onPress={() => setCodeWordBreak(!appearance.codeWordBreak)}
171 - >
172 - <Toolbar.Label>Word wrap</Toolbar.Label>
173 - </Toolbar.MenuAction>
174 - </Toolbar.Menu>
175 - </Toolbar>
150 <PullRequestMarkdownRepository params={route.params} changeRequest={detail.data}>
151 <ScreenScrollView
152 contentInsetAdjustmentBehavior="automatic"
apps/mobile/src/features/pull-requests/usePullRequestListActions.ts
+6 -8
@@ -1,6 +1,5 @@
1 import * as Dialog from "../../components/ui/Dialog";
2 import { RegistryContext, useAtomValue } from "@effect/atom-react";
3 -import { useNavigation } from "@react-navigation/native";
3 import {
4 executeAtomQuery,
5 settlePromise,
@@ -23,6 +22,7 @@ import { scopedPullRequestListKey, type EnvironmentPullRequestListEntry } from "
22 import { copyPullRequestLink, sharePullRequestLink } from "./pullRequestLink";
23 import { pullRequestTarget } from "./usePullRequestDiff";
24 import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";
25 +import { useOpenWorkspaceDetail } from "../layout/useOpenWorkspaceDetail";
26
27 export function usePullRequestListActions(
28 environmentIds: readonly EnvironmentId[],
@@ -32,8 +32,8 @@ export function usePullRequestListActions(
32 ) => void,
33 ) {
34 const registry = use(RegistryContext);
35 - const navigation = useNavigation();
35 const selectDetail = useSelectWorkspaceDetail();
36 + const openDetail = useOpenWorkspaceDetail();
37 const permissionKey = JSON.stringify(environmentIds);
38 const permissionAtom = (() => {
39 const ids: readonly EnvironmentId[] = JSON.parse(permissionKey);
@@ -79,12 +79,10 @@ export function usePullRequestListActions(
79 !pr.viewerPermissions.requestReviewers
80 )
81 throw new Error(`Review requests aren't available for this ${terminology.singular}.`);
82 - if (Platform.OS === "android") {
83 - selectDetail(
84 - { name: "PullRequest", params: params(entry) },
85 - { name: "PullRequestReviewers", params: params(entry) },
86 - );
87 - } else navigation.navigate("PullRequestReviewers", params(entry));
82 + openDetail(
83 + { name: "PullRequest", params: params(entry) },
84 + { name: "PullRequestReviewers", params: params(entry) },
85 + );
86 return;
87 }
88 if (
apps/mobile/src/features/pull-requests/usePullRequestThreads.ts
+5 -15
@@ -3,12 +3,7 @@ import { visibleLinkedThreads } from "@t3tools/client-runtime/state/threads";
3 import { AsyncResult } from "effect/reactivity";
4 import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
5 import * as Dialog from "../../components/ui/Dialog";
6 -import {
7 - StackActions,
8 - useNavigation,
9 - useNavigationState,
10 - useRoute,
11 -} from "@react-navigation/native";
6 +import { useNavigationState, useRoute } from "@react-navigation/native";
7 import { threadPullRequestLinkMode } from "@t3tools/client-runtime/thread-pull-request-compatibility";
8 import {
9 AuthOrchestrationOperateScope,
@@ -21,8 +16,7 @@ import { formatComposerContextReference } from "@t3tools/shared/composerContextR
16 import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
17 import { normalizeThreadPullRequestKey } from "@t3tools/client-runtime/thread-pull-requests";
18 import { useRef, useState } from "react";
24 -import { Platform } from "react-native";
25 -import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";
19 +import { useOpenWorkspaceDetail } from "../layout/useOpenWorkspaceDetail";
20 import { pullRequestComposerContext } from "../../lib/composerContext";
21 import { scopedThreadKey } from "../../lib/scopedEntities";
22 import { uuidv4 } from "../../lib/uuid";
@@ -88,18 +82,14 @@ export function usePullRequestThreads(
82 const canOperate = useEnvironmentScope(target.environmentId, AuthOrchestrationOperateScope);
83 const canAsk = !connected || canOperate;
84 const canCheckout = useEnvironmentScope(target.environmentId, AuthSourceControlWriteScope);
91 - const navigation = useNavigation();
92 - const selectDetail = useSelectWorkspaceDetail();
85 + const openDetail = useOpenWorkspaceDetail();
86 const pending = useRef(false);
87 const previousPrompts = useRef(new Map<string, string>());
88 const openThread = (thread: LinkedThread) => {
89 openThreadRoute({ environmentId: params.environmentId, threadId: thread.id });
90 };
98 - // Android shows one page at a time; iOS opens the thread over the pull request, so Back returns.
99 - const openThreadRoute = (destination: ReactNavigation.RootParamList["Thread"]) => {
100 - if (Platform.OS === "android") selectDetail({ name: "Thread", params: destination });
101 - else navigation.dispatch(StackActions.push("Thread", destination));
102 - };
91 + const openThreadRoute = (destination: ReactNavigation.RootParamList["Thread"]) =>
92 + openDetail({ name: "Thread", params: destination });
93 const [busy, setBusy] = useState(false);
94 const ask = async (thread?: LinkedThread, task: PullRequestAgentTask = "ask") => {
95 if (!pr || !canAsk || pending.current) return;
apps/mobile/src/features/review/ReviewCommentComposerSheet.tsx
+4 -21
@@ -2,13 +2,13 @@ import { useNavigation, type StaticScreenProps } from "@react-navigation/native"
2 import { TextInputWrapper } from "expo-paste-input";
3 import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
4 import { useMemo, useState } from "react";
5 -import { Platform, Pressable, ScrollView, View, useWindowDimensions } from "react-native";
5 +import { Platform, ScrollView, View, useWindowDimensions } from "react-native";
6 import { KeyboardAvoidingView, KeyboardStickyView } from "react-native-keyboard-controller";
7 import { useSafeAreaInsets } from "react-native-safe-area-context";
8 import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
9
10 import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText";
11 -import { SymbolView } from "../../components/ui/AppSymbol";
11 +import { SheetHeader } from "../../components/ui/SheetHeader";
12 import { ComposerAttachmentStrip } from "../../components/ComposerAttachmentStrip";
13 import { ControlPill } from "../../components/ui/ControlPill";
14 import { cn } from "../../lib/cn";
@@ -129,32 +129,15 @@ export function ReviewCommentComposerSheet(props: ReviewCommentComposerSheetProp
129
130 return (
131 <View className="flex-1 bg-sheet">
132 + <SheetHeader title="Add Comment" onClose={dismissComposer} />
133 <KeyboardAvoidingView automaticOffset behavior="padding" className="flex-1">
134 <View
135 className="flex-1 px-5"
136 style={{
136 - paddingTop: isAndroid ? insets.top + 8 : 8,
137 + paddingTop: 8,
138 paddingBottom: target ? (isAndroid ? 72 : 0) : Math.max(insets.bottom, 18),
139 }}
140 >
140 - <View className="flex-row items-center justify-between py-2">
141 - <Pressable
142 - className="bg-subtle h-12 w-12 items-center justify-center rounded-full"
143 - onPress={dismissComposer}
144 - >
145 - <SymbolView
146 - name="xmark"
147 - size={18}
148 - tintColorClassName={"accent-icon"}
149 - type="monochrome"
150 - />
151 - </Pressable>
152 -
153 - <Text className="text-lg font-t3-bold text-foreground">Add Comment</Text>
154 -
155 - <View className="h-12 w-12" />
156 - </View>
157 -
141 {!target ? (
142 <View className="rounded-[22px] border border-border bg-card px-4 py-5">
143 <Text className="text-base font-t3-bold text-foreground">No selection</Text>
apps/mobile/src/features/review/ReviewSheet.tsx
+5 -9
@@ -22,6 +22,7 @@ import {
22 import { useSafeAreaInsets } from "react-native-safe-area-context";
23 import { useReduceMotionEnabled } from "../../lib/appState";
24 import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
25 +import { useContentTopInset } from "../../components/ui/useBarInset";
26 import { NativeScrollView } from "../../native/NativeScrollViewMarker";
27
28 import { AppText as Text } from "../../components/ui/AppText";
@@ -31,7 +32,6 @@ import { cn } from "../../lib/cn";
32 import { environmentCatalog } from "../../connection/catalog";
33 import { useEnvironmentPresentation } from "../../state/presentation";
34 import { useAtomCommand } from "../../state/use-atom-command";
34 -import { useUniwindTheme } from "../../lib/useUniwindTheme";
35 import { useThreadDraftForThread } from "../../state/use-thread-composer-state";
36 import { EnvironmentConnectionNotice } from "../connection/EnvironmentConnectionNotice";
37 import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
@@ -59,7 +59,6 @@ import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail"
59
60 function ReviewHeader(
61 props: Parameters<typeof useReviewHeaderPresentation>[0] & {
62 - readonly iconColor: string;
62 readonly sectionMenu: ReturnType<typeof buildReviewSectionMenu>;
63 readonly showSectionToolbar: boolean;
64 readonly showChangedFilesToggle: boolean;
@@ -84,7 +83,6 @@ function ReviewHeader(
83 subtitle={presentation.subtitle}
84 onBack={props.onReturnToThread}
85 hideBottomBorder
87 - options={{ headerTintColor: props.iconColor, headerTitle: props.title }}
86 backInSplitView={{ accessibilityLabel: "Back to chat", icon: "chevron.left" }}
87 actions={
88 props.showChangedFilesToggle
@@ -335,15 +333,15 @@ function ReviewFileNavigator({ files, sectionId, onSelectFile, ref }: ReviewFile
333 <AppBar
334 title="Changed files"
335 subtitle={`${files.length} ${files.length === 1 ? "file" : "files"}`}
338 - hideBottomBorder={Platform.OS === "android"}
336 + hideBottomBorder
337 />
338 <ScreenContent insetHorizontal>
339 <FlatList
342 - renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
340 + renderScrollComponent={NativeScrollView}
341 data={files}
342 extraData={selectedFileId}
343 keyExtractor={(file) => file.id}
346 - contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
344 + contentInsetAdjustmentBehavior="automatic"
345 contentContainerStyle={{ paddingHorizontal: 8, paddingVertical: 8 }}
346 renderItem={renderFile}
347 />
@@ -365,7 +363,6 @@ export function ReviewSheet(props: ReviewSheetProps) {
363 const selectDetail = useSelectWorkspaceDetail();
364 const insets = useSafeAreaInsets();
365 const { themeAppearance: selectedTheme } = useAppearancePreferences();
368 - const headerIcon = String(useUniwindTheme()["--color-icon"]);
366 const { environmentId, threadId } = props.route.params;
367 const environment = useEnvironmentPresentation(environmentId);
368 const retryEnvironment = useAtomCommand(environmentCatalog.retryNow, "environment retry");
@@ -375,7 +372,7 @@ export function ReviewSheet(props: ReviewSheetProps) {
372 const { selectedThreadCwd } = useSelectedThreadWorktree();
373 const columnMetrics = useNativeColumnLayoutMetrics();
374 const safeArea = columnMetrics?.safeArea ?? insets;
378 - const topContentInset = Platform.OS === "ios" ? safeArea.top : 0;
375 + const topContentInset = useContentTopInset();
376 const bottomContentInset =
377 Platform.OS === "ios" ? safeArea.bottom + 8 : Math.max(insets.bottom, 18) + 18;
378
@@ -620,7 +617,6 @@ export function ReviewSheet(props: ReviewSheetProps) {
617 title={headerTitleText}
618 subtitle={headerSubtitle}
619 androidSubtitle={androidHeaderSubtitle}
623 - iconColor={headerIcon}
620 selectedThreadCwd={selectedThreadCwd}
621 sectionMenu={sectionMenu}
622 selectedSection={selectedSection}
apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx
+9 -27
@@ -4,12 +4,10 @@ import { useAtomValue } from "@effect/atom-react";
4 import { managedRelaySessionAtom } from "@t3tools/client-runtime/relay";
5 import type { EnvironmentId } from "@t3tools/contracts";
6 import { useRef, useState } from "react";
7 -import { Platform, RefreshControl } from "react-native";
7 +import { RefreshControl } from "react-native";
8 import { useSafeAreaInsets } from "react-native-safe-area-context";
9
10 import { SettingsScreen } from "./components/SettingsScreen";
11 -import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
12 -import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
11 import { CloudEnvironmentRows } from "../connection/CloudEnvironmentRows";
12 import { LocalEnvironmentList } from "../connection/LocalEnvironmentList";
13 import { PullRequestRoutingSettings } from "../connection/PullRequestRoutingSettings";
@@ -94,30 +92,14 @@ export function SettingsEnvironmentsRouteScreen() {
92 return (
93 <SettingsScreen
94 title="Environments"
97 - trailing={
98 - Platform.OS === "android" && relaySession ? (
99 - <AndroidAnchoredMenu
100 - title="Environment options"
101 - actions={[
102 - {
103 - id: "refresh",
104 - title: "Refresh cloud environments",
105 - attributes: { disabled: isRefreshingCloud },
106 - },
107 - ]}
108 - onPressAction={({ nativeEvent }) => {
109 - if (nativeEvent.event === "refresh") void refreshCloudEnvironments();
110 - }}
111 - >
112 - {(open) => (
113 - <AndroidHeaderIconButton
114 - accessibilityLabel="Environment options"
115 - icon="ellipsis"
116 - onPress={open}
117 - />
118 - )}
119 - </AndroidAnchoredMenu>
120 - ) : undefined
95 + refresh={
96 + relaySession
97 + ? {
98 + accessibilityLabel: "Refresh cloud environments",
99 + disabled: isRefreshingCloud,
100 + onPress: () => void refreshCloudEnvironments(),
101 + }
102 + : undefined
103 }
104 actions={[
105 {
apps/mobile/src/features/settings/SettingsFollowUpRouteScreen.tsx
+1 -8
@@ -1,7 +1,6 @@
1 import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
2 import { useAtomSet, useAtomValue } from "@effect/atom-react";
3 import { AsyncResult } from "effect/reactivity";
4 -import { Platform, View } from "react-native";
4 import { useSafeAreaInsets } from "react-native-safe-area-context";
5
6 import { AppText as Text } from "../../components/ui/AppText";
@@ -65,11 +64,5 @@ export function SettingsFollowUpRouteScreen() {
64 </ScrollView>
65 );
66
68 - return Platform.OS === "android" ? (
69 - <SettingsScreen title="Chat">{content}</SettingsScreen>
70 - ) : (
71 - <View collapsable={false} className="flex-1 bg-sheet">
72 - {content}
73 - </View>
74 - );
67 + return <SettingsScreen title="Chat">{content}</SettingsScreen>;
68 }
apps/mobile/src/features/settings/SettingsOpenSourceLicensesRouteScreen.tsx
+15 -68
@@ -1,6 +1,5 @@
1 import { NativeScrollView } from "../../native/NativeScrollViewMarker";
2 -import { SearchField } from "../../components/ui/SearchField";
3 -import { Toolbar } from "../../components/ui/Toolbar";
2 +import { useSearchToolbarInset } from "../../components/ui/useBarInset";
3 import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
4 import { LegendList } from "@legendapp/list/react-native";
5 import { type StaticScreenProps, useNavigation } from "@react-navigation/native";
@@ -11,20 +10,14 @@ import {
10 thirdPartyLicenseEntryKey,
11 type ThirdPartyLicenseEntry,
12 } from "@t3tools/shared/thirdPartyLicenses";
14 -import { useMemo, useRef, useState } from "react";
15 -import { Linking, Platform, Pressable, type TextInputInstance, View } from "react-native";
13 +import { useMemo, useState } from "react";
14 +import { Linking, Platform, Pressable, View } from "react-native";
15 import { useSafeAreaInsets } from "react-native-safe-area-context";
16
17 import { SymbolView } from "../../components/ui/AppSymbol";
18 import { AppText as Text } from "../../components/ui/AppText";
19 import { ListRow } from "../../components/ui/ListRow";
20 import { SettingsScreen } from "./components/SettingsScreen";
22 -import { NativeStackScreenOptions } from "../../native/StackHeader";
23 -import {
24 - createNativeMailSearchToolbarItem,
25 - NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET,
26 -} from "../layout/native-mail-search-toolbar";
27 -import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
21
22 import { getMobileThirdPartyLicenses } from "./mobileThirdPartyLicenses";
23
@@ -54,11 +47,17 @@ function LicenseRow(props: {
47 }
48
49 export function SettingsOpenSourceLicensesRouteScreen() {
57 - const searchRef = useRef<TextInputInstance>(null);
50 const navigation = useNavigation();
51 const insets = useSafeAreaInsets();
52 const [query, setQuery] = useState("");
61 - const usesNativeMailSearchToolbar = useNativeMailSearchToolbar();
53 + const search = {
54 + value: query,
55 + onChangeText: setQuery,
56 + placeholder: "Search packages",
57 + accessibilityLabel: "Search open-source licenses",
58 + clearAccessibilityLabel: "Clear package search",
59 + };
60 + const searchInset = useSearchToolbarInset(search);
61 const manifest = useMobileThirdPartyLicenses();
62 const entries = manifest?.entries ?? [];
63 const filteredEntries = filterThirdPartyLicenseEntries(entries, query);
@@ -86,50 +85,13 @@ export function SettingsOpenSourceLicensesRouteScreen() {
85 }
86
87 return (
89 - <SettingsScreen title="Open source licenses">
90 - {Platform.OS === "ios" ? (
91 - <NativeStackScreenOptions
92 - options={{
93 - unstable_headerToolbarItems: usesNativeMailSearchToolbar
94 - ? () => [
95 - createNativeMailSearchToolbarItem({
96 - onSearchTextChange: setQuery,
97 - placeholder: "Search packages",
98 - searchTextChangeId: "open-source-licenses-search-text",
99 - showsSearchDismissButton: true,
100 - }),
101 - ]
102 - : undefined,
103 - headerSearchBarOptions: usesNativeMailSearchToolbar
104 - ? undefined
105 - : {
106 - allowToolbarIntegration: true,
107 - autoCapitalize: "none",
108 - hideNavigationBar: false,
109 - hideWhenScrolling: false,
110 - obscureBackground: false,
111 - onCancelButtonPress: () => setQuery(""),
112 - onChangeText: (event) => setQuery(event.nativeEvent.text),
113 - placeholder: "Search packages",
114 - },
115 - }}
116 - />
117 - ) : null}
118 - {Platform.OS === "ios" && !usesNativeMailSearchToolbar ? (
119 - <Toolbar placement="bottom">
120 - <Toolbar.SearchBarSlot />
121 - </Toolbar>
122 - ) : null}
123 -
88 + <SettingsScreen title="Open source licenses" search={search}>
89 <LegendList
125 - renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
90 + renderScrollComponent={NativeScrollView}
91 className="flex-1"
92 contentContainerStyle={{
128 - paddingBottom: usesNativeMailSearchToolbar
129 - ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 18
130 - : Platform.OS === "ios"
131 - ? 18
132 - : Math.max(insets.bottom, 18) + 18,
93 + paddingBottom:
94 + searchInset + (Platform.OS === "ios" ? 18 : Math.max(insets.bottom, 18) + 18),
95 }}
96 contentInsetAdjustmentBehavior="automatic"
97 data={filteredEntries}
@@ -144,21 +106,6 @@ export function SettingsOpenSourceLicensesRouteScreen() {
106 </Text>
107 </View>
108 }
147 - ListHeaderComponent={
148 - Platform.OS !== "ios" ? (
149 - <View className="px-5 pt-4 pb-5">
150 - <SearchField
151 - inputRef={searchRef}
152 - autoFocus={false}
153 - accessibilityLabel="Search open-source licenses"
154 - clearAccessibilityLabel="Clear package search"
155 - onChangeText={setQuery}
156 - placeholder="Search packages"
157 - value={query}
158 - />
159 - </View>
160 - ) : null
161 - }
109 renderItem={renderItem}
110 showsVerticalScrollIndicator={false}
111 />
apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx
+36 -42
@@ -38,10 +38,7 @@ import { SettingsScreen } from "./components/SettingsScreen";
38 import { SettingsSection } from "./components/SettingsSection";
39 import { ListActionRow as SettingsActionRow } from "../../components/ui/ListActionRow";
40 import { SettingsSwitchRow } from "./components/SettingsSwitchRow";
41 -import {
42 - useSettingsEnvironmentMenu,
43 - SettingsEnvironmentFilterHeader,
44 -} from "./components/SettingsEnvironmentFilterHeader";
41 +import { useSettingsEnvironmentMenu } from "./components/SettingsEnvironmentFilterHeader";
42 import { useSettingsEnvironmentFilter, type SettingsTarget } from "./settings-environment-filter";
43 import { leaveSettingsPage } from "./settings-navigation";
44 import { workspaceHasColumns } from "../workspace/workspace-selection-store";
@@ -87,44 +84,41 @@ export function SettingsProjectOverviewRouteScreen() {
84 .filter((project) => selectedEnvironmentIds.has(project.environmentId)) ?? [];
85
86 return (
90 - <>
91 - <SettingsEnvironmentFilterHeader />
92 - <SettingsScreen title="Projects" menus={[environmentMenu]}>
93 - <ScrollView
94 - contentInsetAdjustmentBehavior="automatic"
95 - showsVerticalScrollIndicator={false}
96 - className="flex-1"
97 - contentContainerClassName="gap-6 px-5 pt-4"
98 - contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
99 - >
100 - {selectedProjectKey === null ? (
101 - <Text className="px-2 text-base text-foreground-muted">
102 - Choose a project with the filter above to manage its name, checkouts and removal.
103 - </Text>
104 - ) : !group || members.length === 0 ? (
105 - <Text className="px-2 text-base text-foreground-muted">
106 - This project has no checkout on the selected connected environments. Change the filter
107 - above.
108 - </Text>
109 - ) : (
110 - <ProjectOverviewContent
111 - key={`${selectedProjectKey}:${members.map((member) => member.id).join(",")}`}
112 - members={members}
113 - group={group}
114 - connectedTargets={availableTargets}
115 - environments={selectedTargets}
116 - hasOtherMembers={members.length < (group?.members.length ?? 0)}
117 - isRemoving={isRemoving}
118 - setIsRemoving={setIsRemoving}
119 - startRemoval={startRemoval}
120 - finishRemoval={finishRemoval}
121 - projectKey={selectedProjectKey}
122 - onProjectRemoved={finishProjectRemoval}
123 - />
124 - )}
125 - </ScrollView>
126 - </SettingsScreen>
127 - </>
87 + <SettingsScreen title="Projects" menus={[environmentMenu]}>
88 + <ScrollView
89 + contentInsetAdjustmentBehavior="automatic"
90 + showsVerticalScrollIndicator={false}
91 + className="flex-1"
92 + contentContainerClassName="gap-6 px-5 pt-4"
93 + contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
94 + >
95 + {selectedProjectKey === null ? (
96 + <Text className="px-2 text-base text-foreground-muted">
97 + Choose a project with the filter above to manage its name, checkouts and removal.
98 + </Text>
99 + ) : !group || members.length === 0 ? (
100 + <Text className="px-2 text-base text-foreground-muted">
101 + This project has no checkout on the selected connected environments. Change the filter
102 + above.
103 + </Text>
104 + ) : (
105 + <ProjectOverviewContent
106 + key={`${selectedProjectKey}:${members.map((member) => member.id).join(",")}`}
107 + members={members}
108 + group={group}
109 + connectedTargets={availableTargets}
110 + environments={selectedTargets}
111 + hasOtherMembers={members.length < (group?.members.length ?? 0)}
112 + isRemoving={isRemoving}
113 + setIsRemoving={setIsRemoving}
114 + startRemoval={startRemoval}
115 + finishRemoval={finishRemoval}
116 + projectKey={selectedProjectKey}
117 + onProjectRemoved={finishProjectRemoval}
118 + />
119 + )}
120 + </ScrollView>
121 + </SettingsScreen>
122 );
123 }
124
apps/mobile/src/features/settings/SettingsProviderAccountsRouteScreen.tsx
+31 -37
@@ -28,10 +28,7 @@ import { serverEnvironment } from "../../state/server";
28 import { useEnvironmentsWithScope } from "../../state/session";
29 import { useAtomCommand } from "../../state/use-atom-command";
30 import { ListActionRow as SettingsActionRow } from "../../components/ui/ListActionRow";
31 -import {
32 - useSettingsEnvironmentMenu,
33 - SettingsEnvironmentFilterHeader,
34 -} from "./components/SettingsEnvironmentFilterHeader";
31 +import { useSettingsEnvironmentMenu } from "./components/SettingsEnvironmentFilterHeader";
32 import { SettingsScreen } from "./components/SettingsScreen";
33 import { SettingsSection } from "./components/SettingsSection";
34 import { AddClaudeAccount, ClaudeAccount } from "./ClaudeAccounts";
@@ -45,39 +42,36 @@ export function SettingsProviderAccountsRouteScreen() {
42 const providersByEnvironment = useAtomValue(environmentPresentations.providersByEnvironmentAtom);
43 const insets = useSafeAreaInsets();
44 return (
48 - <>
49 - <SettingsEnvironmentFilterHeader />
50 - <SettingsScreen title="Providers" menus={[environmentMenu]}>
51 - <ScreenScrollView
52 - className="flex-1"
53 - contentInsetAdjustmentBehavior="automatic"
54 - contentContainerClassName="gap-6 px-5 pt-4"
55 - contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
56 - >
57 - {selectedTargets.length === 0 ? (
58 - <Text className="text-foreground-muted">Select a connected environment.</Text>
59 - ) : (
60 - selectedTargets.map((environment) => (
61 - <SettingsSection key={environment.environmentId} title={environment.label}>
62 - {!permittedEnvironments.has(environment.environmentId) ? (
63 - <View className="gap-1 p-4">
64 - <Text className="text-base text-foreground">Limited permissions</Text>
65 - <Text className="text-sm text-foreground-muted">
66 - {`This session can view ${environment.label}'s providers but can't change their settings.`}
67 - </Text>
68 - </View>
69 - ) : (
70 - <EnvironmentProviders
71 - environment={environment}
72 - providers={managedProviders(environment, providersByEnvironment)}
73 - />
74 - )}
75 - </SettingsSection>
76 - ))
77 - )}
78 - </ScreenScrollView>
79 - </SettingsScreen>
80 - </>
45 + <SettingsScreen title="Providers" menus={[environmentMenu]}>
46 + <ScreenScrollView
47 + className="flex-1"
48 + contentInsetAdjustmentBehavior="automatic"
49 + contentContainerClassName="gap-6 px-5 pt-4"
50 + contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
51 + >
52 + {selectedTargets.length === 0 ? (
53 + <Text className="text-foreground-muted">Select a connected environment.</Text>
54 + ) : (
55 + selectedTargets.map((environment) => (
56 + <SettingsSection key={environment.environmentId} title={environment.label}>
57 + {!permittedEnvironments.has(environment.environmentId) ? (
58 + <View className="gap-1 p-4">
59 + <Text className="text-base text-foreground">Limited permissions</Text>
60 + <Text className="text-sm text-foreground-muted">
61 + {`This session can view ${environment.label}'s providers but can't change their settings.`}
62 + </Text>
63 + </View>
64 + ) : (
65 + <EnvironmentProviders
66 + environment={environment}
67 + providers={managedProviders(environment, providersByEnvironment)}
68 + />
69 + )}
70 + </SettingsSection>
71 + ))
72 + )}
73 + </ScreenScrollView>
74 + </SettingsScreen>
75 );
76 }
77
apps/mobile/src/features/settings/SettingsRouteScreen.tsx
+43 -40
@@ -29,17 +29,30 @@ import { SettingsRow } from "./components/SettingsRow";
29 import { SettingsSection, SettingsSidebarContext } from "./components/SettingsSection";
30 import { SettingsScreen } from "./components/SettingsScreen";
31 import type { SettingsPageTarget } from "./components/settings-page-targets";
32 -import {
33 - useSettingsEnvironmentMenu,
34 - SettingsEnvironmentFilterHeader,
35 -} from "./components/SettingsEnvironmentFilterHeader";
32 +import { useSettingsEnvironmentMenu } from "./components/SettingsEnvironmentFilterHeader";
33 import { useSettingsEnvironmentFilter } from "./settings-environment-filter";
34 import { filterSettingsSections } from "./settings-search";
38 -import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
35 +import { usePaneRole } from "../../components/ui/Pane";
36
37 export function SettingsRouteScreen() {
41 - const { layout } = useAdaptiveWorkspaceLayout();
42 - const inSidebar = use(NativePrimaryColumnContext) !== null && layout.usesSplitView;
38 + const list = useSettingsListPlacement();
39 + return <SettingsListScreen sidebar={list.sidebar} selected={list.selected} />;
40 +}
41 +
42 +/** The Settings list inside a workspace shell that draws its bar, title and search itself. */
43 +export function WorkspaceSettingsList() {
44 + const list = useSettingsListPlacement();
45 + return (
46 + <SettingsSidebarContext value={list.sidebar ? { selected: list.selected } : null}>
47 + <View className="flex-1 bg-screen">
48 + <SettingsListContent />
49 + </View>
50 + </SettingsSidebarContext>
51 + );
52 +}
53 +
54 +function useSettingsListPlacement() {
55 + const sidebar = usePaneRole() === "sidebar";
56 // The page open beside the list: the route right above the Settings tab's route. While
57 // another tab is open this list stays mounted, hidden, and must keep showing the page Settings
58 // reopens on; otherwise returning shows it unselected for a frame before the page arrives.
@@ -49,7 +62,11 @@ export function SettingsRouteScreen() {
62 ? rememberedSettingsPage(currentWorkspaceSelections())
63 : (state.routes[list + 1]?.name ?? null);
64 });
52 - return <SettingsListScreen sidebar={inSidebar} selected={selected} />;
65 + return { sidebar, selected };
66 +}
67 +
68 +function SettingsListContent() {
69 + return hasCloudPublicConfig() ? <ConfiguredSettingsRouteScreen /> : <LocalSettingsRouteScreen />;
70 }
71
72 export function SettingsListScreen(props: {
@@ -58,40 +75,26 @@ export function SettingsListScreen(props: {
75 }) {
76 const workspace = useWorkspaceTabs();
77 const environmentMenu = useSettingsEnvironmentMenu();
61 - const inSidebar = props.sidebar;
62 - const selected = props.selected;
63 - const sidebar = inSidebar ? { selected } : null;
64 - const content = hasCloudPublicConfig() ? (
65 - <ConfiguredSettingsRouteScreen />
66 - ) : (
67 - <LocalSettingsRouteScreen />
68 - );
69 -
78 return (
71 - <SettingsSidebarContext value={sidebar}>
79 + <SettingsSidebarContext value={props.sidebar ? { selected: props.selected } : null}>
80 <View className="flex-1 bg-screen">
73 - <SettingsEnvironmentFilterHeader />
74 - {Platform.OS === "android" ? (
75 - <SettingsScreen
76 - title="Settings"
77 - workspaceRoot={inSidebar}
78 - menus={[environmentMenu]}
79 - search={
80 - workspace
81 - ? {
82 - value: workspace.state.tabs.settings.query,
83 - onChangeText: (query) =>
84 - workspace.dispatch({ type: "query", tab: "settings", query }),
85 - placeholder: "Search settings",
86 - }
87 - : undefined
88 - }
89 - >
90 - {content}
91 - </SettingsScreen>
92 - ) : (
93 - content
94 - )}
81 + <SettingsScreen
82 + title="Settings"
83 + workspaceRoot={props.sidebar}
84 + menus={[environmentMenu]}
85 + search={
86 + workspace
87 + ? {
88 + value: workspace.state.tabs.settings.query,
89 + onChangeText: (query) =>
90 + workspace.dispatch({ type: "query", tab: "settings", query }),
91 + placeholder: "Search settings",
92 + }
93 + : undefined
94 + }
95 + >
96 + <SettingsListContent />
97 + </SettingsScreen>
98 </View>
99 </SettingsSidebarContext>
100 );
apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx
+56 -94
@@ -62,14 +62,10 @@ import { useProjects, useEnvironmentServerConfig } from "../../state/entities";
62 import { useEnvironmentQuery } from "../../state/query";
63 import { serverEnvironment } from "../../state/server";
64 import { useAtomCommand } from "../../state/use-atom-command";
65 -import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
65 import { resolveNewTaskBranchLabel } from "../threads/new-task-context-presentation";
66 import { useVoiceInputController } from "../voice-input/useVoiceInputController";
67 import { ScheduledTaskPromptField } from "./components/ScheduledTaskPromptField";
69 -import {
70 - useSettingsEnvironmentMenu,
71 - SettingsEnvironmentFilterHeader,
72 -} from "./components/SettingsEnvironmentFilterHeader";
68 +import { useSettingsEnvironmentMenu } from "./components/SettingsEnvironmentFilterHeader";
69 import { SettingsScreen } from "./components/SettingsScreen";
70 import { SettingsSection } from "./components/SettingsSection";
71 import { useSettingsEnvironmentFilter, type SettingsTarget } from "./settings-environment-filter";
@@ -414,79 +410,61 @@ export function SettingsScheduledTasksRouteScreen() {
410 };
411
412 return (
417 - <>
418 - <SettingsEnvironmentFilterHeader
419 - trailingItems={[
420 - withNativeGlassHeaderItem({
421 - type: "button",
422 - label: "",
423 - accessibilityLabel: "New task",
424 - icon: { type: "sfSymbol", name: "plus" } as const,
425 - disabled: visibleEnvironments.length === 0,
426 - onPress: newTask,
427 - }),
428 - ]}
429 - />
430 - <SettingsScreen
431 - title="Scheduled tasks"
432 - actions={
433 - Platform.OS === "android"
434 - ? [
435 - {
436 - accessibilityLabel: "New task",
437 - icon: "plus",
438 - disabled: visibleEnvironments.length === 0,
439 - onPress: newTask,
440 - },
441 - ]
442 - : undefined
443 - }
444 - menus={[environmentMenu]}
413 + <SettingsScreen
414 + title="Scheduled tasks"
415 + actions={[
416 + {
417 + accessibilityLabel: "New task",
418 + icon: "plus",
419 + disabled: visibleEnvironments.length === 0,
420 + onPress: newTask,
421 + },
422 + ]}
423 + menus={[environmentMenu]}
424 + >
425 + <ScrollView
426 + keyboardShouldPersistTaps="handled"
427 + keyboardDismissMode="on-drag"
428 + contentInsetAdjustmentBehavior="automatic"
429 + showsVerticalScrollIndicator={false}
430 + className="flex-1"
431 + contentContainerClassName="gap-5 px-5 pt-4"
432 + contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
433 >
446 - <ScrollView
447 - keyboardShouldPersistTaps="handled"
448 - keyboardDismissMode="on-drag"
449 - contentInsetAdjustmentBehavior="automatic"
450 - showsVerticalScrollIndicator={false}
451 - className="flex-1"
452 - contentContainerClassName="gap-5 px-5 pt-4"
453 - contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
454 - >
455 - {visibleEnvironments.length > 0 ? (
456 - visibleEnvironments.map((environment) => (
457 - <EnvironmentTasks
458 - key={environment.environmentId}
459 - environment={environment}
460 - now={now}
461 - projectIds={
462 - selectedProjectKey === null
463 - ? null
464 - : (selectedGroup?.members
465 - .filter(
466 - (member) => member.project.environmentId === environment.environmentId,
467 - )
468 - .map((member) => member.project.id) ?? [])
469 - }
470 - onEdit={(task) => {
471 - startEditor({
472 - environmentId: environment.environmentId,
473 - environmentLabel: environment.label,
474 - draft: editDraft(task),
475 - });
476 - navigation.navigate("SettingsScheduledTaskEdit");
477 - }}
478 - />
479 - ))
480 - ) : (
481 - <Text className="px-2 text-base text-foreground-muted">
482 - {availableTargets.length === 0
483 - ? "Connect an environment to view and create scheduled tasks."
484 - : "No environments match these filters. Change the filter above."}
485 - </Text>
486 - )}
487 - </ScrollView>
488 - </SettingsScreen>
489 - </>
434 + {visibleEnvironments.length > 0 ? (
435 + visibleEnvironments.map((environment) => (
436 + <EnvironmentTasks
437 + key={environment.environmentId}
438 + environment={environment}
439 + now={now}
440 + projectIds={
441 + selectedProjectKey === null
442 + ? null
443 + : (selectedGroup?.members
444 + .filter(
445 + (member) => member.project.environmentId === environment.environmentId,
446 + )
447 + .map((member) => member.project.id) ?? [])
448 + }
449 + onEdit={(task) => {
450 + startEditor({
451 + environmentId: environment.environmentId,
452 + environmentLabel: environment.label,
453 + draft: editDraft(task),
454 + });
455 + navigation.navigate("SettingsScheduledTaskEdit");
456 + }}
457 + />
458 + ))
459 + ) : (
460 + <Text className="px-2 text-base text-foreground-muted">
461 + {availableTargets.length === 0
462 + ? "Connect an environment to view and create scheduled tasks."
463 + : "No environments match these filters. Change the filter above."}
464 + </Text>
465 + )}
466 + </ScrollView>
467 + </SettingsScreen>
468 );
469 }
470
@@ -574,23 +552,7 @@ function SettingsScheduledTaskEditorScreen({ title }: { readonly title: string }
552 <SettingsScreen
553 title={title}
554 // Native Back pops before removal guards; a bar action lets the guard run first.
577 - options={
578 - Platform.OS === "ios"
579 - ? {
580 - headerBackVisible: false,
581 - gestureEnabled: !preventRemove,
582 - unstable_headerLeftItems: () => [
583 - withNativeGlassHeaderItem({
584 - type: "button",
585 - label: "",
586 - accessibilityLabel: "Back",
587 - icon: { type: "sfSymbol", name: "chevron.backward" },
588 - onPress: () => navigation.goBack(),
589 - }),
590 - ],
591 - }
592 - : undefined
593 - }
555 + guardBack={preventRemove}
556 >
557 <ScrollView
558 keyboardShouldPersistTaps="handled"
apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx
-1
@@ -92,7 +92,6 @@ vi.mock("./components/SettingsEnvironmentFilterHeader", () => ({
92 icon: "line.3.horizontal.decrease.circle",
93 items: [],
94 }),
95 - SettingsEnvironmentFilterHeader: () => null,
95 }));
96 vi.mock("./components/DatabaseStorageNotice", () => ({ DatabaseStorageNotice: () => null }));
97 vi.mock("./components/SettingsSection", () => ({ SettingsSection: Children }));
apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx
+268 -276
@@ -22,10 +22,7 @@ import {
22 withManagedRuntimeModeLimits,
23 } from "../threads/thread-settings-options";
24 import { SettingsScreen } from "./components/SettingsScreen";
25 -import {
26 - useSettingsEnvironmentMenu,
27 - SettingsEnvironmentFilterHeader,
28 -} from "./components/SettingsEnvironmentFilterHeader";
25 +import { useSettingsEnvironmentMenu } from "./components/SettingsEnvironmentFilterHeader";
26 import { BranchNamingSettings } from "./components/BranchNamingSettings";
27 import { DatabaseStorageNotice } from "./components/DatabaseStorageNotice";
28 import { ListChoiceRow as SettingsChoiceRow } from "../../components/ui/ListChoiceRow";
@@ -284,292 +281,287 @@ function ServerSettingsDetail(props: { readonly page: SettingsPage }) {
281 ));
282
283 return (
287 - <>
288 - <SettingsEnvironmentFilterHeader />
289 - <SettingsScreen title={PAGE_TITLES[props.page]} menus={[environmentMenu]}>
290 - <ScrollView
291 - contentInsetAdjustmentBehavior="automatic"
292 - showsVerticalScrollIndicator={false}
293 - className="flex-1"
294 - contentContainerClassName="gap-6 px-5 pt-4"
295 - contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
296 - >
297 - {!hasConnectedSelection || reference === null ? (
298 - <Text className="px-2 text-base text-foreground-muted">
299 - {projectSelected
300 - ? "Select a project with a checkout on a connected environment."
301 - : "Use the filter above to select a connected environment."}
302 - </Text>
303 - ) : (
304 - <>
305 - <ManagedPolicyNotice targets={targets} />
306 - {projectSelected ? (
307 - <SettingsProjectOverridesSection
308 - projectLabel={selectedProject?.label ?? "Unavailable project"}
309 - hasOverrides={targets.some((target) =>
310 - PAGE_PROJECT_KEYS[props.page].some((key) => target.sources[key] === "project"),
311 - )}
312 - pending={pendingWrites > 0}
313 - disabled={!canWriteSettings}
314 - onClear={clearProjectOverrides}
315 - />
316 - ) : null}
317 - {props.page === "threads" ? (
318 - <>
319 - <SettingsSection
320 - title="Default workspace"
321 - footer={managed("defaultThreadEnvMode")}
322 - trailing={
323 - pendingWrites === 0 && isMixed("defaultThreadEnvMode") ? (
324 - <MixedValuesLabel projectSelected={projectSelected} />
325 - ) : null
326 - }
327 - >
328 - {WORKSPACE_CHOICES.filter(
329 - (choice) => choice.mode !== null || !projectSelected,
330 - ).map((choice, index) => (
331 - <SettingsChoiceRow
332 - key={choice.mode ?? "inherit"}
333 - label={choice.label}
334 - description={choice.description}
335 - selected={
336 - !isMixed("defaultThreadEnvMode") &&
337 - uniform("defaultThreadEnvMode") === choice.mode
338 - }
339 - separated={index > 0}
340 - disabled={disabledFor("defaultThreadEnvMode")}
341 - onPress={() => write({ defaultThreadEnvMode: choice.mode })}
342 - />
343 - ))}
344 - </SettingsSection>
345 - <SettingsSection
346 - title="Default permissions"
347 - footer={managed("defaultRuntimeMode")}
348 - trailing={
349 - pendingWrites === 0 && uniform("defaultRuntimeMode") === null ? (
350 - <MixedValuesLabel projectSelected={projectSelected} />
351 - ) : null
352 - }
353 - >
354 - {runtimeModeChoices.map((choice, index) => (
355 - <SettingsChoiceRow
356 - key={choice.mode}
357 - label={choice.label}
358 - description={choice.disabledReason ?? choice.description}
359 - selected={uniform("defaultRuntimeMode") === choice.mode}
360 - separated={index > 0}
361 - disabled={
362 - disabledFor("defaultRuntimeMode") || choice.disabledReason !== undefined
363 - }
364 - onPress={() => write({ defaultRuntimeMode: choice.mode })}
365 - />
366 - ))}
367 - </SettingsSection>
368 - <SettingsSection
369 - title="Response streaming"
370 - footer={managed("responseStreamingMode")}
371 - trailing={
372 - pendingWrites === 0 && uniform("responseStreamingMode") === null ? (
373 - <MixedValuesLabel projectSelected={projectSelected} />
374 - ) : null
375 - }
376 - >
377 - {STREAMING_CHOICES.map((choice, index) => (
378 - <SettingsChoiceRow
379 - key={choice.mode}
380 - label={choice.label}
381 - description={choice.description}
382 - selected={uniform("responseStreamingMode") === choice.mode}
383 - separated={index > 0}
384 - disabled={disabledFor("responseStreamingMode")}
385 - onPress={() => write({ responseStreamingMode: choice.mode })}
386 - />
387 - ))}
388 - </SettingsSection>
389 - <SettingsSection title="Preview browser">
390 - <SettingsSwitchRow
391 - icon="globe"
392 - label="Agent browser access"
393 - subtitle={managedSubtitle(
394 - "enableAgentBrowserAccess",
395 - "Allow agents to use the in-app preview browser.",
396 - )}
397 - value={uniform("enableAgentBrowserAccess")}
398 - disabled={disabledFor("enableAgentBrowserAccess")}
399 - onValueChange={(value) => write({ enableAgentBrowserAccess: value })}
400 - />
401 - </SettingsSection>
402 - <AutoSettleSettingsRows write={write} pending={pendingWrites > 0} />
403 - </>
404 - ) : null}
405 -
406 - {props.page === "source-control" ? (
407 - <>
408 - {projectSelected ? null : (
409 - <SourceControlSignInSection
410 - environments={selectedTargets}
411 - canWrite={(environmentId) => writableEnvironments.has(environmentId)}
284 + <SettingsScreen title={PAGE_TITLES[props.page]} menus={[environmentMenu]}>
285 + <ScrollView
286 + contentInsetAdjustmentBehavior="automatic"
287 + showsVerticalScrollIndicator={false}
288 + className="flex-1"
289 + contentContainerClassName="gap-6 px-5 pt-4"
290 + contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
291 + >
292 + {!hasConnectedSelection || reference === null ? (
293 + <Text className="px-2 text-base text-foreground-muted">
294 + {projectSelected
295 + ? "Select a project with a checkout on a connected environment."
296 + : "Use the filter above to select a connected environment."}
297 + </Text>
298 + ) : (
299 + <>
300 + <ManagedPolicyNotice targets={targets} />
301 + {projectSelected ? (
302 + <SettingsProjectOverridesSection
303 + projectLabel={selectedProject?.label ?? "Unavailable project"}
304 + hasOverrides={targets.some((target) =>
305 + PAGE_PROJECT_KEYS[props.page].some((key) => target.sources[key] === "project"),
306 + )}
307 + pending={pendingWrites > 0}
308 + disabled={!canWriteSettings}
309 + onClear={clearProjectOverrides}
310 + />
311 + ) : null}
312 + {props.page === "threads" ? (
313 + <>
314 + <SettingsSection
315 + title="Default workspace"
316 + footer={managed("defaultThreadEnvMode")}
317 + trailing={
318 + pendingWrites === 0 && isMixed("defaultThreadEnvMode") ? (
319 + <MixedValuesLabel projectSelected={projectSelected} />
320 + ) : null
321 + }
322 + >
323 + {WORKSPACE_CHOICES.filter(
324 + (choice) => choice.mode !== null || !projectSelected,
325 + ).map((choice, index) => (
326 + <SettingsChoiceRow
327 + key={choice.mode ?? "inherit"}
328 + label={choice.label}
329 + description={choice.description}
330 + selected={
331 + !isMixed("defaultThreadEnvMode") &&
332 + uniform("defaultThreadEnvMode") === choice.mode
333 + }
334 + separated={index > 0}
335 + disabled={disabledFor("defaultThreadEnvMode")}
336 + onPress={() => write({ defaultThreadEnvMode: choice.mode })}
337 />
413 - )}
414 - <SettingsSection title="Pull requests">
415 - <SettingsSwitchRow
416 - icon={PullRequestGlyph.merged}
417 - label="Remove agent credits when merging"
418 - subtitle={managedSubtitle(
419 - "removeAgentCreditsOnMerge",
420 - "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.",
421 - )}
422 - value={uniform("removeAgentCreditsOnMerge")}
423 - disabled={disabledFor("removeAgentCreditsOnMerge")}
424 - onValueChange={(value) => write({ removeAgentCreditsOnMerge: value })}
425 - />
426 - </SettingsSection>
427 - <SettingsSection title="Default branch">
428 - <SettingsSwitchRow
429 - icon="arrow.down.circle"
430 - label="Automatically pull"
431 - subtitle={managedSubtitle(
432 - "defaultAutoPull",
433 - "Keep the default branch current when there are no local changes.",
434 - )}
435 - value={uniform("defaultAutoPull")}
436 - disabled={disabledFor("defaultAutoPull")}
437 - onValueChange={(value) => write({ defaultAutoPull: value })}
338 + ))}
339 + </SettingsSection>
340 + <SettingsSection
341 + title="Default permissions"
342 + footer={managed("defaultRuntimeMode")}
343 + trailing={
344 + pendingWrites === 0 && uniform("defaultRuntimeMode") === null ? (
345 + <MixedValuesLabel projectSelected={projectSelected} />
346 + ) : null
347 + }
348 + >
349 + {runtimeModeChoices.map((choice, index) => (
350 + <SettingsChoiceRow
351 + key={choice.mode}
352 + label={choice.label}
353 + description={choice.disabledReason ?? choice.description}
354 + selected={uniform("defaultRuntimeMode") === choice.mode}
355 + separated={index > 0}
356 + disabled={
357 + disabledFor("defaultRuntimeMode") || choice.disabledReason !== undefined
358 + }
359 + onPress={() => write({ defaultRuntimeMode: choice.mode })}
360 />
439 - </SettingsSection>
440 - <SettingsSection title="Clones">
441 - <SettingsSwitchRow
442 - icon="folder"
443 - label="Clone into host folders"
444 - subtitle="Clones go to github.com/owner/repo under the Add project folder, like ghq."
445 - value={uniform("ghqCloneLayout")}
446 - disabled={disabledFor("ghqCloneLayout")}
447 - onValueChange={(value) => write({ ghqCloneLayout: value })}
361 + ))}
362 + </SettingsSection>
363 + <SettingsSection
364 + title="Response streaming"
365 + footer={managed("responseStreamingMode")}
366 + trailing={
367 + pendingWrites === 0 && uniform("responseStreamingMode") === null ? (
368 + <MixedValuesLabel projectSelected={projectSelected} />
369 + ) : null
370 + }
371 + >
372 + {STREAMING_CHOICES.map((choice, index) => (
373 + <SettingsChoiceRow
374 + key={choice.mode}
375 + label={choice.label}
376 + description={choice.description}
377 + selected={uniform("responseStreamingMode") === choice.mode}
378 + separated={index > 0}
379 + disabled={disabledFor("responseStreamingMode")}
380 + onPress={() => write({ responseStreamingMode: choice.mode })}
381 />
449 - </SettingsSection>
450 - </>
451 - ) : null}
382 + ))}
383 + </SettingsSection>
384 + <SettingsSection title="Preview browser">
385 + <SettingsSwitchRow
386 + icon="globe"
387 + label="Agent browser access"
388 + subtitle={managedSubtitle(
389 + "enableAgentBrowserAccess",
390 + "Allow agents to use the in-app preview browser.",
391 + )}
392 + value={uniform("enableAgentBrowserAccess")}
393 + disabled={disabledFor("enableAgentBrowserAccess")}
394 + onValueChange={(value) => write({ enableAgentBrowserAccess: value })}
395 + />
396 + </SettingsSection>
397 + <AutoSettleSettingsRows write={write} pending={pendingWrites > 0} />
398 + </>
399 + ) : null}
400
453 - {props.page === "worktrees" ? (
454 - <>
455 - <SettingsSection title="New worktrees">
456 - <SettingsSwitchRow
457 - icon="arrow.triangle.branch"
458 - label="Start from remote"
459 - subtitle={managedSubtitle(
460 - "newWorktreesStartFromOrigin",
461 - "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.",
462 - )}
463 - value={uniform("newWorktreesStartFromOrigin")}
464 - disabled={disabledFor("newWorktreesStartFromOrigin")}
465 - onValueChange={(value) => write({ newWorktreesStartFromOrigin: value })}
401 + {props.page === "source-control" ? (
402 + <>
403 + {projectSelected ? null : (
404 + <SourceControlSignInSection
405 + environments={selectedTargets}
406 + canWrite={(environmentId) => writableEnvironments.has(environmentId)}
407 + />
408 + )}
409 + <SettingsSection title="Pull requests">
410 + <SettingsSwitchRow
411 + icon={PullRequestGlyph.merged}
412 + label="Remove agent credits when merging"
413 + subtitle={managedSubtitle(
414 + "removeAgentCreditsOnMerge",
415 + "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.",
416 + )}
417 + value={uniform("removeAgentCreditsOnMerge")}
418 + disabled={disabledFor("removeAgentCreditsOnMerge")}
419 + onValueChange={(value) => write({ removeAgentCreditsOnMerge: value })}
420 + />
421 + </SettingsSection>
422 + <SettingsSection title="Default branch">
423 + <SettingsSwitchRow
424 + icon="arrow.down.circle"
425 + label="Automatically pull"
426 + subtitle={managedSubtitle(
427 + "defaultAutoPull",
428 + "Keep the default branch current when there are no local changes.",
429 + )}
430 + value={uniform("defaultAutoPull")}
431 + disabled={disabledFor("defaultAutoPull")}
432 + onValueChange={(value) => write({ defaultAutoPull: value })}
433 + />
434 + </SettingsSection>
435 + <SettingsSection title="Clones">
436 + <SettingsSwitchRow
437 + icon="folder"
438 + label="Clone into host folders"
439 + subtitle="Clones go to github.com/owner/repo under the Add project folder, like ghq."
440 + value={uniform("ghqCloneLayout")}
441 + disabled={disabledFor("ghqCloneLayout")}
442 + onValueChange={(value) => write({ ghqCloneLayout: value })}
443 + />
444 + </SettingsSection>
445 + </>
446 + ) : null}
447 +
448 + {props.page === "worktrees" ? (
449 + <>
450 + <SettingsSection title="New worktrees">
451 + <SettingsSwitchRow
452 + icon="arrow.triangle.branch"
453 + label="Start from remote"
454 + subtitle={managedSubtitle(
455 + "newWorktreesStartFromOrigin",
456 + "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.",
457 + )}
458 + value={uniform("newWorktreesStartFromOrigin")}
459 + disabled={disabledFor("newWorktreesStartFromOrigin")}
460 + onValueChange={(value) => write({ newWorktreesStartFromOrigin: value })}
461 + />
462 + </SettingsSection>
463 + <SettingsSection
464 + title="Worktree submodules"
465 + footer={managed("worktreeSubmodules")}
466 + trailing={
467 + pendingWrites === 0 && isMixed("worktreeSubmodules") ? (
468 + <MixedValuesLabel projectSelected={projectSelected} />
469 + ) : null
470 + }
471 + >
472 + {SUBMODULE_CHOICES.filter(
473 + (choice) => choice.mode !== null || !projectSelected,
474 + ).map((choice, index) => (
475 + <SettingsChoiceRow
476 + key={choice.mode ?? "inherit"}
477 + label={choice.label}
478 + description={choice.description}
479 + selected={
480 + !isMixed("worktreeSubmodules") &&
481 + uniform("worktreeSubmodules") === choice.mode
482 + }
483 + separated={index > 0}
484 + disabled={disabledFor("worktreeSubmodules")}
485 + onPress={() => write({ worktreeSubmodules: choice.mode })}
486 />
467 - </SettingsSection>
468 - <SettingsSection
469 - title="Worktree submodules"
470 - footer={managed("worktreeSubmodules")}
471 - trailing={
472 - pendingWrites === 0 && isMixed("worktreeSubmodules") ? (
473 - <MixedValuesLabel projectSelected={projectSelected} />
474 - ) : null
475 - }
476 - >
477 - {SUBMODULE_CHOICES.filter(
478 - (choice) => choice.mode !== null || !projectSelected,
479 - ).map((choice, index) => (
480 - <SettingsChoiceRow
481 - key={choice.mode ?? "inherit"}
482 - label={choice.label}
483 - description={choice.description}
484 - selected={
485 - !isMixed("worktreeSubmodules") &&
486 - uniform("worktreeSubmodules") === choice.mode
487 + ))}
488 + </SettingsSection>
489 + <BranchNamingSettings
490 + key={targetsKey}
491 + mode={uniform("branchNamingMode")}
492 + prefix={uniform("branchNamePrefix")}
493 + instructions={uniform("branchNameInstructions")}
494 + disabled={{
495 + mode: disabledFor("branchNamingMode"),
496 + prefix: disabledFor("branchNamePrefix"),
497 + instructions: disabledFor("branchNameInstructions"),
498 + }}
499 + onChange={write}
500 + />
501 + </>
502 + ) : null}
503 +
504 + {props.page === "maintenance" ? (
505 + <>
506 + {!projectSelected ? (
507 + <DatabaseStorageNotice
508 + targets={selectedTargets.filter(
509 + (target) =>
510 + target.serverConfig.environment.capabilities.databaseStorage === true,
511 + )}
512 + />
513 + ) : null}
514 + {!projectSelected ? (
515 + <SettingsSection title="Manage environments">
516 + {selectedTargets.map((target) => (
517 + <SettingsRow
518 + key={target.environmentId}
519 + icon="server.rack"
520 + label={target.label}
521 + value="Server and provider updates"
522 + onPress={() =>
523 + navigation.navigate("SettingsEnvironmentDetail", {
524 + environmentId: target.environmentId,
525 + })
526 }
488 - separated={index > 0}
489 - disabled={disabledFor("worktreeSubmodules")}
490 - onPress={() => write({ worktreeSubmodules: choice.mode })}
527 />
528 ))}
529 </SettingsSection>
494 - <BranchNamingSettings
495 - key={targetsKey}
496 - mode={uniform("branchNamingMode")}
497 - prefix={uniform("branchNamePrefix")}
498 - instructions={uniform("branchNameInstructions")}
499 - disabled={{
500 - mode: disabledFor("branchNamingMode"),
501 - prefix: disabledFor("branchNamePrefix"),
502 - instructions: disabledFor("branchNameInstructions"),
503 - }}
504 - onChange={write}
530 + ) : null}
531 + <SettingsSection title="Updates">
532 + <SettingsSwitchRow
533 + icon="arrow.clockwise"
534 + label="Check provider updates"
535 + subtitle={managedSubtitle(
536 + "enableProviderUpdateChecks",
537 + projectSelected
538 + ? "Environment-wide setting. Select All projects to change it."
539 + : "Check installed provider CLIs for newer versions and fetch model catalog updates. When off, new models may not appear.",
540 + )}
541 + value={uniform("enableProviderUpdateChecks")}
542 + disabled={disabledFor("enableProviderUpdateChecks")}
543 + onValueChange={(value) => write({ enableProviderUpdateChecks: value })}
544 />
506 - </>
507 - ) : null}
508 -
509 - {props.page === "maintenance" ? (
510 - <>
511 - {!projectSelected ? (
512 - <DatabaseStorageNotice
513 - targets={selectedTargets.filter(
514 - (target) =>
515 - target.serverConfig.environment.capabilities.databaseStorage === true,
516 - )}
517 - />
518 - ) : null}
519 - {!projectSelected ? (
520 - <SettingsSection title="Manage environments">
521 - {selectedTargets.map((target) => (
522 - <SettingsRow
523 - key={target.environmentId}
524 - icon="server.rack"
525 - label={target.label}
526 - value="Server and provider updates"
527 - onPress={() =>
528 - navigation.navigate("SettingsEnvironmentDetail", {
529 - environmentId: target.environmentId,
530 - })
531 - }
532 - />
533 - ))}
534 - </SettingsSection>
535 - ) : null}
536 - <SettingsSection title="Updates">
545 + <View className="border-t border-border-subtle">
546 <SettingsSwitchRow
538 - icon="arrow.clockwise"
539 - label="Check provider updates"
547 + icon="arrow.uturn.forward"
548 + label="Continue after restart"
549 subtitle={managedSubtitle(
541 - "enableProviderUpdateChecks",
542 - projectSelected
543 - ? "Environment-wide setting. Select All projects to change it."
544 - : "Check installed provider CLIs for newer versions and fetch model catalog updates. When off, new models may not appear.",
550 + "continueThreadsAfterServerUpdate",
551 + "Resume interrupted threads after an update or restart.",
552 )}
546 - value={uniform("enableProviderUpdateChecks")}
547 - disabled={disabledFor("enableProviderUpdateChecks")}
548 - onValueChange={(value) => write({ enableProviderUpdateChecks: value })}
553 + value={uniform("continueThreadsAfterServerUpdate")}
554 + disabled={disabledFor("continueThreadsAfterServerUpdate")}
555 + onValueChange={(value) => write({ continueThreadsAfterServerUpdate: value })}
556 />
550 - <View className="border-t border-border-subtle">
551 - <SettingsSwitchRow
552 - icon="arrow.uturn.forward"
553 - label="Continue after restart"
554 - subtitle={managedSubtitle(
555 - "continueThreadsAfterServerUpdate",
556 - "Resume interrupted threads after an update or restart.",
557 - )}
558 - value={uniform("continueThreadsAfterServerUpdate")}
559 - disabled={disabledFor("continueThreadsAfterServerUpdate")}
560 - onValueChange={(value) =>
561 - write({ continueThreadsAfterServerUpdate: value })
562 - }
563 - />
564 - </View>
565 - </SettingsSection>
566 - </>
567 - ) : null}
568 - </>
569 - )}
570 - </ScrollView>
571 - </SettingsScreen>
572 - </>
557 + </View>
558 + </SettingsSection>
559 + </>
560 + ) : null}
561 + </>
562 + )}
563 + </ScrollView>
564 + </SettingsScreen>
565 );
566 }
567
apps/mobile/src/features/settings/components/SettingsEnvironmentFilterHeader.tsx
+42 -135
@@ -1,124 +1,14 @@
1 -import type { NativeStackHeaderItem } from "@react-navigation/native-stack";
1 import { resolveEnvironmentMachineKind } from "@t3tools/contracts";
3 -import { Platform } from "react-native";
2
3 import type { AppBarMenu } from "../../../components/ui/AppBar.types";
4 import { ENVIRONMENT_MACHINE_SYMBOLS } from "../../../components/EnvironmentMachineSymbol";
7 -import { NativeStackScreenOptions } from "../../../native/StackHeader";
8 -import { withNativeGlassHeaderItem } from "../../layout/native-glass-header-items";
5 import { useSettingsEnvironmentFilter } from "../settings-environment-filter";
6
11 -export function SettingsEnvironmentFilterHeader(props: {
12 - readonly trailingItems?: readonly NativeStackHeaderItem[];
13 -}) {
14 - const {
15 - availableTargets,
16 - selectedTargets,
17 - selectedIds,
18 - selectAll,
19 - toggleEnvironment,
20 - selectableProjectGroups,
21 - selectedProjectKey,
22 - selectProject,
23 - } = useSettingsEnvironmentFilter();
24 - if (Platform.OS !== "ios") return null;
25 -
26 - const filterIcon =
27 - selectedIds === null && selectedProjectKey === null
28 - ? "line.3.horizontal.decrease"
29 - : "line.3.horizontal.decrease.circle.fill";
30 - const filterVersion = JSON.stringify({
31 - selection: selectedIds === null ? null : [...selectedIds].sort(),
32 - targets: availableTargets.map((entry) => [
33 - entry.environmentId,
34 - entry.label,
35 - entry.displayUrl,
36 - resolveEnvironmentMachineKind(entry.serverConfig),
37 - ]),
38 - project: selectedProjectKey,
39 - projects: selectableProjectGroups.map((group) => [group.key, group.label]),
40 - trailingItems: props.trailingItems,
41 - });
42 -
43 - return (
44 - <NativeStackScreenOptions
45 - optionsVersion={filterVersion}
46 - options={{
47 - unstable_headerRightItems: () => [
48 - withNativeGlassHeaderItem({
49 - accessibilityLabel: "Filter settings environments and projects",
50 - icon: { name: filterIcon, type: "sfSymbol" },
51 - label: "",
52 - type: "menu",
53 - menu: {
54 - title: "Settings scope",
55 - items: [
56 - {
57 - type: "submenu",
58 - label:
59 - selectedIds === null
60 - ? "All environments"
61 - : `${selectedTargets.length} ${selectedTargets.length === 1 ? "environment" : "environments"}`,
62 - items: [
63 - {
64 - type: "action",
65 - label: "All connected environments",
66 - state: selectedIds === null ? "on" : undefined,
67 - onPress: selectAll,
68 - },
69 - ...availableTargets.map((entry) => ({
70 - type: "action" as const,
71 - label: entry.label,
72 - icon: {
73 - type: "sfSymbol" as const,
74 - name: ENVIRONMENT_MACHINE_SYMBOLS[
75 - resolveEnvironmentMachineKind(entry.serverConfig)
76 - ],
77 - },
78 - description: entry.displayUrl ?? undefined,
79 - state:
80 - selectedIds === null || selectedIds.has(entry.environmentId)
81 - ? ("on" as const)
82 - : undefined,
83 - onPress: () => toggleEnvironment(entry.environmentId),
84 - })),
85 - ],
86 - },
87 - {
88 - type: "submenu",
89 - label:
90 - selectableProjectGroups.find((group) => group.key === selectedProjectKey)
91 - ?.label ??
92 - (selectedProjectKey === null ? "All projects" : "Unavailable project"),
93 - items: [
94 - {
95 - type: "action",
96 - label: "All projects",
97 - state: selectedProjectKey === null ? "on" : undefined,
98 - onPress: () => selectProject(null),
99 - },
100 - ...selectableProjectGroups.map((group) => ({
101 - type: "action" as const,
102 - label: projectMenuLabel(group),
103 - state: selectedProjectKey === group.key ? ("on" as const) : undefined,
104 - onPress: () => selectProject(group.key),
105 - })),
106 - ],
107 - },
108 - ],
109 - },
110 - }),
111 - ...(props.trailingItems ?? []),
112 - ],
113 - }}
114 - />
115 - );
116 -}
117 -
118 -/** Android's settings scope filter, as an `AppBar` menu. */
7 +/** The settings scope filter, as an `AppBar` menu. */
8 export function useSettingsEnvironmentMenu(): AppBarMenu {
9 const {
10 availableTargets,
11 + selectedTargets,
12 selectedIds,
13 selectAll,
14 toggleEnvironment,
@@ -130,35 +20,52 @@ export function useSettingsEnvironmentMenu(): AppBarMenu {
20 title: "Filter settings environments and projects",
21 icon:
22 selectedIds === null && selectedProjectKey === null
133 - ? "line.3.horizontal.decrease.circle"
23 + ? "line.3.horizontal.decrease"
24 : "line.3.horizontal.decrease.circle.fill",
25 items: [
26 {
137 - id: "all",
138 - title: "All connected environments",
139 - selected: selectedIds === null,
140 - onPress: selectAll,
27 + id: "environments",
28 + title:
29 + selectedIds === null
30 + ? "All environments"
31 + : `${selectedTargets.length} ${selectedTargets.length === 1 ? "environment" : "environments"}`,
32 + items: [
33 + {
34 + id: "all",
35 + title: "All connected environments",
36 + selected: selectedIds === null,
37 + onPress: selectAll,
38 + },
39 + ...availableTargets.map((entry) => ({
40 + id: `environment:${entry.environmentId}`,
41 + title: entry.label,
42 + icon: ENVIRONMENT_MACHINE_SYMBOLS[resolveEnvironmentMachineKind(entry.serverConfig)],
43 + subtitle: entry.displayUrl ?? undefined,
44 + selected: selectedIds === null || selectedIds.has(entry.environmentId),
45 + onPress: () => toggleEnvironment(entry.environmentId),
46 + })),
47 + ],
48 },
142 - ...availableTargets.map((entry) => ({
143 - id: `environment:${entry.environmentId}`,
144 - title: `Environment · ${entry.label}`,
145 - icon: ENVIRONMENT_MACHINE_SYMBOLS[resolveEnvironmentMachineKind(entry.serverConfig)],
146 - subtitle: entry.displayUrl ?? undefined,
147 - selected: selectedIds === null || selectedIds.has(entry.environmentId),
148 - onPress: () => toggleEnvironment(entry.environmentId),
149 - })),
49 {
151 - id: "project:all",
152 - title: "All projects",
153 - selected: selectedProjectKey === null,
154 - onPress: () => selectProject(null),
50 + id: "projects",
51 + title:
52 + selectableProjectGroups.find((group) => group.key === selectedProjectKey)?.label ??
53 + (selectedProjectKey === null ? "All projects" : "Unavailable project"),
54 + items: [
55 + {
56 + id: "project:all",
57 + title: "All projects",
58 + selected: selectedProjectKey === null,
59 + onPress: () => selectProject(null),
60 + },
61 + ...selectableProjectGroups.map((group) => ({
62 + id: `project:${group.key}`,
63 + title: projectMenuLabel(group),
64 + selected: selectedProjectKey === group.key,
65 + onPress: () => selectProject(group.key),
66 + })),
67 + ],
68 },
156 - ...selectableProjectGroups.map((group) => ({
157 - id: `project:${group.key}`,
158 - title: `Project · ${projectMenuLabel(group)}`,
159 - selected: selectedProjectKey === group.key,
160 - onPress: () => selectProject(group.key),
161 - })),
69 ],
70 };
71 }
apps/mobile/src/features/settings/components/SettingsScreen.tsx
+13 -24
@@ -1,6 +1,6 @@
1 import { useRoute } from "@react-navigation/native";
2 import type { ReactNode } from "react";
3 -import { Platform, View } from "react-native";
3 +import { View } from "react-native";
4
5 import type { AppBarProps } from "../../../components/ui/AppBar.types";
6 import { AppBar } from "../../../components/ui/AppBar";
@@ -8,7 +8,6 @@ import { ScreenContent as SettingsScreenContent } from "../../../components/ui/S
8 import { useWorkspaceTabs } from "../../workspace/WorkspaceTabsContext";
9 import { useDeviceType } from "../../../native/native-layout-metrics";
10 import { useCompactWorkspaceTabs } from "../../workspace/useSystemWorkspaceTabBar";
11 -import { useAdaptiveWorkspaceLayout } from "../../layout/adaptive-workspace-context";
11 import { useSettingsPageBack } from "../useSettingsPageBack";
12 import {
13 ScreenScrollViewBottomInset,
@@ -18,9 +17,11 @@ import {
17 export { SettingsScreenContent };
18
19 export function SettingsScreen(
21 - props: Pick<AppBarProps, "title" | "actions" | "trailing" | "search" | "menus" | "options"> & {
20 + props: Pick<
21 + AppBarProps,
22 + "title" | "actions" | "refresh" | "trailing" | "search" | "menus" | "guardBack"
23 + > & {
24 readonly children: ReactNode;
23 - readonly formSheet?: boolean;
25 readonly workspaceRoot?: boolean;
26 },
27 ) {
@@ -28,13 +29,10 @@ export function SettingsScreen(
29 const workspace = useWorkspaceTabs();
30 const deviceType = useDeviceType();
31 const compactTabs = useCompactWorkspaceTabs();
31 - const { layout } = useAdaptiveWorkspaceLayout();
32 const back = useSettingsPageBack();
33 const cover = deviceType === "duo-folded";
34 - // Android opens Settings as a workspace tab; its root page has nothing to go back to.
35 - const workspaceRoot =
36 - props.workspaceRoot ||
37 - (Platform.OS === "android" && workspace !== null && route.name === "Settings");
34 + // Opened as a workspace tab, the Settings list has nothing to go back to.
35 + const workspaceRoot = props.workspaceRoot || (workspace !== null && route.name === "Settings");
36
37 const surfaceClassName = workspaceRoot || cover ? "bg-screen" : "bg-sheet";
38
@@ -43,26 +41,17 @@ export function SettingsScreen(
41 <AppBar
42 title={props.title}
43 actions={props.actions}
44 + refresh={props.refresh}
45 search={props.search}
47 - trailing={Platform.OS === "android" ? props.trailing : undefined}
48 - // iOS screens put their filter menus in native header items themselves.
49 - menus={Platform.OS === "android" ? props.menus : undefined}
50 - sheet={Platform.OS === "android" && props.formSheet}
46 + trailing={props.trailing}
47 + menus={props.menus}
48 onBack={workspaceRoot ? undefined : back}
52 - hideBottomBorder={!props.formSheet || Platform.OS === "android"}
53 - options={props.options}
49 + guardBack={props.guardBack}
50 + hideBottomBorder
51 />
52 <ScreenScrollViewBottomInset value={deviceType === "pad" || compactTabs ? 80 : 0}>
53 <ScreenScrollViewSurface value={surfaceClassName}>
57 - {props.formSheet && Platform.OS !== "android" ? (
58 - props.children
59 - ) : (
60 - <SettingsScreenContent
61 - insetHorizontal={Platform.OS === "android" && layout.usesSplitView}
62 - >
63 - {props.children}
64 - </SettingsScreenContent>
65 - )}
54 + <SettingsScreenContent>{props.children}</SettingsScreenContent>
55 </ScreenScrollViewSurface>
56 </ScreenScrollViewBottomInset>
57 </View>
apps/mobile/src/features/terminal/TerminalContextSheet.tsx
+2 -2
@@ -7,7 +7,7 @@ import {
7 } from "@t3tools/contracts";
8 import { formatComposerContextReference } from "@t3tools/shared/composerContextReferences";
9 import { useState } from "react";
10 -import { Platform, Pressable, ScrollView, View } from "react-native";
10 +import { Pressable, ScrollView, View } from "react-native";
11 import { useSafeAreaInsets } from "react-native-safe-area-context";
12 import { REVIEW_MONO_FONT_FAMILY } from "../review/reviewDiffRendering";
13 import { AppText as Text } from "../../components/ui/AppText";
@@ -60,7 +60,7 @@ export function TerminalContextSheet(props: {
60 <ScrollView
61 nestedScrollEnabled
62 className="flex-1"
63 - contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
63 + contentInsetAdjustmentBehavior="automatic"
64 contentContainerStyle={{ paddingHorizontal: 20, paddingTop: 12, paddingBottom: 20 }}
65 >
66 <Text className="pb-4 text-sm text-foreground-muted">
apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx
+3 -2
@@ -11,6 +11,7 @@ import { type KnownTerminalSession } from "@t3tools/client-runtime/state/termina
11 import { SymbolView } from "../../components/ui/AppSymbol";
12 import { AppBar } from "../../components/ui/AppBar";
13 import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
14 +import { useContentTopInset } from "../../components/ui/useBarInset";
15 import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
16 import { useAtomMount } from "@effect/atom-react";
17 import { useMemo, useRef, useState } from "react";
@@ -377,6 +378,7 @@ function ThreadTerminal(props: {
378 } = props.knownSessions;
379 const insets = useSafeAreaInsets();
380 const nativeColumnMetrics = useNativeColumnLayoutMetrics();
381 + const contentTopInset = useContentTopInset();
382 const navigation = useNavigation();
383 const writeTerminal = useAtomCommand(terminalEnvironment.write, "terminal write");
384 const clearTerminal = useAtomCommand(terminalEnvironment.clear, "terminal clear");
@@ -839,8 +841,7 @@ function ThreadTerminal(props: {
841 ? themeVariables["--color-card-alt"]
842 : terminalTheme.background,
843 // Measured top reservation is zero when UIKit already inset the body or moved the bar.
842 - paddingTop:
843 - Platform.OS === "ios" ? (nativeColumnMetrics?.safeArea.top ?? insets.top) : 0,
844 + paddingTop: contentTopInset,
845 paddingBottom:
846 Platform.OS === "android" && !keyboardState.isVisible ? insets.bottom : 0,
847 }}
apps/mobile/src/features/threads/DraftThreadHeader.tsx
-7
@@ -8,8 +8,6 @@ import type {
8 EnvironmentProject,
9 EnvironmentThreadShell,
10 } from "@t3tools/client-runtime/state/shell";
11 -import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
12 -import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
11 import { useEnvironmentQuery } from "../../state/query";
12 import { useEnvironmentScope } from "../../state/session";
13 import { useAtomCommand } from "../../state/use-atom-command";
@@ -23,7 +21,6 @@ export function DraftThreadHeader(props: {
21 readonly cwd: string | null;
22 }) {
23 const navigation = useNavigation();
26 - const { themeVariables } = useAppearancePreferences();
24 const environmentId = props.thread.environmentId;
25 const canReadFiles = useEnvironmentScope(environmentId, AuthFilesystemReadScope);
26 const canWriteGit = useEnvironmentScope(environmentId, AuthSourceControlWriteScope);
@@ -51,15 +48,11 @@ export function DraftThreadHeader(props: {
48 draft
49 title="New thread"
50 subtitle=""
54 - headerColor={themeVariables["--color-header"]}
55 - usesNativeHeaderGlass={NATIVE_LIQUID_GLASS_SUPPORTED}
51 hasThreadCwd={props.cwd !== null}
57 - hasWorkspaceRoot={Boolean(props.project.workspaceRoot)}
52 fileInspectorSupported={false}
53 inspectorMode={null}
54 onToggleInspector={openFiles}
55 onOpenFilesInspector={openFiles}
62 - onOpenGitInspector={requiresThread}
56 gitControls={{
57 environmentId,
58 threadId: props.thread.id,
apps/mobile/src/features/threads/GitActionProgressOverlay.tsx
+2 -14
@@ -1,13 +1,8 @@
1 import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
2 -import { HeaderHeightContext } from "@react-navigation/elements";
3 -import { useContext } from "react";
4 -import { Platform } from "react-native";
2 import Animated, { FadeIn, FadeOut, ReduceMotion } from "react-native-reanimated";
6 -import { useSafeAreaInsets } from "react-native-safe-area-context";
3 import { Toast } from "../../components/ui/Toast";
8 -import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
4 +import { useBarInset } from "../../components/ui/useBarInset";
5 import { MOBILE_MOTION } from "../../lib/designTokens";
10 -import { APP_BAR_HEIGHT } from "../../lib/layoutMetrics";
6 import type { GitActionProgress } from "../../state/use-vcs-action-state";
7
8 export function GitActionProgressOverlay(props: {
@@ -17,14 +12,7 @@ export function GitActionProgressOverlay(props: {
12 }) {
13 const { progress, onDismiss } = props;
14 const openPullRequest = props.onOpenPullRequest;
20 - const insets = useSafeAreaInsets();
21 - // Keyboard-copy feedback sits outside the screen's native header context.
22 - const headerHeight = useContext(HeaderHeightContext) ?? insets.top + APP_BAR_HEIGHT;
23 - const toolbar = useToolbarLayout();
24 - const top =
25 - Platform.OS === "android"
26 - ? toolbar.paddingTop + toolbar.height + toolbar.paddingBottom + 8
27 - : headerHeight + 8;
15 + const top = useBarInset() + 8;
16 const handlePress = () => {
17 if (progress.prUrl) {
18 void (openPullRequest
apps/mobile/src/features/threads/LinkRequestCard.tsx
+8 -11
@@ -24,7 +24,7 @@ import {
24 import * as Option from "effect/Option";
25 import * as Result from "effect/Result";
26 import { useMemo, useRef, useState } from "react";
27 -import { Modal, Platform, Pressable, ScrollView, View, type ColorValue } from "react-native";
27 +import { Pressable, ScrollView, View, type ColorValue } from "react-native";
28 import { useSafeAreaInsets } from "react-native-safe-area-context";
29
30 import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";
@@ -37,6 +37,7 @@ import { useAtomCommand } from "../../state/use-atom-command";
37 import { ListChoiceRow as SettingsChoiceRow } from "../../components/ui/ListChoiceRow";
38 import { SettingsSection } from "../settings/components/SettingsSection";
39 import { Button } from "../../components/ui/Button";
40 +import { Sheet } from "../../components/ui/Sheet";
41 import { RUNTIME_MODE_CHOICES } from "./thread-settings-options";
42
43 /** The same five levels as web's access picker: read-only, then the runtime modes. */
@@ -316,24 +317,20 @@ function LinkRequestSheet(props: {
317 };
318
319 return (
319 - <Modal
320 - animationType="slide"
321 - presentationStyle={Platform.OS === "ios" ? "pageSheet" : "fullScreen"}
320 + <Sheet
321 + title={pickMachine ? "Link a machine" : `Link ${targetName}`}
322 + onClose={props.onClose}
323 // An answer that lands after a close would still link, and would close a reopened sheet.
323 - onRequestClose={() => {
324 - if (!busy) props.onClose();
325 - }}
324 + dismissDisabled={busy}
325 >
326 <ScrollView
327 className="flex-1 bg-sheet-solid"
328 + contentInsetAdjustmentBehavior="automatic"
329 contentContainerClassName="gap-5 p-5"
330 contentContainerStyle={{ paddingBottom: insets.bottom + 20 }}
331 keyboardShouldPersistTaps="handled"
332 >
333 <View className="gap-1">
334 - <Text className="font-t3-bold text-lg text-foreground">
335 - {pickMachine ? "Link a machine" : `Link ${targetName}`}
336 - </Text>
334 <Text className="font-sans text-sm leading-5 text-foreground-muted">
335 Agents here can then launch, message and wait on threads there. It appears in that
336 machine's Connections, where it can be revoked.
@@ -457,7 +454,7 @@ function LinkRequestSheet(props: {
454 />
455 <Button label="Cancel" tone="secondary" disabled={busy} onPress={props.onClose} fullWidth />
456 </ScrollView>
460 - </Modal>
457 + </Sheet>
458 );
459 }
460
apps/mobile/src/features/threads/McpAppFullscreenScreen.tsx
+8 -16
@@ -4,11 +4,11 @@ import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell
4 import { turnItemDetailRevision } from "@t3tools/client-runtime/work-log/item-detail";
5 import { mcpAppFromToolItem } from "@t3tools/shared/toolOutput";
6 import { useEffect, useRef, useState } from "react";
7 -import { Pressable, View } from "react-native";
7 +import { View } from "react-native";
8 import { useSafeAreaInsets } from "react-native-safe-area-context";
9
10 import { AppText as Text } from "../../components/ui/AppText";
11 -import { SymbolView } from "../../components/ui/AppSymbol";
11 +import { AppBar } from "../../components/ui/AppBar";
12 import { orchestrationEnvironment } from "../../state/orchestration";
13 import { scopeThreadRef } from "@t3tools/client-runtime/environment";
14 import { useThreadShell, useThreadShells } from "../../state/entities";
@@ -108,20 +108,12 @@ export function McpAppFullscreenScreen({ route }: McpAppFullscreenScreenProps) {
108 }, [awaitingUser, focused, navigation]);
109
110 return (
111 - <View className="flex-1 bg-screen" style={{ paddingTop: insets.top }}>
112 - <View className="h-11 flex-row items-center justify-between px-3">
113 - <Text className="text-base font-semibold text-foreground" numberOfLines={1}>
114 - {app?.server ?? "App"}
115 - </Text>
116 - <Pressable
117 - accessibilityRole="button"
118 - accessibilityLabel="Exit full screen"
119 - hitSlop={8}
120 - onPress={onClose}
121 - >
122 - <SymbolView name="xmark" size={18} tintColor="gray" />
123 - </Pressable>
124 - </View>
111 + <View className="flex-1 bg-screen">
112 + <AppBar
113 + title={app?.server ?? "App"}
114 + onClose={onClose}
115 + closeAccessibilityLabel="Exit full screen"
116 + />
117 <View
118 className="flex-1"
119 style={{ paddingBottom: insets.bottom }}
apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx
+24 -84
@@ -1,7 +1,5 @@
1 import { NativeScrollView } from "../../native/NativeScrollViewMarker";
2 -import { SearchField } from "../../components/ui/SearchField";
2 import { Button } from "../../components/ui/Button";
4 -import { Toolbar } from "../../components/ui/Toolbar";
3 import * as Dialog from "../../components/ui/Dialog";
4 import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
5 import { SelectionRow } from "../../components/ui/SelectionRow";
@@ -32,15 +30,11 @@ import { AppText as Text } from "../../components/ui/AppText";
30 import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
31 import { ThemedSwitch } from "../../components/ui/ThemedSwitch";
32 import { cn } from "../../lib/cn";
35 -import { NativeStackScreenOptions } from "../../native/StackHeader";
33 import { useEnvironmentScope } from "../../state/session";
34 import { useAtomCommand } from "../../state/use-atom-command";
35 import { vcsEnvironment } from "../../state/vcs";
39 -import {
40 - createNativeMailSearchToolbarItem,
41 - NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET,
42 -} from "../layout/native-mail-search-toolbar";
43 -import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
36 +import { useSearchToolbarInset } from "../../components/ui/useBarInset";
37 +import type { AppBarSearch } from "../../components/ui/AppBar";
38 import { branchBadgeLabel, useNewTaskFlow } from "./new-task-flow-provider";
39 import { checkoutNewTaskBranch } from "./checkout-new-task-branch";
40 import { filterNewTaskBranches } from "./new-task-context-presentation";
@@ -188,15 +182,7 @@ export function NewTaskEnvironmentPickerRouteScreen() {
182 const insets = useSafeAreaInsets();
183 return (
184 <View className="flex-1 bg-sheet" collapsable={false}>
191 - <NativeStackScreenOptions
192 - options={{
193 - headerShown: Platform.OS !== "android",
194 - title: "Environment",
195 - }}
196 - />
197 - {Platform.OS === "android" ? (
198 - <AppBar embedded title="Environment" hideBottomBorder onBack={() => navigation.goBack()} />
199 - ) : null}
185 + <AppBar title="Environment" hideBottomBorder onBack={() => navigation.goBack()} />
186 <ScreenContent>
187 <ScrollView
188 contentInsetAdjustmentBehavior="automatic"
@@ -365,18 +351,25 @@ export function BranchPickerScreen(props: {
351 readonly onChangeStartFromOrigin: (value: boolean) => void;
352 };
353 }) {
368 - const searchRef = useRef<import("react-native").TextInputInstance>(null);
354 const navigation = useNavigation();
355 const insets = useSafeAreaInsets();
371 - const usesNativeMailSearchToolbar = useNativeMailSearchToolbar();
356 + const search: AppBarSearch = {
357 + value: props.query,
358 + onChangeText: props.onQueryChange,
359 + placeholder: "Find a branch",
360 + clearAccessibilityLabel: "Clear branch search",
361 + mode: "inline",
362 + compactToolbar: true,
363 + };
364 + const searchToolbarInset = useSearchToolbarInset(search);
365 const selectedBranchName =
366 props.selectedBranchName ??
367 props.branches.find((branch) => branch.current)?.name ??
368 props.branches.find((branch) => branch.isDefault)?.name ??
369 null;
370 const branchListContentStyle = {
378 - paddingBottom: usesNativeMailSearchToolbar
379 - ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 16
371 + paddingBottom: searchToolbarInset
372 + ? searchToolbarInset + 16
373 : Platform.OS === "ios"
374 ? 16
375 : Math.max(insets.bottom, 16) + 16,
@@ -425,9 +418,7 @@ export function BranchPickerScreen(props: {
418 <View
419 className="flex-1 items-center justify-center gap-3 px-4"
420 style={{
428 - marginBottom: usesNativeMailSearchToolbar
429 - ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET
430 - : 0,
421 + marginBottom: searchToolbarInset,
422 }}
423 >
424 {props.loading ? <AppActivityIndicator /> : null}
@@ -449,7 +440,7 @@ export function BranchPickerScreen(props: {
440 </ScrollView>
441 ) : (
442 <LegendList
452 - renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
443 + renderScrollComponent={NativeScrollView}
444 alwaysBounceVertical={false}
445 automaticallyAdjustsScrollIndicatorInsets
446 automaticallyAdjustKeyboardInsets={Platform.OS === "ios"}
@@ -477,66 +468,15 @@ export function BranchPickerScreen(props: {
468 />
469 );
470
480 - if (Platform.OS === "android") {
481 - return (
482 - <View className="flex-1 bg-sheet" collapsable={false}>
483 - <NativeStackScreenOptions options={{ headerShown: false }} />
484 - <AppBar embedded title={props.title} hideBottomBorder onBack={() => navigation.goBack()} />
485 - <View className="bg-header px-4 pb-3 pt-1">
486 - <SearchField
487 - inputRef={searchRef}
488 - autoFocus={false}
489 - accessibilityLabel="Find a branch"
490 - clearAccessibilityLabel="Clear branch search"
491 - onChangeText={props.onQueryChange}
492 - placeholder="Find a branch"
493 - value={props.query}
494 - />
495 - </View>
496 - <ScreenContent>{branchContent}</ScreenContent>
497 - </View>
498 - );
499 - }
500 -
471 return (
502 - <>
503 - <NativeStackScreenOptions
504 - options={{
505 - headerShown: true,
506 - title: props.title,
507 - unstable_headerToolbarItems: usesNativeMailSearchToolbar
508 - ? () => [
509 - createNativeMailSearchToolbarItem({
510 - onSearchTextChange: props.onQueryChange,
511 - placeholder: "Find a branch",
512 - searchTextChangeId: "new-task-branch-search-text",
513 - showsSearchDismissButton: true,
514 - }),
515 - ]
516 - : undefined,
517 - headerSearchBarOptions: usesNativeMailSearchToolbar
518 - ? undefined
519 - : {
520 - allowToolbarIntegration: true,
521 - autoCapitalize: "none",
522 - hideNavigationBar: false,
523 - obscureBackground: false,
524 - placeholder: "Find a branch",
525 - onChangeText: (event) => {
526 - props.onQueryChange(event.nativeEvent.text);
527 - },
528 - onCancelButtonPress: () => {
529 - props.onQueryChange("");
530 - },
531 - },
532 - }}
472 + <View className="flex-1 bg-sheet" collapsable={false}>
473 + <AppBar
474 + title={props.title}
475 + hideBottomBorder
476 + onBack={() => navigation.goBack()}
477 + search={search}
478 />
534 - {usesNativeMailSearchToolbar ? null : (
535 - <Toolbar placement="bottom">
536 - <Toolbar.SearchBarSlot />
537 - </Toolbar>
538 - )}
539 - {branchContent}
540 - </>
479 + <ScreenContent>{branchContent}</ScreenContent>
480 + </View>
481 );
482 }
apps/mobile/src/features/threads/NewTaskDraftRouteScreen.test.tsx
+4 -1
@@ -54,7 +54,10 @@ vi.mock("../../components/ui/AppText", () => ({
54 AppText: ({ children }: { children: ReactNode }) => <span>{children}</span>,
55 }));
56 vi.mock("../../components/ui/Dialog", () => ({ alert: vi.fn() }));
57 -vi.mock("../../native/StackHeader", () => ({ NativeStackScreenOptions: () => null }));
57 +vi.mock("../../components/ui/AppBar", () => ({ AppBar: () => null }));
58 +vi.mock("../workspace/useAndroidWorkspaceNavigation", () => ({
59 + useWorkspaceBackNavigation: () => () => undefined,
60 +}));
61 vi.mock("./ThreadScreenHost", () => ({
62 ThreadScreenFallback: ({ children }: { children: ReactNode }) => <>{children}</>,
63 }));
apps/mobile/src/features/threads/NewTaskDraftRouteScreen.tsx
+4 -3
@@ -30,7 +30,8 @@ import {
30 makeNewTaskBranchCheckouts,
31 } from "./new-task-branch-checkout";
32 import { liveNewTaskFlowKeys, newTaskFlowKey } from "./new-task-flow-state";
33 -import { NativeStackScreenOptions } from "../../native/StackHeader";
33 +import { AppBar } from "../../components/ui/AppBar";
34 +import { useWorkspaceBackNavigation } from "../workspace/useAndroidWorkspaceNavigation";
35
36 import { ThreadScreenFallback } from "./ThreadScreenHost";
37 import { NewTaskDraftScreen } from "./NewTaskDraftScreen";
@@ -89,6 +90,7 @@ const idleBranchCheckoutAtom = Atom.make(AsyncResult.initial<BranchCheckoutResul
90
91 export function NewTaskDraftRouteScreen({ route }: StaticScreenProps<NewTaskDraftRouteParams>) {
92 const currentRoute = useRoute();
93 + const goBack = useWorkspaceBackNavigation("threads");
94 const params = route.params ?? {};
95 const draftId = Array.isArray(params.draftId) ? params.draftId[0] : params.draftId;
96 const projects = useProjects();
@@ -197,8 +199,7 @@ export function NewTaskDraftRouteScreen({ route }: StaticScreenProps<NewTaskDraf
199 return (
200 <>
201 {preparingBranch ? (
200 - <ThreadScreenFallback>
201 - <NativeStackScreenOptions options={{ title: "New thread" }} />
202 + <ThreadScreenFallback header={<AppBar title="New thread" onBack={goBack} />}>
203 <View className="flex-1 items-center justify-center bg-screen">
204 <Text className="text-foreground">Switching branch...</Text>
205 </View>
apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
+1 -16
@@ -1,8 +1,6 @@
1 import { DraftEnvironmentControl } from "./DraftEnvironmentControl";
2 import { NativeScrollEdgeEffectsContext } from "../../native/NativeScrollViewMarker";
3 import { DraftThreadHeader } from "./DraftThreadHeader";
4 -import { threadHeaderAppearance } from "./thread-header-appearance";
5 -import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
4 import { useComposerAttachmentActions } from "../../state/use-composer-attachment-actions";
5 import { useWorkspaceBackNavigation } from "../workspace/useAndroidWorkspaceNavigation";
6 import { submittedThreadParams } from "./thread-route-state";
@@ -851,20 +849,7 @@ export function NewTaskDraftScreen(props: {
849
850 if (!flow.selectedModel) {
851 return (
854 - <ThreadScreenFallback
855 - header={
856 - <AppBar
857 - title="New thread"
858 - onBack={goBack}
859 - options={{
860 - ...threadHeaderAppearance(NATIVE_LIQUID_GLASS_SUPPORTED),
861 - unstable_headerSubtitle: undefined,
862 - unstable_headerRightItems: () => [],
863 - unstable_headerToolbarItems: () => [],
864 - }}
865 - />
866 - }
867 - >
852 + <ThreadScreenFallback header={<AppBar title="New thread" onBack={goBack} />}>
853 <View className="flex-1 justify-end gap-3 p-4">
854 {environmentControl}
855 <Text className="text-foreground-muted">
apps/mobile/src/features/threads/NewTaskRouteScreen.tsx
-1
@@ -127,7 +127,6 @@ function NewTaskHeader(props: {
127 <AppBar
128 title={props.title}
129 subtitle={props.subtitle ?? undefined}
130 - options={{ headerBackVisible: true }}
130 hideBottomBorder
131 onBack={goBack}
132 actions={
apps/mobile/src/features/threads/ThreadAgentsSheet.tsx
+1 -3
@@ -28,7 +28,6 @@ import { useVisibleSecondClock } from "./use-visible-second-clock";
28 import { SubagentStopButton } from "./SubagentStopButton";
29 import { ThreadWorkflowGroup } from "./ThreadWorkflowGroup";
30 import { ScreenContent } from "../../components/ui/ScreenContent";
31 -import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
31 import { subagentThreadTarget } from "./threadAgentsPresentation";
32
33 import { useOpenThreadInspector } from "./thread-inspector-navigation";
@@ -48,7 +47,6 @@ export function useThreadTurnSubagents(target: AgentsTarget | null): ThreadTurnS
47 }
48
49 export function ThreadAgentsSheet({ route }: StaticScreenProps<AgentsTarget>) {
51 - const { layout } = useAdaptiveWorkspaceLayout();
50 const target = route.params;
51 const navigation = useNavigation();
52 const openInspector = useOpenThreadInspector();
@@ -130,7 +128,7 @@ export function ThreadAgentsSheet({ route }: StaticScreenProps<AgentsTarget>) {
128 return (
129 <View collapsable={false} className="flex-1 bg-sheet">
130 <SheetHeader title="Agents" onClose={() => navigation.goBack()} />
133 - <ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
131 + <ScreenContent>{content}</ScreenContent>
132 </View>
133 );
134 }
apps/mobile/src/features/threads/ThreadBackgroundWorkSheet.tsx
+1 -3
@@ -15,7 +15,6 @@ import { SymbolView } from "../../components/ui/AppSymbol";
15 import { AppText as Text } from "../../components/ui/AppText";
16 import { ScreenContent } from "../../components/ui/ScreenContent";
17 import { environmentThreadShells } from "../../state/threads";
18 -import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
18
19 const KIND_LABELS = {
20 subagent: "Subagent",
@@ -27,7 +26,6 @@ const KIND_LABELS = {
26 type BackgroundWorkTarget = { readonly environmentId: EnvironmentId; readonly threadId: ThreadId };
27
28 export function ThreadBackgroundWorkSheet({ route }: StaticScreenProps<BackgroundWorkTarget>) {
30 - const { layout } = useAdaptiveWorkspaceLayout();
29 const navigation = useNavigation();
30 const insets = useSafeAreaInsets();
31 const target = route.params;
@@ -64,7 +62,7 @@ export function ThreadBackgroundWorkSheet({ route }: StaticScreenProps<Backgroun
62 return (
63 <View collapsable={false} className="flex-1 bg-sheet">
64 <SheetHeader title="Background work" onClose={() => navigation.goBack()} />
67 - <ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
65 + <ScreenContent>{content}</ScreenContent>
66 </View>
67 );
68 }
apps/mobile/src/features/threads/ThreadComposer.tsx
+4 -2
@@ -2,6 +2,7 @@ import { useSidebarWorkspaceTabs } from "../workspace/useSystemWorkspaceTabBar";
2 import { Button } from "../../components/ui/Button";
3 import * as Dialog from "../../components/ui/Dialog";
4 import type { ComposerTextPaste } from "../../native/T3ComposerEditor.types";
5 +import { useDeviceType } from "../../native/native-layout-metrics";
6 import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
7 import {
8 useAppearancePreferences,
@@ -586,8 +587,9 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
587 const isExpanded = isFocused || settingsSheetPresentation.keepsComposerExpanded;
588 const { layout, setComposerEditing } = useAdaptiveWorkspaceLayout();
589 const floatingSidebarComposer = useAndroidFloatingTabs() && layout.usesSplitView;
589 - const usesLargeControls =
590 - useSidebarWorkspaceTabs() === "picker" || (Platform.OS === "ios" && Platform.isPad);
590 + const sidebarWorkspaceTabs = useSidebarWorkspaceTabs();
591 + const deviceType = useDeviceType();
592 + const usesLargeControls = sidebarWorkspaceTabs === "picker" || deviceType === "pad";
593 const surfacePaddingVertical = usesLargeControls ? 9 : floatingSidebarComposer ? 6 : 2;
594 const [compactRowWidth, setCompactRowWidth] = useState(0);
595 const compactAttachmentLimit = compactRowWidth >= 500 ? 3 : 1;
apps/mobile/src/features/threads/ThreadDetailScreen.tsx
+2 -3
@@ -35,7 +35,6 @@ import {
35 import { useKeyboardChatComposerInset, useKeyboardScrollToEnd } from "@legendapp/list/keyboard";
36 import { resolveProviderSkillsForCwd } from "@t3tools/client-runtime/providerSkills";
37 import type { LegendListRef } from "@legendapp/list/react-native";
38 -import { HeaderHeightContext } from "@react-navigation/elements";
38 import { NativeLayoutObserver } from "../../native/NativeLayoutObserver";
39 import { deriveBottomControlInsets, type NativeLayoutMetrics } from "../../lib/reserved-regions";
40 import type {
@@ -79,7 +78,6 @@ import type { ActiveTurnComposerAction } from "@t3tools/client-runtime/state/com
78 import * as Haptics from "expo-haptics";
79 import {
80 useCallback,
82 - useContext,
81 useEffect,
82 useEffectEvent,
83 useRef,
@@ -116,6 +114,7 @@ import Animated, {
114 withTiming,
115 } from "react-native-reanimated";
116 import { useSafeAreaInsets } from "react-native-safe-area-context";
117 +import { useBarOverlap } from "../../components/ui/useBarInset";
118 import { useWorkspaceContentWidth } from "../layout/workspace-content-width";
119 import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
120 import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";
@@ -468,7 +467,7 @@ function ThreadDetailBody(
467 }
468 };
469 const windowHeight = useWindowDimensions().height;
471 - const navigationHeaderHeight = useContext(HeaderHeightContext) ?? insets.top + 44;
470 + const navigationHeaderHeight = useBarOverlap();
471 const [screenMetrics, setScreenMetrics] = useState<NativeLayoutMetrics | null>(null);
472 const columnMetrics = useNativeColumnLayoutMetrics();
473 const windowMetrics = useNativeLayoutMetrics();
apps/mobile/src/features/threads/ThreadFeed.tsx
+4 -8
@@ -95,7 +95,6 @@ import { CHAT_LIST_ANCHOR_OFFSET, resolveChatListAnchoredEndSpace } from "@t3too
95 import { imageMimeType } from "@t3tools/shared/image";
96 import { videoMimeType } from "@t3tools/shared/video";
97 import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";
98 -import { HeaderHeightContext } from "@react-navigation/elements";
98 import { useFocusEffect, useNavigation } from "@react-navigation/native";
99 import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";
100 import { useDeviceType } from "../../native/native-layout-metrics";
@@ -103,7 +102,6 @@ import { isDuoDevice } from "../../lib/device-type";
102 import {
103 memo,
104 useCallback,
106 - useContext,
105 useEffect,
106 useEffectEvent,
107 useImperativeHandle,
@@ -150,7 +148,6 @@ import { NativeScrollViewMarker } from "../../native/NativeScrollViewMarker";
148 import { useSafeAreaInsets } from "react-native-safe-area-context";
149 import Animated, { FadeIn, FadeInDown, type SharedValue } from "react-native-reanimated";
150 import { useUniwindTheme } from "../../lib/useUniwindTheme";
153 -import { IOS_NAV_BAR_HEIGHT } from "../../lib/layoutMetrics";
151 import { FONT_FAMILIES } from "../../lib/fontFamilies";
152 import { scopedThreadKey } from "../../lib/scopedEntities";
153 import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
@@ -176,6 +173,7 @@ import { getReviewSectionIdForCheckpoint } from "../review/reviewModel";
173 import { setReviewSelectedSectionId } from "../review/reviewState";
174 import { Menu } from "../../components/ui/Menu";
175 import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
176 +import { useBarInset } from "../../components/ui/useBarInset";
177 import { copyPromptLink } from "../prompt-links/prompt-link-actions";
178 import { parseReviewCommentMessageSegments } from "../review/reviewCommentSelection";
179 import {
@@ -2802,7 +2800,8 @@ export const ThreadFeed = memo(function ThreadFeed({
2800 const markdownContentWidth = Math.max(0, contentWidth - ASSISTANT_ROW_HORIZONTAL_PADDING * 2);
2801 const reviewCommentBubbleWidth = Math.min(Math.max(280, contentWidth * 0.85), contentWidth);
2802 const insets = useSafeAreaInsets();
2805 - const topContentInset = props.contentTopInset ?? insets.top + IOS_NAV_BAR_HEIGHT;
2803 + const barInset = useBarInset();
2804 + const topContentInset = props.contentTopInset ?? barInset;
2805 const bottomContentInset = props.contentBottomInset ?? 18;
2806 const usesNativeAutomaticInsets =
2807 props.usesAutomaticContentInsets === true && Platform.OS === "ios";
@@ -2812,10 +2811,7 @@ export const ThreadFeed = memo(function ThreadFeed({
2811 bottomContentInset,
2812 });
2813 // LegendList cannot see UIKit's adjustedContentInset; include header height in anchor offsets.
2815 - const navigationHeaderHeight = useContext(HeaderHeightContext);
2816 - const anchorTopInset = usesNativeAutomaticInsets
2817 - ? (navigationHeaderHeight ?? insets.top + IOS_NAV_BAR_HEIGHT)
2818 - : topContentInset;
2814 + const anchorTopInset = usesNativeAutomaticInsets ? barInset : topContentInset;
2815
2816 const theme = useUniwindTheme();
2817 const iconSubtleColor = theme["--color-icon-subtle"];
apps/mobile/src/features/threads/ThreadGitControls.android.tsx deleted
-33
@@ -1,33 +0,0 @@
1 -import type {
2 - ThreadGitControls as IosThreadGitControls,
3 - ThreadGitMenu as IosThreadGitMenu,
4 - useThreadGitRightHeaderItems as useIosThreadGitRightHeaderItems,
5 -} from "./ThreadGitControls";
6 -
7 -export type { ThreadGitMenuProps } from "./ThreadGitControls";
8 -
9 -type ThreadGitControlsProps = Parameters<typeof IosThreadGitControls>[0];
10 -const EMPTY_HEADER_ITEMS: ReturnType<typeof useIosThreadGitRightHeaderItems> = [];
11 -
12 -// oxlint-disable-next-line t3code/no-hookless-use-function -- Android stub of a hook; the iOS file calls hooks.
13 -export function useThreadGitRightHeaderItems(_props: ThreadGitControlsProps) {
14 - return EMPTY_HEADER_ITEMS;
15 -}
16 -
17 -// oxlint-disable-next-line t3code/no-hookless-use-function -- Android stub of a hook; the iOS file calls hooks.
18 -export function useThreadGitCenterHeaderItems(_props: ThreadGitControlsProps) {
19 - return EMPTY_HEADER_ITEMS;
20 -}
21 -
22 -export function ThreadGitControls(_props: ThreadGitControlsProps) {
23 - return null;
24 -}
25 -
26 -export function ThreadGitMenu(_props: Parameters<typeof IosThreadGitMenu>[0]) {
27 - return null;
28 -}
29 -
30 -// oxlint-disable-next-line t3code/no-hookless-use-function -- Android stub of a hook; the iOS file calls hooks.
31 -export function useThreadGitMenuDefinition(_props: Parameters<typeof IosThreadGitMenu>[0]) {
32 - return null;
33 -}
apps/mobile/src/features/threads/ThreadGitControls.tsx
+59 -274
@@ -1,7 +1,5 @@
1 -import { Toolbar } from "../../components/ui/Toolbar";
1 import * as Dialog from "../../components/ui/Dialog";
2 import { useOpenPullRequest } from "../../native/useOpenPullRequest";
4 -import { createNativeHeaderMenu } from "../../components/ui/nativeHeaderMenu.ios";
3 import type { AppBarMenu } from "../../components/ui/AppBar.types";
4 import {
5 AuthSourceControlWriteScope,
@@ -73,13 +71,6 @@ function compactMenuStatus(gitStatus: VcsStatusResult | null): string {
71 return parts.join(" · ");
72 }
73
76 -type HeaderItem = Record<string, unknown>;
77 -type HeaderItems = HeaderItem[];
78 -type ThreadGitHeaderActionItems = {
79 - readonly terminal: HeaderItem;
80 - readonly files: HeaderItem;
81 - readonly git: HeaderItem;
82 -};
74 type QuickActionIcon =
75 | "arrow.down.circle"
76 | "arrow.up.right.circle"
@@ -100,18 +91,12 @@ export type ThreadGitMenuProps = {
91 readonly onRunAction: (input: GitActionRequestInput) => Promise<GitRunStackedActionResult | null>;
92 };
93
103 -type ThreadGitControlsProps = ThreadGitMenuProps & {
104 - readonly auxiliaryPaneControl?: {
105 - readonly accessibilityLabel: string;
106 - readonly onPress: () => void;
107 - };
94 +export type ThreadGitControlsProps = ThreadGitMenuProps & {
95 readonly canOpenTerminal: boolean;
96 readonly canOperateTerminal: boolean;
97 readonly canOpenFiles: boolean;
98 readonly projectScripts: ReadonlyArray<ProjectScript>;
99 readonly terminalSessions: ReadonlyArray<TerminalMenuSession>;
113 - readonly showActionControls?: boolean;
114 - readonly showDirectFileControl?: boolean;
100 readonly onOpenTerminal: (terminalId?: string | null) => void;
101 readonly onOpenNewTerminal: () => void;
102 readonly onRunProjectScript: (script: ProjectScript) => Promise<void>;
@@ -233,17 +218,6 @@ function useThreadGitControlModel(props: ThreadGitMenuProps) {
218 }
219 };
220
236 - const openFiles = () => {
237 - if (props.onOpenFilesInspector) {
238 - props.onOpenFilesInspector();
239 - return;
240 - }
241 - navigation.navigate("ThreadFiles", {
242 - environmentId: String(environmentId),
243 - threadId: String(threadId),
244 - });
245 - };
246 -
221 const openReview = () => {
222 navigation.navigate("ThreadReview", {
223 environmentId: EnvironmentId.make(String(environmentId)),
@@ -265,7 +239,6 @@ function useThreadGitControlModel(props: ThreadGitMenuProps) {
239 return {
240 currentBranchLabel,
241 isRepo,
268 - openFiles,
242 openGitInspector,
243 openReview,
244 quickAction,
@@ -275,261 +248,62 @@ function useThreadGitControlModel(props: ThreadGitMenuProps) {
248 };
249 }
250
278 -function useThreadGitHeaderActionItems(props: ThreadGitControlsProps): ThreadGitHeaderActionItems {
279 - const model = useThreadGitControlModel(props);
280 -
251 +export function threadTerminalMenu(props: ThreadGitControlsProps): AppBarMenu | null {
252 + if (!props.canOpenTerminal) return null;
253 return {
282 - terminal: {
283 - accessibilityLabel: "Open terminal",
284 - disabled: !props.canOpenTerminal,
285 - icon: { name: "terminal", type: "sfSymbol" },
286 - identifier: "thread-right-terminal",
287 - label: "Terminal",
288 - menu: {
289 - items: [
290 - ...props.projectScripts.map((script) => ({
291 - description: script.command,
254 + title: "Terminal",
255 + icon: "terminal",
256 + separateBackground: false,
257 + items: [
258 + ...(props.projectScripts.length > 0
259 + ? props.projectScripts.map((script) => ({
260 + id: `script-${script.id}`,
261 + title: projectScriptMenuLabel(script),
262 + icon: projectScriptMenuIcon(script.icon),
263 + subtitle: script.command,
264 disabled: !props.canOperateTerminal,
293 - icon: { name: projectScriptMenuIcon(script.icon), type: "sfSymbol" as const },
294 - label: projectScriptMenuLabel(script),
265 onPress: () => void props.onRunProjectScript(script),
296 - type: "action" as const,
297 - })),
298 - ...(props.projectScripts.length === 0
299 - ? [
300 - {
301 - description: "This project has no saved scripts yet",
302 - disabled: true,
303 - icon: { name: "play", type: "sfSymbol" as const },
304 - label: "No project scripts",
305 - onPress: () => {},
306 - type: "action" as const,
307 - },
308 - ]
309 - : []),
310 - ...props.terminalSessions.map((session) => ({
311 - description: [
312 - getTerminalStatusLabel({
313 - status: session.status,
314 - hasRunningSubprocess: session.hasRunningSubprocess,
315 - }),
316 - basename(session.cwd),
317 - ]
318 - .filter(Boolean)
319 - .join(" · "),
320 - icon: { name: "terminal", type: "sfSymbol" as const },
321 - label: session.displayLabel,
322 - onPress: () => props.onOpenTerminal(session.terminalId),
323 - type: "action" as const,
324 - })),
325 - {
326 - description: "Start another shell for this thread",
327 - disabled: !props.canOperateTerminal,
328 - icon: { name: "plus", type: "sfSymbol" },
329 - label: "Open new terminal",
330 - onPress: props.onOpenNewTerminal,
331 - type: "action",
332 - },
333 - ],
334 - title: "Terminal",
335 - },
336 - sharesBackground: true,
337 - type: "menu",
338 - variant: "plain",
339 - },
340 - files: {
341 - accessibilityLabel: "Open files",
342 - disabled: !props.canOpenFiles,
343 - icon: { name: "folder", type: "sfSymbol" },
344 - identifier: "thread-right-files",
345 - label: "Files",
346 - onPress: model.openFiles,
347 - sharesBackground: true,
348 - type: "button",
349 - variant: "plain",
350 - },
351 - git: {
352 - accessibilityLabel: "Git actions",
353 - icon: { name: "point.topleft.down.curvedto.point.bottomright.up", type: "sfSymbol" },
354 - identifier: "thread-right-git",
355 - label: "Git",
356 - menu: {
357 - items: [
358 - {
359 - description: compactMenuStatus(props.gitStatus),
360 - disabled: true,
361 - icon: {
362 - name: "point.topleft.down.curvedto.point.bottomright.up",
363 - type: "sfSymbol",
266 + }))
267 + : [
268 + {
269 + id: "script-none",
270 + title: "No project scripts",
271 + icon: "play",
272 + subtitle: "This project has no saved scripts yet",
273 + disabled: true,
274 + onPress: () => {},
275 },
365 - label: compactMenuBranchLabel(model.currentBranchLabel),
366 - onPress: (): void => {},
367 - type: "action",
368 - },
369 - {
370 - description: model.quickActionHint ?? undefined,
371 - disabled: model.quickAction.disabled,
372 - icon: { name: model.quickActionIcon, type: "sfSymbol" },
373 - label: model.quickAction.label,
374 - onPress: (): void => void model.runQuickAction(),
375 - type: "action",
376 - },
377 - {
378 - description:
379 - props.hasThread === false
380 - ? "Available after the first message"
381 - : "Turn diffs and worktree changes",
382 - disabled: !model.isRepo || props.hasThread === false,
383 - icon: { name: "text.bubble", type: "sfSymbol" },
384 - label: "Review changes",
385 - onPress: model.openReview,
386 - type: "action",
387 - },
388 - ...(props.onMergeBack
389 - ? [
390 - {
391 - description: "Bring this thread's latest turn into its source",
392 - icon: { name: PullRequestGlyph.merged, type: "sfSymbol" as const },
393 - label: "Merge back to source",
394 - onPress: props.onMergeBack,
395 - type: "action" as const,
396 - },
397 - ]
398 - : []),
399 - {
400 - description:
401 - props.hasThread === false
402 - ? "Available after the first message"
403 - : "Commit, files, branches",
404 - disabled: props.hasThread === false,
405 - icon: { name: "ellipsis", type: "sfSymbol" },
406 - label: "More",
407 - onPress: model.openGitInspector,
408 - type: "action",
409 - },
410 - ],
411 - title: "Git",
276 + ]),
277 + ...props.terminalSessions.map((session) => ({
278 + id: `terminal-${session.terminalId}`,
279 + title: session.displayLabel,
280 + icon: "terminal",
281 + subtitle: [
282 + getTerminalStatusLabel({
283 + status: session.status,
284 + hasRunningSubprocess: session.hasRunningSubprocess,
285 + }),
286 + basename(session.cwd),
287 + ]
288 + .filter(Boolean)
289 + .join(" · "),
290 + onPress: () => props.onOpenTerminal(session.terminalId),
291 + })),
292 + {
293 + id: "terminal-new",
294 + title: "Open new terminal",
295 + icon: "plus",
296 + subtitle: "Start another shell for this thread",
297 + disabled: !props.canOperateTerminal,
298 + onPress: props.onOpenNewTerminal,
299 },
413 - sharesBackground: true,
414 - type: "menu",
415 - variant: "plain",
416 - },
300 + ],
301 };
302 }
303
420 -export function useThreadGitRightHeaderItems(props: ThreadGitControlsProps): HeaderItems {
421 - const actionItems = useThreadGitHeaderActionItems(props);
422 - return [actionItems.git, actionItems.files, actionItems.terminal] as HeaderItems;
423 -}
424 -
425 -export function useThreadGitCenterHeaderItems(props: ThreadGitControlsProps): HeaderItems {
426 - const actionItems = useThreadGitHeaderActionItems(props);
427 - return [actionItems.files, actionItems.git, actionItems.terminal] as HeaderItems;
428 -}
429 -
430 -export function ThreadGitControls(props: ThreadGitControlsProps) {
431 - const model = useThreadGitControlModel(props);
432 - const showActionControls = props.showActionControls ?? true;
433 -
434 - if (!showActionControls) {
435 - return null;
436 - }
437 -
438 - return (
439 - <Toolbar placement="right">
440 - {showActionControls && props.auxiliaryPaneControl ? (
441 - <Toolbar.Button
442 - accessibilityLabel={props.auxiliaryPaneControl.accessibilityLabel}
443 - icon="sidebar.right"
444 - onPress={props.auxiliaryPaneControl.onPress}
445 - separateBackground
446 - />
447 - ) : null}
448 - {showActionControls ? (
449 - <Toolbar.Menu
450 - accessibilityLabel="Open terminal"
451 - icon="terminal"
452 - disabled={!props.canOpenTerminal}
453 - separateBackground
454 - >
455 - {props.projectScripts.length > 0 ? (
456 - props.projectScripts.map((script) => (
457 - <Toolbar.MenuAction
458 - key={script.id}
459 - icon={projectScriptMenuIcon(script.icon)}
460 - disabled={!props.canOperateTerminal}
461 - onPress={() => void props.onRunProjectScript(script)}
462 - subtitle={script.command}
463 - >
464 - <Toolbar.Label>{projectScriptMenuLabel(script)}</Toolbar.Label>
465 - </Toolbar.MenuAction>
466 - ))
467 - ) : (
468 - <Toolbar.MenuAction
469 - icon="play"
470 - disabled
471 - onPress={() => {}}
472 - subtitle="This project has no saved scripts yet"
473 - >
474 - <Toolbar.Label>No project scripts</Toolbar.Label>
475 - </Toolbar.MenuAction>
476 - )}
477 - {props.terminalSessions.map((session) => (
478 - <Toolbar.MenuAction
479 - key={session.terminalId}
480 - icon="terminal"
481 - onPress={() => props.onOpenTerminal(session.terminalId)}
482 - subtitle={[
483 - getTerminalStatusLabel({
484 - status: session.status,
485 - hasRunningSubprocess: session.hasRunningSubprocess,
486 - }),
487 - basename(session.cwd),
488 - ]
489 - .filter(Boolean)
490 - .join(" · ")}
491 - >
492 - <Toolbar.Label>{session.displayLabel}</Toolbar.Label>
493 - </Toolbar.MenuAction>
494 - ))}
495 - <Toolbar.MenuAction
496 - icon="plus"
497 - disabled={!props.canOperateTerminal}
498 - onPress={props.onOpenNewTerminal}
499 - subtitle="Start another shell for this thread"
500 - >
501 - <Toolbar.Label>Open new terminal</Toolbar.Label>
502 - </Toolbar.MenuAction>
503 - </Toolbar.Menu>
504 - ) : null}
505 - {showActionControls && props.showDirectFileControl ? (
506 - <Toolbar.Button
507 - accessibilityLabel="Open files"
508 - disabled={!props.canOpenFiles}
509 - icon="folder"
510 - onPress={model.openFiles}
511 - separateBackground
512 - />
513 - ) : null}
514 - {showActionControls ? createNativeHeaderMenu(threadGitMenuDefinition(props, model)) : null}
515 - </Toolbar>
516 - );
517 -}
518 -
519 -export function ThreadGitMenu(props: ThreadGitMenuProps) {
520 - const menu = useThreadGitMenuDefinition(props);
521 - return menu ? createNativeHeaderMenu(menu) : null;
522 -}
523 -
524 -/** Returns menu data because native toolbars serialize direct items rather than rendering component children. */
304 +/** The thread's git menu, shared by the thread bar and Review. */
305 export function useThreadGitMenuDefinition(props: ThreadGitMenuProps): AppBarMenu | null {
526 - return threadGitMenuDefinition(props, useThreadGitControlModel(props));
527 -}
528 -
529 -function threadGitMenuDefinition(
530 - props: ThreadGitMenuProps,
531 - model: ReturnType<typeof useThreadGitControlModel>,
532 -): AppBarMenu {
306 + const model = useThreadGitControlModel(props);
307 return {
308 title: "Git controls",
309 icon: "point.topleft.down.curvedto.point.bottomright.up",
@@ -564,6 +338,17 @@ function threadGitMenuDefinition(
338 : "Turn diffs and worktree changes",
339 onPress: model.openReview,
340 },
341 + ...(props.onMergeBack
342 + ? [
343 + {
344 + id: "git-merge-back",
345 + title: "Merge back to source",
346 + icon: PullRequestGlyph.merged,
347 + subtitle: "Bring this thread's latest turn into its source",
348 + onPress: props.onMergeBack,
349 + },
350 + ]
351 + : []),
352 {
353 id: "git-more",
354 title: "More",
apps/mobile/src/features/threads/ThreadHeader.tsx
+65 -96
@@ -1,108 +1,77 @@
1 -import { useMemo } from "react";
1 import { AppBar } from "../../components/ui/AppBar";
2 import { ScreenHeaderButton } from "../../components/ui/ScreenHeaderButton";
4 -import type { AppBarAction } from "../../components/ui/AppBar.types";
3 +import type { AppBarAction, AppBarMenu } from "../../components/ui/AppBar.types";
4 import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
5 import type { ThreadInspectorMode } from "./thread-inspector-navigation";
7 -import { useThreadHeaderOptions } from "./useThreadHeaderOptions";
6 import { useWorkspaceBackNavigation } from "../workspace/useAndroidWorkspaceNavigation";
9 -import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
7 +import {
8 + threadTerminalMenu,
9 + useThreadGitMenuDefinition,
10 + type ThreadGitControlsProps,
11 +} from "./ThreadGitControls";
12
11 -export function ThreadHeader(
12 - props: Parameters<typeof useThreadHeaderOptions>[0] & {
13 - readonly hasThreadCwd: boolean;
14 - readonly hasWorkspaceRoot: boolean;
15 - readonly fileInspectorSupported: boolean;
16 - readonly inspectorMode: ThreadInspectorMode | null;
17 - readonly onToggleInspector: () => void;
18 - readonly onOpenGitInspector: () => void;
19 - readonly onOpenFilesInspector: () => void;
20 - },
21 -) {
13 +export function ThreadHeader(props: {
14 + readonly title: string;
15 + readonly subtitle: string;
16 + readonly gitControls: ThreadGitControlsProps;
17 + readonly onReturnToThread?: () => void;
18 + readonly draft?: boolean;
19 + readonly hasThreadCwd: boolean;
20 + readonly fileInspectorSupported: boolean;
21 + readonly inspectorMode: ThreadInspectorMode | null;
22 + readonly onToggleInspector: () => void;
23 + readonly onOpenFilesInspector: () => void;
24 +}) {
25 const goBack = useWorkspaceBackNavigation("threads");
23 - const { layout, panes, toggleAuxiliaryPane, composerKeyboardActive } =
26 + const { panes, toggleAuxiliaryPane, composerKeyboardActive, startNewTask } =
27 useAdaptiveWorkspaceLayout();
25 - const { onOpenTerminal, onMergeBack } = props.gitControls;
26 - const native = useThreadHeaderOptions(props);
27 - const androidHeaderActions = useMemo<ReadonlyArray<AppBarAction>>(() => {
28 - const actions: AppBarAction[] = [];
29 - if (props.onReturnToThread) {
30 - actions.push({
31 - accessibilityLabel: "Return to chat",
32 - icon: "chevron.left",
33 - onPress: props.onReturnToThread,
34 - });
35 - }
36 - if (props.hasThreadCwd) {
37 - const filesVisible = props.inspectorMode === "files" && panes.auxiliaryPaneVisible;
38 - actions.push({
39 - accessibilityLabel: filesVisible ? "Close files" : "Open files",
40 - selected: filesVisible,
41 - icon: "folder",
42 - onPress: filesVisible ? toggleAuxiliaryPane : props.onOpenFilesInspector,
43 - });
44 - }
45 - if (props.hasWorkspaceRoot && props.gitControls.canOpenTerminal) {
46 - actions.push({
47 - accessibilityLabel: "Open terminal",
48 - icon: "terminal",
49 - onPress: () => onOpenTerminal(null),
50 - });
51 - }
52 - actions.push({
53 - accessibilityLabel: "Open git controls",
54 - icon: "point.topleft.down.curvedto.point.bottomright.up",
55 - onPress: props.onOpenGitInspector,
56 - });
57 - if (onMergeBack) {
58 - actions.push({
59 - accessibilityLabel: "Merge back to source",
60 - icon: PullRequestGlyph.merged,
61 - onPress: onMergeBack,
62 - });
63 - }
64 - return actions;
65 - }, [
66 - props.inspectorMode,
67 - panes.auxiliaryPaneVisible,
68 - props.onOpenFilesInspector,
69 - onOpenTerminal,
70 - onMergeBack,
71 - props.onOpenGitInspector,
72 - toggleAuxiliaryPane,
73 - props.onReturnToThread,
74 - props.hasThreadCwd,
75 - props.hasWorkspaceRoot,
76 - props.gitControls.canOpenTerminal,
77 - ]);
28 + const gitMenu = useThreadGitMenuDefinition(props.gitControls);
29 + const terminalMenu = threadTerminalMenu(props.gitControls);
30 + const filesVisible = props.inspectorMode === "files" && panes.auxiliaryPaneVisible;
31 + const inspectorVisible = props.inspectorMode !== null && panes.auxiliaryPaneVisible;
32 + const actions: AppBarAction[] = props.hasThreadCwd
33 + ? [
34 + {
35 + accessibilityLabel: filesVisible ? "Close files" : "Open files",
36 + icon: "folder",
37 + selected: filesVisible,
38 + disabled: !props.gitControls.canOpenFiles,
39 + separateBackground: false,
40 + onPress: filesVisible ? toggleAuxiliaryPane : props.onOpenFilesInspector,
41 + },
42 + ]
43 + : [];
44 + const menus = [gitMenu, terminalMenu].filter((menu): menu is AppBarMenu => menu !== null);
45
46 return (
80 - <>
81 - <AppBar
82 - title={props.title}
83 - subtitle={props.subtitle}
84 - options={native.options}
85 - optionsVersion={native.optionsVersion}
86 - trailing={
87 - props.fileInspectorSupported && props.hasThreadCwd ? (
88 - <ScreenHeaderButton
89 - accessibilityLabel={
90 - props.inspectorMode !== null && panes.auxiliaryPaneVisible
91 - ? "Hide inspector"
92 - : "Show inspector"
93 - }
94 - icon="sidebar.right"
95 - selected={props.inspectorMode !== null && panes.auxiliaryPaneVisible}
96 - onPress={props.onToggleInspector}
97 - />
98 - ) : null
99 - }
100 - onBack={layout.usesSplitView ? undefined : goBack}
101 - actions={androidHeaderActions}
102 - hideBottomBorder
103 - compact={composerKeyboardActive}
104 - />
105 - {native.fallback}
106 - </>
47 + <AppBar
48 + title={props.title}
49 + subtitle={props.subtitle}
50 + onBackToList={goBack}
51 + onCompose={props.draft ? undefined : startNewTask}
52 + backInSplitView={
53 + props.onReturnToThread
54 + ? {
55 + accessibilityLabel: "Return to chat",
56 + icon: "chevron.left",
57 + onPress: props.onReturnToThread,
58 + }
59 + : undefined
60 + }
61 + actions={actions}
62 + menus={menus}
63 + trailing={
64 + props.fileInspectorSupported && props.hasThreadCwd ? (
65 + <ScreenHeaderButton
66 + accessibilityLabel={inspectorVisible ? "Hide inspector" : "Show inspector"}
67 + icon="sidebar.right"
68 + selected={inspectorVisible}
69 + onPress={props.onToggleInspector}
70 + />
71 + ) : null
72 + }
73 + hideBottomBorder
74 + compact={composerKeyboardActive}
75 + />
76 );
77 }
apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+32 -130
@@ -19,8 +19,7 @@ import { THREAD_SIDEBAR_ROW_LAYOUT } from "./threadListAnimations";
19 import type { MenuAction } from "@react-native-menu/menu";
20 import { useAtomValue } from "@effect/atom-react";
21 import { useMemo, useRef, useState } from "react";
22 -import type { LayoutChangeEvent, TextInputInstance } from "react-native";
23 -import { Platform, StyleSheet, TextInput, View } from "react-native";
22 +import { Platform, StyleSheet, View } from "react-native";
23 import { GestureDetector, useNativeGesture } from "react-native-gesture-handler";
24 import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
25 import { FLOATING_TABS } from "../workspace/floating-workspace-tabs";
@@ -28,9 +27,6 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
27 import type { SearchBarCommands } from "react-native-screens";
28
29 import { AppText as Text } from "../../components/ui/AppText";
31 -import { CompactBrandTitle } from "../../components/CompactBrandTitle";
32 -import { Menu } from "../../components/ui/Menu";
33 -import { SymbolView } from "../../components/ui/AppSymbol";
30 import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
31 import { NativeStackScreenOptions } from "../../native/StackHeader";
32 import { scopedProjectKey, scopedThreadKey } from "../../lib/scopedEntities";
@@ -55,14 +51,9 @@ import { buildHomeProjectScopes } from "../home/homeThreadList";
51 import { SwipeableScrollGateProvider, useSwipeableScrollGate } from "../home/thread-swipe-actions";
52 import { usePendingTaskListActions } from "../home/usePendingTaskListActions";
53 import { useThreadListActions } from "../home/useThreadListActions";
58 -import {
59 - getConnectionAwareBrandHeaderOptions,
60 - WorkspaceConnectionTitle,
61 -} from "../home/WorkspaceConnectionTitle";
62 -import { SidebarHeaderActions } from "./sidebar-header-actions";
54 +import { getConnectionAwareBrandHeaderOptions } from "../home/WorkspaceConnectionTitle";
55 import { ThreadListToolbar } from "../home/ThreadListToolbar";
56 import { useFabScroll } from "../home/FabScrollContext";
65 -import { SidebarFilterButton } from "./sidebar-filter-button";
57 import { createSidebarHeaderItems } from "./sidebar-native-header-items";
58 import { getCompactBrandHeaderOptions } from "../../components/CompactBrandTitle";
59 import { StandaloneStack } from "../layout/nested-stacks";
@@ -97,8 +88,6 @@ type SidebarListItem =
88 readonly state?: "loading" | "failed";
89 };
90
100 -const SIDEBAR_STICKY_HEADER_HEIGHT = 106;
101 -
91 interface ThreadNavigationSidebarProps {
92 readonly width: number;
93 readonly visible: boolean;
@@ -163,7 +152,6 @@ function ThreadNavigationSidebarPane(
152 const threads = useNavigationThreadShells();
153 const { environments: workspaceEnvironments, state: catalogState } = useWorkspaceState();
154 const { savedConnectionsById } = useSavedRemoteConnections();
166 - const searchInputRef = useRef<TextInputInstance>(null);
155 const searchBarRef = useRef<SearchBarCommands>(null);
156 const openSwipeableRef = useRef<SwipeableMethods | null>(null);
157 const sidebarScrollGesture = useNativeGesture();
@@ -420,13 +408,6 @@ function ThreadNavigationSidebarPane(
408 }
409 };
410
423 - const [measuredHeaderHeight, setMeasuredHeaderHeight] = useState<number | null>(null);
424 - const stickyHeaderHeight = measuredHeaderHeight ?? insets.top + SIDEBAR_STICKY_HEADER_HEIGHT;
425 - const topListInset = stickyHeaderHeight + 6;
426 - const handleStickyHeaderLayout = (event: LayoutChangeEvent) => {
427 - const nextHeight = event.nativeEvent.layout.height;
428 - setMeasuredHeaderHeight((current) => (current === nextHeight ? current : nextHeight));
429 - };
411 const handleSwipeableWillOpen = (methods: SwipeableMethods) => {
412 if (openSwipeableRef.current !== methods) {
413 openSwipeableRef.current?.close();
@@ -490,14 +471,8 @@ function ThreadNavigationSidebarPane(
471 return false;
472 };
473 const focusSearch = () => {
493 - if (Platform.OS === "android") return false;
494 - const focus = () => {
495 - if (props.nativeChrome) {
496 - searchBarRef.current?.focus();
497 - return;
498 - }
499 - searchInputRef.current?.focus();
500 - };
474 + if (!props.nativeChrome) return false;
475 + const focus = () => searchBarRef.current?.focus();
476 if (!props.visible) {
477 props.onRequestVisibility();
478 setTimeout(focus, 240);
@@ -738,7 +713,7 @@ function ThreadNavigationSidebarPane(
713 <SwipeableScrollGateProvider enabled={swipeEnabled}>
714 <GestureDetector gesture={sidebarScrollGesture}>
715 <AnimatedLegendList
741 - renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
716 + renderScrollComponent={NativeScrollView}
717 itemLayoutAnimation={THREAD_SIDEBAR_ROW_LAYOUT}
718 data={listItems}
719 drawDistance={500}
@@ -754,7 +729,6 @@ function ThreadNavigationSidebarPane(
729 }
730 contentContainerStyle={[
731 styles.threadListContent,
757 - Platform.OS === "android" ? { paddingHorizontal: 0 } : null,
732 {
733 paddingBottom: Math.max(insets.bottom, 16) + 16,
734 paddingTop: 6,
@@ -777,36 +751,26 @@ function ThreadNavigationSidebarPane(
751 );
752 }
753
754 + // Android: the bar is the floating ThreadListToolbar below the list.
755 return (
781 - <View
782 - testID="thread-navigation-sidebar"
783 - className={
784 - Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 border-r border-border bg-drawer"
785 - }
786 - // Android fills its pane, which animates its width while a hinge resizes the split.
787 - style={Platform.OS === "android" ? undefined : { width: props.width }}
788 - >
756 + <View testID="thread-navigation-sidebar" className="flex-1 bg-header">
757 <View
758 className="flex-1"
791 - style={
792 - Platform.OS === "android"
793 - ? {
794 - marginHorizontal: 4,
795 - paddingBottom: insets.bottom,
796 - backgroundColor: drawerColor,
797 - borderTopLeftRadius: 28,
798 - borderTopRightRadius: 28,
799 - overflow: "hidden",
800 - }
801 - : { paddingBottom: insets.bottom }
802 - }
759 + style={{
760 + marginHorizontal: 4,
761 + paddingBottom: insets.bottom,
762 + backgroundColor: drawerColor,
763 + borderTopLeftRadius: 28,
764 + borderTopRightRadius: 28,
765 + overflow: "hidden",
766 + }}
767 >
804 - {Platform.OS === "android" && listItems.length === 0 ? (
768 + {listItems.length === 0 ? (
769 <View className="flex-1 items-center justify-center">{listEmpty}</View>
770 ) : (
771 <SwipeableScrollGateProvider enabled={swipeEnabled}>
772 <GestureDetector gesture={sidebarScrollGesture}>
809 - {/* 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. */}
773 + {/* oxlint-disable-next-line t3code/require-registered-list-scroll -- The Android sidebar has no native header to register with. */}
774 <AnimatedLegendList
775 itemLayoutAnimation={THREAD_SIDEBAR_ROW_LAYOUT}
776 data={listItems}
@@ -817,19 +781,12 @@ function ThreadNavigationSidebarPane(
781 itemsAreEqual={sidebarItemsAreEqual}
782 keyExtractor={(item) => item.key}
783 renderItem={renderListItem}
820 - contentContainerStyle={[
821 - styles.threadListContent,
822 - Platform.OS === "android" ? { paddingHorizontal: 0 } : null,
823 - {
824 - paddingBottom:
825 - Platform.OS === "android"
826 - ? floatingTabsEnabled
827 - ? FLOATING_TABS.bottom + FLOATING_TABS.edge + fabSize
828 - : Math.max(insets.bottom, 16) + fabClearance - insets.bottom
829 - : 16 + insets.bottom,
830 - paddingTop: Platform.OS === "android" ? 6 : topListInset,
831 - },
832 - ]}
784 + contentContainerStyle={{
785 + paddingBottom: floatingTabsEnabled
786 + ? FLOATING_TABS.bottom + FLOATING_TABS.edge + fabSize
787 + : Math.max(insets.bottom, 16) + fabClearance - insets.bottom,
788 + paddingTop: 6,
789 + }}
790 keyboardDismissMode="on-drag"
791 keyboardShouldPersistTaps="handled"
792 {...scrollGateHandlers}
@@ -843,70 +800,15 @@ function ThreadNavigationSidebarPane(
800 </SwipeableScrollGateProvider>
801 )}
802 </View>
846 -
847 - {Platform.OS === "android" ? (
848 - <ThreadListToolbar
849 - searchQuery={props.searchQuery}
850 - onSearchQueryChange={props.onSearchQueryChange}
851 - filterActions={listMenuActions}
852 - filterCustomized={filterCustomized}
853 - onFilterSelect={(event) => handleListMenuAction({ nativeEvent: { event } })}
854 - onOpenEnvironments={props.onOpenEnvironmentSettings}
855 - onRequestVisibility={props.onRequestVisibility}
856 - />
857 - ) : (
858 - <View
859 - className="absolute inset-x-0 top-0 z-[4] bg-drawer"
860 - collapsable={false}
861 - onLayout={handleStickyHeaderLayout}
862 - pointerEvents="auto"
863 - style={{ paddingTop: insets.top }}
864 - >
865 - <View className="h-[50px] flex-row items-end gap-0.5 pr-2 pl-5">
866 - <WorkspaceConnectionTitle
867 - grow
868 - onPress={props.onOpenEnvironmentSettings}
869 - size="pageTitle"
870 - brand={
871 - <View className="h-11 flex-1 justify-center">
872 - <CompactBrandTitle allowFontScaling={false} />
873 - </View>
874 - }
875 - />
876 - <View className="flex-row items-center gap-2.5">
877 - <Menu actions={listMenuActions} onPressAction={handleListMenuAction}>
878 - <SidebarFilterButton accessibilityLabel="Filter threads" icon={filterIcon} />
879 - </Menu>
880 - <SidebarHeaderActions onOpenSettings={props.onOpenSettings} />
881 - </View>
882 - </View>
883 -
884 - <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]">
885 - <SymbolView
886 - name="magnifyingglass"
887 - size={15}
888 - tintColorClassName="accent-drawer-foreground-muted"
889 - type="monochrome"
890 - />
891 - <TextInput
892 - ref={searchInputRef}
893 - accessibilityLabel="Search threads"
894 - autoCapitalize="none"
895 - autoCorrect={false}
896 - clearButtonMode="while-editing"
897 - onChangeText={props.onSearchQueryChange}
898 - placeholder="Search"
899 - placeholderTextColorClassName="accent-placeholder"
900 - selectionColorClassName={undefined}
901 - cursorColorClassName={undefined}
902 - selectionHandleColorClassName={undefined}
903 - returnKeyType="search"
904 - className="h-[34px] flex-1 px-0 py-0 font-sans text-base text-drawer-foreground"
905 - value={props.searchQuery}
906 - />
907 - </View>
908 - </View>
909 - )}
803 + <ThreadListToolbar
804 + searchQuery={props.searchQuery}
805 + onSearchQueryChange={props.onSearchQueryChange}
806 + filterActions={listMenuActions}
807 + filterCustomized={filterCustomized}
808 + onFilterSelect={(event) => handleListMenuAction({ nativeEvent: { event } })}
809 + onOpenEnvironments={props.onOpenEnvironmentSettings}
810 + onRequestVisibility={props.onRequestVisibility}
811 + />
812 <ThreadUndoNotice visible={props.visible} />
813 </View>
814 );
apps/mobile/src/features/threads/ThreadPullRequestsSheet.tsx
+5 -29
@@ -4,14 +4,11 @@ import { useMemo } from "react";
4 import { Platform, View } from "react-native";
5 import { useSafeAreaInsets } from "react-native-safe-area-context";
6
7 -import { AppBar } from "../../components/ui/AppBar";
7 import { AppText as Text } from "../../components/ui/AppText";
8 import { ScreenContent } from "../../components/ui/ScreenContent";
9 import { SheetHeader } from "../../components/ui/SheetHeader";
11 -import { Toolbar } from "../../components/ui/Toolbar";
10 import { useOpenPullRequest } from "../../native/useOpenPullRequest";
11 import { useThreadSelection } from "../../state/use-thread-selection";
14 -import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
12 import {
13 LinkedPullRequestRow,
14 linkedPullRequestKey,
@@ -22,7 +19,6 @@ import { useLinkedPullRequestActions } from "./useLinkedPullRequestActions";
19 export function ThreadPullRequestsSheet(
20 _props: StaticScreenProps<{ readonly environmentId: string; readonly threadId: string }>,
21 ) {
25 - const { layout } = useAdaptiveWorkspaceLayout();
22 const navigation = useNavigation();
23 const insets = useSafeAreaInsets();
24 const { selectedThread, selectedThreadProject, selectedEnvironmentRuntime } =
@@ -67,7 +63,7 @@ export function ThreadPullRequestsSheet(
63 recycleItems
64 alwaysBounceVertical
65 style={{ flex: 1 }}
70 - contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
66 + contentInsetAdjustmentBehavior="automatic"
67 showsVerticalScrollIndicator={false}
68 contentContainerStyle={{
69 paddingBottom: Math.max(insets.bottom, 18) + 18,
@@ -89,31 +85,11 @@ export function ThreadPullRequestsSheet(
85 </View>
86 );
87
92 - if (Platform.OS === "ios") {
93 - return (
94 - <View collapsable={false} className="flex-1 bg-sheet">
95 - <SheetHeader presentation="native" title={title} onClose={() => navigation.goBack()} />
96 - {actions.canLink ? (
97 - <Toolbar placement="right">
98 - <Toolbar.Button
99 - icon="plus"
100 - accessibilityLabel={`Link ${singular}`}
101 - onPress={actions.promptLink}
102 - />
103 - </Toolbar>
104 - ) : null}
105 - {content}
106 - </View>
107 - );
108 - }
109 -
88 return (
111 - <View collapsable={false} className="flex-1 bg-header">
112 - <AppBar
113 - sheet
89 + <View collapsable={false} className="flex-1 bg-sheet">
90 + <SheetHeader
91 title={title}
115 - hideBottomBorder
116 - onBack={() => navigation.goBack()}
92 + onClose={() => navigation.goBack()}
93 actions={
94 actions.canLink
95 ? [
@@ -126,7 +102,7 @@ export function ThreadPullRequestsSheet(
102 : undefined
103 }
104 />
129 - <ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
105 + <ScreenContent>{content}</ScreenContent>
106 </View>
107 );
108 }
apps/mobile/src/features/threads/ThreadQueueControl.tsx
+1 -3
@@ -34,7 +34,6 @@ import { assetImageSource } from "../../lib/assetImageSource";
34 import { beginQueuedRunEdit, useQueuedRunEdit } from "../../state/queued-run-edit";
35 import { environmentThreadDetails, threadEnvironment } from "../../state/threads";
36 import { useAtomCommand } from "../../state/use-atom-command";
37 -import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
37 import {
38 REMOVE_QUEUED_MESSAGE_ACCESSIBILITY_LABEL,
39 buildCancelQueuedRunCommand,
@@ -117,7 +116,6 @@ function QueuedRunSender(props: {
116 }
117
118 export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
120 - const { layout } = useAdaptiveWorkspaceLayout();
119 const theme = useUniwindTheme();
120 const target = route.params;
121 const navigation = useNavigation();
@@ -362,7 +360,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
360 <GestureHandlerRootView style={{ flex: 1 }}>
361 <View collapsable={false} className="flex-1 bg-sheet">
362 <SheetHeader title="Queued" onClose={() => navigation.goBack()} />
365 - <ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
363 + <ScreenContent>{content}</ScreenContent>
364 </View>
365 </GestureHandlerRootView>
366 );
apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+31 -43
@@ -12,7 +12,15 @@ import {
12 useRoute,
13 type StaticScreenProps,
14 } from "@react-navigation/native";
15 -import { useEffect, useEffectEvent, useRef, useState, type ReactNode } from "react";
15 +import {
16 + createContext,
17 + use,
18 + useEffect,
19 + useEffectEvent,
20 + useRef,
21 + useState,
22 + type ReactNode,
23 +} from "react";
24 import * as Option from "effect/Option";
25 import {
26 AuthOrchestrationOperateScope,
@@ -30,7 +38,6 @@ import {
38 projectScriptTerminalInput,
39 resolveProjectScripts,
40 } from "@t3tools/shared/projectScripts";
33 -import { Platform } from "react-native";
41 import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
42 import { useConnectionsReady } from "../../state/workspace";
43 import { useEnvironmentShellReadiness } from "../../state/shell";
@@ -88,7 +95,6 @@ import { threadEnvironment } from "../../state/threads";
95 import { EMPTY_ENVIRONMENT_THREAD_STATE } from "@t3tools/client-runtime/state/threads";
96 import { useProjects } from "../../state/entities";
97 import { projectThreadContentPresentation } from "./threadContentPresentation";
91 -import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
98 import { Inspector, useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
99 import { ThreadFileNavigatorPane } from "../files/thread-file-navigator-pane";
100 import { InspectorSheetContext } from "../layout/workspace-inspector-sheet";
@@ -120,34 +126,29 @@ function firstRouteParam(value: string | string[] | undefined): string | null {
126 return first === undefined || first.trim().length === 0 ? null : first;
127 }
128
129 +// The inspector pane's bar belongs to ThreadInspectorHeader; the fallback must not draw its own.
130 +const InspectorHeaderShownContext = createContext(false);
131 +
132 function ThreadRouteFallbackLayout(props: { readonly children: ReactNode }) {
133 const goBack = useWorkspaceBackNavigation("threads");
125 - const { layout } = useAdaptiveWorkspaceLayout();
126 - const { themeVariables } = useAppearancePreferences();
127 - if (Platform.OS !== "android")
128 - return <ThreadScreenFallback>{props.children}</ThreadScreenFallback>;
129 -
134 + const inspectorHeaderShown = use(InspectorHeaderShownContext);
135 return (
131 - <>
132 - <AppBar
133 - title="Thread"
134 - options={{ contentStyle: { backgroundColor: themeVariables["--color-header"] } }}
135 - onBack={layout.usesSplitView ? undefined : goBack}
136 - hideBottomBorder
137 - />
138 - <ThreadScreenFallback>{props.children}</ThreadScreenFallback>
139 - </>
136 + <ThreadScreenFallback
137 + header={
138 + inspectorHeaderShown ? undefined : (
139 + <AppBar title="Thread" onBackToList={goBack} hideBottomBorder />
140 + )
141 + }
142 + >
143 + {props.children}
144 + </ThreadScreenFallback>
145 );
146 }
147
148 function OpeningThreadLoadingScreen() {
149 return (
150 <ThreadRouteFallbackLayout>
146 - <LoadingScreen
147 - message="Opening thread…"
148 - messagePlacement="above-spinner"
149 - embedded={Platform.OS === "android"}
150 - />
151 + <LoadingScreen message="Opening thread…" messagePlacement="above-spinner" embedded />
152 </ThreadRouteFallbackLayout>
153 );
154 }
@@ -265,17 +266,18 @@ function LiveThreadRouteController(props: ThreadRouteScreenProps) {
266 if (routeConnectionState !== "connected" && errorBeforeConnected !== detailError) {
267 setErrorBeforeConnected(detailError);
268 }
268 - const withInspectorHeader = (content: ReactNode) => (
269 - <>
270 - {props.inspectorPresentation ? (
269 + const withInspectorHeader = (content: ReactNode) =>
270 + props.inspectorPresentation ? (
271 + <InspectorHeaderShownContext value>
272 <ThreadInspectorHeader
273 title={selectedThread?.title ?? "Thread"}
274 {...props.inspectorPresentation}
275 />
275 - ) : null}
276 - {content}
277 - </>
278 - );
276 + {content}
277 + </InspectorHeaderShownContext>
278 + ) : (
279 + content
280 + );
281
282 if (environmentId === null || threadIdRaw === null) {
283 return withInspectorHeader(<OpeningThreadLoadingScreen />);
@@ -340,8 +342,6 @@ function ThreadRouteContent(
342 readonly selectedThreadDetailState: ReturnType<typeof useSelectedThreadDetailState>;
343 },
344 ) {
343 - const { themeVariables } = useAppearancePreferences();
344 - const headerColor = themeVariables["--color-header"];
345 const { fileInspector, layout, panes, showInspector, toggleAuxiliaryPane } =
346 useAdaptiveWorkspaceLayout();
347 const { connectionState } = useRemoteConnectionStatus();
@@ -779,13 +779,6 @@ function ThreadRouteContent(
779 const threadGitControlProps = {
780 environmentId: environmentIdRaw ?? "",
781 threadId: threadId ?? "",
782 - auxiliaryPaneControl:
783 - !layout.usesSplitView && fileInspector.supported && selectedThreadCwd !== null
784 - ? {
785 - accessibilityLabel: "Toggle inspector",
786 - onPress: handleToggleInspector,
787 - }
788 - : undefined,
782 onOpenFilesInspector: selectedThreadCwd !== null ? handleOpenFilesInspector : undefined,
783 onOpenGitInspector: handleOpenGitInspector,
784 onMergeBack:
@@ -806,7 +799,6 @@ function ThreadRouteContent(
799 )
800 : [],
801 terminalSessions: terminalMenuSessions,
809 - showDirectFileControl: layout.usesSplitView,
802 onOpenTerminal: handleOpenTerminal,
803 onOpenNewTerminal: handleOpenNewTerminal,
804 onRunProjectScript: handleRunProjectScript,
@@ -969,15 +961,11 @@ function ThreadRouteContent(
961 <ThreadHeader
962 title={selectedThread.title}
963 subtitle={headerSubtitle}
972 - headerColor={headerColor}
973 - usesNativeHeaderGlass={usesNativeHeaderGlass}
964 gitControls={threadGitControlProps}
965 hasThreadCwd={selectedThreadCwd !== null}
976 - hasWorkspaceRoot={Boolean(selectedThreadProject?.workspaceRoot)}
966 fileInspectorSupported={fileInspector.supported}
967 inspectorMode={inspectorMode}
968 onToggleInspector={handleToggleInspector}
980 - onOpenGitInspector={handleOpenGitInspector}
969 onOpenFilesInspector={handleOpenFilesInspector}
970 onReturnToThread={props.onReturnToThread}
971 />
apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
+58 -236
@@ -2,8 +2,6 @@ import {
2 getPromptControlledTraits,
3 getTraitSelectChange,
4 } from "@t3tools/client-runtime/model-traits";
5 -import { SheetHeader } from "../../components/ui/SheetHeader";
6 -import { Toolbar } from "../../components/ui/Toolbar";
5 import * as Dialog from "../../components/ui/Dialog";
6 import { createV5StackNavigator as createNativeStackNavigator } from "../../native/createV5StackNavigator";
7 import { useSheetStackOptions } from "../layout/nested-stacks";
@@ -49,7 +47,7 @@ import {
47 useState,
48 type ReactNode,
49 } from "react";
52 -import { Platform, Pressable, RefreshControl, ScrollView, TextInput, View } from "react-native";
50 +import { Platform, Pressable, RefreshControl, ScrollView, View } from "react-native";
51 import Animated, {
52 FadeIn,
53 FadeOut,
@@ -61,8 +59,6 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
59 import { SymbolView } from "../../components/ui/AppSymbol";
60 import { AppText as Text } from "../../components/ui/AppText";
61 import { AppBar } from "../../components/ui/AppBar";
64 -import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
65 -import { IconButton } from "../../components/ui/IconButton";
62 import { ProviderIcon } from "../../components/ProviderIcon";
63 import { ThemedSwitch } from "../../components/ui/ThemedSwitch";
64 import { cn } from "../../lib/cn";
@@ -79,7 +75,6 @@ import {
75 rememberModelOptions,
76 withRememberedModelOptions,
77 } from "../../state/use-model-option-memory";
82 -import { NativeStackScreenOptions } from "../../native/StackHeader";
78 import { ChatGptSharingStatus } from "./ChatGptSharingStatus";
79 import { environmentCatalog } from "../../connection/catalog";
80 import { useEnvironmentQuery } from "../../state/query";
@@ -105,12 +100,8 @@ import {
100 createProviderCatalogRefreshRunner,
101 providerCatalogRefreshError,
102 } from "./provider-catalog-refresh";
108 -import {
109 - createNativeMailSearchToolbarItem,
110 - NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET,
111 -} from "../layout/native-mail-search-toolbar";
112 -import { useNativeLayoutMetrics } from "../../native/native-layout-metrics";
113 -import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
103 +import { useSearchToolbarInset } from "../../components/ui/useBarInset";
104 +import type { AppBarSearch } from "../../components/ui/AppBar";
105 import { ModelRow, ChoiceRow } from "./ThreadSettingsRows";
106 import {
107 compatibleRuntimeModeForChoices,
@@ -824,6 +815,7 @@ function buildThreadSettingsCatalogItems(
815
816 function ThreadSettingsOptionsItem(props: {
817 readonly animationsReady: boolean;
818 + readonly bottomInset: number;
819 readonly onOpenSubmenu: (submenu: ThreadSettingsSubmenuPage) => void;
820 }) {
821 const insets = useSafeAreaInsets();
@@ -834,11 +826,9 @@ function ThreadSettingsOptionsItem(props: {
826 .get(session.environmentId)
827 ?.providers.find((provider) => provider.instanceId === session.providerInstanceId) ?? null)
828 : null;
837 - // Both iOS search layouts float a bottom toolbar over the list's last rows.
838 - const bottomToolbarInset = Platform.OS === "ios" ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET : 0;
829
830 return (
841 - <View style={{ paddingBottom: insets.bottom + bottomToolbarInset + 12 }}>
831 + <View style={{ paddingBottom: insets.bottom + props.bottomInset + 12 }}>
832 <ChatGptSharingStatus provider={selectedProvider} />
833 <Text className="px-5 pb-2 pt-2 text-sm font-t3-medium text-foreground-muted">Options</Text>
834 <Animated.View
@@ -907,22 +897,15 @@ function ThreadSettingsOptionsItem(props: {
897 label="Manage hidden models"
898 value={session.manageHidden}
899 onValueChange={session.setManageHidden}
910 - isLast={Platform.OS === "ios" || !session.hasLegacyModels}
900 + isLast
901 />
912 - {Platform.OS !== "ios" && session.hasLegacyModels ? (
913 - <SwitchRow
914 - isLast
915 - label="Legacy models"
916 - onValueChange={session.setShowLegacy}
917 - value={session.showLegacy}
918 - />
919 - ) : null}
902 </View>
903 </View>
904 );
905 }
906
907 function ThreadSettingsMainContent(props: {
908 + readonly bottomInset: number;
909 readonly onOpenSubmenu: (submenu: ThreadSettingsSubmenuPage) => void;
910 }) {
911 const session = useThreadSettingsSession();
@@ -985,6 +968,7 @@ function ThreadSettingsMainContent(props: {
968 content = (
969 <ThreadSettingsOptionsItem
970 animationsReady={animationsReady}
971 + bottomInset={props.bottomInset}
972 onOpenSubmenu={props.onOpenSubmenu}
973 />
974 );
@@ -1023,47 +1007,6 @@ function ThreadSettingsMainContent(props: {
1007 keyboardDismissMode="on-drag"
1008 keyboardShouldPersistTaps="handled"
1009 maintainVisibleContentPosition={THREAD_SETTINGS_MAINTAIN_VISIBLE_CONTENT_POSITION}
1026 - ListHeaderComponent={
1027 - <>
1028 - {Platform.OS === "android" ? (
1029 - <View className="px-4 pb-2 pt-3">
1030 - <View
1031 - className="flex-row items-center rounded-full bg-input px-2"
1032 - style={{ minHeight: 56 }}
1033 - >
1034 - <View pointerEvents="none" className="px-2">
1035 - <SymbolView
1036 - name="magnifyingglass"
1037 - size={24}
1038 - tintColorClassName="accent-icon-subtle"
1039 - />
1040 - </View>
1041 - <TextInput
1042 - accessibilityLabel="Find a model"
1043 - autoCapitalize="none"
1044 - autoCorrect={false}
1045 - className="min-w-0 flex-1 px-2 py-0 text-base text-foreground"
1046 - style={{ minHeight: 56, includeFontPadding: false, textAlignVertical: "center" }}
1047 - onChangeText={session.setSearchQuery}
1048 - placeholder="Find a model"
1049 - placeholderTextColorClassName="accent-placeholder"
1050 - selectionColorClassName="accent-focus/32"
1051 - cursorColorClassName="accent-focus"
1052 - selectionHandleColorClassName="accent-focus"
1053 - value={session.searchQuery}
1054 - />
1055 - {session.searchQuery.length > 0 ? (
1056 - <IconButton
1057 - accessibilityLabel="Clear model search"
1058 - icon="xmark"
1059 - onPress={() => session.setSearchQuery("")}
1060 - />
1061 - ) : null}
1062 - </View>
1063 - </View>
1064 - ) : null}
1065 - </>
1066 - }
1010 recycleItems
1011 refreshControl={
1012 session.environmentId ? (
@@ -1204,22 +1147,24 @@ function useThreadSettingsPickerPresentation() {
1147 return value;
1148 }
1149
1207 -// With a Duo vertical bar, filter and search join cancel and confirm in the rail.
1208 -function useThreadSettingsMailSearchToolbar() {
1209 - const metrics = useNativeLayoutMetrics();
1210 - return useNativeMailSearchToolbar() && (metrics?.verticalBarEdge ?? "none") === "none";
1211 -}
1212 -
1150 function ThreadSettingsModelsScreen() {
1151 const session = useThreadSettingsSession();
1152 const presentation = useThreadSettingsPickerPresentation();
1153 const navigation = useNavigation<NativeStackNavigationProp<ThreadSettingsPickerStackParams>>();
1217 - const usesNativeMailSearchToolbar = useThreadSettingsMailSearchToolbar();
1154 const hasCustomCatalogFilter = session.providerFilter !== null || session.showLegacy;
1155 const commitAndClose = useEffectEvent(() => {
1156 if (!session.commitPendingModel()) return;
1157 presentation.onClose();
1158 });
1159 + const search: AppBarSearch = {
1160 + value: session.searchQuery,
1161 + onChangeText: session.setSearchQuery,
1162 + placeholder: "Find a model",
1163 + clearAccessibilityLabel: "Clear model search",
1164 + mode: "inline",
1165 + compactToolbar: true,
1166 + };
1167 + const searchToolbarInset = useSearchToolbarInset(search);
1168 const providerFilters = [
1169 { id: "all-providers", title: "All providers", value: null },
1170 { id: "favorites", title: "Favorites", value: FAVORITES_PROVIDER_FILTER },
@@ -1229,124 +1174,59 @@ function ThreadSettingsModelsScreen() {
1174 value: group.providerKey,
1175 })),
1176 ];
1232 - const filterMenu = {
1233 - title: "Model filters",
1234 - items: [
1235 - {
1236 - type: "submenu" as const,
1237 - title: "Provider",
1238 - items: providerFilters.map((filter) => ({
1239 - type: "action" as const,
1240 - title: filter.title,
1241 - state: session.providerFilter === filter.value ? ("on" as const) : ("off" as const),
1242 - onPress: () => session.setProviderFilter(filter.value),
1243 - })),
1244 - },
1245 - ...(session.hasLegacyModels
1246 - ? [
1247 - {
1248 - type: "action" as const,
1249 - title: "Show legacy models",
1250 - state: session.showLegacy ? ("on" as const) : ("off" as const),
1251 - onPress: () => session.setShowLegacy(!session.showLegacy),
1252 - },
1253 - ]
1254 - : []),
1255 - ],
1256 - };
1177
1178 return (
1179 <>
1260 - {Platform.OS === "android" ? (
1261 - <SheetHeader
1262 - trailing={
1263 - <View className="flex-row items-center">
1264 - <AndroidAnchoredMenu
1265 - title="Model filters"
1266 - actions={[
1267 - {
1268 - title: "Provider",
1269 - subactions: providerFilters.map((filter) => ({
1270 - id: filter.id,
1271 - title: filter.title,
1272 - state: session.providerFilter === filter.value ? "on" : "off",
1273 - })),
1274 - },
1275 - ...(session.hasLegacyModels
1276 - ? [
1277 - {
1278 - id: "show-legacy",
1279 - title: "Show legacy models",
1280 - state: session.showLegacy ? ("on" as const) : ("off" as const),
1281 - },
1282 - ]
1283 - : []),
1284 - ]}
1285 - onPressAction={({ nativeEvent }) => {
1286 - if (nativeEvent.event === "show-legacy") {
1287 - session.setShowLegacy(!session.showLegacy);
1288 - } else {
1289 - const filter = providerFilters.find((item) => item.id === nativeEvent.event);
1290 - if (filter) session.setProviderFilter(filter.value);
1291 - }
1292 - }}
1293 - >
1294 - {(open) => (
1295 - <IconButton
1296 - accessibilityLabel="Filter models"
1297 - icon="line.3.horizontal.decrease"
1298 - selected={hasCustomCatalogFilter}
1299 - variant={hasCustomCatalogFilter ? "tonal" : "standard"}
1300 - onPress={open}
1301 - />
1302 - )}
1303 - </AndroidAnchoredMenu>
1304 - </View>
1305 - }
1306 - onCancel={presentation.onClose}
1307 - title="Thread settings"
1308 - confirm={session.pendingModel ? { label: "Save", onPress: commitAndClose } : undefined}
1309 - />
1310 - ) : null}
1311 - <NativeStackScreenOptions
1180 + <AppBar
1181 + title="Thread settings"
1182 + onClose={presentation.onClose}
1183 + closeAccessibilityLabel="Cancel thread settings"
1184 + search={search}
1185 + menus={[
1186 + {
1187 + title: "Model filters",
1188 + icon: hasCustomCatalogFilter
1189 + ? "line.3.horizontal.decrease.circle.fill"
1190 + : "line.3.horizontal.decrease",
1191 + items: [
1192 + {
1193 + id: "provider",
1194 + title: "Provider",
1195 + items: providerFilters.map((filter) => ({
1196 + id: filter.id,
1197 + title: filter.title,
1198 + selected: session.providerFilter === filter.value,
1199 + onPress: () => session.setProviderFilter(filter.value),
1200 + })),
1201 + },
1202 + ...(session.hasLegacyModels
1203 + ? [
1204 + {
1205 + id: "show-legacy",
1206 + title: "Show legacy models",
1207 + selected: session.showLegacy,
1208 + onPress: () => session.setShowLegacy(!session.showLegacy),
1209 + },
1210 + ]
1211 + : []),
1212 + ],
1213 + },
1214 + ]}
1215 optionsVersion={[
1216 session.providerFilter,
1217 session.providerGroups.map((group) => group.providerKey),
1218 session.showLegacy,
1219 + session.hasLegacyModels,
1220 ]}
1317 - options={{
1318 - unstable_headerToolbarItems: usesNativeMailSearchToolbar
1319 - ? () => [
1320 - createNativeMailSearchToolbarItem({
1321 - filterButtonId: "thread-settings-model-filter",
1322 - filterMenu,
1323 - filterSystemImageName: hasCustomCatalogFilter
1324 - ? "line.3.horizontal.decrease.circle.fill"
1325 - : "line.3.horizontal.decrease",
1326 - onSearchTextChange: session.setSearchQuery,
1327 - placeholder: "Find a model",
1328 - searchTextChangeId: "thread-settings-model-search-text",
1329 - showsSearchDismissButton: true,
1330 - }),
1331 - ]
1332 - : undefined,
1333 - headerShown: Platform.OS !== "android",
1334 - headerSearchBarOptions:
1335 - Platform.OS === "ios" && !usesNativeMailSearchToolbar
1336 - ? {
1337 - allowToolbarIntegration: true,
1338 - autoCapitalize: "none",
1339 - hideNavigationBar: false,
1340 - obscureBackground: false,
1341 - onCancelButtonPress: () => session.setSearchQuery(""),
1342 - onChangeText: (event) => session.setSearchQuery(event.nativeEvent.text),
1343 - placeholder: "Find a model",
1344 - }
1345 - : undefined,
1221 + confirm={{
1222 + label: session.pendingModel ? "Save thread settings" : "Done",
1223 + onPress: commitAndClose,
1224 }}
1225 + hideBottomBorder
1226 />
1227 <ScreenContent>
1228 <ThreadSettingsMainContent
1229 + bottomInset={searchToolbarInset}
1230 onOpenSubmenu={(submenu) => {
1231 const title =
1232 submenu.kind === "runtime"
@@ -1358,64 +1238,6 @@ function ThreadSettingsModelsScreen() {
1238 }}
1239 />
1240 </ScreenContent>
1361 - {Platform.OS === "ios" ? (
1362 - <SheetHeader
1363 - title="Thread settings"
1364 - onCancel={presentation.onClose}
1365 - accessibilityLabel="Cancel thread settings"
1366 - confirm={{
1367 - label: session.pendingModel ? "Save thread settings" : "Done",
1368 - onPress: commitAndClose,
1369 - }}
1370 - />
1371 - ) : null}
1372 - {Platform.OS === "ios" && !usesNativeMailSearchToolbar ? (
1373 - <Toolbar placement="bottom">
1374 - <Toolbar.Menu
1375 - accessibilityLabel="Filter models"
1376 - icon={
1377 - hasCustomCatalogFilter
1378 - ? "line.3.horizontal.decrease.circle.fill"
1379 - : "line.3.horizontal.decrease.circle"
1380 - }
1381 - title="Model filters"
1382 - >
1383 - <Toolbar.Menu title="Provider">
1384 - <Toolbar.Label>Provider</Toolbar.Label>
1385 - <Toolbar.MenuAction
1386 - isOn={session.providerFilter === null}
1387 - onPress={() => session.setProviderFilter(null)}
1388 - >
1389 - All providers
1390 - </Toolbar.MenuAction>
1391 - <Toolbar.MenuAction
1392 - isOn={session.providerFilter === FAVORITES_PROVIDER_FILTER}
1393 - onPress={() => session.setProviderFilter(FAVORITES_PROVIDER_FILTER)}
1394 - >
1395 - Favorites
1396 - </Toolbar.MenuAction>
1397 - {session.providerGroups.map((group) => (
1398 - <Toolbar.MenuAction
1399 - key={group.providerKey}
1400 - isOn={session.providerFilter === group.providerKey}
1401 - onPress={() => session.setProviderFilter(group.providerKey)}
1402 - >
1403 - {group.providerLabel}
1404 - </Toolbar.MenuAction>
1405 - ))}
1406 - </Toolbar.Menu>
1407 - {session.hasLegacyModels ? (
1408 - <Toolbar.MenuAction
1409 - isOn={session.showLegacy}
1410 - onPress={() => session.setShowLegacy(!session.showLegacy)}
1411 - >
1412 - Show legacy models
1413 - </Toolbar.MenuAction>
1414 - ) : null}
1415 - </Toolbar.Menu>
1416 - <Toolbar.SearchBarSlot />
1417 - </Toolbar>
1418 - ) : null}
1241 </>
1242 );
1243 }
apps/mobile/src/features/threads/git/GitBranchesSheet.occupancy.test.tsx
-1
@@ -19,7 +19,6 @@ vi.mock("react-native", () => ({
19 }));
20 vi.mock("@react-navigation/native", () => ({ useNavigation: () => ({}) }));
21 vi.mock("react-native-safe-area-context", () => ({ useSafeAreaInsets: () => ({ bottom: 0 }) }));
22 -vi.mock("../../../components/ui/AppBar", () => ({ AppBar: () => null }));
22 vi.mock("../../../components/ui/SheetHeader", () => ({ SheetHeader: () => null }));
23 vi.mock("../../../components/ui/ScreenContent", () => ({
24 ScreenContent: ({ children }: { children: ReactNode }) => <div>{children}</div>,
apps/mobile/src/features/threads/git/GitBranchesSheet.test.tsx
-1
@@ -27,7 +27,6 @@ vi.mock("react-native", () => ({
27 vi.mock("react-native-safe-area-context", () => ({
28 useSafeAreaInsets: () => ({ bottom: 0 }),
29 }));
30 -vi.mock("../../../components/ui/AppBar", () => ({ AppBar: () => null }));
30 vi.mock("../../../components/ui/SheetHeader", () => ({ SheetHeader: () => null }));
31 vi.mock("../../../components/ui/ScreenContent", () => ({
32 ScreenContent: ({ children }: { children: ReactNode }) => children,
apps/mobile/src/features/threads/git/GitBranchesSheet.tsx
+3 -17
@@ -4,7 +4,6 @@ import { useState } from "react";
4 import { Platform, Pressable, ScrollView, useWindowDimensions, View } from "react-native";
5 import { useSafeAreaInsets } from "react-native-safe-area-context";
6
7 -import { AppBar } from "../../../components/ui/AppBar";
7 import { SheetHeader } from "../../../components/ui/SheetHeader";
8 import { ScreenContent } from "../../../components/ui/ScreenContent";
9 import { AppText as Text, AppTextInput as TextInput } from "../../../components/ui/AppText";
@@ -65,28 +64,14 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {
64 return (
65 <View
66 collapsable={false}
68 - className="bg-sheet ios:flex-1"
67 + className="bg-sheet ios:flex-1 android:flex-col-reverse"
68 style={Platform.OS === "android" ? { maxHeight: windowHeight * 0.92 } : undefined}
69 >
71 - {Platform.OS === "android" ? (
72 - <AppBar
73 - sheet
74 - title="Branches & worktrees"
75 - onBack={() => navigation.goBack()}
76 - hideBottomBorder
77 - />
78 - ) : (
79 - <SheetHeader
80 - presentation="native"
81 - title="Branches & worktrees"
82 - onClose={() => navigation.goBack()}
83 - />
84 - )}
70 <ScreenContent fitToContents>
71 <ScrollView
72 nestedScrollEnabled
73 className="android:shrink android:grow-0 ios:flex-1"
89 - contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
74 + contentInsetAdjustmentBehavior="automatic"
75 keyboardShouldPersistTaps="handled"
76 showsVerticalScrollIndicator={false}
77 contentInset={{ bottom: Math.max(insets.bottom, 18) + 18 }}
@@ -230,6 +215,7 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {
215 </View>
216 </ScrollView>
217 </ScreenContent>
218 + <SheetHeader title="Branches & worktrees" onClose={() => navigation.goBack()} />
219 </View>
220 );
221 }
apps/mobile/src/features/threads/git/GitCommitSheet.tsx
+1 -3
@@ -69,7 +69,6 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {
69 const android = Platform.OS === "android";
70 const header = (
71 <SheetHeader
72 - presentation={android ? "inline" : "native"}
72 title="Commit changes"
73 subtitle={gitStatus.data?.refName ?? "(detached HEAD)"}
74 onCancel={() => navigation.goBack()}
@@ -85,7 +84,6 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {
84 className="bg-sheet ios:flex-1 android:flex-col-reverse"
85 style={android ? { maxHeight: windowHeight * 0.92 } : undefined}
86 >
88 - {android ? null : header}
87 <ScreenContent fitToContents>
88 <ScrollView
89 nestedScrollEnabled
@@ -229,7 +227,7 @@ export function GitCommitSheet(_props: GitCommitSheetProps) {
227 </View>
228 </ScrollView>
229 </ScreenContent>
232 - {android ? header : null}
230 + {header}
231 </View>
232 );
233 }
apps/mobile/src/features/threads/git/GitConfirmSheet.tsx
+3 -8
@@ -9,7 +9,7 @@ import { Platform, ScrollView, useWindowDimensions, View } from "react-native";
9
10 import { useSafeAreaInsets } from "react-native-safe-area-context";
11
12 -import { AppBar } from "../../../components/ui/AppBar";
12 +import { SheetHeader } from "../../../components/ui/SheetHeader";
13 import { ScreenContent } from "../../../components/ui/ScreenContent";
14 import { AppText as Text } from "../../../components/ui/AppText";
15 import { useSelectedThreadGitActions } from "../../../state/use-selected-thread-git-actions";
@@ -117,15 +117,9 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {
117 return (
118 <View
119 collapsable={false}
120 - className="bg-sheet ios:flex-1"
120 + className="bg-sheet ios:flex-1 android:flex-col-reverse"
121 style={Platform.OS === "android" ? { maxHeight: windowHeight * 0.92 } : undefined}
122 >
123 - {Platform.OS === "android" ? (
124 - <AppBar sheet title="Confirm action" onBack={() => navigation.goBack()} hideBottomBorder />
125 - ) : (
126 - <View className="min-h-4 pt-2" />
127 - )}
128 -
123 <ScreenContent fitToContents>
124 <ScrollView
125 nestedScrollEnabled
@@ -176,6 +170,7 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {
170 </View>
171 </ScrollView>
172 </ScreenContent>
173 + <SheetHeader title="Confirm action" onClose={() => navigation.goBack()} />
174 </View>
175 );
176 }
apps/mobile/src/features/threads/git/GitOverviewSheet.tsx
+7 -36
@@ -1,5 +1,5 @@
1 import * as Dialog from "../../../components/ui/Dialog";
2 -import { SheetHeader } from "../../../components/ui/SheetHeader";
2 +import { cn } from "../../../lib/cn";
3 import { useOpenPullRequest } from "../../../native/useOpenPullRequest";
4 import {
5 type GitActionRequestInput,
@@ -24,7 +24,6 @@ import { AppBar } from "../../../components/ui/AppBar";
24 import { ListRow } from "../../../components/ui/ListRow";
25 import { ListSection } from "../../../components/ui/ListSection";
26 import { ScreenContent } from "../../../components/ui/ScreenContent";
27 -import { useAdaptiveWorkspaceLayout } from "../../layout/AdaptiveWorkspaceLayout";
27 import { InspectorSheetContext } from "../../layout/workspace-inspector-sheet";
28 import { AppText as Text } from "../../../components/ui/AppText";
29 import { useEnvironmentQuery } from "../../../state/query";
@@ -61,7 +60,6 @@ export function GitOverviewSheet(props: GitOverviewSheetProps) {
60 }
61
62 function GitOverviewSheetContent(props: GitOverviewSheetProps) {
64 - const { layout } = useAdaptiveWorkspaceLayout();
63 const navigation = useNavigation();
64 const insets = useSafeAreaInsets();
65 const presentation = props.presentation ?? "sheet";
@@ -234,7 +232,7 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
232 nestedScrollEnabled
233 alwaysBounceVertical
234 className="flex-1 android:bg-sheet-solid ios:bg-screen"
237 - contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
235 + contentInsetAdjustmentBehavior="automatic"
236 showsVerticalScrollIndicator={false}
237 contentInset={{ bottom: Math.max(insets.bottom, 18) + 18 }}
238 contentContainerStyle={{
@@ -243,9 +241,7 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
241 gap: Platform.OS === "android" ? 8 : 14,
242 }}
243 refreshControl={
246 - Platform.OS === "ios" || isInspector ? (
247 - <RefreshControl refreshing={isRefreshing} onRefresh={() => void handleRefresh()} />
248 - ) : undefined
244 + <RefreshControl refreshing={isRefreshing} onRefresh={() => void handleRefresh()} />
245 }
246 >
247 <ListSection>
@@ -347,44 +343,19 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
343 onPress: () => void handleRefresh(),
344 };
345
350 - if (isInspector) {
351 - return (
352 - <View collapsable={false} className="flex-1 ios:bg-screen android:bg-header">
353 - <AppBar title={currentBranchLabel} subtitle={currentStatusSummary} refresh={refresh} />
354 - <ScreenContent insetHorizontal>{content}</ScreenContent>
355 - </View>
356 - );
357 - }
358 -
359 - if (Platform.OS === "ios") {
360 - return (
361 - <View collapsable={false} className="flex-1 bg-sheet">
362 - <SheetHeader
363 - presentation="native"
364 - title={currentBranchLabel}
365 - subtitle={currentStatusSummary}
366 - onClose={() => navigation.goBack()}
367 - />
368 - {content}
369 - </View>
370 - );
371 - }
372 -
346 return (
347 <View
348 collapsable={false}
376 - className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-sheet"}
349 + className={cn("flex-1 android:bg-header", isInspector ? "ios:bg-screen" : "ios:bg-sheet")}
350 >
351 <AppBar
379 - sheet
352 title={currentBranchLabel}
381 - hideBottomBorder={Platform.OS === "android"}
353 subtitle={currentStatusSummary}
383 - onBack={() => navigation.goBack()}
354 + hideBottomBorder={!isInspector}
355 + onClose={isInspector ? undefined : () => navigation.goBack()}
356 refresh={refresh}
357 />
386 -
387 - <ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
358 + <ScreenContent insetHorizontal={isInspector ? true : undefined}>{content}</ScreenContent>
359 </View>
360 );
361 }
apps/mobile/src/features/threads/sidebar-filter-button.tsx deleted
-27
@@ -1,27 +0,0 @@
1 -import { SymbolView } from "../../components/ui/AppSymbol";
2 -import { Pressable } from "react-native";
3 -
4 -export type SidebarFilterButtonIcon =
5 - | "line.3.horizontal.decrease.circle"
6 - | "line.3.horizontal.decrease.circle.fill";
7 -
8 -export function SidebarFilterButton(props: {
9 - readonly accessibilityLabel: string;
10 - readonly icon: SidebarFilterButtonIcon;
11 -}) {
12 - return (
13 - <Pressable
14 - className="size-11 cursor-pointer items-center justify-center rounded-full bg-subtle active:opacity-70"
15 - accessibilityLabel={props.accessibilityLabel}
16 - accessibilityRole="button"
17 - hitSlop={4}
18 - >
19 - <SymbolView
20 - name={props.icon}
21 - size={16}
22 - tintColorClassName="accent-foreground"
23 - type="monochrome"
24 - />
25 - </Pressable>
26 - );
27 -}
apps/mobile/src/features/threads/sidebar-header-actions.tsx deleted
-41
@@ -1,41 +0,0 @@
1 -import { SymbolView } from "../../components/ui/AppSymbol";
2 -import { Pressable, View } from "react-native";
3 -
4 -export interface SidebarHeaderActionsProps {
5 - readonly onOpenSettings: () => void;
6 -}
7 -
8 -function FallbackHeaderButton(props: {
9 - readonly accessibilityLabel: string;
10 - readonly icon: "gearshape" | "square.and.pencil";
11 - readonly onPress: () => void;
12 -}) {
13 - return (
14 - <Pressable
15 - className="size-11 items-center justify-center rounded-full bg-subtle active:opacity-70"
16 - accessibilityLabel={props.accessibilityLabel}
17 - accessibilityRole="button"
18 - hitSlop={4}
19 - onPress={props.onPress}
20 - >
21 - <SymbolView
22 - name={props.icon}
23 - size={18}
24 - tintColorClassName="accent-foreground"
25 - type="monochrome"
26 - />
27 - </Pressable>
28 - );
29 -}
30 -
31 -export function SidebarHeaderActions(props: SidebarHeaderActionsProps) {
32 - return (
33 - <View className="flex-row items-center gap-0.5">
34 - <FallbackHeaderButton
35 - accessibilityLabel="Open settings"
36 - icon="gearshape"
37 - onPress={props.onOpenSettings}
38 - />
39 - </View>
40 - );
41 -}
apps/mobile/src/features/threads/thread-header-appearance.ts deleted
-21
@@ -1,21 +0,0 @@
1 -import { Platform } from "react-native";
2 -import {
3 - nativeHeaderScrollEdgeEffects,
4 - type AppNativeStackNavigationOptions,
5 -} from "../../native/StackHeader";
6 -
7 -export function threadHeaderAppearance(
8 - usesNativeHeaderGlass: boolean,
9 -): AppNativeStackNavigationOptions {
10 - return {
11 - headerShown: true,
12 - headerTransparent: usesNativeHeaderGlass,
13 - headerStyle: usesNativeHeaderGlass ? { backgroundColor: "transparent" } : undefined,
14 - headerShadowVisible: false,
15 - scrollEdgeEffects: usesNativeHeaderGlass
16 - ? nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version)
17 - : undefined,
18 - headerTitleStyle: usesNativeHeaderGlass ? { fontSize: 17, fontWeight: "800" } : undefined,
19 - contentStyle: undefined,
20 - };
21 -}
apps/mobile/src/features/threads/useThreadHeaderOptions.android.ts deleted
-13
@@ -1,13 +0,0 @@
1 -import type { useThreadHeaderOptions as useIosThreadHeaderOptions } from "./useThreadHeaderOptions";
2 -
3 -// oxlint-disable-next-line t3code/no-hookless-use-function -- Android stub of a hook; the iOS file calls hooks.
4 -export function useThreadHeaderOptions(
5 - props: Parameters<typeof useIosThreadHeaderOptions>[0],
6 -): ReturnType<typeof useIosThreadHeaderOptions> {
7 - return {
8 - options: { contentStyle: { backgroundColor: props.headerColor } },
9 - // Android renders header actions as children, not native item factories.
10 - optionsVersion: [],
11 - fallback: null,
12 - };
13 -}
apps/mobile/src/features/threads/useThreadHeaderOptions.tsx deleted
-117
@@ -1,117 +0,0 @@
1 -import { useWorkspaceSidebarHeaderItem } from "../layout/useWorkspaceSidebarHeaderItem";
2 -import { StackActions, useNavigation } from "@react-navigation/native";
3 -import { threadHeaderAppearance } from "./thread-header-appearance";
4 -import { isDuoDevice } from "../../lib/device-type";
5 -import type { AppNativeStackNavigationOptions } from "../../native/StackHeader";
6 -import { useDeviceType } from "../../native/native-layout-metrics";
7 -import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";
8 -import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
9 -import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
10 -import {
11 - ThreadGitControls,
12 - useThreadGitCenterHeaderItems,
13 - useThreadGitRightHeaderItems,
14 -} from "./ThreadGitControls";
15 -
16 -type NativeHeaderItems = ReadonlyArray<Record<string, unknown>>;
17 -
18 -export function useThreadHeaderOptions(props: {
19 - readonly title: string;
20 - readonly subtitle: string;
21 - readonly headerColor: string;
22 - readonly usesNativeHeaderGlass: boolean;
23 - readonly gitControls: Parameters<typeof ThreadGitControls>[0];
24 - readonly onReturnToThread?: () => void;
25 - readonly draft?: boolean;
26 -}) {
27 - const usesNativeWorkspaceColumns = useNativeWorkspaceColumnsSupported();
28 - const deviceType = useDeviceType();
29 - const usesDuoHeader = usesNativeWorkspaceColumns && isDuoDevice(deviceType);
30 - const navigation = useNavigation();
31 - const { layout, startNewTask } = useAdaptiveWorkspaceLayout();
32 - const sidebarHeaderItem = useWorkspaceSidebarHeaderItem();
33 - const threadCenterHeaderItems = useThreadGitCenterHeaderItems(props.gitControls);
34 - const compactRightHeaderItems = useThreadGitRightHeaderItems(props.gitControls);
35 - const splitLeftHeaderItems: NativeHeaderItems = [
36 - ...(!usesDuoHeader
37 - ? [
38 - {
39 - spacing: 18,
40 - type: "spacing" as const,
41 - },
42 - ]
43 - : []),
44 - ...(props.onReturnToThread
45 - ? [
46 - withNativeGlassHeaderItem({
47 - accessibilityLabel: "Return to chat",
48 - icon: { name: "chevron.left", type: "sfSymbol" as const },
49 - identifier: "thread-left-return",
50 - onPress: props.onReturnToThread,
51 - type: "button" as const,
52 - }),
53 - ]
54 - : []),
55 - ...(sidebarHeaderItem ? [sidebarHeaderItem] : []),
56 - ...(!usesDuoHeader && !props.draft
57 - ? [
58 - withNativeGlassHeaderItem({
59 - accessibilityLabel: "New task",
60 - icon: { name: "square.and.pencil", type: "sfSymbol" as const },
61 - identifier: "thread-left-new-task",
62 - label: "New task",
63 - onPress: startNewTask,
64 - type: "button" as const,
65 - }),
66 - ]
67 - : []),
68 - ];
69 - const canGoBack = navigation.canGoBack();
70 - const compactHomeHeaderItems: NativeHeaderItems = [
71 - withNativeGlassHeaderItem({
72 - accessibilityLabel: "Go to threads list",
73 - icon: { name: "list.bullet", type: "sfSymbol" as const },
74 - identifier: "thread-left-home",
75 - onPress: () => navigation.dispatch(StackActions.replace("Home")),
76 - type: "button" as const,
77 - }),
78 - ];
79 -
80 - const options: AppNativeStackNavigationOptions = {
81 - ...threadHeaderAppearance(props.usesNativeHeaderGlass),
82 - headerTitle: props.title,
83 - title: props.title,
84 - headerBackVisible: !layout.usesSplitView,
85 - unstable_headerLeftItems: layout.usesSplitView
86 - ? () => splitLeftHeaderItems
87 - : canGoBack
88 - ? undefined
89 - : () => compactHomeHeaderItems,
90 - // The workspace navigator adds compose to the Duo detail column's bar.
91 - unstable_headerRightItems: () =>
92 - usesDuoHeader || layout.usesSplitView ? threadCenterHeaderItems : compactRightHeaderItems,
93 - unstable_headerToolbarItems: () => [],
94 - unstable_headerSubtitle: props.usesNativeHeaderGlass ? props.subtitle : undefined,
95 - contentStyle: undefined,
96 - };
97 - const { environmentId, threadId, gitStatus } = props.gitControls;
98 - return {
99 - options,
100 - // Factories re-read only on version changes; include displayed items and hidden callback state such as default refs.
101 - optionsVersion: [
102 - splitLeftHeaderItems,
103 - threadCenterHeaderItems,
104 - compactRightHeaderItems,
105 - usesDuoHeader,
106 - environmentId,
107 - threadId,
108 - gitStatus?.isDefaultRef,
109 - gitStatus?.refName,
110 - gitStatus?.pr?.url,
111 - ],
112 - fallback:
113 - !layout.usesSplitView && !props.usesNativeHeaderGlass ? (
114 - <ThreadGitControls {...props.gitControls} showActionControls />
115 - ) : null,
116 - };
117 -}
apps/mobile/src/features/threads/worktree-setup-card.tsx
+3 -5
@@ -12,7 +12,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
12 import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
13 import { AppText as Text } from "../../components/ui/AppText";
14 import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";
15 -import { WorktreeSetupSheet } from "./worktree-setup-sheet";
15 +import { Sheet } from "../../components/ui/Sheet";
16 import { ShimmeringWorkContent } from "./thread-work-log";
17 import { useVisibleSecondClock } from "./use-visible-second-clock";
18
@@ -198,14 +198,12 @@ function SetupDetailsSheet({
198 now,
199 }: WorktreeSetupCardProps & { onClose: () => void; now: number }) {
200 const insets = useSafeAreaInsets();
201 - const [bodyHeight, setBodyHeight] = useState(0);
201 const canCancel = snapshot.phase === "running" && !turnStarted;
202 return (
204 - <WorktreeSetupSheet height={bodyHeight} onClose={onClose}>
203 + <Sheet title="Worktree setup" onClose={onClose}>
204 <ScrollView
205 contentInsetAdjustmentBehavior="automatic"
206 bounces={false}
208 - onContentSizeChange={(_width, height) => setBodyHeight(height)}
207 contentContainerStyle={{
208 paddingHorizontal: 20,
209 paddingTop: 12,
@@ -252,7 +250,7 @@ function SetupDetailsSheet({
250 </View>
251 ) : null}
252 </ScrollView>
255 - </WorktreeSetupSheet>
253 + </Sheet>
254 );
255 }
256
apps/mobile/src/features/threads/worktree-setup-sheet.android.tsx deleted
-40
@@ -1,40 +0,0 @@
1 -import { Host, ModalBottomSheet, RNHostView } from "@expo/ui/jetpack-compose";
2 -import { View, useWindowDimensions } from "react-native";
3 -import { withUniwind } from "uniwind";
4 -import { AppBar } from "../../components/ui/AppBar";
5 -import type { WorktreeSetupSheetProps } from "./worktree-setup-sheet";
6 -
7 -const NativeBottomSheet = withUniwind(ModalBottomSheet, {
8 - containerColor: { fromClassName: "containerColorClassName", styleProperty: "accentColor" },
9 -});
10 -
11 -export function WorktreeSetupSheet({ children, height, onClose }: WorktreeSetupSheetProps) {
12 - const window = useWindowDimensions();
13 - return (
14 - <Host style={{ position: "absolute", width: 0, height: 0 }}>
15 - <NativeBottomSheet
16 - onDismissRequest={onClose}
17 - skipPartiallyExpanded
18 - containerColorClassName="accent-sheet-solid"
19 - >
20 - <RNHostView matchContents>
21 - <View
22 - style={{
23 - width: Math.min(window.width, 640),
24 - height: Math.min((height || 360) + 64, window.height * 0.85),
25 - }}
26 - >
27 - <AppBar
28 - sheet
29 - title="Worktree setup"
30 - actions={[
31 - { accessibilityLabel: "Close setup details", icon: "xmark", onPress: onClose },
32 - ]}
33 - />
34 - {children}
35 - </View>
36 - </RNHostView>
37 - </NativeBottomSheet>
38 - </Host>
39 - );
40 -}
apps/mobile/src/features/threads/worktree-setup-sheet.tsx deleted
-16
@@ -1,16 +0,0 @@
1 -import type { ReactElement } from "react";
2 -import { Sheet } from "../../components/ui/Sheet";
3 -
4 -export interface WorktreeSetupSheetProps {
5 - children: ReactElement;
6 - height: number;
7 - onClose: () => void;
8 -}
9 -
10 -export function WorktreeSetupSheet({ children, onClose }: WorktreeSetupSheetProps) {
11 - return (
12 - <Sheet title="Worktree setup" onClose={onClose}>
13 - {children}
14 - </Sheet>
15 - );
16 -}
apps/mobile/src/features/usage/UsageRouteScreen.tsx
+18 -61
@@ -30,7 +30,7 @@ import {
30 usageSourceMessages,
31 } from "@t3tools/shared/usageFormat";
32 import { useRef, useState, type ReactNode } from "react";
33 -import { Platform, RefreshControl, View } from "react-native";
33 +import { RefreshControl, View } from "react-native";
34 import Animated, { FadeIn, ReduceMotion } from "react-native-reanimated";
35 import { useSafeAreaInsets } from "react-native-safe-area-context";
36
@@ -49,8 +49,6 @@ import { UsageDailyChart } from "./UsageDailyChart";
49 import { toggleUsageEnvironment } from "./usageEnvironmentSelection";
50 import { useRefreshLimits } from "./UsageLimitsSection";
51 import { UsageLimitsSection } from "./UsageLimitsPooled";
52 -import { NativeStackScreenOptions } from "../../native/StackHeader";
53 -import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
52 import type { UsageChartMetric } from "./usageChartData";
53 import { PROVIDER_LABEL, useProviderColors, useUsageMixColors } from "./usageProviders";
54
@@ -197,27 +195,6 @@ function UsageScreen(props: {
195 );
196
197 const showEnvironmentFilter = environments.length > 0 || selectedEnvironmentIds !== null;
200 - const filterIcon =
201 - selectedEnvironmentIds === null
202 - ? "line.3.horizontal.decrease"
203 - : "line.3.horizontal.decrease.circle.fill";
204 - const environmentActions = [
205 - {
206 - id: "all",
207 - title: "All environments",
208 - subtitle: undefined,
209 - state: selectedEnvironmentIds === null ? ("on" as const) : ("off" as const),
210 - },
211 - ...environments.map((environment) => ({
212 - id: environment.environmentId,
213 - title: environment.label,
214 - subtitle: usageEnvironmentStatus(environment, refreshingUsage),
215 - state:
216 - selectedEnvironmentIds === null || selectedEnvironmentIds.has(environment.environmentId)
217 - ? ("on" as const)
218 - : ("off" as const),
219 - })),
220 - ];
198 const selectEnvironment = (value: string) => {
199 if (value === "all") {
200 setSelectedEnvironmentIds(null);
@@ -230,15 +207,24 @@ function UsageScreen(props: {
207 title: "Filter usage environments",
208 icon:
209 selectedEnvironmentIds === null
233 - ? ("line.3.horizontal.decrease.circle" as const)
210 + ? ("line.3.horizontal.decrease" as const)
211 : ("line.3.horizontal.decrease.circle.fill" as const),
235 - items: environmentActions.map((action) => ({
236 - id: action.id,
237 - title: action.title,
238 - subtitle: action.subtitle,
239 - selected: action.state === "on",
240 - onPress: () => selectEnvironment(action.id),
241 - })),
212 + items: [
213 + {
214 + id: "all",
215 + title: "All environments",
216 + selected: selectedEnvironmentIds === null,
217 + onPress: () => selectEnvironment("all"),
218 + },
219 + ...environments.map((environment) => ({
220 + id: environment.environmentId,
221 + title: environment.label,
222 + subtitle: usageEnvironmentStatus(environment, refreshingUsage),
223 + selected:
224 + selectedEnvironmentIds === null || selectedEnvironmentIds.has(environment.environmentId),
225 + onPress: () => selectEnvironment(environment.environmentId),
226 + })),
227 + ],
228 };
229
230 return (
@@ -247,35 +233,6 @@ function UsageScreen(props: {
233 menus={showEnvironmentFilter ? [environmentMenu] : undefined}
234 workspaceRoot={props.workspace}
235 >
250 - {Platform.OS === "ios" ? (
251 - <NativeStackScreenOptions
252 - optionsVersion={JSON.stringify({ showEnvironmentFilter, filterIcon, environmentActions })}
253 - options={{
254 - // A native menu item, unlike a custom view, moves into the Duo's vertical bar.
255 - unstable_headerRightItems: () =>
256 - showEnvironmentFilter
257 - ? [
258 - withNativeGlassHeaderItem({
259 - accessibilityLabel: "Filter usage environments",
260 - icon: { name: filterIcon, type: "sfSymbol" },
261 - label: "",
262 - type: "menu",
263 - menu: {
264 - title: "Environments",
265 - items: environmentActions.map((action) => ({
266 - type: "action" as const,
267 - label: action.title,
268 - description: action.subtitle,
269 - state: action.state === "on" ? ("on" as const) : undefined,
270 - onPress: () => selectEnvironment(action.id),
271 - })),
272 - },
273 - }),
274 - ]
275 - : [],
276 - }}
277 - />
278 - ) : null}
236 <ScrollView
237 contentInsetAdjustmentBehavior="automatic"
238 showsVerticalScrollIndicator={false}
apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
+47 -92
@@ -1,16 +1,15 @@
1 import { WorkspaceNoTabs } from "./WorkspaceNoTabs";
2 import { WORKSPACE_TAB_LABELS, useEnabledNavigationTabs } from "./navigation-tabs";
3 import { WorkspaceExtraTab } from "./WorkspaceExtraTab";
4 -import { SettingsRouteScreen } from "../settings/SettingsRouteScreen";
4 +import { WorkspaceSettingsList } from "../settings/SettingsRouteScreen";
5 import { WorkspaceSectionToolbar } from "./WorkspaceSectionToolbar";
6 import { useNavigation } from "@react-navigation/native";
7 import { use } from "react";
8 -import { Platform, View, useWindowDimensions } from "react-native";
8 +import { View, useWindowDimensions } from "react-native";
9 import { useKeyboardState } from "react-native-keyboard-controller";
10 import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
11
12 import { CompactBrandTitle } from "../../components/CompactBrandTitle";
13 -import { AppBar } from "../../components/ui/AppBar";
13 import { HeaderItemsWidthContext } from "../../native/header-items-width";
14 import { NativeStackScreenOptions } from "../../native/StackHeader";
15 import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
@@ -22,7 +21,6 @@ import {
21 useNativeLayoutMetrics,
22 } from "../../native/native-layout-metrics";
23 import { HomeRouteScreen } from "../home/HomeRouteScreen";
25 -import { dispatchHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
24 import { WorkspaceConnectionTitle } from "../home/WorkspaceConnectionTitle";
25 import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
26 import { PullRequestsScreen } from "../pull-requests/PullRequestsScreen";
@@ -32,11 +30,7 @@ import {
30 useWorkspaceTabs,
31 } from "./WorkspaceTabsContext";
32 import { WorkspaceToolbar } from "./WorkspaceToolbar";
35 -import {
36 - WORKSPACE_DOCK,
37 - workspaceDockBottomClearance,
38 - workspaceToolbarHeight,
39 -} from "./workspace-tabs-state";
33 +import { WORKSPACE_DOCK, workspaceDockBottomClearance } from "./workspace-tabs-state";
34 import { WorkspaceSidebarTabs } from "./WorkspaceSidebarTabs";
35 import {
36 useCompactWorkspaceTabs,
@@ -44,7 +38,6 @@ import {
38 useSystemWorkspaceTabBar,
39 } from "./useSystemWorkspaceTabBar";
40 import { openSettings } from "../settings/settings-navigation";
47 -import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab";
41
42 const TAB_TITLES = WORKSPACE_TAB_LABELS;
43
@@ -73,7 +66,6 @@ function WorkspaceRootTitle(props: {
66
67 function WorkspaceRootContent() {
68 const navigation = useNavigation();
76 - const selectTab = useSelectWorkspaceTab();
69 const { width: windowWidth } = useWindowDimensions();
70 const { layout, startNewTask } = useAdaptiveWorkspaceLayout();
71 const primaryColumn = use(NativePrimaryColumnContext);
@@ -107,89 +99,58 @@ function WorkspaceRootContent() {
99 const bottomClearance =
100 layout.variant === "medium" && state.selectedTab === "usage"
101 ? workspaceDockBottomClearance({ bottomInset: insets.bottom, keyboardHeight })
110 - : Platform.OS === "ios" && isDuoDevice(deviceType)
102 + : isDuoDevice(deviceType)
103 ? // The column's safe area already holds the Duo's search toolbar and keyboard.
104 Math.max(insets.bottom, keyboardHeight) + 16
105 : compactTabs || deviceType === "pad"
106 ? workspaceDockBottomClearance({ bottomInset: insets.bottom, keyboardHeight })
115 - : Platform.OS === "ios"
116 - ? Math.max(insets.bottom, keyboardHeight) +
117 - (systemTabBar || sidebarTabs || tab.searchMode !== "resting"
118 - ? sidebarPicker
119 - ? 80
120 - : 16
121 - : WORKSPACE_DOCK.height + WORKSPACE_DOCK.bottomGap + 16)
122 - : keyboardHeight > 0 && tab.searchMode !== "resting"
123 - ? keyboardHeight + 64
124 - : Math.max(insets.bottom, 12) + workspaceToolbarHeight(tab.searchMode) + 16;
107 + : Math.max(insets.bottom, keyboardHeight) +
108 + (systemTabBar || sidebarTabs || tab.searchMode !== "resting"
109 + ? sidebarPicker
110 + ? 80
111 + : 16
112 + : WORKSPACE_DOCK.height + WORKSPACE_DOCK.bottomGap + 16);
113 const context = { ...workspace, bottomClearance };
114
115 return (
116 <WorkspaceTabsContext value={context}>
117 <View className={sidebarPicker ? "flex-1 bg-drawer" : "flex-1 bg-screen"}>
130 - {Platform.OS === "ios" ? (
131 - <NativeStackScreenOptions
132 - optionsVersion={[
133 - settingsOpen,
134 - state.selectedTab,
135 - state.selectionRevision,
136 - width,
137 - sidebarNavigation,
138 - enabled.length,
139 - ]}
140 - options={{
141 - title: settingsOpen
142 - ? "Settings"
143 - : enabled.length
144 - ? TAB_TITLES[state.selectedTab]
145 - : "Navigation",
146 - headerShown: true,
147 - headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,
148 - headerStyle: NATIVE_LIQUID_GLASS_SUPPORTED
149 - ? { backgroundColor: "transparent" }
118 + <NativeStackScreenOptions
119 + optionsVersion={[
120 + settingsOpen,
121 + state.selectedTab,
122 + state.selectionRevision,
123 + width,
124 + sidebarNavigation,
125 + enabled.length,
126 + ]}
127 + options={{
128 + title: settingsOpen
129 + ? "Settings"
130 + : enabled.length
131 + ? TAB_TITLES[state.selectedTab]
132 + : "Navigation",
133 + headerShown: true,
134 + headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,
135 + headerStyle: NATIVE_LIQUID_GLASS_SUPPORTED
136 + ? { backgroundColor: "transparent" }
137 + : undefined,
138 + contentStyle: undefined,
139 + ...(enabled.length === 0
140 + ? { headerSearchBarOptions: undefined, unstable_headerRightItems: () => [] }
141 + : {}),
142 + unstable_headerLeftItems: () => [],
143 + // Beside a detail column the tab bar names the tab and the detail header the page,
144 + // so the sidebar keeps the brand.
145 + headerTitle:
146 + sidebarNavigation || (!settingsOpen && state.selectedTab !== "usage")
147 + ? renderHeaderTitle
148 : undefined,
151 - contentStyle: undefined,
152 - ...(enabled.length === 0
153 - ? { headerSearchBarOptions: undefined, unstable_headerRightItems: () => [] }
154 - : {}),
155 - unstable_headerLeftItems: () => [],
156 - // Beside a detail column the tab bar names the tab and the detail header the page,
157 - // so the sidebar keeps the brand.
158 - headerTitle:
159 - sidebarNavigation || (!settingsOpen && state.selectedTab !== "usage")
160 - ? renderHeaderTitle
161 - : undefined,
162 - }}
163 - />
164 - ) : (
165 - <AppBar
166 - embedded
167 - title="T3 Code"
168 - titleContent={renderHeaderTitle()}
169 - actions={[
170 - ...(state.selectedTab === "threads" || state.selectedTab === "pullRequests"
171 - ? [
172 - {
173 - accessibilityLabel:
174 - state.selectedTab === "threads" ? "Search threads" : "Search pull requests",
175 - icon: "magnifyingglass" as const,
176 - onPress: () => {
177 - dispatchHardwareKeyboardCommand("focusSearch");
178 - },
179 - },
180 - ]
181 - : []),
182 - {
183 - accessibilityLabel: "Settings",
184 - icon: "gearshape",
185 - onPress: () => selectTab("settings"),
186 - },
187 - ]}
188 - />
189 - )}
149 + }}
150 + />
151 <SafeAreaInsetsContext value={compactTabs ? { ...insets, bottom: 0 } : insets}>
152 {settingsOpen ? (
192 - <SettingsRouteScreen />
153 + <WorkspaceSettingsList />
154 ) : enabled.length === 0 ? (
155 <WorkspaceNoTabs />
156 ) : state.selectedTab === "threads" ? (
@@ -203,12 +164,9 @@ function WorkspaceRootContent() {
164 {deviceType !== "pad" && deviceType !== "phone" && sidebarPicker ? (
165 <WorkspaceSidebarTabs />
166 ) : null}
206 - {/* Android's Settings list carries its own search in its app bar. */}
207 - {enabled.length === 0 && !settingsOpen ? null : (
208 - settingsOpen
209 - ? Platform.OS === "ios"
210 - : state.selectedTab === "threads" || state.selectedTab === "pullRequests"
211 - ) ? (
167 + {enabled.length === 0 && !settingsOpen ? null : settingsOpen ||
168 + state.selectedTab === "threads" ||
169 + state.selectedTab === "pullRequests" ? (
170 <WorkspaceToolbar sidebar={sidebarNavigation} onNewTask={startNewTask} />
171 ) : (
172 <WorkspaceSectionToolbar onNewTask={startNewTask} showCompose={false} />
@@ -219,11 +177,8 @@ function WorkspaceRootContent() {
177 }
178
179 export function WorkspaceRootScreen() {
222 - const { layout } = useAdaptiveWorkspaceLayout();
180 const workspace = useWorkspaceTabs();
224 - return Platform.OS === "android" && layout.usesSplitView ? (
225 - <HomeRouteScreen />
226 - ) : workspace ? (
181 + return workspace ? (
182 <WorkspaceRootContent />
183 ) : (
184 <WorkspaceTabsProvider>
apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx
+10 -5
@@ -2,9 +2,10 @@ import { useActiveNewTask } from "../../state/active-new-task";
2 import { Toolbar } from "../../components/ui/Toolbar";
3 import { useFocusEffect, useIsFocused } from "@react-navigation/native";
4 import { use, useCallback, useEffect, useRef } from "react";
5 -import { Platform } from "react-native";
5 import { isDuoDevice } from "../../lib/device-type";
6 import { useDeviceType } from "../../native/native-layout-metrics";
7 +import { createNativeHeaderMenu } from "../../components/ui/nativeHeaderMenu.ios";
8 +import { useSettingsEnvironmentMenu } from "../settings/components/SettingsEnvironmentFilterHeader";
9 import type { SearchBarCommands } from "react-native-screens";
10
11 import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
@@ -39,7 +40,6 @@ export function WorkspaceToolbar(props: {
40 const bottomSearch = duoSearch && sidebarTabs !== "picker";
41 // On the Duo, compose belongs to the threads tab, in the detail column's bar when unfolded.
42 const nativeToolbarCompose =
42 - Platform.OS === "ios" &&
43 deviceType === "duo-folded" &&
44 !workspace.settingsOpen &&
45 workspace.state.selectedTab === "threads" &&
@@ -48,6 +48,7 @@ export function WorkspaceToolbar(props: {
48 const focused = useIsFocused();
49 const { layout, panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
50 const searchRef = useRef<SearchBarCommands>(null);
51 + const settingsMenu = useSettingsEnvironmentMenu();
52 // The Settings list takes the selected tab's place, so search follows it.
53 const selectedTab = workspace.settingsOpen ? "settings" : workspace.state.selectedTab;
54 const tab = workspace.state.tabs[selectedTab];
@@ -181,9 +182,13 @@ export function WorkspaceToolbar(props: {
182 : undefined,
183 }}
184 />
184 - {/* UIKit lays trailing items out from the edge inward. A trailing toolbar replaces the
185 - header's own items, so an empty one would hide the Settings scope filter. */}
186 - {workspace.settingsOpen && !foldedSearch ? null : (
185 + {/* UIKit lays trailing items out from the edge inward. */}
186 + {workspace.settingsOpen ? (
187 + <Toolbar placement="right">
188 + {searchButton}
189 + {createNativeHeaderMenu(settingsMenu)}
190 + </Toolbar>
191 + ) : (
192 <Toolbar placement="right">
193 {searchButton}
194 {nativeToolbarCompose && foldedSearch ? <Toolbar.Spacer width={8} /> : null}
apps/mobile/src/lib/filePreview.test.ts
+4 -1
@@ -257,7 +257,10 @@ vi.mock("../native/NativeScrollViewMarker", () => ({
257 vi.mock("../native/NativeWorkspaceColumns", () => ({
258 useNativeWorkspaceColumnsSupported: () => false,
259 }));
260 -vi.mock("../native/native-layout-metrics", () => ({ useDeviceType: () => "phone" }));
260 +vi.mock("../native/native-layout-metrics", () => ({
261 + useDeviceType: () => "phone",
262 + useNativeColumnLayoutMetrics: () => null,
263 +}));
264 vi.mock("../features/layout/workspace-content-width", () => ({
265 useWorkspaceSettledContentWidth: () => null,
266 }));