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, 07:00 UTC
fix(mobile): keep One UI navigation and Compose on one row (#29203)
Nick Anisimov committed
Nov 2, 2026 at 20:33 UTC
5e966bc04aa54782f57f81b08386d0e192f64eca
10 files changed
+52
-74
apps/mobile/src/components/ScrollComposeButton.android.tsx
+3
-1
@@ -17,12 +17,14 @@ import { resolveScaledTextRole } from "../lib/appearancePreferences";
17
export function ScrollComposeButton(props: {
18
readonly expanded: boolean;
19
readonly onPress: () => void;
20
+ readonly size?: number;
21
readonly className?: string;
22
readonly style?: StyleProp<ViewStyle>;
23
}) {
24
const { appearance, themeVariables: colors } = useAppearancePreferences();
25
const typography = resolveScaledTextRole("footnote", appearance.baseFontSize);
25
- const { iconSize, fabSize } = useAndroidControlSizing();
26
+ const { iconSize, fabSize: scaledFabSize } = useAndroidControlSizing();
27
+ const fabSize = props.size ?? scaledFabSize;
28
const nativeSize = Math.max(56, fabSize);
29
const scale = fabSize / nativeSize;
30
const nativeIconSize = Math.round(iconSize / scale);
apps/mobile/src/features/home/AndroidHomeFab.android.tsx
+14
-17
@@ -6,7 +6,7 @@ import {
6
type NativeSyntheticEvent,
7
} from "react-native";
8
import { useSafeAreaInsets } from "react-native-safe-area-context";
9
-import { NewThreadButton } from "../../components/NewThreadButton";
9
+import { ScrollComposeButton } from "../../components/ScrollComposeButton.android";
10
import {
11
androidHomeFabPosition,
12
type AndroidHomeFabLayout as SharedAndroidHomeFabLayout,
@@ -15,9 +15,9 @@ import { useWorkspaceState } from "../../state/workspace";
15
import { FabScrollContext } from "./FabScrollContext";
16
import { updateFabScroll } from "./fab-scroll";
17
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
18
-import { useEnabledNavigationTabs } from "../workspace/navigation-tabs";
18
import { WorkspaceTabsContext, useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
19
import { FLOATING_TABS, floatingTabsMetrics } from "../workspace/floating-workspace-tabs";
20
+import { useEnabledNavigationTabs } from "../workspace/navigation-tabs";
21
import {
22
useAppearancePreferences,
23
useAndroidFloatingTabs,
@@ -32,19 +32,16 @@ export function AndroidHomeFabLayout(props: ComponentProps<typeof SharedAndroidH
32
const { state } = useWorkspaceState();
33
const [expanded, setExpanded] = useState(true);
34
const { scale, fabSize } = useAndroidControlSizing();
35
- const tabs = useEnabledNavigationTabs();
36
- const floating = floatingTabsMetrics(
37
- tabs.length + 1,
38
- scale,
39
- fabSize,
40
- props.paneWidth ?? layoutWidth ?? undefined,
41
- );
35
+ const enabledTabs = useEnabledNavigationTabs();
36
+ const barWidth =
37
+ layoutWidth === null
38
+ ? undefined
39
+ : layoutWidth - (Math.max(insets.left, FLOATING_TABS.edge) - FLOATING_TABS.edge);
40
+ const size = floatingTabsEnabled
41
+ ? floatingTabsMetrics(enabledTabs.length + 1, scale, fabSize, barWidth).height
42
+ : fabSize;
43
const workspace = useWorkspaceTabs();
43
- const bottomClearance =
44
- insets.bottom +
45
- FLOATING_TABS.bottom +
46
- FLOATING_TABS.edge +
47
- Math.max(floating.height, floating.fabOffset + fabSize);
44
+ const bottomClearance = insets.bottom + FLOATING_TABS.bottom + FLOATING_TABS.edge + size;
45
const context = floatingTabsEnabled && workspace ? { ...workspace, bottomClearance } : workspace;
46
const scrollState = useRef({ anchor: 0, expanded: true });
47
const onScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
@@ -69,9 +66,9 @@ export function AndroidHomeFabLayout(props: ComponentProps<typeof SharedAndroidH
66
(!props.sidebar || floatingTabsEnabled) &&
67
state.hasConnections &&
68
layoutWidth !== null ? (
72
- <NewThreadButton
69
+ <ScrollComposeButton
70
key={`${appearance.baseFontSize}:${fontScale}:${layoutWidth}`}
74
- extended
71
+ size={size}
72
expanded={floatingTabsEnabled ? false : expanded}
73
onPress={props.onStartNewTask}
74
className="absolute"
@@ -79,7 +76,7 @@ export function AndroidHomeFabLayout(props: ComponentProps<typeof SharedAndroidH
76
floatingTabsEnabled
77
? {
78
right: FLOATING_TABS.edge,
82
- bottom: insets.bottom + FLOATING_TABS.bottom + floating.fabOffset,
79
+ bottom: insets.bottom + FLOATING_TABS.bottom,
80
}
81
: androidHomeFabPosition(insets.bottom, props.sidebar)
82
}
apps/mobile/src/features/home/AndroidHomeFab.shared.tsx
-1
@@ -5,7 +5,6 @@ export function AndroidHomeFabLayout(props: {
5
readonly children: ReactNode;
6
readonly sidebar?: boolean;
7
readonly disabled?: boolean;
8
- readonly paneWidth?: number;
8
}) {
9
return <>{props.children}</>;
10
}
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
-1
@@ -935,7 +935,6 @@ function AdaptiveWorkspaceLayoutContent(
935
<AndroidHomeFabLayout
936
sidebar
937
disabled={workspacePage}
938
- paneWidth={layout.listPaneWidth}
938
onStartNewTask={handleStartNewTask}
939
>
940
<ThreadNavigationSidebar
apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+3
-8
@@ -23,8 +23,7 @@ import type { LayoutChangeEvent, TextInputInstance } from "react-native";
23
import { Platform, StyleSheet, TextInput, View } from "react-native";
24
import { GestureDetector, useNativeGesture } from "react-native-gesture-handler";
25
import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
26
-import { useEnabledNavigationTabs } from "../workspace/navigation-tabs";
27
-import { FLOATING_TABS, floatingTabsMetrics } from "../workspace/floating-workspace-tabs";
26
+import { FLOATING_TABS } from "../workspace/floating-workspace-tabs";
27
import { useSafeAreaInsets } from "react-native-safe-area-context";
28
import type { SearchBarCommands } from "react-native-screens";
29
@@ -152,9 +151,7 @@ function ThreadNavigationSidebarPane(
151
const drawerColor = materialTheme["--color-drawer"];
152
153
const insets = useSafeAreaInsets();
155
- const { fabClearance, scale, fabSize } = useAndroidControlSizing();
156
- const enabledTabs = useEnabledNavigationTabs();
157
- const floatingTabs = floatingTabsMetrics(enabledTabs.length + 1, scale, fabSize, props.width);
154
+ const { fabClearance, fabSize } = useAndroidControlSizing();
155
const projects = useProjects();
156
const threads = useNavigationThreadShells();
157
const { environments: workspaceEnvironments, state: catalogState } = useWorkspaceState();
@@ -826,9 +823,7 @@ function ThreadNavigationSidebarPane(
823
paddingBottom:
824
Platform.OS === "android"
825
? floatingTabsEnabled
829
- ? FLOATING_TABS.bottom +
830
- FLOATING_TABS.edge +
831
- Math.max(floatingTabs.height, floatingTabs.fabOffset + fabSize)
826
+ ? FLOATING_TABS.bottom + FLOATING_TABS.edge + fabSize
827
: Math.max(insets.bottom, 16) + fabClearance - insets.bottom
828
: 16 + insets.bottom,
829
paddingTop: Platform.OS === "android" ? 6 : topListInset,
apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.android.tsx
+2
-2
@@ -97,8 +97,8 @@ export function AndroidWorkspaceNavigation(props: {
97
);
98
// FloatingWorkspaceTabs starts the bar at the left inset, so a cutout narrows the room.
99
const barWidth =
100
- props.paneWidth ??
101
- window.width - (Math.max(insets.left, FLOATING_TABS.edge) - FLOATING_TABS.edge);
100
+ (props.paneWidth ?? window.width) -
101
+ (Math.max(insets.left, FLOATING_TABS.edge) - FLOATING_TABS.edge);
102
const metrics = floatingTabsMetrics(tabs.length, scale, fabSize, barWidth, props.fillWidth);
103
if (!rail && keyboardVisible) return null;
104
apps/mobile/src/features/workspace/AndroidWorkspaceSidebar.android.tsx
+3
-4
@@ -5,7 +5,7 @@ import { NAVIGATION_TAB_ORDER } from "./navigation-tab-order";
5
import { type ReactNode } from "react";
6
import { useSafeAreaInsets } from "react-native-safe-area-context";
7
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
8
-import { FLOATING_TABS, floatingTabsMetrics } from "./floating-workspace-tabs";
8
+import { FLOATING_TABS } from "./floating-workspace-tabs";
9
import { View } from "react-native";
10
import { ScreenContent } from "../../components/ui/ScreenContent";
11
import { PullRequestsScreen } from "../pull-requests/PullRequestsScreen";
@@ -22,10 +22,9 @@ export function AndroidWorkspaceSidebar(props: {
22
const workspace = useWorkspaceTabs()!;
23
const enabled = useEnabledNavigationTabs();
24
const insets = useSafeAreaInsets();
25
- const { scale, fabSize } = useAndroidControlSizing();
26
- const floating = floatingTabsMetrics(enabled.length + 1, scale, fabSize);
25
+ const { fabSize } = useAndroidControlSizing();
26
const bottomClearance = floatingTabsEnabled
28
- ? insets.bottom + FLOATING_TABS.bottom + FLOATING_TABS.edge + floating.height
27
+ ? insets.bottom + FLOATING_TABS.bottom + FLOATING_TABS.edge + fabSize
28
: 16;
29
const context = { ...workspace, bottomClearance };
30
if (enabled.length === 0) return <WorkspaceNoTabs />;
apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx
+4
-12
@@ -3,7 +3,7 @@ import { WorkspaceNoTabs } from "./WorkspaceNoTabs";
3
import { useEnabledNavigationTabs } from "./navigation-tabs";
4
import { NAVIGATION_TAB_ORDER } from "./navigation-tab-order";
5
import { WorkspaceExtraTab } from "./WorkspaceExtraTab";
6
-import { useWindowDimensions, View } from "react-native";
6
+import { View } from "react-native";
7
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
8
import { NativeStackScreenOptions } from "../../native/StackHeader";
9
import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
@@ -15,7 +15,7 @@ import { PullRequestsScreen } from "../pull-requests/PullRequestsScreen";
15
import { PullRequestToolbar } from "../pull-requests/PullRequestToolbar.android";
16
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
17
import { AndroidWorkspaceNavigation, FloatingWorkspaceTabs } from "./AndroidWorkspaceNavigation";
18
-import { FLOATING_TABS, floatingTabsMetrics } from "./floating-workspace-tabs";
18
+import { FLOATING_TABS } from "./floating-workspace-tabs";
19
import { WorkspaceTabsContext, useWorkspaceTabs } from "./WorkspaceTabsContext";
20
import { WorkspaceTabPanes } from "./WorkspaceTabPanes";
21
import type { WorkspaceTab } from "./workspace-tabs-state";
@@ -28,21 +28,13 @@ export function WorkspaceRootScreen() {
28
const workspace = useWorkspaceTabs()!;
29
const enabled = useEnabledNavigationTabs();
30
const insets = useSafeAreaInsets();
31
- const { fabClearance, scale, fabSize } = useAndroidControlSizing();
32
- const window = useWindowDimensions();
33
- const floating = floatingTabsMetrics(enabled.length + 1, scale, fabSize, window.width);
31
+ const { fabClearance, fabSize } = useAndroidControlSizing();
32
const context = {
33
...workspace,
34
bottomClearance: layout.usesSplitView
35
? workspace.bottomClearance
36
: floatingTabsEnabled
39
- ? insets.bottom +
40
- FLOATING_TABS.bottom +
41
- FLOATING_TABS.edge +
42
- Math.max(
43
- floating.height,
44
- workspace.state.selectedTab === "threads" ? floating.fabOffset + fabSize : 0,
45
- )
37
+ ? insets.bottom + FLOATING_TABS.bottom + FLOATING_TABS.edge + fabSize
38
: workspace.state.selectedTab === "threads"
39
? fabClearance + 16
40
: 16,
apps/mobile/src/features/workspace/floating-workspace-tabs.test.ts
+15
-16
@@ -20,22 +20,21 @@ it.each([
20
);
21
22
it.each([
23
- [475, 1, 56],
24
- [411, 1, 56],
25
- [475, 1.25, 70],
23
+ [475, 1, 56, 4, 56],
24
+ [411, 1, 56, 4, 56],
25
+ [475, 1.25, 70, 4, 70],
26
+ [320, 11 / 16, 48, 4, 48],
27
+ [320, 1, 56, 4, 55.2],
28
+ [320, 22 / 16, 77, 4, 55.2],
29
+ [300, 22 / 16, 77, 4, 51.2],
30
+ [411, 22 / 16, 77, 4, 73.4],
31
+ [320, 22 / 16, 77, 2, 77],
32
] as const)(
27
- "fills a %sdp cover row at scale %s with a %sdp compose button",
28
- (width, scale, fabSize) => {
29
- const metrics = floatingTabsMetrics(4, scale, fabSize, width, true);
30
- expect(metrics.sharesRow).toBe(true);
31
- expect(metrics.pill + 2 * 16 + 12 + fabSize).toBe(width);
32
- expect(metrics.height).toBe(fabSize);
33
+ "fills a %sdp row at scale %s beside a %sdp compose button",
34
+ (width, scale, fabSize, count, height) => {
35
+ const metrics = floatingTabsMetrics(count, scale, fabSize, width, true);
36
+ expect(metrics.pill + 2 * 16 + 12 + metrics.height).toBeCloseTo(width);
37
+ expect(metrics.height).toBeCloseTo(height);
38
+ expect(metrics.pill / count).toBeGreaterThanOrEqual(metrics.height - 0.001);
39
},
40
);
35
-
36
-it("stacks compose above a full-width pill when a cover row is too narrow", () => {
37
- const metrics = floatingTabsMetrics(4, 1, 56, 300, true);
38
- expect(metrics.sharesRow).toBe(false);
39
- expect(metrics.pill).toBe(268);
40
- expect(metrics.fabOffset).toBe(68);
41
-});
apps/mobile/src/features/workspace/floating-workspace-tabs.ts
+8
-12
@@ -9,22 +9,18 @@ export function floatingTabsMetrics(
9
fillWidth = false,
10
) {
11
const unit = Math.max(1, scale);
12
- const height = fabSize;
13
- const beside = 2 * FLOATING_TABS.edge + FLOATING_TABS.gap + fabSize;
14
- const row = beside + count * 60 * unit;
15
- const sharesRow = paneWidth === undefined || paneWidth >= row;
16
- const room =
12
+ const spacing = 2 * FLOATING_TABS.edge + FLOATING_TABS.gap;
13
+ // Share width evenly when space is tight, retaining Android's 48dp touch target.
14
+ const height =
15
paneWidth === undefined
18
- ? count * 60 * unit
19
- : sharesRow
20
- ? paneWidth - beside
21
- : paneWidth - 2 * FLOATING_TABS.edge;
16
+ ? fabSize
17
+ : Math.max(48, Math.min(fabSize, (paneWidth - spacing) / (count + 1)));
18
+ const beside = spacing + height;
19
+ const room = paneWidth === undefined ? count * 60 * unit : paneWidth - beside;
20
return {
21
// Reserve the compose slot even while its button is hidden.
22
pill: Math.max(0, fillWidth ? room : Math.min(count * 72 * unit, room)),
23
height,
26
- row,
27
- sharesRow,
28
- fabOffset: sharesRow ? (height - fabSize) / 2 : height + FLOATING_TABS.gap,
24
+ row: beside + count * 60 * unit,
25
};
26
}