GeezerVison is showing github.com — fix(mobile): keep compact native workspace root sidebar pinned · pingdotgg/t3code@b8c0952
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx +7-4Lines changed: 7 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -38,6 +38,7 @@ import { | 38 | 38 | deriveLayout, | 39 | 39 | type VerticalHinge, | 40 | 40 | deriveWorkspacePaneLayout, | | 41 | + isPrimarySidebarPinned, | 41 | 42 | type FileInspectorPaneLayout, | 42 | 43 | type Layout, | 43 | 44 | type WorkspaceAuxiliaryPaneRole, | @@ -245,10 +246,6 @@ function AdaptiveWorkspaceLayoutContent( | 245 | 246 | const navigation = useNavigation(); | 246 | 247 | const activeRoleOwner = useRef<symbol | null>(null); | 247 | 248 | 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; | 252 | 249 | const [supplementaryPanePreferredVisible, setSupplementaryPanePreferredVisible] = useState(true); | 253 | 250 | const [supplementaryPanePreferredWidth, setSupplementaryPanePreferredWidth] = useState< | 254 | 251 | number | null | @@ -264,6 +261,12 @@ function AdaptiveWorkspaceLayoutContent( | 264 | 261 | () => deriveLayout({ width: viewportWidth, height, nativeMetrics }), | 265 | 262 | [height, viewportWidth, nativeMetrics], | 266 | 263 | ); | | 264 | + const primarySidebarPinned = isPrimarySidebarPinned({ | | 265 | + pathname, | | 266 | + nativeWorkspace, | | 267 | + usesSplitView: baseLayout.usesSplitView, | | 268 | + }); | | 269 | + const showPrimarySidebar = primarySidebarPinned || primarySidebarPreferredVisible; | 267 | 270 | const shouldRenderNavigationRail = Platform.OS === "android" && baseLayout.usesSplitView; | 268 | 271 | const navigationRailWidth = | 269 | 272 | shouldRenderNavigationRail && showPrimarySidebar | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/lib/layout.test.ts +31Lines changed: 31 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 | deriveThreadFeedInitialContentInset, | 10 | 10 | deriveThreadWorkLogSizing, | 11 | 11 | deriveWorkspacePaneLayout, | | 12 | + isPrimarySidebarPinned, | 12 | 13 | SPLIT_LAYOUT_MIN_HEIGHT, | 13 | 14 | SPLIT_LAYOUT_MIN_WIDTH, | 14 | 15 | } from "./layout"; | @@ -161,6 +162,36 @@ describe("deriveLayout", () => { | 161 | 162 | }); | 162 | 163 | }); | 163 | 164 |
| | 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 | + | 164 | 195 | describe("deriveWorkspacePaneLayout", () => { | 165 | 196 | it("keeps the auxiliary pane out of a standard iPad detail column", () => { | 166 | 197 | const layout = deriveLayout({ width: 1_194, height: 834 }); | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/lib/layout.ts +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -158,6 +158,20 @@ export function alignListPaneToHinge(input: { | 158 | 158 | return { ...layout, listPaneWidth, listPaneGap: hinge.width }; | 159 | 159 | } | 160 | 160 |
| | 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 | + | 161 | 175 | export function deriveWorkspacePaneLayout(input: { | 162 | 176 | readonly layout: Layout; | 163 | 177 | readonly viewportWidth: number; | |
|