Skip to content

Commit b8c0952

Browse files
fix(mobile): keep compact native workspace root sidebar pinned
Focusing search on a compact native root (iPad Slide Over, folded Duo) saw the sidebar as hidden and flipped the saved preference, so expanding into split view hid the sidebar and its search results. Only native split columns may collapse the sidebar on the workspace root. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3f183a6 commit b8c0952

3 files changed

Lines changed: 52 additions & 4 deletions

File tree

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
deriveLayout,
3939
type VerticalHinge,
4040
deriveWorkspacePaneLayout,
41+
isPrimarySidebarPinned,
4142
type FileInspectorPaneLayout,
4243
type Layout,
4344
type WorkspaceAuxiliaryPaneRole,
@@ -245,10 +246,6 @@ function AdaptiveWorkspaceLayoutContent(
245246
const navigation = useNavigation();
246247
const activeRoleOwner = useRef<symbol | null>(null);
247248
const [primarySidebarPreferredVisible, setPrimarySidebarPreferredVisible] = useState(true);
248-
// Native columns keep a sidebar toggle in the empty detail header, so only
249-
// the JS layout must pin the sidebar open on the workspace root.
250-
const primarySidebarPinned = pathname === "/" && !nativeWorkspace;
251-
const showPrimarySidebar = primarySidebarPinned || primarySidebarPreferredVisible;
252249
const [supplementaryPanePreferredVisible, setSupplementaryPanePreferredVisible] = useState(true);
253250
const [supplementaryPanePreferredWidth, setSupplementaryPanePreferredWidth] = useState<
254251
number | null
@@ -264,6 +261,12 @@ function AdaptiveWorkspaceLayoutContent(
264261
() => deriveLayout({ width: viewportWidth, height, nativeMetrics }),
265262
[height, viewportWidth, nativeMetrics],
266263
);
264+
const primarySidebarPinned = isPrimarySidebarPinned({
265+
pathname,
266+
nativeWorkspace,
267+
usesSplitView: baseLayout.usesSplitView,
268+
});
269+
const showPrimarySidebar = primarySidebarPinned || primarySidebarPreferredVisible;
267270
const shouldRenderNavigationRail = Platform.OS === "android" && baseLayout.usesSplitView;
268271
const navigationRailWidth =
269272
shouldRenderNavigationRail && showPrimarySidebar

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
deriveThreadFeedInitialContentInset,
1010
deriveThreadWorkLogSizing,
1111
deriveWorkspacePaneLayout,
12+
isPrimarySidebarPinned,
1213
SPLIT_LAYOUT_MIN_HEIGHT,
1314
SPLIT_LAYOUT_MIN_WIDTH,
1415
} from "./layout";
@@ -161,6 +162,36 @@ describe("deriveLayout", () => {
161162
});
162163
});
163164

165+
describe("isPrimarySidebarPinned", () => {
166+
it("lets native split columns collapse the sidebar on the workspace root", () => {
167+
expect(
168+
isPrimarySidebarPinned({ pathname: "/", nativeWorkspace: true, usesSplitView: true }),
169+
).toBe(false);
170+
});
171+
172+
it("keeps compact native roots pinned so search cannot hide the sidebar for a later split", () => {
173+
expect(
174+
isPrimarySidebarPinned({ pathname: "/", nativeWorkspace: true, usesSplitView: false }),
175+
).toBe(true);
176+
});
177+
178+
it("keeps the JS split layout pinned on the workspace root", () => {
179+
expect(
180+
isPrimarySidebarPinned({ pathname: "/", nativeWorkspace: false, usesSplitView: true }),
181+
).toBe(true);
182+
});
183+
184+
it("never pins outside the workspace root", () => {
185+
expect(
186+
isPrimarySidebarPinned({
187+
pathname: "/threads/a/b",
188+
nativeWorkspace: false,
189+
usesSplitView: true,
190+
}),
191+
).toBe(false);
192+
});
193+
});
194+
164195
describe("deriveWorkspacePaneLayout", () => {
165196
it("keeps the auxiliary pane out of a standard iPad detail column", () => {
166197
const layout = deriveLayout({ width: 1_194, height: 834 });

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,20 @@ export function alignListPaneToHinge(input: {
158158
return { ...layout, listPaneWidth, listPaneGap: hinge.width };
159159
}
160160

161+
/**
162+
* Whether the workspace root must keep the primary sidebar open. Native split
163+
* columns keep a sidebar toggle in the empty detail header, so only they may
164+
* collapse it there. Compact layouts stay pinned so a reveal request (such as
165+
* focusing search) cannot flip the saved preference for a later split view.
166+
*/
167+
export function isPrimarySidebarPinned(input: {
168+
readonly pathname: string;
169+
readonly nativeWorkspace: boolean;
170+
readonly usesSplitView: boolean;
171+
}): boolean {
172+
return input.pathname === "/" && !(input.nativeWorkspace && input.usesSplitView);
173+
}
174+
161175
export function deriveWorkspacePaneLayout(input: {
162176
readonly layout: Layout;
163177
readonly viewportWidth: number;

0 commit comments

Comments
 (0)