@devries-cameron20 / t3code Mirror · read-only / commits / 6df3584ca2
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, 04:30 UTC

feat(mobile): medium windows float the sidebar over the page (#27088)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 3, 2026 at 16:53 UTC 6df3584ca20add7e3059dd0ce7c9ddbadd774147
10 files changed +154 -58
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+99 -31
@@ -20,7 +20,14 @@ import {
20 useState,
21 type ReactNode,
22 } from "react";
23 -import { Keyboard, Platform, useWindowDimensions, View } from "react-native";
23 +import {
24 + BackHandler,
25 + Keyboard,
26 + Platform,
27 + Pressable,
28 + useWindowDimensions,
29 + View,
30 +} from "react-native";
31 import { KeyboardController, useKeyboardState } from "react-native-keyboard-controller";
32 import Animated, {
33 runOnJS,
@@ -241,17 +248,17 @@ function AdaptiveWorkspaceLayoutContent(
248 // The overlay sidebar closes when a page opens from it, and stays open on a list or on the
249 // page a tab switch opened (`keepOpenFor`, set by that switch).
250 const [overlaySidebar, setOverlaySidebar] = useState({
244 - active: baseLayout.primarySidebarOverlaysContent,
251 + active: baseLayout.variant === "medium",
252 pathname,
253 visible: isWorkspaceListPath(pathname),
254 keepOpenFor: null as string | null,
255 });
256 if (
250 - overlaySidebar.active !== baseLayout.primarySidebarOverlaysContent ||
257 + overlaySidebar.active !== (baseLayout.variant === "medium") ||
258 (overlaySidebar.active && overlaySidebar.pathname !== pathname)
259 ) {
260 setOverlaySidebar({
254 - active: baseLayout.primarySidebarOverlaysContent,
261 + active: baseLayout.variant === "medium",
262 pathname,
263 visible:
264 isWorkspaceListPath(pathname) ||
@@ -260,9 +267,8 @@ function AdaptiveWorkspaceLayoutContent(
267 keepOpenFor: null,
268 });
269 }
263 - const preferredSidebarVisible = baseLayout.primarySidebarOverlaysContent
264 - ? overlaySidebar.visible
265 - : primarySidebarPreferredVisible;
270 + const preferredSidebarVisible =
271 + baseLayout.variant === "medium" ? overlaySidebar.visible : primarySidebarPreferredVisible;
272 const primarySidebarPinned = isPrimarySidebarPinned({
273 pathname,
274 nativeWorkspace,
@@ -279,6 +285,10 @@ function AdaptiveWorkspaceLayoutContent(
285 const showPrimarySidebar =
286 !workspacePage &&
287 (primarySidebarPinned || (preferredSidebarVisible && !composerKeyboardActive));
288 + // Medium windows float the sidebar over a page; beside a list it keeps its room.
289 + const sidebarFloats =
290 + baseLayout.variant === "medium" &&
291 + (nativeWorkspace || (!primarySidebarPinned && !workspacePage));
292 const shouldRenderNavigationRail =
293 Platform.OS === "android" && baseLayout.usesSplitView && !floatingTabsEnabled;
294 const enabledTabs = useEnabledNavigationTabs();
@@ -319,7 +329,8 @@ function AdaptiveWorkspaceLayoutContent(
329 floatingTabs.row,
330 floatingTabsEnabled,
331 ]);
322 - const width = viewportWidth - navigationRailWidth;
332 + // A floating sidebar brings the rail with it.
333 + const width = viewportWidth - (sidebarFloats ? 0 : navigationRailWidth);
334 // The sidebar stays mounted under a workspace page, so its list is ready on the way back.
335 const shouldRenderPrimarySidebar = layout.usesSplitView;
336 const fileInspector = useMemo(
@@ -329,11 +340,18 @@ function AdaptiveWorkspaceLayoutContent(
340 viewportWidth: width,
341 preferredWidth: fileInspectorPreferredWidth ?? undefined,
342 reservedLeadingWidth:
332 - shouldRenderPrimarySidebar && showPrimarySidebar && !layout.primarySidebarOverlaysContent
343 + shouldRenderPrimarySidebar && showPrimarySidebar && !sidebarFloats
344 ? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0)
345 : 0,
346 }),
336 - [fileInspectorPreferredWidth, layout, showPrimarySidebar, shouldRenderPrimarySidebar, width],
347 + [
348 + fileInspectorPreferredWidth,
349 + layout,
350 + showPrimarySidebar,
351 + shouldRenderPrimarySidebar,
352 + sidebarFloats,
353 + width,
354 + ],
355 );
356 const [workspaceInspector, setWorkspaceInspector] = useState<{
357 readonly render: () => ReactNode;
@@ -346,6 +364,7 @@ function AdaptiveWorkspaceLayoutContent(
364 layout,
365 viewportWidth: width,
366 nativeWorkspace,
367 + primarySidebarFloats: sidebarFloats,
368 primarySidebarPreferredVisible: showPrimarySidebar,
369 // Only a column a screen fills makes room, so a stale preference can't hide the sidebar.
370 auxiliaryPanePreferredVisible:
@@ -359,6 +378,7 @@ function AdaptiveWorkspaceLayoutContent(
378 layout,
379 nativeWorkspace,
380 showPrimarySidebar,
381 + sidebarFloats,
382 width,
383 workspacePage,
384 ],
@@ -396,7 +416,7 @@ function AdaptiveWorkspaceLayoutContent(
416 setWorkspaceInspector((current) => (current !== null && !current.active ? null : current));
417 };
418 const setPrimarySidebarVisible = (visible: boolean) => {
399 - if (layout.primarySidebarOverlaysContent) {
419 + if (layout.variant === "medium") {
420 setOverlaySidebar((current) => ({ ...current, visible }));
421 } else {
422 setPrimarySidebarPreferredVisible(visible);
@@ -410,7 +430,7 @@ function AdaptiveWorkspaceLayoutContent(
430 // intact. One the user had hidden still opens.
431 if (composerKeyboardActive) {
432 void KeyboardController.dismiss();
413 - if (primarySidebarPreferredVisible) return;
433 + if (preferredSidebarVisible) return;
434 }
435 if (!panes.primarySidebarVisible && panes.primarySidebarSuppressedByAuxiliary) {
436 setFileInspectorPreferredVisible(false);
@@ -469,7 +489,7 @@ function AdaptiveWorkspaceLayoutContent(
489 overlays,
490 },
491 );
472 - if (layout.primarySidebarOverlaysContent) {
492 + if (layout.variant === "medium") {
493 const opened = next.routes.at(-1 - overlays.length)?.key ?? null;
494 setOverlaySidebar((current) => ({ ...current, visible: true, keepOpenFor: opened }));
495 }
@@ -482,7 +502,7 @@ function AdaptiveWorkspaceLayoutContent(
502 threadSelectionDeferral.run(() => {
503 if (Platform.OS === "android") Keyboard.dismiss();
504 setFileInspectorPreferredVisible(false);
485 - if (layout.primarySidebarOverlaysContent) setPrimarySidebarVisible(false);
505 + if (layout.variant === "medium") setPrimarySidebarVisible(false);
506 workspace?.dispatch({
507 type: "select",
508 tab: detail.name === "Thread" ? "threads" : "pullRequests",
@@ -604,11 +624,12 @@ function AdaptiveWorkspaceLayoutContent(
624 // against the edge that stays put while the other one slides, so nothing reflows after the
625 // panes land. A sliding sidebar uncovers the strip it is about to fill, or covers the content
626 // until it is gone.
607 - const contentLeftTarget =
608 - navigationRailWidth +
609 - (shouldRenderPrimarySidebar && !workspacePage && panes.primarySidebarVisible
610 - ? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0)
611 - : 0);
627 + const contentLeftTarget = sidebarFloats
628 + ? 0
629 + : navigationRailWidth +
630 + (shouldRenderPrimarySidebar && !workspacePage && panes.primarySidebarVisible
631 + ? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0)
632 + : 0);
633 const [contentAnchor, setContentAnchor] = useState({
634 viewportWidth,
635 left: contentLeftTarget,
@@ -670,6 +691,29 @@ function AdaptiveWorkspaceLayoutContent(
691 workspacePage,
692 ]);
693 const railAnimatedStyle = useAnimatedStyle(() => ({ width: renderedRailWidth.value }));
694 + const floatingSidebarAnimatedStyle = useAnimatedStyle(() => ({ left: renderedRailWidth.value }));
695 + const floatingSidebarOpen = sidebarFloats && panes.primarySidebarVisible;
696 + // Its own value, so a sidebar that was beside a list doesn't dim the page as it leaves.
697 + const scrimOpacity = useSharedValue(0);
698 + // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- animates the Reanimated scrim with the floating sidebar
699 + useEffect(() => {
700 + scrimOpacity.set(withTiming(floatingSidebarOpen ? 0.32 : 0, WORKSPACE_PANE_TIMING));
701 + }, [floatingSidebarOpen, scrimOpacity]);
702 + const scrimAnimatedStyle = useAnimatedStyle(() => ({ opacity: scrimOpacity.value }));
703 + // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Back closes a floating sidebar before it leaves the page
704 + useEffect(() => {
705 + if (!floatingSidebarOpen || nativeWorkspace) return;
706 + const subscription = BackHandler.addEventListener("hardwareBackPress", () => {
707 + // A sheet or modal over the workspace takes Back first.
708 + const state = rootStackState(navigation);
709 + if (state && workspaceRoutesOf(state.routes.slice(0, state.index + 1)).overlays.length > 0) {
710 + return false;
711 + }
712 + setPrimarySidebarVisible(false);
713 + return true;
714 + });
715 + return () => subscription.remove();
716 + }, [floatingSidebarOpen, nativeWorkspace, navigation, setPrimarySidebarVisible]);
717 // Showing or hiding the sidebar clips a fixed-width list. A hinge resize instead tracks the
718 // animated edge, so the header actions slide with it rather than jumping or being covered.
719 const listPaneGap = layout.listPaneGap ?? 0;
@@ -694,8 +738,8 @@ function AdaptiveWorkspaceLayoutContent(
738 Math.max(
739 0,
740 viewportWidth -
697 - renderedRailWidth.value -
698 - (workspacePage ? 0 : renderedSidebarWidth.value) -
741 + (sidebarFloats ? 0 : renderedRailWidth.value) -
742 + (workspacePage || sidebarFloats ? 0 : renderedSidebarWidth.value) -
743 renderedInspectorWidth.value,
744 ),
745 );
@@ -716,14 +760,13 @@ function AdaptiveWorkspaceLayoutContent(
760 const sidebarOverRotates =
761 nativeWorkspace && nativeMetrics?.hasHinge === true && layout.usesSplitView;
762 // The current orientation's panes already account for an inspector that needs the sidebar's room.
719 - const sidebarInLandscape = baseLayout.primarySidebarOverlaysContent
720 - ? primarySidebarPinned || primarySidebarPreferredVisible
721 - : panes.primarySidebarVisible;
763 + const sidebarInLandscape =
764 + baseLayout.variant === "medium"
765 + ? primarySidebarPinned || primarySidebarPreferredVisible
766 + : panes.primarySidebarVisible;
767 const sidebarInPortrait =
768 primarySidebarPinned ||
724 - (baseLayout.primarySidebarOverlaysContent
725 - ? overlaySidebar.visible
726 - : isWorkspaceListPath(pathname));
769 + (baseLayout.variant === "medium" ? overlaySidebar.visible : isWorkspaceListPath(pathname));
770 const sidebarByOrientation = useMemo(
771 () =>
772 sidebarOverRotates ? { landscape: sidebarInLandscape, portrait: sidebarInPortrait } : null,
@@ -775,7 +818,10 @@ function AdaptiveWorkspaceLayoutContent(
818 >
819 <AndroidHingeObserver onChange={handleHingeChange} />
820 {shouldRenderNavigationRail ? (
778 - <Animated.View className="shrink self-stretch" style={railAnimatedStyle} />
821 + <Animated.View
822 + className={sidebarFloats ? "absolute inset-y-0 left-0" : "shrink self-stretch"}
823 + style={railAnimatedStyle}
824 + />
825 ) : null}
826 {shouldRenderPrimarySidebar && layout.listPaneWidth !== null ? (
827 <Animated.View
@@ -791,6 +837,12 @@ function AdaptiveWorkspaceLayoutContent(
837 // content pane, laid out after it, covers it, in the same mount as the page.
838 style={[
839 workspacePage ? { position: "absolute", top: 0, bottom: 0, left: 0 } : null,
840 + sidebarFloats
841 + ? [
842 + { position: "absolute", top: 0, bottom: 0, zIndex: 2, elevation: 8 },
843 + floatingSidebarAnimatedStyle,
844 + ]
845 + : null,
846 sidebarAnimatedStyle,
847 ]}
848 >
@@ -828,6 +880,8 @@ function AdaptiveWorkspaceLayoutContent(
880 }
881 style={Platform.OS === "android" ? androidContentSlotStyle : undefined}
882 collapsable={false}
883 + importantForAccessibility={floatingSidebarOpen ? "no-hide-descendants" : "auto"}
884 + accessibilityElementsHidden={floatingSidebarOpen}
885 >
886 <Animated.View
887 collapsable={false}
@@ -888,6 +942,19 @@ function AdaptiveWorkspaceLayoutContent(
942 </WorkspaceContentWidthContext>
943 </Animated.View>
944 </Animated.View>
945 + {sidebarFloats ? (
946 + <Animated.View
947 + className="absolute inset-0 bg-black"
948 + pointerEvents={floatingSidebarOpen ? "auto" : "none"}
949 + style={[{ zIndex: 1 }, scrimAnimatedStyle]}
950 + >
951 + <Pressable
952 + accessibilityLabel="Hide sidebar"
953 + className="flex-1"
954 + onPress={() => setPrimarySidebarVisible(false)}
955 + />
956 + </Animated.View>
957 + ) : null}
958 <PaneContext value="inspector">
959 <WorkspaceInspectorPane
960 pathname={props.pathname}
@@ -903,11 +970,12 @@ function AdaptiveWorkspaceLayoutContent(
970 // Its trailing inset clips the old rail as soon as Android fits the workspace to a cover display.
971 <View
972 className="absolute inset-y-0 left-0 overflow-hidden"
906 - style={
973 + style={[
974 railOverlay
975 ? { right: 0 }
909 - : { right: viewportWidth - navigationRailWidth, maxWidth: navigationRailWidth }
910 - }
976 + : { right: viewportWidth - navigationRailWidth, maxWidth: navigationRailWidth },
977 + sidebarFloats ? { zIndex: 3, elevation: 8 } : null,
978 + ]}
979 >
980 <AndroidWorkspaceNavigation
981 onNewThread={handleStartNewTask}
apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx
+3 -3
@@ -320,7 +320,7 @@ function WorkspaceColumns(
320 ref={hostRef}
321 testID="adaptive-workspace-layout"
322 preferredSplitBehavior={
323 - !sidebarByOrientation && layout.primarySidebarOverlaysContent ? "overlay" : "tile"
323 + !sidebarByOrientation && layout.variant === "medium" ? "overlay" : "tile"
324 }
325 portraitPreferredSplitBehavior={sidebarByOrientation ? "overlay" : undefined}
326 portraitPreferredDisplayMode={
@@ -358,11 +358,11 @@ function WorkspaceColumns(
358 ? panes.primarySidebarVisible
359 : panes.primarySidebarWhenExpanded) ||
360 (!layout.usesSplitView && !activeDetailKey),
361 - layout.primarySidebarOverlaysContent,
361 + layout.variant === "medium",
362 )
363 }
364 onDisplayModeWillChange={({ nativeEvent }) => {
365 - if (!layout.primarySidebarOverlaysContent) return;
365 + if (layout.variant !== "medium") return;
366 if (nativeEvent.nextDisplayMode === "oneOverSecondary") setPrimarySidebarVisible(true);
367 else if (nativeEvent.nextDisplayMode === "secondaryOnly") setPrimarySidebarVisible(false);
368 }}
apps/mobile/src/features/layout/useSidebarToggle.ts
+1 -1
@@ -6,7 +6,7 @@ export function useSidebarToggle() {
6 const role = usePaneRole();
7 const { layout, panes, sidebarToggleable, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
8 if (role !== "content" || !sidebarToggleable) return null;
9 - const maximizes = panes.primarySidebarVisible && !layout.primarySidebarOverlaysContent;
9 + const maximizes = panes.primarySidebarVisible && layout.variant !== "medium";
10 return {
11 visible: panes.primarySidebarVisible,
12 accessibilityLabel: panes.primarySidebarVisible
apps/mobile/src/features/threads/ThreadDetailScreen.tsx
+1 -1
@@ -1175,7 +1175,7 @@ function ThreadDetailBody(
1175 ),
1176 );
1177 const layoutVariant = props.layoutVariant ?? "compact";
1178 - const isSplitLayout = layoutVariant === "split";
1178 + const isSplitLayout = layoutVariant !== "compact";
1179 const contentMaxWidth =
1180 Platform.OS === "android"
1181 ? ANDROID_READING_MAX_WIDTH
apps/mobile/src/features/threads/ThreadFeed.tsx
+4 -5
@@ -2693,9 +2693,8 @@ export const ThreadFeed = memo(function ThreadFeed({
2693 fontScale,
2694 });
2695 const settledPaneWidth = useWorkspaceSettledContentWidth();
2696 - const [measuredViewportWidth, setViewportWidth] = useState(() =>
2697 - props.layoutVariant === "split" ? 0 : windowWidth,
2698 - );
2696 + const splitLayout = (props.layoutVariant ?? "compact") !== "compact";
2697 + const [measuredViewportWidth, setViewportWidth] = useState(() => (splitLayout ? 0 : windowWidth));
2698 const viewportWidth =
2699 settledPaneWidth !== null ? Math.round(settledPaneWidth) : measuredViewportWidth;
2700 const [viewportHeight, setViewportHeight] = useState(0);
@@ -2797,7 +2796,7 @@ export const ThreadFeed = memo(function ThreadFeed({
2796 props.threadId,
2797 fileShareSourceIdentifier,
2798 );
2800 - const horizontalPadding = props.layoutVariant === "split" ? 20 : 16;
2799 + const horizontalPadding = splitLayout ? 20 : 16;
2800 const contentLeftInset = props.contentSideInsets?.left ?? 0;
2801 const contentRightInset = props.contentSideInsets?.right ?? 0;
2802 const usableViewportWidth = Math.max(0, viewportWidth - contentLeftInset - contentRightInset);
@@ -3822,7 +3821,7 @@ export const ThreadFeed = memo(function ThreadFeed({
3821 // Horizontal Duo reservations are already included in the row padding.
3822 contentInsetAdjustmentBehavior={
3823 usesNativeAutomaticInsets
3825 - ? duoColumns && props.layoutVariant === "split"
3824 + ? duoColumns && splitLayout
3825 ? "scrollableAxes"
3826 : "automatic"
3827 : "never"
apps/mobile/src/features/workspace/WorkspaceNativeTabs.ios.tsx
+1 -1
@@ -151,7 +151,7 @@ export function WorkspaceNativeTabs(props: {
151 </Tabs.Host>
152 {(deviceType === "pad" ||
153 compactTabs ||
154 - (layout.primarySidebarOverlaysContent &&
154 + (layout.variant === "medium" &&
155 !workspaceUsesColumns(selectedTab, workspace.settingsOpen))) &&
156 !props.hidden ? (
157 <View
apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
+1 -1
@@ -107,7 +107,7 @@ function WorkspaceRootContent() {
107 );
108 const tab = state.tabs[settingsOpen ? "settings" : state.selectedTab];
109 const bottomClearance =
110 - layout.primarySidebarOverlaysContent && state.selectedTab === "usage"
110 + layout.variant === "medium" && state.selectedTab === "usage"
111 ? workspaceDockBottomClearance({ bottomInset: insets.bottom, keyboardHeight })
112 : Platform.OS === "ios" && isDuoDevice(deviceType)
113 ? // The column's safe area already holds the Duo's search toolbar and keyboard.
apps/mobile/src/features/workspace/useSystemWorkspaceTabBar.ts
+1 -1
@@ -58,7 +58,7 @@ export function useSystemWorkspaceTabBar() {
58 return (
59 Platform.OS === "ios" &&
60 deviceType !== "pad" &&
61 - !layout.primarySidebarOverlaysContent &&
61 + layout.variant !== "medium" &&
62 sidebarTabs === null &&
63 !compactTabs
64 );
apps/mobile/src/lib/layout.test.ts
+13 -1
@@ -79,7 +79,7 @@ describe("native workspace sizing", () => {
79 reservedRegions: [],
80 };
81 const layout = deriveLayout({ ...size, nativeMetrics, nativeWorkspace });
82 - expect(layout.primarySidebarOverlaysContent).toBe(overlay);
82 + expect(layout.variant === "medium").toBe(overlay);
83 for (const primarySidebarPreferredVisible of [true, false]) {
84 expect(
85 deriveWorkspacePaneLayout({
@@ -131,6 +131,18 @@ describe("native workspace sizing", () => {
131 });
132 });
133
134 +describe("width classes", () => {
135 + it.each([
136 + { width: 599, height: 900, variant: "compact" },
137 + { width: 600, height: 900, variant: "medium" },
138 + { width: 719, height: 900, variant: "medium" },
139 + { width: 720, height: 900, variant: "expanded" },
140 + { width: 900, height: 599, variant: "compact" },
141 + ] as const)("classes a window without native columns by size: %j", ({ variant, ...size }) => {
142 + expect(deriveLayout(size).variant).toBe(variant);
143 + });
144 +});
145 +
146 describe("isPrimarySidebarPinned", () => {
147 // regression: #20406 sidebar toggle works on iPad and iPhone Duo
148 it("keeps compact native roots pinned so search cannot hide the sidebar for a later split", () => {
apps/mobile/src/lib/layout.ts
+30 -13
@@ -6,7 +6,8 @@ function clamp(value: number, min: number, max: number): number {
6 return Math.min(Math.max(value, min), max);
7 }
8
9 -const SPLIT_LAYOUT_MIN_WIDTH = 720;
9 +const MEDIUM_LAYOUT_MIN_WIDTH = 600;
10 +const EXPANDED_LAYOUT_MIN_WIDTH = 720;
11 const SPLIT_LAYOUT_MIN_HEIGHT = 600;
12
13 const SPLIT_SIDEBAR_MIN_WIDTH = 280;
@@ -58,12 +59,16 @@ const AUXILIARY_PANE_DEFAULT_MAX_WIDTH = 320;
59 const FILE_INSPECTOR_MIN_VIEWPORT_WIDTH = 820;
60 const FILE_INSPECTOR_MIN_MAIN_WIDTH = 560;
61
61 -export type LayoutVariant = "compact" | "split";
62 +/**
63 + * The window's width class. Compact: the sidebar is the root and pages push over it. Medium: the
64 + * sidebar floats over the content. Expanded: the sidebar sits beside the content.
65 + */
66 +export type LayoutVariant = "compact" | "medium" | "expanded";
67
68 export interface Layout {
69 readonly variant: LayoutVariant;
70 + /** Medium or expanded: pages replace the content beside the sidebar instead of pushing. */
71 readonly usesSplitView: boolean;
66 - readonly primarySidebarOverlaysContent: boolean;
72 readonly listPaneWidth: number | null;
73 readonly listPaneGap?: number;
74 readonly shellPadding: number;
@@ -115,18 +120,29 @@ export function deriveLayout(input: {
120 (metrics.hasHinge === true ||
121 metrics.verticalBarEdge !== "none" ||
122 metrics.reservedRegions.some((region) => region.kind === "division"));
118 - const wideEnoughForSplit =
123 + const variant: LayoutVariant =
124 metrics && (input.nativeWorkspace || hasDuoGeometry)
125 ? metrics.horizontalSizeClass === "regular" &&
126 usableWidth >= SPLIT_SIDEBAR_MIN_WIDTH + 320 &&
127 (input.nativeWorkspace || height >= 400)
123 - : width >= SPLIT_LAYOUT_MIN_WIDTH && height >= SPLIT_LAYOUT_MIN_HEIGHT;
128 + ? // The native split floats its sidebar over an unfolded portrait Duo.
129 + input.nativeWorkspace === true && metrics.hasHinge === true && width < height
130 + ? "medium"
131 + : "expanded"
132 + : "compact"
133 + : height < SPLIT_LAYOUT_MIN_HEIGHT || width < MEDIUM_LAYOUT_MIN_WIDTH
134 + ? "compact"
135 + : width >= EXPANDED_LAYOUT_MIN_WIDTH
136 + ? "expanded"
137 + : // Only the Android shell floats a sidebar over a page; iOS keeps its phone stack.
138 + metrics
139 + ? "compact"
140 + : "medium";
141
125 - if (!wideEnoughForSplit) {
142 + if (variant === "compact") {
143 return {
127 - variant: "compact",
144 + variant,
145 usesSplitView: false,
129 - primarySidebarOverlaysContent: false,
146 listPaneWidth: null,
147 shellPadding: 0,
148 };
@@ -140,10 +156,8 @@ export function deriveLayout(input: {
156 width - region.x - region.width - metrics.safeArea.right >= 320,
157 );
158 return {
143 - variant: "split",
159 + variant,
160 usesSplitView: true,
145 - primarySidebarOverlaysContent:
146 - input.nativeWorkspace === true && metrics?.hasHinge === true && width < height,
161 listPaneWidth:
162 division?.x ??
163 clamp(Math.round(width * 0.32), SPLIT_SIDEBAR_MIN_WIDTH, SPLIT_SIDEBAR_DEFAULT_MAX_WIDTH),
@@ -202,15 +216,18 @@ export function deriveWorkspacePaneLayout(input: {
216 readonly layout: Layout;
217 readonly viewportWidth: number;
218 readonly nativeWorkspace?: boolean;
219 + /** Whether the sidebar floats over the content rather than taking its room; medium by default. */
220 + readonly primarySidebarFloats?: boolean;
221 readonly primarySidebarPreferredVisible: boolean;
222 readonly auxiliaryPanePreferredVisible: boolean;
223 readonly auxiliaryPanePreferredWidth?: number;
224 }): WorkspacePaneLayout {
225 const viewportWidth = Math.max(0, input.viewportWidth);
226 + const floats = input.primarySidebarFloats ?? input.layout.variant === "medium";
227 const preferredPrimarySidebarVisible =
228 input.layout.usesSplitView && input.primarySidebarPreferredVisible;
229 const preferredPrimarySidebarWidth =
213 - preferredPrimarySidebarVisible && !input.layout.primarySidebarOverlaysContent
230 + preferredPrimarySidebarVisible && !floats
231 ? (input.layout.listPaneWidth ?? 0) + (input.layout.listPaneGap ?? 0)
232 : 0;
233 const fileInspector = deriveFileInspectorPaneLayout({
@@ -223,7 +240,7 @@ export function deriveWorkspacePaneLayout(input: {
240 const primarySidebarSuppressedByAuxiliary =
241 !input.nativeWorkspace &&
242 preferredPrimarySidebarVisible &&
226 - !input.layout.primarySidebarOverlaysContent &&
243 + !floats &&
244 auxiliaryPaneVisible &&
245 fileInspector.width !== null &&
246 input.layout.listPaneWidth !== null &&