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, 18:00 UTC
fix(mobile): restore file viewer insets and glass header (#17073)
Julius Marminge committed
Oct 7, 2026 at 22:33 UTC
e803242d936af3e052757d59ab32bc7c4fcc2390
9 files changed
+77
-37
apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffModule.swift
+8
@@ -49,6 +49,14 @@ public class T3ReviewDiffModule: Module {
49
view.setContentWidth(CGFloat(contentWidth))
50
}
51
52
+ Prop("contentInsetTop") { (view: T3ReviewDiffView, inset: Double) in
53
+ view.setContentInsetTop(CGFloat(inset))
54
+ }
55
+
56
+ Prop("contentInsetBottom") { (view: T3ReviewDiffView, inset: Double) in
57
+ view.setContentInsetBottom(CGFloat(inset))
58
+ }
59
+
60
Prop("initialRowIndex") { (view: T3ReviewDiffView, initialRowIndex: Double) in
61
view.setInitialRowIndex(initialRowIndex)
62
}
apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffView.swift
+28
-8
@@ -563,6 +563,24 @@ public final class T3ReviewDiffView: ExpoView, UIScrollViewDelegate {
563
])
564
}
565
566
+ // Source files fill the screen so UIKit can sample content below the glass bar.
567
+ // Keep the same visible row when header or safe-area reservations change.
568
+ func setContentInsetTop(_ inset: CGFloat) {
569
+ scrollView.automaticallyAdjustsScrollIndicatorInsets = false
570
+ let inset = max(0, inset)
571
+ let delta = inset - scrollView.contentInset.top
572
+ guard delta != 0 else { return }
573
+ scrollView.contentInset.top = inset
574
+ scrollView.verticalScrollIndicatorInsets.top = inset
575
+ scrollView.contentOffset.y -= delta
576
+ updateViewportFrame()
577
+ }
578
+
579
+ func setContentInsetBottom(_ inset: CGFloat) {
580
+ scrollView.contentInset.bottom = max(0, inset)
581
+ scrollView.verticalScrollIndicatorInsets.bottom = max(0, inset)
582
+ }
583
+
584
func setContentResetKey(_ contentResetKey: String) {
585
guard contentResetKey != self.contentResetKey else {
586
return
@@ -577,7 +595,7 @@ public final class T3ReviewDiffView: ExpoView, UIScrollViewDelegate {
595
hasAppliedInitialRowIndex = false
596
pendingScrollFileId = nil
597
isProgrammaticScrollActive = false
580
- scrollView.setContentOffset(.zero, animated: false)
598
+ scrollView.setContentOffset(CGPoint(x: 0, y: -scrollView.contentInset.top), animated: false)
599
updateContentMetrics()
600
updateViewportFrame()
601
lastVisibleFileId = nil
@@ -870,8 +888,12 @@ public final class T3ReviewDiffView: ExpoView, UIScrollViewDelegate {
888
}
889
890
private func setVerticalContentOffset(_ targetOffset: CGFloat, animated: Bool) {
873
- let maxOffset = max(scrollView.contentSize.height - scrollView.bounds.height, 0)
874
- let clampedOffset = min(max(targetOffset, 0), maxOffset)
891
+ let topInset = scrollView.contentInset.top
892
+ let maxOffset = max(
893
+ scrollView.contentSize.height - scrollView.bounds.height + scrollView.contentInset.bottom,
894
+ -topInset
895
+ )
896
+ let clampedOffset = min(max(targetOffset - topInset, -topInset), maxOffset)
897
let shouldAnimate = animated && abs(scrollView.contentOffset.y - clampedOffset) > 0.5
898
isProgrammaticScrollActive = shouldAnimate
899
contentView.isVerticalScrollActive = shouldAnimate
@@ -889,12 +911,10 @@ public final class T3ReviewDiffView: ExpoView, UIScrollViewDelegate {
911
return
912
}
913
892
- let targetScreenY = max(0, (bounds.height - rowFrame.height) * 0.3)
893
- let maxOffset = max(scrollView.contentSize.height - scrollView.bounds.height, 0)
894
- let targetOffset = min(max(rowFrame.minY - targetScreenY, 0), maxOffset)
914
+ let visibleHeight = bounds.height - scrollView.contentInset.top - scrollView.contentInset.bottom
915
+ let targetScreenY = max(0, (visibleHeight - rowFrame.height) * 0.3)
916
hasAppliedInitialRowIndex = true
896
- scrollView.setContentOffset(CGPoint(x: 0, y: targetOffset), animated: false)
897
- updateViewportFrame()
917
+ setVerticalContentOffset(rowFrame.minY - targetScreenY, animated: false)
918
}
919
}
920
apps/mobile/src/Stack.tsx
+2
-2
@@ -159,7 +159,7 @@ const GLASS_HEADER_OPTIONS: AppScreenOptions = {
159
};
160
161
// SOLID: opaque sheet-colored header for surfaces whose content scrolls internally
162
-// (file viewer, terminal, review) — there is nothing for glass to sample there.
162
+// (terminal, review) — there is nothing for glass to sample there.
163
const SOLID_HEADER_OPTIONS: AppScreenOptions = {
164
headerBackButtonDisplayMode: "minimal",
165
headerBackTitle: "",
@@ -750,7 +750,7 @@ const RootStackConfig = createWorkspaceStackNavigator({
750
ThreadFile: createNativeStackScreen({
751
screen: ThreadFileScreen,
752
linking: `${THREAD_LINKING_PREFIX}/files/:path*`,
753
- options: SOLID_HEADER_OPTIONS,
753
+ options: GLASS_HEADER_OPTIONS,
754
}),
755
ThreadMcpApp: createNativeStackScreen({
756
screen: McpAppFullscreenScreen,
apps/mobile/src/components/ComposerContextSheet.tsx
+1
@@ -47,6 +47,7 @@ function ContextField(props: { label: string; value: string | null | undefined;
47
style={{ height: Math.min(260, Math.max(100, props.value.split("\n").length * 22 + 36)) }}
48
>
49
<SourceFileSurface
50
+ embedded
51
contents={props.value}
52
path={props.label === "HTML" ? "element.html" : "styles.css"}
53
/>
apps/mobile/src/features/diffs/nativeReviewDiffSurface.ts
+2
@@ -121,6 +121,8 @@ export interface NativeReviewDiffViewProps extends ViewProps {
121
readonly styleJson?: string;
122
readonly rowHeight: number;
123
readonly contentWidth: number;
124
+ readonly contentInsetTop?: number;
125
+ readonly contentInsetBottom?: number;
126
readonly initialRowIndex?: number;
127
readonly refreshing?: boolean;
128
readonly nativeViewRef?: Ref<NativeReviewDiffViewHandle>;
apps/mobile/src/features/files/FileTreeBrowser.tsx
+6
-18
@@ -8,7 +8,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
8
import { AppText as Text } from "../../components/AppText";
9
import { PierreEntryIcon } from "../../components/PierreEntryIcon";
10
import { cn } from "../../lib/cn";
11
-import { IOS_NAV_BAR_HEIGHT } from "../../lib/layoutMetrics";
11
+import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
12
import {
13
buildFileTree,
14
flattenFileTree,
@@ -42,7 +42,6 @@ const FileTreeRow = memo(function FileTreeRow(props: {
42
readonly item: VisibleFileTreeNode;
43
readonly selected: boolean;
44
readonly expanded: boolean;
45
- readonly loaded: boolean;
45
readonly loading: boolean;
46
readonly onPressDirectory: (path: string, expand: boolean) => void;
47
readonly onPreviewFile?: (path: string) => void;
@@ -98,10 +97,6 @@ const FileTreeRow = memo(function FileTreeRow(props: {
97
</Text>
98
{node.kind === "directory" && props.expanded && props.loading ? (
99
<ActivityIndicator size="small" accessibilityLabel={`Loading ${node.name}`} />
101
- ) : node.kind === "directory" && props.loaded ? (
102
- <Text className="text-2xs font-t3-medium text-foreground-tertiary">
103
- {node.children.length}
104
- </Text>
100
) : null}
101
</Pressable>
102
);
@@ -115,7 +110,6 @@ export function FileTreeBrowser(props: {
110
readonly searchQuery: string;
111
readonly searchTruncated: boolean;
112
readonly selectedPath: string | null;
118
- readonly loadedDirectories: ReadonlySet<string>;
113
readonly loadingDirectories: ReadonlySet<string>;
114
readonly onLoadDirectory: (path: string) => void;
115
readonly onPreviewFile?: (path: string) => void;
@@ -128,14 +122,12 @@ export function FileTreeBrowser(props: {
122
readonly selectedPathAtPress: string | null;
123
} | null>(null);
124
const insets = useSafeAreaInsets();
131
- // Native transparent-header height ≈ safe-area top + nav bar (~44). Matches the
132
- // observed adjustedContentInset bottom (~102) seen in the native trace.
133
- const headerInset = Platform.OS === "ios" ? insets.top + IOS_NAV_BAR_HEIGHT : 0;
125
+ const columnMetrics = useNativeColumnLayoutMetrics();
126
+ const headerInset = Platform.OS === "ios" ? (columnMetrics?.safeArea.top ?? insets.top) : 0;
127
const {
128
onLoadDirectory,
129
onPreviewFile,
130
onSelectFile,
138
- loadedDirectories,
131
loadingDirectories,
132
selectedPath: controlledSelectedPath,
133
} = props;
@@ -226,7 +218,6 @@ export function FileTreeBrowser(props: {
218
item={item}
219
selected={item.node.kind === "file" && item.node.path === selectedPath}
220
expanded={expandedPaths.has(item.node.path)}
229
- loaded={loadedDirectories.has(item.node.path)}
221
loading={loadingDirectories.has(item.node.path)}
222
onPressDirectory={toggleDirectory}
223
onPreviewFile={onPreviewFile}
@@ -237,7 +228,6 @@ export function FileTreeBrowser(props: {
228
expandedPaths,
229
handleSelectFile,
230
onPreviewFile,
240
- loadedDirectories,
231
loadingDirectories,
232
selectedPath,
233
toggleDirectory,
@@ -245,8 +235,8 @@ export function FileTreeBrowser(props: {
235
);
236
237
const extraData = useMemo(
248
- () => ({ expandedPaths, loadedDirectories, loadingDirectories, selectedPath }),
249
- [expandedPaths, loadedDirectories, loadingDirectories, selectedPath],
238
+ () => ({ expandedPaths, loadingDirectories, selectedPath }),
239
+ [expandedPaths, loadingDirectories, selectedPath],
240
);
241
242
// UIKit owns the header inset on every supported iOS version. Keep the
@@ -259,9 +249,7 @@ export function FileTreeBrowser(props: {
249
data={visibleNodes}
250
keyExtractor={(item) => item.node.path}
251
contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
262
- scrollIndicatorInsets={
263
- Platform.OS === "ios" ? { top: headerInset, left: 0, right: 0, bottom: 0 } : undefined
264
- }
252
+ automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
253
keyboardDismissMode="on-drag"
254
keyboardShouldPersistTaps="handled"
255
estimatedItemSize={42}
apps/mobile/src/features/files/SourceFileSurface.tsx
+23
-6
@@ -11,9 +11,10 @@ import {
11
useWindowDimensions,
12
View,
13
} from "react-native";
14
-
14
+import { useSafeAreaInsets } from "react-native-safe-area-context";
15
import { AppText as Text } from "../../components/AppText";
16
import { LoadingStrip } from "../../components/LoadingStrip";
17
+import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
18
import {
19
type NativeReviewDiffViewProps,
20
resolveNativeReviewDiffView,
@@ -39,7 +40,11 @@ import { sourceHighlightAtom } from "./sourceHighlightingState";
40
interface SourceFileSurfaceProps {
41
readonly contents: string;
42
readonly path: string;
43
+ /** The enclosing sheet or card already reserves its own chrome and safe area. */
44
+ readonly embedded?: boolean;
45
readonly initialLine?: number | null;
46
+ /** Override when a fixed notice already reserves the native header. */
47
+ readonly headerInsetTop?: number;
48
/** Keep the entire document in one native text-selection scope. */
49
readonly selectable?: boolean;
50
/** Enables native pull-to-refresh on the source surface. */
@@ -184,6 +189,9 @@ function NativeSourceFileSurface(
189
},
190
) {
191
const { NativeView, onRefresh } = props;
192
+ const insets = useSafeAreaInsets();
193
+ const columnMetrics = useNativeColumnLayoutMetrics();
194
+ const safeArea = columnMetrics?.safeArea ?? insets;
195
const { codeSurface, codeWordBreak, nativeSourceStyle } = useAppearanceCodeSurface();
196
const { themeAppearance, themeId } = useAppearancePreferences();
197
const appTheme = useUniwindTheme();
@@ -214,6 +222,8 @@ function NativeSourceFileSurface(
222
appearanceScheme={themeAppearance}
223
contentResetKey={props.path}
224
contentWidth={contentWidth}
225
+ contentInsetTop={props.embedded ? 0 : (props.headerInsetTop ?? safeArea.top)}
226
+ contentInsetBottom={props.embedded ? 0 : safeArea.bottom + 8}
227
initialRowIndex={targetIndex ?? -1}
228
rowHeight={nativeSourceStyle.rowHeight ?? codeSurface.rowHeight}
229
rowsJson={rowsJson}
@@ -233,6 +243,7 @@ function NativeSourceFileSurface(
243
}
244
245
function JavaScriptSourceFileSurface(props: SourceFileSurfaceProps) {
246
+ const usesAutomaticInsets = Platform.OS === "ios" && !props.embedded;
247
const foreground = useUniwindTheme()["--color-foreground"];
248
const { codeSurface, codeWordBreak } = useAppearanceCodeSurface();
249
const { normalizedContents, lines, status, targetIndex, tokens } = useSourceFileModel(props);
@@ -323,6 +334,8 @@ function JavaScriptSourceFileSurface(props: SourceFileSurfaceProps) {
334
const list = (
335
<FlatList
336
ref={listRef}
337
+ contentInsetAdjustmentBehavior={usesAutomaticInsets ? "automatic" : "never"}
338
+ automaticallyAdjustsScrollIndicatorInsets={usesAutomaticInsets}
339
refreshControl={refreshControl}
340
data={lines}
341
keyExtractor={(_line, index) => String(index)}
@@ -354,6 +367,8 @@ function JavaScriptSourceFileSurface(props: SourceFileSurfaceProps) {
367
<ScrollView
368
refreshControl={refreshControl}
369
className="flex-1"
370
+ contentInsetAdjustmentBehavior={usesAutomaticInsets ? "automatic" : "never"}
371
+ automaticallyAdjustsScrollIndicatorInsets={usesAutomaticInsets}
372
contentContainerStyle={{
373
paddingBottom: codeSurface.rowHeight,
374
paddingHorizontal: 12,
@@ -393,9 +408,11 @@ export function SourceFileSurface(props: SourceFileSurfaceProps) {
408
// The native canvas draws source lines without text selection or wrapping. Attachments
409
// need one selectable text view in either wrap mode; workspace line navigation can still
410
// use the canvas when wrapping is disabled.
396
- return NativeView && !codeWordBreak && !props.selectable ? (
397
- <NativeSourceFileSurface {...props} NativeView={NativeView} />
398
- ) : (
399
- <JavaScriptSourceFileSurface {...props} />
400
- );
411
+ const surface =
412
+ NativeView && !codeWordBreak && !props.selectable ? (
413
+ <NativeSourceFileSurface {...props} NativeView={NativeView} />
414
+ ) : (
415
+ <JavaScriptSourceFileSurface {...props} />
416
+ );
417
+ return surface;
418
}
apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx
+7
-2
@@ -48,6 +48,7 @@ import { FileTreeBrowser } from "./FileTreeBrowser";
48
import { useFileTreeEntries } from "./useFileTreeEntries";
49
import { preloadWorkspaceFileContents } from "./preload-workspace-file";
50
import { SourceFileSurface } from "./SourceFileSurface";
51
+import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
52
import { ThreadFileNavigatorPane } from "./thread-file-navigator-pane";
53
import { ScreenHeader } from "../../components/ScreenHeader";
54
import { WorkspaceFileImagePreview } from "./WorkspaceFileImagePreview";
@@ -229,6 +230,10 @@ function FileContent(props: {
230
}) {
231
// Reopening a mutable host file must not reuse a poster from an earlier visit.
232
const thumbnailInstanceId = useId();
233
+ const insets = useSafeAreaInsets();
234
+ const columnMetrics = useNativeColumnLayoutMetrics();
235
+ const reservedHeaderInset =
236
+ Platform.OS === "ios" && props.truncated ? (columnMetrics?.safeArea.top ?? insets.top) : 0;
237
const isMarkdown = isMarkdownPreviewFile(props.relativePath);
238
const isBrowserFile = isWorkspaceBrowserPreviewPath(props.relativePath);
239
const isImageFile = isWorkspaceImagePreviewPath(props.relativePath);
@@ -300,7 +305,7 @@ function FileContent(props: {
305
}
306
307
return (
303
- <View className="flex-1 bg-sheet">
308
+ <View className="flex-1 bg-sheet" style={{ paddingTop: reservedHeaderInset }}>
309
{props.truncated ? (
310
<FilePreviewNotice title="Partial file">
311
Preview limited to the first 1 MB of a truncated file.
@@ -320,6 +325,7 @@ function FileContent(props: {
325
contents={props.fileContents}
326
path={props.relativePath}
327
initialLine={props.initialLine}
328
+ headerInsetTop={props.truncated ? 0 : undefined}
329
onRefresh={props.onRefresh}
330
/>
331
)}
@@ -561,7 +567,6 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
567
<FileTreeBrowser
568
key={JSON.stringify([environmentId, cwd])}
569
entries={entriesQuery.entries}
564
- loadedDirectories={entriesQuery.loadedDirectories}
570
loadingDirectories={entriesQuery.loadingDirectories}
571
onLoadDirectory={entriesQuery.loadDirectory}
572
error={entriesQuery.error}
apps/mobile/src/features/files/thread-file-navigator-pane.tsx
-1
@@ -87,7 +87,6 @@ export function ThreadFileNavigatorPane(props: {
87
<FileTreeBrowser
88
key={JSON.stringify([props.environmentId, props.cwd])}
89
entries={entriesQuery.entries}
90
- loadedDirectories={entriesQuery.loadedDirectories}
90
loadingDirectories={entriesQuery.loadingDirectories}
91
onLoadDirectory={entriesQuery.loadDirectory}
92
error={