@devries-cameron20 / t3code Mirror · read-only / commits / 6c21798485
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, 18:15 UTC

fix(mobile): Home and pull request lists let UIKit own their top inset (#24284)

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

Julius Marminge committed Oct 23, 2026 at 18:06 UTC 6c217984850438bd1b9b1f70e9409a4ea36f9564
6 files changed +16 -149
apps/mobile/src/features/home/HomeScreen.tsx
+4 -12
@@ -45,7 +45,6 @@ import type { SavedRemoteConnection } from "../../lib/connection";
45 import { scopedProjectKey, scopedThreadKey } from "../../lib/scopedEntities";
46 import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
47 import { nativeHeaderScrollEdgeEffects } from "../../native/scrollEdgeEffects";
48 -import { useRestingTopOffset } from "../../native/useRestingTopOffset";
48 import {
49 useNativeColumnLayoutMetrics,
50 useNativeLayoutMetrics,
@@ -218,9 +217,7 @@ function HomeTopContentSpacer() {
217 }
218
219 function HomeScrollView(props: ComponentProps<typeof ScrollView>) {
221 - const insets = useSafeAreaInsets();
220 const primaryColumn = use(NativePrimaryColumnContext);
223 - const restingOffset = useRestingTopOffset(insets.top, props);
221 if (Platform.OS !== "ios") return <ScrollView {...props} />;
222
223 // v5 needs the actual content scroll view registered with its screen controller.
@@ -235,14 +232,8 @@ function HomeScrollView(props: ComponentProps<typeof ScrollView>) {
232 >
233 <ScrollView
234 {...props}
238 - {...restingOffset}
235 // UIKit's scroll-edge material needs the scroll view's own surface color.
236 className={cn(props.className, primaryColumn ? "bg-drawer" : "bg-screen")}
241 - // Use the column's measured inset so UIKit recognizes the resting top.
242 - // Padding visually clears the bar but leaves the native scroll offset
243 - // past its edge, activating scroll-edge protection before any scroll.
244 - automaticallyAdjustContentInsets={false}
245 - contentInsetAdjustmentBehavior="never"
237 />
238 </ScrollViewMarker>
239 );
@@ -885,8 +876,9 @@ export function HomeScreen(props: HomeScreenProps) {
876 ListEmptyComponent={v2ListEmpty}
877 style={{ flex: 1 }}
878 automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
888 - contentInsetAdjustmentBehavior="never"
889 - contentInset={Platform.OS === "ios" ? { top: insets.top } : undefined}
879 + // UIKit owns the bar's inset, so a minimizing bar and a resized column move
880 + // the list in the same frame as the bar.
881 + contentInsetAdjustmentBehavior="automatic"
882 contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
883 initialScrollOffset={
884 initialScrollOffset > 0
@@ -905,7 +897,7 @@ export function HomeScreen(props: HomeScreenProps) {
897 (contentSideInsets?.right ?? 0) + (primaryColumn ? 8 : 0) + androidListGutter,
898 paddingBottom:
899 Platform.OS === "ios"
908 - ? iosBottomClearance
900 + ? iosBottomClearance - (columnMetrics?.safeArea.bottom ?? insets.bottom)
901 : (workspace?.bottomClearance ??
902 Math.max(insets.bottom, 16) +
903 (Platform.OS === "android" ? fabClearance : 88)),
apps/mobile/src/features/pull-requests/PullRequestReviewersScreen.tsx
+1 -10
@@ -20,7 +20,6 @@ import { ScrollViewMarker } from "react-native-screens";
20 import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText";
21 import { EmptyState } from "../../components/ui/EmptyState";
22 import { Button } from "../../components/ui/Button";
23 -import { useRestingTopOffset } from "../../native/useRestingTopOffset";
23 import { SymbolView } from "../../components/ui/AppSymbol";
24 import { NativeStackScreenOptions } from "../../native/StackHeader";
25 import { useNativeLayoutMetrics } from "../../native/native-layout-metrics";
@@ -35,17 +34,9 @@ import { PullRequestAvatar } from "./PullRequestPresentation";
34 import { pullRequestTarget, type PullRequestParams } from "./usePullRequestDiff";
35
36 function ReviewerScrollView(props: ScrollViewProps) {
38 - const insets = useSafeAreaInsets();
39 - const restingOffset = useRestingTopOffset(insets.top, props);
37 return (
38 <ScrollViewMarker style={{ flex: 1 }}>
42 - <ScrollView
43 - {...props}
44 - {...restingOffset}
45 - automaticallyAdjustContentInsets={false}
46 - contentInsetAdjustmentBehavior="never"
47 - contentInset={{ top: insets.top }}
48 - />
39 + <ScrollView {...props} contentInsetAdjustmentBehavior="automatic" />
40 </ScrollViewMarker>
41 );
42 }
apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
+4 -13
@@ -56,7 +56,6 @@ import {
56 View,
57 } from "react-native";
58 import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
59 -import { useRestingTopOffset } from "../../native/useRestingTopOffset";
59 import { useSafeAreaInsets } from "react-native-safe-area-context";
60
61 import { AppText as Text } from "../../components/ui/AppText";
@@ -117,16 +116,9 @@ import { usePullRequestEnvironmentFallback } from "./usePullRequestEnvironmentFa
116 const EMPTY_IDS: readonly string[] = [];
117
118 function PullRequestTabScrollView(props: ScrollViewProps) {
120 - const insets = useSafeAreaInsets();
121 - const restingOffset = useRestingTopOffset(insets.top, props);
119 return (
120 <ScrollViewMarker style={{ flex: 1 }}>
124 - <ScrollView
125 - {...props}
126 - {...restingOffset}
127 - automaticallyAdjustContentInsets={false}
128 - contentInsetAdjustmentBehavior="never"
129 - />
121 + <ScrollView {...props} />
122 </ScrollViewMarker>
123 );
124 }
@@ -572,10 +564,9 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
564 renderScrollComponent={
565 Platform.OS === "ios" ? PullRequestTabScrollView : undefined
566 }
575 - contentInsetAdjustmentBehavior="never"
576 - contentInset={
577 - Platform.OS === "ios" ? { top: insets.top, bottom: insets.bottom } : undefined
578 - }
567 + // UIKit owns the bar's inset, so a minimizing bar and a resized column
568 + // move the list in the same frame as the bar.
569 + contentInsetAdjustmentBehavior="automatic"
570 contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
571 refreshControl={
572 <RefreshControl
apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx
+7 -12
@@ -21,7 +21,6 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
21
22 import { AppText as Text } from "../../components/ui/AppText";
23 import { EmptyState } from "../../components/ui/EmptyState";
24 -import { useRestingTopOffset } from "../../native/useRestingTopOffset";
24 import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
25 import { useWorkspaceState } from "../../state/workspace";
26 import { useProjects } from "../../state/entities";
@@ -46,16 +45,9 @@ import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
45 import { useAndroidWorkspaceSelection } from "../workspace/useAndroidWorkspaceSelection";
46
47 function PullRequestScrollView(props: ScrollViewProps) {
49 - const insets = useSafeAreaInsets();
50 - const restingOffset = useRestingTopOffset(insets.top, props);
48 return (
49 <ScrollViewMarker style={{ flex: 1 }}>
53 - <ScrollView
54 - {...props}
55 - {...restingOffset}
56 - automaticallyAdjustContentInsets={false}
57 - contentInsetAdjustmentBehavior="never"
58 - />
50 + <ScrollView {...props} />
51 </ScrollViewMarker>
52 );
53 }
@@ -266,8 +258,9 @@ export function PullRequestsScreen(
258 showsVerticalScrollIndicator={Platform.OS !== "android"}
259 recycleItems
260 renderScrollComponent={Platform.OS === "ios" ? PullRequestScrollView : undefined}
269 - contentInsetAdjustmentBehavior="never"
270 - contentInset={Platform.OS === "ios" ? { top: insets.top } : undefined}
261 + // UIKit owns the bar's inset, so a minimizing bar and a resized column move
262 + // the list in the same frame as the bar.
263 + contentInsetAdjustmentBehavior="automatic"
264 // A plain offset: LegendList adds the list header to an index-based restore, which
265 // landed every return one header lower.
266 initialScrollOffset={
@@ -275,7 +268,9 @@ export function PullRequestsScreen(
268 }
269 contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
270 contentContainerStyle={{
278 - paddingBottom: Math.max(insets.bottom, workspace.bottomClearance),
271 + paddingBottom:
272 + Math.max(insets.bottom, workspace.bottomClearance) -
273 + (Platform.OS === "ios" ? insets.bottom : 0),
274 }}
275 onScroll={(event) => {
276 workspace.recordScrollOffset(
apps/mobile/src/native/useRestingTopOffset.test.tsx deleted
-73
@@ -1,73 +0,0 @@
1 -import { act, useLayoutEffect } from "react";
2 -import { createRoot, type Root } from "react-dom/client";
3 -import { afterEach, describe, expect, it } from "vite-plus/test";
4 -
5 -import { useRestingTopOffset } from "./useRestingTopOffset";
6 -
7 -let root: Root | null = null;
8 -let latest: ReturnType<typeof useRestingTopOffset> | null = null;
9 -
10 -function Probe(props: { readonly topInset: number; readonly restoredOffset?: number }) {
11 - const restingOffset = useRestingTopOffset(
12 - props.topInset,
13 - props.restoredOffset === undefined ? {} : { contentOffset: { x: 0, y: props.restoredOffset } },
14 - );
15 - useLayoutEffect(() => {
16 - latest = restingOffset;
17 - });
18 - return null;
19 -}
20 -
21 -function render(topInset: number, restoredOffset?: number) {
22 - (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
23 - root ??= createRoot(document.createElement("div"));
24 - act(() => root!.render(<Probe topInset={topInset} restoredOffset={restoredOffset} />));
25 -}
26 -
27 -function scrollTo(y: number) {
28 - const event = { nativeEvent: { contentOffset: { x: 0, y } } } as Parameters<
29 - ReturnType<typeof useRestingTopOffset>["onScroll"]
30 - >[0];
31 - act(() => latest!.onScroll(event));
32 -}
33 -
34 -function offset() {
35 - return latest!.contentOffset.y;
36 -}
37 -
38 -afterEach(() => {
39 - act(() => root?.unmount());
40 - root = null;
41 - latest = null;
42 -});
43 -
44 -describe("useRestingTopOffset", () => {
45 - it("keeps an untouched list below the header once the column's inset arrives", () => {
46 - // The folded iPhone Duo's window has no top inset; the header's arrives after mount.
47 - render(0);
48 - render(54);
49 - expect(offset()).toBe(-54);
50 - });
51 -
52 - it("does not move a list the reader scrolled when the inset changes", () => {
53 - render(54);
54 - scrollTo(300);
55 - render(90);
56 - expect(offset()).toBe(-54);
57 - });
58 -
59 - it("follows the inset again once the list is back at the top", () => {
60 - render(54);
61 - scrollTo(300);
62 - render(90);
63 - scrollTo(-90);
64 - render(54);
65 - expect(offset()).toBe(-54);
66 - });
67 -
68 - it("holds a restored position through an inset change", () => {
69 - render(0, 1_200);
70 - render(54);
71 - expect(offset()).toBe(1_200);
72 - });
73 -});
apps/mobile/src/native/useRestingTopOffset.ts deleted
-29
@@ -1,29 +0,0 @@
1 -import { useState } from "react";
2 -import type { NativeScrollEvent, NativeSyntheticEvent, ScrollViewProps } from "react-native";
3 -
4 -/**
5 - * A scroll view with a manual top inset rests at `-topInset`, just below the header. The inset
6 - * can change after mount: a column's safe area starts as the window's until UIKit measures it,
7 - * and rotation or folding changes it again. While the view rests below the header it follows the
8 - * inset; once scrolled away it holds the last resting offset, because RN re-applies a changed
9 - * `contentOffset` prop and would move the reader.
10 - */
11 -export function holdRestingTopOffset(held: number | null, scrollY: number, topInset: number) {
12 - return Math.abs(scrollY + topInset) <= 1 ? null : (held ?? -topInset);
13 -}
14 -
15 -export function useRestingTopOffset(
16 - topInset: number,
17 - props: Pick<ScrollViewProps, "contentOffset" | "onScroll">,
18 -) {
19 - // A list restoring a saved position mounts away from its resting offset.
20 - const [held, setHeld] = useState(props.contentOffset?.y ?? null);
21 - return {
22 - contentOffset: { x: 0, y: held ?? -topInset },
23 - onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => {
24 - const scrollY = event.nativeEvent.contentOffset.y;
25 - setHeld((current) => holdRestingTopOffset(current, scrollY, topInset));
26 - props.onScroll?.(event);
27 - },
28 - };
29 -}