@devries-cameron20 / t3code Mirror · read-only / commits / eb1db29e54
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 22, 04:30 UTC

fix(mobile): the Android split slides as one strip, so sidebar and detail pane always fill the width (#26328)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 3, 2026 at 18:40 UTC eb1db29e54f88f9b95383821b00cb3ed52409a0c
6 files changed +204 -40
apps/mobile/src/components/ui/SegmentedControl.shared.tsx
+12 -3
@@ -1,6 +1,11 @@
1 import { useState } from "react";
2 import { I18nManager, Platform, Pressable, View } from "react-native";
3 -import Animated, { useAnimatedStyle, useReducedMotion, withTiming } from "react-native-reanimated";
3 +import Animated, {
4 + useAnimatedStyle,
5 + useDerivedValue,
6 + useReducedMotion,
7 + withTiming,
8 +} from "react-native-reanimated";
9
10 import { segmentedControlColors } from "./segmentedControlColors";
11 import { AppText } from "./AppText";
@@ -18,10 +23,14 @@ export function SegmentedControl<Value extends string | number>(
23 const reduceMotion = useReducedMotion();
24 const selectedIndex = props.options.findIndex((option) => option.value === props.selected);
25 const segmentWidth = props.options.length ? Math.max(0, width - 6) / props.options.length : 0;
21 - const selectionOffset = selectedIndex * segmentWidth * (I18nManager.isRTL ? -1 : 1);
26 + const direction = I18nManager.isRTL ? -1 : 1;
27 + // The index animates, not the offset, so a resize moves the selection without sliding it.
28 + const selectedPosition = useDerivedValue(() =>
29 + withTiming(selectedIndex, { duration: reduceMotion ? 0 : 160 }),
30 + );
31 const selectionStyle = useAnimatedStyle(() => ({
32 width: segmentWidth,
24 - transform: [{ translateX: withTiming(selectionOffset, { duration: reduceMotion ? 0 : 160 }) }],
33 + transform: [{ translateX: selectedPosition.value * segmentWidth * direction }],
34 }));
35 const { trackColor, selectedColor, selectedTextColor, mutedColor } = segmentedControlColors(
36 colors,
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+161 -32
@@ -8,6 +8,7 @@ import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area
8 import { AdaptiveWorkspaceContext, useAdaptiveWorkspaceLayout } from "./adaptive-workspace-context";
9 import { threadSelectionDeferral } from "./deferred-navigation";
10 import { uuidv4 } from "../../lib/uuid";
11 +import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
12 import { EnvironmentId, ThreadId, type SidebarProjectGroupingMode } from "@t3tools/contracts";
13 import { useAtomValue } from "@effect/atom-react";
14 import { NavigationContext, NavigationRouteContext, useNavigation } from "@react-navigation/native";
@@ -29,7 +30,11 @@ import {
30 useWindowDimensions,
31 View,
32 } from "react-native";
32 -import { KeyboardController, useKeyboardContext } from "react-native-keyboard-controller";
33 +import {
34 + KeyboardController,
35 + useKeyboardContext,
36 + useKeyboardState,
37 +} from "react-native-keyboard-controller";
38 import Animated, {
39 runOnJS,
40 useAnimatedStyle,
@@ -312,15 +317,17 @@ function AdaptiveWorkspaceLayoutContent(
317 !sidebarFloats &&
318 (composerEditing || composerKeyboardActive);
319 const keyboardProgress = useKeyboardContext().reanimated.progress;
320 + // From the moment the keyboard starts showing until it has fully hidden. The detail pane keeps
321 + // the sidebar's room for that whole span, so on the way back the sidebar pushes the wide pane
322 + // aside instead of arriving beside one that already shrank.
323 + const keyboardOnScreen = useKeyboardState((state) => state.isVisible);
324 const shouldRenderNavigationRail =
325 Platform.OS === "android" && baseLayout.usesSplitView && !floatingTabsEnabled;
326 const enabledTabs = useEnabledNavigationTabs();
327 const { scale, fabSize } = useAndroidControlSizing();
328 const floatingTabs = floatingTabsMetrics(enabledTabs.length + 1, scale, fabSize);
320 - const navigationRailWidth =
321 - shouldRenderNavigationRail && (showPrimarySidebar || workspacePage)
322 - ? ANDROID_WORKSPACE_RAIL_WIDTH
323 - : 0;
329 + // The rail stays whether or not the sidebar shows; only the list pane comes and goes.
330 + const navigationRailWidth = shouldRenderNavigationRail ? ANDROID_WORKSPACE_RAIL_WIDTH : 0;
331 const [hinge, setHinge] = useState<VerticalHinge | null>(null);
332 const [windowHinge, setWindowHinge] = useState<VerticalHinge | null>(null);
333 const handleHingeChange = (next: VerticalHinge | null, nextWindow: VerticalHinge | null) => {
@@ -655,9 +662,58 @@ function AdaptiveWorkspaceLayoutContent(
662 : 0;
663 // Android's split content is a rounded card: keep it off the screen edge like the list card.
664 const contentEndGap = Platform.OS === "android" && layout.usesSplitView ? 4 : 0;
658 - const contentTargetWidth = layout.usesSplitView
659 - ? Math.max(0, panes.contentPaneWidth - inspectorColumnTargetWidth - contentEndGap)
660 - : null;
665 + // Android's split is one strip: a sidebar slot of fixed width, then the detail pane. The
666 + // sidebar never resizes; both slide by one offset, so together they always fill the width.
667 + // The pane spans the sidebar's room too unless the sidebar has finished arriving: a sidebar on
668 + // its way in pushes the wide pane past the edge, and one leaving uncovers it.
669 + const stripSidebar =
670 + Platform.OS === "android" &&
671 + layout.usesSplitView &&
672 + layout.listPaneWidth !== null &&
673 + !workspacePage &&
674 + !sidebarFloats;
675 + const sidebarSlotWidth = (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0);
676 + const sidebarTargetOpen = keyboardHoldsSidebar ? sidebarRestsOpen : panes.primarySidebarVisible;
677 + const [sidebarMotion, setSidebarMotion] = useState({
678 + strip: stripSidebar,
679 + settledOpen: sidebarTargetOpen,
680 + });
681 + if (sidebarMotion.strip !== stripSidebar) {
682 + // Entering or leaving the strip (a workspace page, a fold) snaps the sidebar into place.
683 + setSidebarMotion({ strip: stripSidebar, settledOpen: sidebarTargetOpen });
684 + } else if (sidebarMotion.settledOpen && !sidebarTargetOpen) {
685 + setSidebarMotion({ strip: stripSidebar, settledOpen: false });
686 + }
687 + const sidebarSettledOpen =
688 + sidebarMotion.strip === stripSidebar ? sidebarMotion.settledOpen : sidebarTargetOpen;
689 + const markSidebarSettled = (open: boolean) =>
690 + setSidebarMotion((current) =>
691 + current.settledOpen === open ? current : { ...current, settledOpen: open },
692 + );
693 + // The keyboard covers the sidebar's share from the moment it starts showing until it is gone.
694 + const contentSpansSidebar =
695 + stripSidebar &&
696 + (!sidebarSettledOpen || !sidebarTargetOpen || (keyboardHoldsSidebar && keyboardOnScreen));
697 + const contentTargetWidth = !layout.usesSplitView
698 + ? null
699 + : Math.max(
700 + 0,
701 + (contentSpansSidebar ? width : panes.contentPaneWidth) -
702 + inspectorColumnTargetWidth -
703 + contentEndGap,
704 + );
705 + // A workspace page (Usage) lays out at this width even while hidden behind another tab, so
706 + // opening it widens nothing it measured.
707 + const workspacePageWidth = !layout.usesSplitView
708 + ? null
709 + : workspacePage
710 + ? contentTargetWidth
711 + : Math.max(
712 + 0,
713 + viewportWidth -
714 + (shouldRenderNavigationRail ? ANDROID_WORKSPACE_RAIL_WIDTH : 0) -
715 + contentEndGap,
716 + );
717 const [listPaneSizing, setListPaneSizing] = useState({
718 viewportWidth,
719 workspacePage,
@@ -773,7 +829,10 @@ function AdaptiveWorkspaceLayoutContent(
829 // The content beside it already took its final width when the page closed.
830 renderedSidebarWidth.set(
831 withTiming(targetWidth, snap ? { duration: 0 } : WORKSPACE_PANE_TIMING, (finished) => {
776 - if (finished && Platform.OS === "android") runOnJS(settleListPane)(listPaneRevision);
832 + if (finished && Platform.OS === "android") {
833 + runOnJS(settleListPane)(listPaneRevision);
834 + runOnJS(markSidebarSettled)(targetWidth > 0);
835 + }
836 }),
837 );
838 }, [
@@ -789,6 +848,7 @@ function AdaptiveWorkspaceLayoutContent(
848 renderedSidebarWidth,
849 renderedRailWidth,
850 settleListPane,
851 + markSidebarSettled,
852 listPaneRevision,
853 workspacePage,
854 ]);
@@ -819,24 +879,45 @@ function AdaptiveWorkspaceLayoutContent(
879 // Showing or hiding the sidebar clips a fixed-width list. A hinge resize instead tracks the
880 // animated edge, so the header actions slide with it rather than jumping or being covered.
881 const listPaneGap = layout.listPaneGap ?? 0;
882 + const keyboardSidebarRest = sidebarRestsOpen
883 + ? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0)
884 + : 0;
885 const drawnSidebarWidth = useDerivedValue(
886 () => renderedSidebarWidth.value * (keyboardHold.value ? 1 - keyboardProgress.value : 1),
887 );
888 const listPaneAnimatedStyle = useAnimatedStyle(() => ({
889 width: Math.min(
890 listPaneCeiling,
828 - Math.max(listPaneFloor, drawnSidebarWidth.value - listPaneGap),
891 + Math.max(
892 + listPaneFloor,
893 + (stripSidebar ? sidebarSlotWidth : drawnSidebarWidth.value) - listPaneGap,
894 + ),
895 ),
830 - // Following the keyboard, the list rides the sidebar's edge like the content beside it,
831 - // instead of being uncovered in place.
832 - transform: [{ translateX: drawnSidebarWidth.value - renderedSidebarWidth.value }],
896 }));
897 + // How far the strip has slid: 0 with the sidebar shown, minus its width with it gone.
898 + const stripOffset = useDerivedValue(() =>
899 + stripSidebar ? drawnSidebarWidth.value - sidebarSlotWidth : 0,
900 + );
901 const sidebarAnimatedStyle = useAnimatedStyle(() => ({
902 // Fading a UIKit glass ancestor can leave remounted header effects missing.
903 opacity:
837 - Platform.OS === "ios" || floatingTabsEnabled ? 1 : Math.min(1, drawnSidebarWidth.value / 80),
838 - width: drawnSidebarWidth.value,
904 + stripSidebar || Platform.OS === "ios" || floatingTabsEnabled
905 + ? 1
906 + : Math.min(1, drawnSidebarWidth.value / 80),
907 + width: stripSidebar ? sidebarSlotWidth : drawnSidebarWidth.value,
908 + flexShrink: stripSidebar ? 0 : 1,
909 + transform: [{ translateX: stripOffset.value }],
910 }));
911 + // The content keeps the width React laid it out at and rides the sidebar's edge, so a keyboard
912 + // transition relays nothing out per frame, the way UIKit animates the iOS split view.
913 + // Until React commits the wider layout, the detail card continues past its right edge, so the
914 + // strip the narrower column leaves shows the card instead of the row behind it.
915 + const contentOverhangStyle = useAnimatedStyle(() => ({
916 + opacity: keyboardHold.value && keyboardProgress.value > 0 ? 1 : 0,
917 + }));
918 + const threadHeader = useToolbarLayout(false, composerKeyboardActive);
919 + const threadHeaderHeight =
920 + threadHeader.paddingTop + threadHeader.height + threadHeader.paddingBottom;
921
922 // Clip the navigator at its settled width so native headers and markdown reflow only once per pane toggle.
923 const renderedInspectorWidth = useSharedValue(inspectorColumnTargetWidth);
@@ -851,13 +932,33 @@ function AdaptiveWorkspaceLayoutContent(
932 );
933 // Android can resize the native row before React removes its split panes on a fold.
934 const androidSplit = Platform.OS === "android" && layout.usesSplitView;
854 - const androidContentSlotStyle = useAnimatedStyle(() => ({
855 - width: androidSplit ? renderedContentWidth.value : ("100%" as const),
856 - }));
935 + // In the strip the column itself slides with the sidebar: Android only delivers touches inside a
936 + // parent's bounds, so content may not slide out of its column.
937 + const androidContentSlotStyle = useAnimatedStyle(() =>
938 + !androidSplit
939 + ? { width: "100%" as const }
940 + : stripSidebar
941 + ? {
942 + // Wide enough for the pane at either width; the margin gives the sidebar's share
943 + // back to the row, so a column after it stays put while the strip slides.
944 + width: Math.max(
945 + 0,
946 + viewportWidth - renderedRailWidth.value - renderedInspectorWidth.value,
947 + ),
948 + marginRight: -sidebarSlotWidth,
949 + transform: [{ translateX: stripOffset.value }],
950 + }
951 + : { width: renderedContentWidth.value },
952 + );
953 // While the sidebar animates, clip the settled navigator instead of reflowing its text every frame.
954 + // In the strip it lifts entirely: the content outgrows its column, and a cap that follows
955 + // React's width would clip the wider layout for the frame it lands.
956 const androidNavigatorLimit = useAnimatedStyle(() => ({
859 - maxWidth:
860 - androidSplit && contentTargetWidth !== null && renderedContentWidth.value < contentTargetWidth
957 + maxWidth: stripSidebar
958 + ? viewportWidth
959 + : androidSplit &&
960 + contentTargetWidth !== null &&
961 + renderedContentWidth.value < contentTargetWidth
962 ? contentTargetWidth
963 : ("100%" as const),
964 }));
@@ -902,8 +1003,10 @@ function AdaptiveWorkspaceLayoutContent(
1003 nativeInspectorColumnWidth(viewportWidth, width / viewportWidth) / viewportWidth,
1004 ),
1005 composerKeyboardActive,
1006 + keyboardHoldsSidebar,
1007 setComposerEditing,
1008 sidebarByOrientation,
1009 + workspacePageWidth,
1010 };
1011
1012 const inspectorSheet = (
@@ -1009,18 +1112,15 @@ function AdaptiveWorkspaceLayoutContent(
1112 <Animated.View
1113 collapsable={false}
1114 style={[
1012 - // While the keyboard moves the sidebar, the content tracks its edge every frame so
1013 - // the two land together; a settled width would jump when React commits mid-slide.
1014 - keyboardHoldsSidebar
1015 - ? { flex: 1, marginRight: contentEndGap }
1016 - : contentTargetWidth !== null
1017 - ? {
1018 - flex: 1,
1019 - width: contentTargetWidth,
1020 - alignSelf: contentAnchor.end ? "flex-end" : "flex-start",
1021 - marginRight: contentAnchor.end ? contentEndGap : 0,
1022 - }
1023 - : { flex: 1 },
1115 + contentTargetWidth !== null
1116 + ? {
1117 + flex: 1,
1118 + width: contentTargetWidth,
1119 + // The strip's column is wider than the pane; the pane sits at its start.
1120 + alignSelf: contentAnchor.end && !stripSidebar ? "flex-end" : "flex-start",
1121 + marginRight: contentAnchor.end && !stripSidebar ? contentEndGap : 0,
1122 + }
1123 + : { flex: 1 },
1124 Platform.OS === "android" ? androidNavigatorLimit : undefined,
1125 ]}
1126 >
@@ -1068,6 +1168,35 @@ function AdaptiveWorkspaceLayoutContent(
1168 </WorkspaceSettledContentWidthContext>
1169 </WorkspaceContentWidthContext>
1170 </Animated.View>
1171 + {keyboardHoldsSidebar && contentTargetWidth !== null ? (
1172 + <>
1173 + <Animated.View
1174 + pointerEvents="none"
1175 + className="absolute top-0 bg-header"
1176 + style={[
1177 + {
1178 + left: contentTargetWidth,
1179 + width: keyboardSidebarRest + contentEndGap,
1180 + height: threadHeaderHeight,
1181 + },
1182 + contentOverhangStyle,
1183 + ]}
1184 + />
1185 + <Animated.View
1186 + pointerEvents="none"
1187 + className="absolute bottom-0 rounded-tr-[28px] bg-thread-canvas"
1188 + style={[
1189 + {
1190 + // Starts under the card's rounded corner so the two read as one card.
1191 + left: contentTargetWidth - 28,
1192 + width: keyboardSidebarRest + 28,
1193 + top: threadHeaderHeight,
1194 + },
1195 + contentOverhangStyle,
1196 + ]}
1197 + />
1198 + </>
1199 + ) : null}
1200 </Animated.View>
1201 {sidebarFloats ? (
1202 <Animated.View
apps/mobile/src/features/layout/adaptive-workspace-context.ts
+4
@@ -58,6 +58,10 @@ interface AdaptiveWorkspaceContextValue {
58 * (the unfolded Duo). The native split switches between them as a rotation starts.
59 */
60 readonly sidebarByOrientation: { readonly landscape: boolean; readonly portrait: boolean } | null;
61 + /** Android split: the composer's keyboard slides the sidebar, from focus until it lets go. */
62 + readonly keyboardHoldsSidebar?: boolean;
63 + /** Android split: the width a workspace page (Usage) opens at; null without columns. */
64 + readonly workspacePageWidth?: number | null;
65 /** The thread composer reports its focus so the layout can make room for typing. */
66 readonly setComposerEditing: (editing: boolean) => void;
67 }
apps/mobile/src/features/usage/UsageRouteScreen.tsx
+4 -1
@@ -37,6 +37,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
37 import { SegmentedControl } from "../../components/ui/SegmentedControl";
38 import { useReduceMotionEnabled } from "../../lib/appState";
39 import { AppText as Text } from "../../components/ui/AppText";
40 +import { useWorkspaceSettledContentWidth } from "../layout/workspace-content-width";
41 import { ProviderIcon } from "../../components/ProviderIcon";
42 import { cn } from "../../lib/cn";
43 import { SettingsScreen } from "../settings/components/SettingsScreen";
@@ -97,7 +98,9 @@ function UsageScreen(props: {
98 }
99 const { view } = selection;
100 const setView = (view: UsageView) => setSelection({ params: props.tabParam, view });
100 - const [width, setWidth] = useState(0);
101 + const [measuredWidth, setWidth] = useState(0);
102 + // A workspace pane knows its width in the render that resizes it; measuring lags a frame.
103 + const width = useWorkspaceSettledContentWidth() ?? measuredWidth;
104 const wide = width >= WIDE_WIDTH;
105 const [windowSelection, setWindowSelection] = useState(() => ({
106 days: 30,
apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.android.tsx
+3 -2
@@ -81,7 +81,7 @@ export function AndroidWorkspaceNavigation(props: {
81 const toolbar = useToolbarLayout();
82 const connectionState = useWorkspaceConnectionState();
83 const keyboardVisible = useSoftKeyboardShowing();
84 - const { layout } = useAdaptiveWorkspaceLayout();
84 + const { layout, keyboardHoldsSidebar } = useAdaptiveWorkspaceLayout();
85 const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
86 const { scale, fabSize } = useAndroidControlSizing();
87 const window = useWindowDimensions();
@@ -102,7 +102,8 @@ export function AndroidWorkspaceNavigation(props: {
102 (props.paneWidth ?? window.width) -
103 (Math.max(insets.left, FLOATING_TABS.edge) - FLOATING_TABS.edge);
104 const metrics = floatingTabsMetrics(tabs.length, scale, fabSize, barWidth, props.fillWidth);
105 - if (!rail && keyboardVisible) return null;
105 + // The composer's keyboard slides the sidebar away with the bar on it; other keyboards don't.
106 + if (!rail && keyboardVisible && !keyboardHoldsSidebar) return null;
107
108 return (
109 <View
apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx
+20 -2
@@ -3,6 +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 type { ReactNode } from "react";
7 import { View } from "react-native";
8 import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
9 import { NativeStackScreenOptions } from "../../native/StackHeader";
@@ -14,6 +15,7 @@ import { HomeRouteScreen } from "../home/HomeRouteScreen";
15 import { PullRequestsScreen } from "../pull-requests/PullRequestsScreen";
16 import { PullRequestToolbar } from "../pull-requests/PullRequestToolbar.android";
17 import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
18 +import { WorkspaceSettledContentWidthContext } from "../layout/workspace-content-width";
19 import { AndroidWorkspaceNavigation, FloatingWorkspaceTabs } from "./AndroidWorkspaceNavigation";
20 import { FLOATING_TABS } from "./floating-workspace-tabs";
21 import { WorkspaceTabsContext, useWorkspaceTabs } from "./WorkspaceTabsContext";
@@ -31,7 +33,7 @@ export function WorkspaceRootScreen() {
33
34 function WorkspaceRoot() {
35 const floatingTabsEnabled = useAndroidFloatingTabs();
34 - const { layout, startNewTask } = useAdaptiveWorkspaceLayout();
36 + const { layout, startNewTask, workspacePageWidth } = useAdaptiveWorkspaceLayout();
37 const workspace = useWorkspaceTabs()!;
38 const enabled = useEnabledNavigationTabs();
39 const insets = useSafeAreaInsets();
@@ -80,7 +82,9 @@ function WorkspaceRoot() {
82 tab === "threads" ? (
83 <HomeRouteScreen />
84 ) : tab !== "pullRequests" ? (
83 - <WorkspaceExtraTab tab={tab} />
85 + <WorkspacePageFrame width={workspacePageWidth ?? null}>
86 + <WorkspaceExtraTab tab={tab} />
87 + </WorkspacePageFrame>
88 ) : layout.usesSplitView ? (
89 <>
90 <NativeStackScreenOptions options={{ headerShown: false }} />
@@ -117,3 +121,17 @@ function WorkspaceRoot() {
121 </WorkspaceTabsContext>
122 );
123 }
124 +
125 +// Hidden, the page sits in the narrower pane beside the list; laying it out at the width it opens
126 +// at keeps measured bars and breakpoints from catching up a frame after it appears.
127 +function WorkspacePageFrame(props: {
128 + readonly width: number | null;
129 + readonly children: ReactNode;
130 +}) {
131 + if (props.width === null) return props.children;
132 + return (
133 + <WorkspaceSettledContentWidthContext value={props.width}>
134 + <View style={{ flex: 1, width: props.width }}>{props.children}</View>
135 + </WorkspaceSettledContentWidthContext>
136 + );
137 +}