Skip to content

Commit fc5de39

Browse files
refactor(mobile): the inspector's bar is its pane's AppBar
Each inspector pane built its own header. On iOS the Files and Git panes mounted a one-screen native stack with a hand-written header config, and Android drew separate headers, so features branched by platform and threaded a header inset through. The iPhone git sheet had no close button. Inspector panes now render AppBar like any screen. The inspector collects the options their AppBar sets, per pane since hidden panes stay mounted, and draws them: in the native inspector column's own navigation bar on iOS 26, and in a one-screen native stack in the JS column and the sheet. On Android the AppBar draws inline as before. In the inspector, AppBar adds a close button that hides the column or dismisses the sheet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a7e98fe commit fc5de39

16 files changed

Lines changed: 329 additions & 433 deletions

‎apps/mobile/src/components/ui/AppBar.android.tsx‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { type RefObject, useRef, useState } from "react";
1+
import { type RefObject, use, useRef, useState } from "react";
22
import { Keyboard, type TextInputInstance, View } from "react-native";
33
import { useHardwareBack } from "../../lib/backHandler";
44
import { useToolbarLayout } from "./useToolbarLayout";
55
import { NativeStackScreenOptions } from "../../native/StackHeader";
66
import { useSidebarToggle } from "../../features/layout/useSidebarToggle";
7+
import { InspectorCloseContext } from "../../features/layout/inspector-bar-store";
78
import { useAppearancePreferences } from "../../features/settings/appearance/AppearancePreferencesProvider";
89
import { AndroidHeaderIconButton, AndroidScreenHeader } from "./AndroidScreenHeader";
910
import { ScreenHeaderButton } from "./ScreenHeaderButton.android";
@@ -69,6 +70,7 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
6970
const { themeVariables } = useAppearancePreferences();
7071
const inWorkspace = useHasWorkspaceAppBar();
7172
const sidebarToggle = useSidebarToggle();
73+
const closeInspector = use(InspectorCloseContext);
7274
const inline = search?.mode === "inline";
7375
const searching = searchState?.searching === true;
7476
const openSearch = () => searchState?.open();
@@ -191,10 +193,17 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
191193
: props.actions
192194
}
193195
trailing={
194-
menuView?.length || props.trailing ? (
196+
menuView?.length || props.trailing || closeInspector ? (
195197
<>
196198
{menuView}
197199
{props.trailing}
200+
{closeInspector ? (
201+
<AndroidHeaderIconButton
202+
accessibilityLabel="Close inspector"
203+
icon="xmark"
204+
onPress={closeInspector}
205+
/>
206+
) : null}
198207
</>
199208
) : undefined
200209
}

‎apps/mobile/src/components/ui/AppBar.tsx‎

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { Toolbar } from "./Toolbar";
22
import { AppActivityIndicator } from "./AppActivityIndicator";
33
import type { HeaderBarButtonMailSearchToolbarItem } from "react-native-screens";
4-
import { useId } from "react";
4+
import { use, useId, useLayoutEffect } from "react";
55
import { View } from "react-native";
66
import { createNativeHeaderMenu } from "./nativeHeaderMenu.ios";
77
import { ScreenHeaderButton } from "./ScreenHeaderButton";
8-
import { NativeStackScreenOptions } from "../../native/StackHeader";
8+
import { NativeStackScreenOptions, useScreenOptionsWriter } from "../../native/StackHeader";
99
import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";
1010
import { useDeviceType } from "../../native/native-layout-metrics";
11+
import { isDuoDevice } from "../../lib/device-type";
1112
import { useAdaptiveWorkspaceLayout } from "../../features/layout/AdaptiveWorkspaceLayout";
1213
import { useSidebarToggle } from "../../features/layout/useSidebarToggle";
14+
import { InspectorCloseContext } from "../../features/layout/inspector-bar-store";
1315
import {
1416
createNativeMailSearchToolbarItem,
1517
NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED,
@@ -44,6 +46,15 @@ export function AppBar(props: AppBarProps) {
4446
const headerId = useId();
4547
const { layout } = useAdaptiveWorkspaceLayout();
4648
const sidebarToggle = useSidebarToggle();
49+
const closeInspector = use(InspectorCloseContext);
50+
const setOptions = useScreenOptionsWriter();
51+
const ownsInspectorBar = closeInspector !== null && !props.embedded && !props.sheet;
52+
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- an inspector pane that stops drawing its bar must not leave it in the out-of-tree inspector bar
53+
useLayoutEffect(() => {
54+
if (!ownsInspectorBar || !setOptions) return;
55+
setOptions({ headerShown: true });
56+
return () => setOptions({ headerShown: false });
57+
}, [ownsInspectorBar, setOptions]);
4758
// The Duo's native columns show their own sidebar button while the sidebar is open.
4859
const showsSidebarToggle =
4960
sidebarToggle !== null &&
@@ -63,6 +74,13 @@ export function AppBar(props: AppBarProps) {
6374
usesNativeMailSearchToolbar;
6475
const visibleMenus = compactSearch ? (menus?.slice(1) ?? []) : (menus ?? []);
6576
const refresh = search?.refreshInToolbar ? search.onRefresh : undefined;
77+
// Where the mail toolbar isn't used, the Duo keeps search at the bottom of the pane like its
78+
// workspace lists; elsewhere inline search is a button in the bar.
79+
const duoBottomSearch =
80+
search !== undefined &&
81+
!compactSearch &&
82+
NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED &&
83+
isDuoDevice(deviceType);
6684
if (props.embedded || props.sheet) return null;
6785
return (
6886
<>
@@ -110,12 +128,16 @@ export function AppBar(props: AppBarProps) {
110128
? undefined
111129
: {
112130
allowToolbarIntegration: true,
113-
...(NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED && search.mode === "inline"
114-
? { placement: "integratedButton" as const }
115-
: undefined),
131+
...(duoBottomSearch
132+
? { placement: "integrated" as const }
133+
: NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED && search.mode === "inline"
134+
? { placement: "integratedButton" as const }
135+
: undefined),
116136
autoCapitalize: "none",
117137
hideNavigationBar: false,
118-
...(search.mode === "inline" ? { obscureBackground: false } : undefined),
138+
...(search.mode === "inline" || duoBottomSearch
139+
? { obscureBackground: false }
140+
: undefined),
119141
placeholder: search.placeholder,
120142
onChangeText: (event) => search.onChangeText(event.nativeEvent.text),
121143
onCancelButtonPress: () => search.onChangeText(""),
@@ -143,7 +165,8 @@ export function AppBar(props: AppBarProps) {
143165
{(props.actions?.length ||
144166
(!compactSearch && refresh) ||
145167
visibleMenus.length ||
146-
props.trailing) &&
168+
props.trailing ||
169+
closeInspector) &&
147170
props.options?.unstable_headerRightItems === undefined ? (
148171
<Toolbar placement="right">
149172
{props.actions?.map(({ loading, ...action }) =>
@@ -175,6 +198,19 @@ export function AppBar(props: AppBarProps) {
175198
) : null}
176199
{visibleMenus.map(createNativeHeaderMenu)}
177200
{props.trailing}
201+
{closeInspector ? (
202+
<ScreenHeaderButton
203+
accessibilityLabel="Close inspector"
204+
icon="xmark"
205+
onPress={closeInspector}
206+
separateBackground
207+
/>
208+
) : null}
209+
</Toolbar>
210+
) : null}
211+
{duoBottomSearch ? (
212+
<Toolbar placement="bottom">
213+
<Toolbar.SearchBarSlot />
178214
</Toolbar>
179215
) : null}
180216
</>

‎apps/mobile/src/features/files/FilesHeader.tsx‎

Lines changed: 0 additions & 98 deletions
This file was deleted.

‎apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,12 +483,11 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
483483
}
484484
navigation.navigate("ThreadFile", params);
485485
};
486-
const renderInspector = (headerInset: number) =>
486+
const renderInspector = () =>
487487
environmentId !== null && cwd !== null ? (
488488
<ThreadFileNavigatorPane
489489
cwd={cwd}
490490
environmentId={environmentId}
491-
headerInset={headerInset}
492491
projectName={projectName}
493492
selectedPath={null}
494493
onSelectFile={handleSelectFile}
@@ -751,12 +750,11 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
751750
if (directoryPath !== null) navigation.dispatch(StackActions.push("ThreadFile", destination));
752751
else navigation.navigate("ThreadFile", destination);
753752
};
754-
const renderInspector = (headerInset: number) =>
753+
const renderInspector = () =>
755754
fileInspector.supported && environmentId !== null && cwd !== null ? (
756755
<ThreadFileNavigatorPane
757756
cwd={directoryPath ?? cwd}
758757
environmentId={environmentId}
759-
headerInset={headerInset}
760758
projectName={directoryPath ?? projectName}
761759
selectedPath={directoryPath === null ? relativePath : null}
762760
onSelectFile={(path) => {
@@ -765,13 +763,11 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
765763
}}
766764
/>
767765
) : undefined;
768-
const safeAreaInsets = useSafeAreaInsets();
769-
const inspectorHeaderInset = Platform.OS === "ios" ? 0 : safeAreaInsets.top;
770766
const renderWorkspaceInspector = () => (
771767
<ThreadInspectorContentStack
772768
mode="files"
773769
resetKeys={[threadId, cwd]}
774-
renderFiles={() => renderInspector(inspectorHeaderInset)}
770+
renderFiles={renderInspector}
775771
/>
776772
);
777773
const inspector = fileInspector.supported ? (

0 commit comments

Comments
 (0)