Skip to content

Commit 64357e9

Browse files
fix(mobile): iPad workspace tabs live in the sidebar and leave with it
On iPad the workspace tab pill was an overlay pinned to the bottom left of the whole split view, so with the sidebar hidden, by hand or by the inspector, it floated over the composer. With native columns the sidebar column now draws the tabs itself, so they move and hide with it, including UIKit's own gestures. The JS columns hide the overlay whenever the sidebar is hidden. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e9a4854 commit 64357e9

2 files changed

Lines changed: 59 additions & 14 deletions

File tree

‎apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,26 @@ import {
1919
type NativeStackNavigatorProps,
2020
type NativeStackTypeBag,
2121
} from "@react-navigation/native-stack";
22-
import { Fragment, use, useEffect, useRef, useState, type ComponentProps } from "react";
22+
import {
23+
Fragment,
24+
use,
25+
useEffect,
26+
useRef,
27+
useState,
28+
type ComponentProps,
29+
type ReactNode,
30+
} from "react";
2331
import { StyleSheet, View } from "react-native";
2432
import { Split, type SplitHostCommands } from "react-native-screens";
2533
import { SafeAreaView } from "react-native-safe-area-context";
2634
import { GestureHandlerRootView } from "react-native-gesture-handler";
2735
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
2836
import { scopedThreadKey } from "../../lib/scopedEntities";
2937
import { WorkspaceTabsProvider, useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
30-
import { WorkspaceNativeTabs } from "../workspace/WorkspaceNativeTabs.ios";
38+
import {
39+
WorkspaceNativeTabs,
40+
WorkspaceSidebarTabsFooter,
41+
} from "../workspace/WorkspaceNativeTabs.ios";
3142
import { workspaceUsesColumns } from "../workspace/workspace-tabs-state";
3243
import { isSettingsRoute, settingsOpenIn } from "../settings/settings-navigation";
3344
import { workspaceRoutesOf } from "./workspace-overlay-routes";
@@ -92,6 +103,7 @@ function ColumnScreen(props: {
92103
readonly onAppearance: (type: "willAppear" | "didAppear" | "willDisappear", key: string) => void;
93104
readonly onCompose?: () => void;
94105
readonly navigation: ViewProps["navigation"];
106+
readonly footer?: ReactNode;
95107
}) {
96108
const { descriptor } = props;
97109
// Options a screen set inside this workspace tab slot, over its route's.
@@ -160,6 +172,7 @@ function ColumnScreen(props: {
160172
<Fragment key={key}>{descriptor.render()}</Fragment>
161173
</NativePrimaryColumnContext>
162174
</ColumnContent>
175+
{props.footer}
163176
</NavigationRouteContext>
164177
</NavigationContext>
165178
</PaneContext>
@@ -387,6 +400,16 @@ function WorkspaceColumns(
387400
<ColumnScreen
388401
descriptor={primary}
389402
primary
403+
footer={
404+
deviceType === "pad" ? (
405+
<View
406+
pointerEvents="box-none"
407+
style={{ position: "absolute", left: 0, right: 0, bottom: 0, height: 128 }}
408+
>
409+
<WorkspaceSidebarTabsFooter />
410+
</View>
411+
) : undefined
412+
}
390413
selectedThreadKey={selectedThreadKey}
391414
selectedPullRequestKey={selectedPullRequestKey}
392415
onDismiss={handleNativeDismiss}
@@ -483,6 +506,7 @@ function WorkspaceColumns(
483506

484507
function WorkspaceStackView(props: ViewProps & { readonly nativeColumns: boolean }) {
485508
const { layout } = useAdaptiveWorkspaceLayout();
509+
const deviceType = useDeviceType();
486510
const workspace = useWorkspaceTabs()!;
487511
// Native dismiss commits the route pop after the transition. Restore the dock
488512
// when the primary screen starts appearing, including interactive back gestures.
@@ -516,6 +540,7 @@ function WorkspaceStackView(props: ViewProps & { readonly nativeColumns: boolean
516540
options: { headerShown: false },
517541
render: () => (
518542
<WorkspaceNativeTabs
543+
tabsInSidebarColumn={props.nativeColumns && !workspacePage && deviceType === "pad"}
519544
hidden={
520545
!workspacePage &&
521546
projection.detail.length > 0 &&

‎apps/mobile/src/features/workspace/WorkspaceNativeTabs.ios.tsx‎

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ function RetainedWorkspaceTab(props: {
6969
export function WorkspaceNativeTabs(props: {
7070
readonly children: ReactNode;
7171
readonly hidden: boolean;
72+
/** The sidebar column draws the tabs itself, so they leave with it. */
73+
readonly tabsInSidebarColumn?: boolean;
7274
}) {
7375
const workspace = useWorkspaceTabs()!;
7476
const order = useEnabledNavigationTabs();
@@ -79,8 +81,13 @@ export function WorkspaceNativeTabs(props: {
7981
const systemTabBar = useSystemWorkspaceTabBar();
8082
const deviceType = useDeviceType();
8183
const compactTabs = useCompactWorkspaceTabs();
82-
const { layout, startNewTask } = useAdaptiveWorkspaceLayout();
83-
const compactSidebarTabs = deviceType === "phone" || !layout.usesSplitView;
84+
const { layout, panes } = useAdaptiveWorkspaceLayout();
85+
// The tabs belong to the sidebar; over a page with the sidebar hidden they'd cover the composer.
86+
const hiddenWithSidebar =
87+
deviceType === "pad" &&
88+
layout.usesSplitView &&
89+
workspaceUsesColumns(workspace.state.selectedTab, workspace.settingsOpen) &&
90+
!panes.primarySidebarVisible;
8491
const { width } = useWindowDimensions();
8592
const { colors } = useControlTheme();
8693
const selectedTab = workspace.state.selectedTab;
@@ -149,7 +156,9 @@ export function WorkspaceNativeTabs(props: {
149156
compactTabs ||
150157
(layout.variant === "medium" &&
151158
!workspaceUsesColumns(selectedTab, workspace.settingsOpen))) &&
152-
!props.hidden ? (
159+
!props.hidden &&
160+
!props.tabsInSidebarColumn &&
161+
!hiddenWithSidebar ? (
153162
<View
154163
pointerEvents="box-none"
155164
style={{
@@ -164,17 +173,28 @@ export function WorkspaceNativeTabs(props: {
164173
height: 128,
165174
}}
166175
>
167-
<WorkspaceSidebarTabs
168-
compact={compactSidebarTabs}
169-
reserveComposeSpace={compactSidebarTabs}
170-
onNewTask={
171-
compactSidebarTabs && !workspace.settingsOpen && selectedTab === "threads"
172-
? startNewTask
173-
: undefined
174-
}
175-
/>
176+
<WorkspaceSidebarTabsFooter />
176177
</View>
177178
) : null}
178179
</View>
179180
);
180181
}
182+
183+
/** The workspace tabs at the foot of the sidebar. */
184+
export function WorkspaceSidebarTabsFooter() {
185+
const workspace = useWorkspaceTabs()!;
186+
const deviceType = useDeviceType();
187+
const { layout, startNewTask } = useAdaptiveWorkspaceLayout();
188+
const compact = deviceType === "phone" || !layout.usesSplitView;
189+
return (
190+
<WorkspaceSidebarTabs
191+
compact={compact}
192+
reserveComposeSpace={compact}
193+
onNewTask={
194+
compact && !workspace.settingsOpen && workspace.state.selectedTab === "threads"
195+
? startNewTask
196+
: undefined
197+
}
198+
/>
199+
);
200+
}

0 commit comments

Comments
 (0)