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, 04:30 UTC
fix(mobile): the iPad inspector hides the sidebar where the page would get too narrow (#27218)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 3, 2026 at 16:53 UTC
e3a97f57254294e583aaf366a20ae743df44e4f2
5 files changed
+65
-41
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+13
@@ -46,6 +46,7 @@ import {
46
deriveWorkspacePaneLayout,
47
isPrimarySidebarPinned,
48
isWorkspaceListPath,
49
+ nativeInspectorColumnWidth,
50
} from "../../lib/layout";
51
import type { ThreadListFilters } from "../../persistence/mobile-preferences";
52
import { appAtomRegistry } from "../../state/atom-registry";
@@ -236,6 +237,11 @@ function AdaptiveWorkspaceLayoutContent(
237
const navigation = useNavigation();
238
const [primarySidebarPreferredVisible, setPrimarySidebarPreferredVisible] = useState(true);
239
const [fileInspectorPreferredVisible, setFileInspectorPreferredVisible] = useState(true);
240
+ const [nativeInspectorWidthFraction, setNativeInspectorWidthFraction] = useState(0.4);
241
+ const nativeInspectorWidth = nativeInspectorColumnWidth(
242
+ viewportWidth,
243
+ nativeInspectorWidthFraction,
244
+ );
245
const [fileInspectorPreferredWidth, setFileInspectorPreferredWidth] = useState<number | null>(
246
null,
247
);
@@ -384,8 +390,10 @@ function AdaptiveWorkspaceLayoutContent(
390
auxiliaryPanePreferredVisible:
391
!workspacePage && inspectorActive && fileInspectorPreferredVisible,
392
auxiliaryPanePreferredWidth: fileInspectorPreferredWidth ?? undefined,
393
+ nativeInspectorWidth,
394
}),
395
[
396
+ nativeInspectorWidth,
397
fileInspectorPreferredVisible,
398
fileInspectorPreferredWidth,
399
inspectorActive,
@@ -830,6 +838,11 @@ function AdaptiveWorkspaceLayoutContent(
838
setPrimarySidebarVisible,
839
openWorkspaceTab,
840
setAuxiliaryPaneWidth: setFileInspectorPreferredWidth,
841
+ nativeInspectorWidth,
842
+ setNativeInspectorWidth: (width: number) =>
843
+ setNativeInspectorWidthFraction(
844
+ nativeInspectorColumnWidth(viewportWidth, width / viewportWidth) / viewportWidth,
845
+ ),
846
composerKeyboardActive,
847
setComposerEditing,
848
sidebarByOrientation,
apps/mobile/src/features/layout/adaptive-workspace-context.ts
+4
@@ -46,6 +46,8 @@ interface AdaptiveWorkspaceContextValue {
46
options?: { readonly columns?: boolean },
47
) => void;
48
readonly setAuxiliaryPaneWidth: (width: number) => void;
49
+ readonly nativeInspectorWidth: number;
50
+ readonly setNativeInspectorWidth: (width: number) => void;
51
/**
52
* Android split view while the thread composer has the soft keyboard: the
53
* sidebar and rail step aside and the thread header drops to one line.
@@ -87,6 +89,8 @@ export const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceContextVa
89
setPrimarySidebarVisible: () => undefined,
90
openWorkspaceTab: () => undefined,
91
setAuxiliaryPaneWidth: () => undefined,
92
+ nativeInspectorWidth: 0,
93
+ setNativeInspectorWidth: () => undefined,
94
composerKeyboardActive: false,
95
sidebarByOrientation: null,
96
setComposerEditing: () => undefined,
apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx
+7
-16
@@ -20,7 +20,7 @@ import {
20
type NativeStackTypeBag,
21
} from "@react-navigation/native-stack";
22
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";
24
import { Split, type SplitHostCommands } from "react-native-screens";
25
import { SafeAreaView } from "react-native-safe-area-context";
26
import { GestureHandlerRootView } from "react-native-gesture-handler";
@@ -193,16 +193,11 @@ function WorkspaceColumns(
193
startNewTask,
194
openWorkspaceTab,
195
sidebarByOrientation,
196
+ nativeInspectorWidth,
197
+ setNativeInspectorWidth,
198
} = useAdaptiveWorkspaceLayout();
199
const deviceType = useDeviceType();
198
- const windowDimensions = useWindowDimensions();
199
- const nativeMetrics = useNativeLayoutMetrics();
200
- const viewportWidth = nativeMetrics?.width ?? windowDimensions.width;
201
- const [inspectorWidthFraction, setInspectorWidthFraction] = useState(0.4);
202
- const inspectorWidth = Math.max(
203
- 260,
204
- Math.min(viewportWidth * 0.6, viewportWidth * inspectorWidthFraction),
205
- );
200
+ const inspectorWidth = nativeInspectorWidth;
201
const resizeStartWidth = useRef(inspectorWidth);
202
const settingsDetailIn = (detail: readonly Route[]) =>
203
layout.usesSplitView && detail[0] && isSettingsRoute(detail[0].name) ? detail[0] : undefined;
@@ -459,13 +454,9 @@ function WorkspaceColumns(
454
onResizeStart={() => {
455
resizeStartWidth.current = inspectorWidth;
456
}}
462
- onResizeBy={(delta) => {
463
- const width = Math.max(
464
- 260,
465
- Math.min(viewportWidth * 0.6, resizeStartWidth.current + delta),
466
- );
467
- setInspectorWidthFraction(width / viewportWidth);
468
- }}
457
+ onResizeBy={(delta) =>
458
+ setNativeInspectorWidth(resizeStartWidth.current + delta)
459
+ }
460
/>
461
</View>
462
</View>
apps/mobile/src/lib/layout.test.ts
+26
-18
@@ -7,6 +7,7 @@ import {
7
deriveThreadArrangementSizing,
8
deriveThreadWorkLogSizing,
9
deriveWorkspacePaneLayout,
10
+ nativeInspectorColumnWidth,
11
isPrimarySidebarPinned,
12
} from "./layout";
13
@@ -153,24 +154,31 @@ describe("isPrimarySidebarPinned", () => {
154
});
155
156
describe("deriveWorkspacePaneLayout", () => {
156
- it("lets UIKit keep the sidebar independent of the inspector in landscape", () => {
157
- const layout = deriveLayout({ width: 1_194, height: 834 });
158
- for (const primarySidebarPreferredVisible of [true, false]) {
159
- expect(
160
- deriveWorkspacePaneLayout({
161
- layout,
162
- viewportWidth: 1_194,
163
- nativeWorkspace: true,
164
- primarySidebarPreferredVisible,
165
- auxiliaryPanePreferredVisible: true,
166
- }),
167
- ).toMatchObject({
168
- primarySidebarVisible: primarySidebarPreferredVisible,
169
- primarySidebarSuppressedByAuxiliary: false,
170
- auxiliaryPaneVisible: true,
171
- });
172
- }
173
- });
157
+ it.each([
158
+ { width: 1_194, height: 834, suppressed: false },
159
+ { width: 1_032, height: 1_376, suppressed: true },
160
+ ])(
161
+ "steps the sidebar aside for the native inspector only when the page gets too narrow ($width wide)",
162
+ ({ width, height, suppressed }) => {
163
+ const layout = deriveLayout({ width, height });
164
+ for (const primarySidebarPreferredVisible of [true, false]) {
165
+ expect(
166
+ deriveWorkspacePaneLayout({
167
+ layout,
168
+ viewportWidth: width,
169
+ nativeWorkspace: true,
170
+ primarySidebarPreferredVisible,
171
+ auxiliaryPanePreferredVisible: true,
172
+ nativeInspectorWidth: nativeInspectorColumnWidth(width, 0.4),
173
+ }),
174
+ ).toMatchObject({
175
+ primarySidebarVisible: primarySidebarPreferredVisible && !suppressed,
176
+ primarySidebarSuppressedByAuxiliary: primarySidebarPreferredVisible && suppressed,
177
+ auxiliaryPaneVisible: true,
178
+ });
179
+ }
180
+ },
181
+ );
182
183
it("keeps an explicitly hidden thread sidebar hidden when the file inspector is visible", () => {
184
const layout = deriveLayout({ width: 1_024, height: 1_366 });
apps/mobile/src/lib/layout.ts
+15
-7
@@ -58,6 +58,9 @@ const AUXILIARY_PANE_MAX_WIDTH = 480;
58
const AUXILIARY_PANE_DEFAULT_MAX_WIDTH = 320;
59
const FILE_INSPECTOR_MIN_VIEWPORT_WIDTH = 820;
60
const FILE_INSPECTOR_MIN_MAIN_WIDTH = 560;
61
+// UIKit's inspector column keeps its own width, so the sidebar steps aside only when the page
62
+// would get narrower than this: landscape 11" and 13" iPads keep three columns, portrait ones don't.
63
+const NATIVE_INSPECTOR_MIN_MAIN_WIDTH = 320;
64
65
/**
66
* The window's width class. Compact: the sidebar is the root and pages push over it. Medium: the
@@ -221,6 +224,8 @@ export function deriveWorkspacePaneLayout(input: {
224
readonly primarySidebarPreferredVisible: boolean;
225
readonly auxiliaryPanePreferredVisible: boolean;
226
readonly auxiliaryPanePreferredWidth?: number;
227
+ /** The native inspector column's width; UIKit lays it out, not this layout. */
228
+ readonly nativeInspectorWidth?: number;
229
}): WorkspacePaneLayout {
230
const viewportWidth = Math.max(0, input.viewportWidth);
231
const floats = input.primarySidebarFloats ?? input.layout.variant === "medium";
@@ -237,18 +242,17 @@ export function deriveWorkspacePaneLayout(input: {
242
reservedLeadingWidth: preferredPrimarySidebarWidth,
243
});
244
const auxiliaryPaneVisible = fileInspector.supported && input.auxiliaryPanePreferredVisible;
245
+ const inspectorWidth = input.nativeWorkspace
246
+ ? (input.nativeInspectorWidth ?? null)
247
+ : fileInspector.width;
248
const primarySidebarSuppressedByAuxiliary =
241
- !input.nativeWorkspace &&
249
preferredPrimarySidebarVisible &&
250
!floats &&
251
auxiliaryPaneVisible &&
245
- fileInspector.width !== null &&
252
+ inspectorWidth !== null &&
253
input.layout.listPaneWidth !== null &&
247
- viewportWidth -
248
- input.layout.listPaneWidth -
249
- (input.layout.listPaneGap ?? 0) -
250
- fileInspector.width <
251
- FILE_INSPECTOR_MIN_MAIN_WIDTH;
254
+ viewportWidth - input.layout.listPaneWidth - (input.layout.listPaneGap ?? 0) - inspectorWidth <
255
+ (input.nativeWorkspace ? NATIVE_INSPECTOR_MIN_MAIN_WIDTH : FILE_INSPECTOR_MIN_MAIN_WIDTH);
256
const primarySidebarVisible =
257
preferredPrimarySidebarVisible && !primarySidebarSuppressedByAuxiliary;
258
const primarySidebarWidth = primarySidebarVisible ? preferredPrimarySidebarWidth : 0;
@@ -264,6 +268,10 @@ export function deriveWorkspacePaneLayout(input: {
268
};
269
}
270
271
+export function nativeInspectorColumnWidth(viewportWidth: number, fraction: number) {
272
+ return Math.max(260, Math.min(viewportWidth * 0.6, viewportWidth * fraction));
273
+}
274
+
275
export function deriveFileInspectorPaneLayout(input: {
276
readonly layout: Layout;
277
readonly viewportWidth: number;