Skip to content

Commit e9a4854

Browse files
fix(mobile): the iPad inspector hides the sidebar where the page would get too narrow
On iOS 26 the native inspector column opened beside the sidebar at any width, so a portrait 13" iPad left the thread about 290pt. The JS columns already step the sidebar aside when the page would drop under 560pt; the native path was exempt because UIKit sizes its inspector column on its own. The shell now owns the native inspector's width and applies the same rule with a 320pt floor: landscape 11" and 13" iPads keep three columns, portrait iPads and the landscape mini show the thread and inspector, and the sidebar button closes the inspector to bring the sidebar back. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 922a591 commit e9a4854

5 files changed

Lines changed: 65 additions & 41 deletions

File tree

‎apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
deriveWorkspacePaneLayout,
3939
isPrimarySidebarPinned,
4040
isWorkspaceListPath,
41+
nativeInspectorColumnWidth,
4142
} from "../../lib/layout";
4243
import type { ThreadListFilters } from "../../persistence/mobile-preferences";
4344
import { appAtomRegistry } from "../../state/atom-registry";
@@ -181,6 +182,11 @@ function AdaptiveWorkspaceLayoutContent(
181182
const navigation = useNavigation();
182183
const [primarySidebarPreferredVisible, setPrimarySidebarPreferredVisible] = useState(true);
183184
const [fileInspectorPreferredVisible, setFileInspectorPreferredVisible] = useState(true);
185+
const [nativeInspectorWidthFraction, setNativeInspectorWidthFraction] = useState(0.4);
186+
const nativeInspectorWidth = nativeInspectorColumnWidth(
187+
viewportWidth,
188+
nativeInspectorWidthFraction,
189+
);
184190
const [fileInspectorPreferredWidth, setFileInspectorPreferredWidth] = useState<number | null>(
185191
null,
186192
);
@@ -329,8 +335,10 @@ function AdaptiveWorkspaceLayoutContent(
329335
auxiliaryPanePreferredVisible:
330336
!workspacePage && inspectorActive && fileInspectorPreferredVisible,
331337
auxiliaryPanePreferredWidth: fileInspectorPreferredWidth ?? undefined,
338+
nativeInspectorWidth,
332339
}),
333340
[
341+
nativeInspectorWidth,
334342
fileInspectorPreferredVisible,
335343
fileInspectorPreferredWidth,
336344
inspectorActive,
@@ -758,6 +766,11 @@ function AdaptiveWorkspaceLayoutContent(
758766
setPrimarySidebarVisible,
759767
openWorkspaceTab,
760768
setAuxiliaryPaneWidth: setFileInspectorPreferredWidth,
769+
nativeInspectorWidth,
770+
setNativeInspectorWidth: (width: number) =>
771+
setNativeInspectorWidthFraction(
772+
nativeInspectorColumnWidth(viewportWidth, width / viewportWidth) / viewportWidth,
773+
),
761774
composerKeyboardActive,
762775
setComposerEditing,
763776
sidebarByOrientation,

‎apps/mobile/src/features/layout/adaptive-workspace-context.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ interface AdaptiveWorkspaceContextValue {
4545
options?: { readonly columns?: boolean },
4646
) => void;
4747
readonly setAuxiliaryPaneWidth: (width: number) => void;
48+
readonly nativeInspectorWidth: number;
49+
readonly setNativeInspectorWidth: (width: number) => void;
4850
/**
4951
* Android split view while the thread composer has the soft keyboard: the
5052
* sidebar and rail step aside and the thread header drops to one line.
@@ -86,6 +88,8 @@ export const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceContextVa
8688
setPrimarySidebarVisible: () => undefined,
8789
openWorkspaceTab: () => undefined,
8890
setAuxiliaryPaneWidth: () => undefined,
91+
nativeInspectorWidth: 0,
92+
setNativeInspectorWidth: () => undefined,
8993
composerKeyboardActive: false,
9094
sidebarByOrientation: null,
9195
setComposerEditing: () => undefined,

‎apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
type NativeStackTypeBag,
2121
} from "@react-navigation/native-stack";
2222
import { Fragment, use, useEffect, useRef, useState, type ComponentProps } from "react";
23-
import { StyleSheet, useWindowDimensions, View } from "react-native";
23+
import { StyleSheet, View } from "react-native";
2424
import { Split, type SplitHostCommands } from "react-native-screens";
2525
import { SafeAreaView } from "react-native-safe-area-context";
2626
import { GestureHandlerRootView } from "react-native-gesture-handler";
@@ -194,16 +194,11 @@ function WorkspaceColumns(
194194
startNewTask,
195195
openWorkspaceTab,
196196
sidebarByOrientation,
197+
nativeInspectorWidth,
198+
setNativeInspectorWidth,
197199
} = useAdaptiveWorkspaceLayout();
198200
const deviceType = useDeviceType();
199-
const windowDimensions = useWindowDimensions();
200-
const nativeMetrics = useNativeLayoutMetrics();
201-
const viewportWidth = nativeMetrics?.width ?? windowDimensions.width;
202-
const [inspectorWidthFraction, setInspectorWidthFraction] = useState(0.4);
203-
const inspectorWidth = Math.max(
204-
260,
205-
Math.min(viewportWidth * 0.6, viewportWidth * inspectorWidthFraction),
206-
);
201+
const inspectorWidth = nativeInspectorWidth;
207202
const resizeStartWidth = useRef(inspectorWidth);
208203
const settingsDetailIn = (detail: readonly Route[]) =>
209204
layout.usesSplitView && detail[0] && isSettingsRoute(detail[0].name) ? detail[0] : undefined;
@@ -470,13 +465,9 @@ function WorkspaceColumns(
470465
onResizeStart={() => {
471466
resizeStartWidth.current = inspectorWidth;
472467
}}
473-
onResizeBy={(delta) => {
474-
const width = Math.max(
475-
260,
476-
Math.min(viewportWidth * 0.6, resizeStartWidth.current + delta),
477-
);
478-
setInspectorWidthFraction(width / viewportWidth);
479-
}}
468+
onResizeBy={(delta) =>
469+
setNativeInspectorWidth(resizeStartWidth.current + delta)
470+
}
480471
/>
481472
</View>
482473
</View>

‎apps/mobile/src/lib/layout.test.ts‎

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
deriveThreadFeedInitialContentInset,
77
deriveThreadWorkLogSizing,
88
deriveWorkspacePaneLayout,
9+
nativeInspectorColumnWidth,
910
isPrimarySidebarPinned,
1011
} from "./layout";
1112

@@ -140,24 +141,31 @@ describe("isPrimarySidebarPinned", () => {
140141
});
141142

142143
describe("deriveWorkspacePaneLayout", () => {
143-
it("lets UIKit keep the sidebar independent of the inspector in landscape", () => {
144-
const layout = deriveLayout({ width: 1_194, height: 834 });
145-
for (const primarySidebarPreferredVisible of [true, false]) {
146-
expect(
147-
deriveWorkspacePaneLayout({
148-
layout,
149-
viewportWidth: 1_194,
150-
nativeWorkspace: true,
151-
primarySidebarPreferredVisible,
152-
auxiliaryPanePreferredVisible: true,
153-
}),
154-
).toMatchObject({
155-
primarySidebarVisible: primarySidebarPreferredVisible,
156-
primarySidebarSuppressedByAuxiliary: false,
157-
auxiliaryPaneVisible: true,
158-
});
159-
}
160-
});
144+
it.each([
145+
{ width: 1_194, height: 834, suppressed: false },
146+
{ width: 1_032, height: 1_376, suppressed: true },
147+
])(
148+
"steps the sidebar aside for the native inspector only when the page gets too narrow ($width wide)",
149+
({ width, height, suppressed }) => {
150+
const layout = deriveLayout({ width, height });
151+
for (const primarySidebarPreferredVisible of [true, false]) {
152+
expect(
153+
deriveWorkspacePaneLayout({
154+
layout,
155+
viewportWidth: width,
156+
nativeWorkspace: true,
157+
primarySidebarPreferredVisible,
158+
auxiliaryPanePreferredVisible: true,
159+
nativeInspectorWidth: nativeInspectorColumnWidth(width, 0.4),
160+
}),
161+
).toMatchObject({
162+
primarySidebarVisible: primarySidebarPreferredVisible && !suppressed,
163+
primarySidebarSuppressedByAuxiliary: primarySidebarPreferredVisible && suppressed,
164+
auxiliaryPaneVisible: true,
165+
});
166+
}
167+
},
168+
);
161169

162170
it("keeps an explicitly hidden thread sidebar hidden when the file inspector is visible", () => {
163171
const layout = deriveLayout({ width: 1_024, height: 1_366 });

‎apps/mobile/src/lib/layout.ts‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ const AUXILIARY_PANE_MAX_WIDTH = 480;
4343
const AUXILIARY_PANE_DEFAULT_MAX_WIDTH = 320;
4444
const FILE_INSPECTOR_MIN_VIEWPORT_WIDTH = 820;
4545
const FILE_INSPECTOR_MIN_MAIN_WIDTH = 560;
46+
// UIKit's inspector column keeps its own width, so the sidebar steps aside only when the page
47+
// would get narrower than this: landscape 11" and 13" iPads keep three columns, portrait ones don't.
48+
const NATIVE_INSPECTOR_MIN_MAIN_WIDTH = 320;
4649

4750
/**
4851
* The window's width class. Compact: the sidebar is the root and pages push over it. Medium: the
@@ -203,6 +206,8 @@ export function deriveWorkspacePaneLayout(input: {
203206
readonly primarySidebarPreferredVisible: boolean;
204207
readonly auxiliaryPanePreferredVisible: boolean;
205208
readonly auxiliaryPanePreferredWidth?: number;
209+
/** The native inspector column's width; UIKit lays it out, not this layout. */
210+
readonly nativeInspectorWidth?: number;
206211
}): WorkspacePaneLayout {
207212
const viewportWidth = Math.max(0, input.viewportWidth);
208213
const floats = input.primarySidebarFloats ?? input.layout.variant === "medium";
@@ -219,18 +224,17 @@ export function deriveWorkspacePaneLayout(input: {
219224
reservedLeadingWidth: preferredPrimarySidebarWidth,
220225
});
221226
const auxiliaryPaneVisible = fileInspector.supported && input.auxiliaryPanePreferredVisible;
227+
const inspectorWidth = input.nativeWorkspace
228+
? (input.nativeInspectorWidth ?? null)
229+
: fileInspector.width;
222230
const primarySidebarSuppressedByAuxiliary =
223-
!input.nativeWorkspace &&
224231
preferredPrimarySidebarVisible &&
225232
!floats &&
226233
auxiliaryPaneVisible &&
227-
fileInspector.width !== null &&
234+
inspectorWidth !== null &&
228235
input.layout.listPaneWidth !== null &&
229-
viewportWidth -
230-
input.layout.listPaneWidth -
231-
(input.layout.listPaneGap ?? 0) -
232-
fileInspector.width <
233-
FILE_INSPECTOR_MIN_MAIN_WIDTH;
236+
viewportWidth - input.layout.listPaneWidth - (input.layout.listPaneGap ?? 0) - inspectorWidth <
237+
(input.nativeWorkspace ? NATIVE_INSPECTOR_MIN_MAIN_WIDTH : FILE_INSPECTOR_MIN_MAIN_WIDTH);
234238
const primarySidebarVisible =
235239
preferredPrimarySidebarVisible && !primarySidebarSuppressedByAuxiliary;
236240
const primarySidebarWidth = primarySidebarVisible ? preferredPrimarySidebarWidth : 0;
@@ -246,6 +250,10 @@ export function deriveWorkspacePaneLayout(input: {
246250
};
247251
}
248252

253+
export function nativeInspectorColumnWidth(viewportWidth: number, fraction: number) {
254+
return Math.max(260, Math.min(viewportWidth * 0.6, viewportWidth * fraction));
255+
}
256+
249257
export function deriveFileInspectorPaneLayout(input: {
250258
readonly layout: Layout;
251259
readonly viewportWidth: number;

0 commit comments

Comments
 (0)