@devries-cameron20 / t3code Mirror · read-only / commits / f8ec357f96
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 23, 08:00 UTC

fix(mobile): sidebar toggle works on iPad and iPhone Duo (#20406)

Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Max Weinbach committed Oct 16, 2026 at 19:23 UTC f8ec357f96a919dacc29dde14f0c7e83f18892eb
5 files changed +65 -42
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+15 -5
@@ -38,6 +38,7 @@ import {
38 deriveLayout,
39 type VerticalHinge,
40 deriveWorkspacePaneLayout,
41 + isPrimarySidebarPinned,
42 type FileInspectorPaneLayout,
43 type Layout,
44 type WorkspaceAuxiliaryPaneRole,
@@ -245,7 +246,6 @@ function AdaptiveWorkspaceLayoutContent(
246 const navigation = useNavigation();
247 const activeRoleOwner = useRef<symbol | null>(null);
248 const [primarySidebarPreferredVisible, setPrimarySidebarPreferredVisible] = useState(true);
248 - const showPrimarySidebar = pathname === "/" || primarySidebarPreferredVisible;
249 const [supplementaryPanePreferredVisible, setSupplementaryPanePreferredVisible] = useState(true);
250 const [supplementaryPanePreferredWidth, setSupplementaryPanePreferredWidth] = useState<
251 number | null
@@ -261,6 +261,12 @@ function AdaptiveWorkspaceLayoutContent(
261 () => deriveLayout({ width: viewportWidth, height, nativeMetrics }),
262 [height, viewportWidth, nativeMetrics],
263 );
264 + const primarySidebarPinned = isPrimarySidebarPinned({
265 + pathname,
266 + nativeWorkspace,
267 + usesSplitView: baseLayout.usesSplitView,
268 + });
269 + const showPrimarySidebar = primarySidebarPinned || primarySidebarPreferredVisible;
270 const shouldRenderNavigationRail = Platform.OS === "android" && baseLayout.usesSplitView;
271 const navigationRailWidth =
272 shouldRenderNavigationRail && showPrimarySidebar
@@ -378,7 +384,7 @@ function AdaptiveWorkspaceLayoutContent(
384 };
385 }, []);
386 const togglePrimarySidebar = useCallback(() => {
381 - if (pathname === "/") {
387 + if (primarySidebarPinned) {
388 return;
389 }
390 if (!panes.primarySidebarVisible && panes.primarySidebarSuppressedByAuxiliary) {
@@ -387,7 +393,11 @@ function AdaptiveWorkspaceLayoutContent(
393 return;
394 }
395 setPrimarySidebarPreferredVisible((current) => !current);
390 - }, [panes.primarySidebarSuppressedByAuxiliary, panes.primarySidebarVisible, pathname]);
396 + }, [
397 + panes.primarySidebarSuppressedByAuxiliary,
398 + panes.primarySidebarVisible,
399 + primarySidebarPinned,
400 + ]);
401 const revealPrimarySidebar = useCallback(() => {
402 if (panes.primarySidebarSuppressedByAuxiliary) {
403 setFileInspectorPreferredVisible(false);
@@ -399,8 +409,8 @@ function AdaptiveWorkspaceLayoutContent(
409 return true;
410 }, [togglePrimarySidebar]);
411 const sidebarCommands = useMemo(
402 - () => (pathname === "/" ? [] : (["toggleSidebar"] as const)),
403 - [pathname],
412 + () => (primarySidebarPinned ? [] : (["toggleSidebar"] as const)),
413 + [primarySidebarPinned],
414 );
415 useHardwareKeyboardCommand(sidebarCommands, handleToggleSidebarCommand);
416 const showAuxiliaryPane = useCallback((role: WorkspaceAuxiliaryPaneRole) => {
apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx
+4 -20
@@ -23,11 +23,10 @@ import { use, useCallback, useEffect, useMemo, useRef, useState, type ComponentP
23 import { View } from "react-native";
24 import { Split, type SplitHostCommands } from "react-native-screens";
25 import { EnvironmentId, ThreadId } from "@t3tools/contracts";
26 -import { isDuoDevice } from "../../lib/device-type";
26 import { scopedThreadKey } from "../../lib/scopedEntities";
27 import { WorkspaceTabsProvider } from "../workspace/WorkspaceTabsContext";
28 import { WorkspaceNativeTabs } from "../workspace/WorkspaceNativeTabs.ios";
30 -import { useDeviceType, useNativeLayoutMetrics } from "../../native/native-layout-metrics";
29 +import { useNativeLayoutMetrics } from "../../native/native-layout-metrics";
30
31 import { useAdaptiveWorkspaceLayout } from "./AdaptiveWorkspaceLayout";
32 import { WorkspaceEmptyDetail } from "./WorkspaceEmptyDetail";
@@ -43,7 +42,6 @@ import {
42 } from "../../native/NativeWorkspaceColumns";
43 import { V5StackHeader } from "../../native/V5StackHeader.ios";
44 import type { AppNativeStackNavigationOptions } from "../../native/StackHeader";
46 -import { dispatchHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
45 import {
46 nativeWorkspacePopAction,
47 projectWorkspaceStack,
@@ -125,7 +123,6 @@ function WorkspaceColumns(
123 props: ViewProps & { readonly primary: Route; readonly detail: Route[] },
124 ) {
125 const { layout, panes, togglePrimarySidebar, toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout();
128 - const deviceType = useDeviceType();
126 const inspector = use(NativeWorkspaceInspectorContext);
127 const hostRef = useRef<SplitHostCommands>(null);
128 const activeDetailKey = props.detail.at(-1)?.key;
@@ -185,7 +182,9 @@ function WorkspaceColumns(
182 preferredSplitBehavior="tile"
183 topColumnForCollapsing={compactColumn}
184 preferredDisplayMode={
188 - panes.primarySidebarVisible || !activeDetailKey ? "oneBesideSecondary" : "secondaryOnly"
185 + panes.primarySidebarVisible || (!layout.usesSplitView && !activeDetailKey)
186 + ? "oneBesideSecondary"
187 + : "secondaryOnly"
188 }
189 displayModeButtonVisibility="never"
190 presentsWithGesture
@@ -222,21 +221,6 @@ function WorkspaceColumns(
221 options={{
222 headerShown: true,
223 title: "",
225 - unstable_headerRightItems: () =>
226 - isDuoDevice(deviceType) && layout.usesSplitView && !panes.primarySidebarVisible
227 - ? [
228 - {
229 - type: "button",
230 - axisBehavior: "verticalPreferred",
231 - accessibilityLabel: "Search threads",
232 - label: "Search threads",
233 - icon: { type: "sfSymbol", name: "magnifyingglass" },
234 - onPress: () => {
235 - dispatchHardwareKeyboardCommand("focusSearch");
236 - },
237 - },
238 - ]
239 - : [],
224 unstable_headerLeftItems: () => [
225 {
226 type: "button",
apps/mobile/src/features/threads/useThreadHeaderOptions.tsx
+1 -17
@@ -6,7 +6,6 @@ import { useDeviceType } from "../../native/native-layout-metrics";
6 import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";
7 import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
8 import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
9 -import { dispatchHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
9 import {
10 ThreadGitControls,
11 useThreadGitCenterHeaderItems,
@@ -105,21 +104,6 @@ export function useThreadHeaderOptions(props: {
104 () => [
105 ...threadCenterHeaderItems,
106 { type: "spacing", spacing: 8 },
108 - ...(layout.usesSplitView && !panes.primarySidebarVisible
109 - ? [
110 - withNativeGlassHeaderItem({
111 - type: "button" as const,
112 - axisBehavior: "verticalPreferred",
113 - identifier: "thread-right-search",
114 - label: "Search threads",
115 - accessibilityLabel: "Search threads",
116 - icon: { name: "magnifyingglass", type: "sfSymbol" as const },
117 - onPress: () => {
118 - dispatchHardwareKeyboardCommand("focusSearch");
119 - },
120 - }),
121 - ]
122 - : []),
107 withNativeGlassHeaderItem({
108 type: "button" as const,
109 axisBehavior: "verticalPreferred",
@@ -130,7 +114,7 @@ export function useThreadHeaderOptions(props: {
114 onPress: () => navigation.navigate("NewTaskSheet", { screen: "NewTask" }),
115 }),
116 ],
133 - [navigation, threadCenterHeaderItems, layout.usesSplitView, panes.primarySidebarVisible],
117 + [navigation, threadCenterHeaderItems],
118 );
119
120 const options: AppNativeStackNavigationOptions = {
apps/mobile/src/lib/layout.test.ts
+31
@@ -9,6 +9,7 @@ import {
9 deriveThreadFeedInitialContentInset,
10 deriveThreadWorkLogSizing,
11 deriveWorkspacePaneLayout,
12 + isPrimarySidebarPinned,
13 SPLIT_LAYOUT_MIN_HEIGHT,
14 SPLIT_LAYOUT_MIN_WIDTH,
15 } from "./layout";
@@ -161,6 +162,36 @@ describe("deriveLayout", () => {
162 });
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 +
195 describe("deriveWorkspacePaneLayout", () => {
196 it("keeps the auxiliary pane out of a standard iPad detail column", () => {
197 const layout = deriveLayout({ width: 1_194, height: 834 });
apps/mobile/src/lib/layout.ts
+14
@@ -158,6 +158,20 @@ export function alignListPaneToHinge(input: {
158 return { ...layout, listPaneWidth, listPaneGap: hinge.width };
159 }
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 +
175 export function deriveWorkspacePaneLayout(input: {
176 readonly layout: Layout;
177 readonly viewportWidth: number;