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
feat(mobile): without an inspector column, the inspector is a sheet (#27090)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 3, 2026 at 16:53 UTC
c6114b04a04406b0cddbd2024d4219dacc1e6fd1
5 files changed
+240
-79
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+57
-14
@@ -81,6 +81,7 @@ import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderE
81
import { PaneContext } from "../../components/ui/Pane";
82
import { WORKSPACE_PANE_TIMING } from "./workspace-pane-animation";
83
import { WorkspaceInspectorPane } from "./workspace-inspector-pane";
84
+import { WorkspaceInspectorSheet } from "./workspace-inspector-sheet";
85
import {
86
WorkspaceContentWidthContext,
87
WorkspaceSettledContentWidthContext,
@@ -129,11 +130,6 @@ export function Inspector(props: {
130
</NavigationRouteContext.Provider>
131
</NavigationContext.Provider>
132
);
132
- const reveal =
133
- props.revealKey === undefined || route === undefined
134
- ? undefined
135
- : { routeKey: route.key, key: props.revealKey };
136
-
133
const focusedRef = useRef(false);
134
const deactivateRef = useRef<(() => void) | null>(null);
135
@@ -142,7 +138,7 @@ export function Inspector(props: {
138
deactivateRef.current?.();
139
return;
140
}
145
- deactivateRef.current = registerWorkspaceInspector(render, reveal);
141
+ deactivateRef.current = registerWorkspaceInspector(render, route?.key, props.revealKey);
142
});
143
144
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Navigation focus events own the inspector registration lifetime.
@@ -356,7 +352,17 @@ function AdaptiveWorkspaceLayoutContent(
352
const [workspaceInspector, setWorkspaceInspector] = useState<{
353
readonly render: () => ReactNode;
354
readonly active: boolean;
355
+ readonly routeKey: string | undefined;
356
} | null>(null);
357
+ // Without a column the inspector is a sheet, opened only on request for the route on top, and
358
+ // shown again when that route returns to the top.
359
+ const [inspectorSheetRoute, setInspectorSheetRoute] = useState<string | null>(null);
360
+ const inspectorSheetOpen =
361
+ !fileInspector.supported &&
362
+ !workspacePage &&
363
+ inspectorSheetRoute !== null &&
364
+ workspaceInspector?.active === true &&
365
+ workspaceInspector.routeKey === inspectorSheetRoute;
366
const inspectorActive = workspaceInspector?.active ?? false;
367
const panes = useMemo(
368
() =>
@@ -388,17 +394,22 @@ function AdaptiveWorkspaceLayoutContent(
394
const workspaceInspectorOwner = useRef<symbol | null>(null);
395
const registerWorkspaceInspector = (
396
render: () => ReactNode,
391
- reveal?: { readonly routeKey: string; readonly key: string },
397
+ routeKey: string | undefined,
398
+ revealKey?: string,
399
) => {
400
const owner = Symbol("workspace-inspector");
401
workspaceInspectorOwner.current = owner;
395
- setWorkspaceInspector({ render, active: true });
396
- if (reveal && revealedInspectors.current.get(reveal.routeKey) !== reveal.key) {
402
+ setWorkspaceInspector({ render, active: true, routeKey });
403
+ if (
404
+ routeKey !== undefined &&
405
+ revealKey !== undefined &&
406
+ revealedInspectors.current.get(routeKey) !== revealKey
407
+ ) {
408
const state = rootStackState(navigation);
409
const live = new Set(state?.routes.slice(0, state.index + 1).map((route) => route.key));
410
revealedInspectors.current = new Map(
400
- [...revealedInspectors.current, [reveal.routeKey, reveal.key] as const].filter(
401
- ([routeKey]) => live.has(routeKey) || routeKey === reveal.routeKey,
411
+ [...revealedInspectors.current, [routeKey, revealKey] as const].filter(
412
+ ([key]) => live.has(key) || key === routeKey,
413
),
414
);
415
setFileInspectorPreferredVisible(true);
@@ -452,7 +463,21 @@ function AdaptiveWorkspaceLayoutContent(
463
};
464
const sidebarCommands = primarySidebarPinned ? [] : (["toggleSidebar"] as const);
465
useHardwareKeyboardCommand(sidebarCommands, handleToggleSidebarCommand);
455
- const showInspector = () => setFileInspectorPreferredVisible(true);
466
+ // Resizing into a column closes the sheet without this, so the inspector moves into the column.
467
+ const dismissInspectorSheet = () => {
468
+ setFileInspectorPreferredVisible(false);
469
+ setInspectorSheetRoute(null);
470
+ };
471
+ const showInspector = () => {
472
+ setFileInspectorPreferredVisible(true);
473
+ if (fileInspector.supported) {
474
+ setInspectorSheetRoute(null);
475
+ return;
476
+ }
477
+ const state = rootStackState(navigation);
478
+ const top = workspaceRoutesOf(state?.routes.slice(0, state.index + 1) ?? []).workspace.at(-1);
479
+ setInspectorSheetRoute(top?.key ?? null);
480
+ };
481
const handleOpenFilesCommand = () => {
482
const activeThread = parseActiveThreadPath(pathname);
483
if (!layout.usesSplitView || !fileInspector.supported || activeThread === null) {
@@ -466,7 +491,13 @@ function AdaptiveWorkspaceLayoutContent(
491
return true;
492
};
493
useHardwareKeyboardCommand("files", handleOpenFilesCommand);
469
- const toggleAuxiliaryPane = () => setFileInspectorPreferredVisible((current) => !current);
494
+ const toggleAuxiliaryPane = () => {
495
+ if (fileInspector.supported) {
496
+ setFileInspectorPreferredVisible((current) => !current);
497
+ setInspectorSheetRoute(null);
498
+ } else if (inspectorSheetOpen) dismissInspectorSheet();
499
+ else showInspector();
500
+ };
501
/**
502
* The one way to open a workspace tab: replaces the workspace with the tab's list and, when the
503
* window has columns, the page it last showed, keeping any sheet on top. An overlay sidebar
@@ -502,6 +533,7 @@ function AdaptiveWorkspaceLayoutContent(
533
threadSelectionDeferral.run(() => {
534
if (Platform.OS === "android") Keyboard.dismiss();
535
setFileInspectorPreferredVisible(false);
536
+ setInspectorSheetRoute(null);
537
if (layout.variant === "medium") setPrimarySidebarVisible(false);
538
workspace?.dispatch({
539
type: "select",
@@ -795,6 +827,11 @@ function AdaptiveWorkspaceLayoutContent(
827
sidebarByOrientation,
828
};
829
830
+ const inspectorSheet = (
831
+ <WorkspaceInspectorSheet open={inspectorSheetOpen} onClose={dismissInspectorSheet}>
832
+ {workspaceInspector?.render()}
833
+ </WorkspaceInspectorSheet>
834
+ );
835
if (nativeWorkspace) {
836
return (
837
<HomeListOptionsProvider
@@ -803,9 +840,14 @@ function AdaptiveWorkspaceLayoutContent(
840
>
841
<AdaptiveWorkspaceContext value={contextValue}>
842
<NativeWorkspaceInspectorContext
806
- value={{ render: workspaceInspector?.render, visible: inspectorColumnTargetWidth > 0 }}
843
+ value={{
844
+ // Without a column the sheet shows it; the hidden native column must not mount it too.
845
+ render: fileInspector.supported ? workspaceInspector?.render : undefined,
846
+ visible: inspectorColumnTargetWidth > 0,
847
+ }}
848
>
849
{props.children}
850
+ {inspectorSheet}
851
</NativeWorkspaceInspectorContext>
852
</AdaptiveWorkspaceContext>
853
</HomeListOptionsProvider>
@@ -966,6 +1008,7 @@ function AdaptiveWorkspaceLayoutContent(
1008
onClosed={handleWorkspaceInspectorClosed}
1009
/>
1010
</PaneContext>
1011
+ {inspectorSheet}
1012
{shouldRenderNavigationRail && navigationRailWidth > 0 ? (
1013
// Its trailing inset clips the old rail as soon as Android fits the workspace to a cover display.
1014
<View
apps/mobile/src/features/layout/adaptive-workspace-context.ts
+3
-1
@@ -23,9 +23,11 @@ interface AdaptiveWorkspaceContextValue {
23
readonly selectDetail?: (detail: WorkspaceDetail, sheet?: WorkspaceDetailSheet) => void;
24
readonly registerWorkspaceInspector: (
25
render: () => ReactNode,
26
- reveal?: { readonly routeKey: string; readonly key: string },
26
+ routeKey: string | undefined,
27
+ revealKey?: string,
28
) => () => void;
29
readonly setPrimarySidebarSearchQuery: (query: string) => void;
30
+ /** Opens the inspector: its column where the window has one, otherwise a sheet. */
31
readonly showInspector: () => void;
32
readonly toggleAuxiliaryPane: () => void;
33
/**
apps/mobile/src/features/layout/workspace-inspector-sheet.tsx
new
+100
@@ -0,0 +1,100 @@
1
+import { createContext, useRef, useState, type ReactNode } from "react";
2
+import { Platform, View } from "react-native";
3
+import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
4
+import { FormSheet } from "react-native-screens";
5
+import { useResolveClassNames } from "uniwind";
6
+
7
+import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary";
8
+import { PaneContext } from "../../components/ui/Pane";
9
+import { RoutedFormSheetContext } from "../../components/ui/RoutedFormSheetContext";
10
+import { formSheetDetents } from "../../native/sheet-surface";
11
+
12
+/**
13
+ * Closes the inspector sheet around the inspector, then runs `then` once it is gone: a route
14
+ * presented over a sheet that isn't one of the stack's own would race its dismissal.
15
+ */
16
+export const InspectorSheetContext = createContext<((then?: () => void) => void) | null>(null);
17
+
18
+/** The inspector where the window has no column for it. Its content draws its own bar. */
19
+export function WorkspaceInspectorSheet(props: {
20
+ readonly open: boolean;
21
+ readonly onClose: () => void;
22
+ readonly children: ReactNode;
23
+}) {
24
+ const containerStyle = useResolveClassNames(Platform.OS === "android" ? "bg-header" : "bg-sheet");
25
+ const insets = useSafeAreaInsets();
26
+ // Stays mounted until the sheet has finished closing, so it doesn't empty as it slides away.
27
+ // Each opening gets a fresh native sheet, even one that starts while the last is closing.
28
+ const [presented, setPresented] = useState({
29
+ open: props.open,
30
+ mounted: props.open,
31
+ session: 0,
32
+ });
33
+ if (presented.open !== props.open) {
34
+ setPresented({
35
+ open: props.open,
36
+ mounted: presented.mounted || props.open,
37
+ session: props.open ? presented.session + 1 : presented.session,
38
+ });
39
+ }
40
+ const afterClose = useRef<(() => void) | null>(null);
41
+ const closed = () => {
42
+ setPresented((current) => ({ ...current, mounted: false }));
43
+ const then = afterClose.current;
44
+ afterClose.current = null;
45
+ then?.();
46
+ };
47
+ const close = (then?: () => void) => {
48
+ afterClose.current = then ?? null;
49
+ props.onClose();
50
+ };
51
+ if (!presented.mounted) return null;
52
+ return (
53
+ <FormSheet
54
+ key={presented.session}
55
+ isOpen={props.open}
56
+ detents={formSheetDetents(0.6, 0.95)}
57
+ prefersGrabberVisible={Platform.OS === "ios"}
58
+ // The inspector's bar holds its actions, so the Duo needs no rail inside this sheet.
59
+ prefersHorizontalBars
60
+ preferredCornerRadius={Platform.OS === "android" ? 28 : undefined}
61
+ nativeContainerStyle={containerStyle}
62
+ onDismiss={closed}
63
+ onNativeDismiss={() => {
64
+ props.onClose();
65
+ closed();
66
+ }}
67
+ >
68
+ <InspectorSheetContext value={close}>
69
+ <RoutedFormSheetContext value={false}>
70
+ {/* The sheet starts below the status bar. */}
71
+ <SafeAreaInsetsContext value={{ ...insets, top: 0 }}>
72
+ <PaneContext value="inspector">
73
+ {/* Android FormSheet does not bound flex children. */}
74
+ <View
75
+ collapsable={false}
76
+ className={
77
+ Platform.OS === "android" ? "absolute inset-0 bg-header pt-3" : "flex-1 bg-sheet"
78
+ }
79
+ >
80
+ <RenderErrorBoundary
81
+ renderFallback={(fallback) => (
82
+ <RenderFailureView {...fallback} title="The inspector couldn't be displayed" />
83
+ )}
84
+ >
85
+ {props.children}
86
+ </RenderErrorBoundary>
87
+ {Platform.OS === "android" ? (
88
+ <View
89
+ pointerEvents="none"
90
+ className="absolute top-1 h-1 w-8 self-center rounded-full bg-header-foreground/40"
91
+ />
92
+ ) : null}
93
+ </View>
94
+ </PaneContext>
95
+ </SafeAreaInsetsContext>
96
+ </RoutedFormSheetContext>
97
+ </InspectorSheetContext>
98
+ </FormSheet>
99
+ );
100
+}
apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+42
-40
@@ -92,6 +92,7 @@ import { projectThreadContentPresentation } from "./threadContentPresentation";
92
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
93
import { Inspector, useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
94
import { ThreadFileNavigatorPane } from "../files/thread-file-navigator-pane";
95
+import { InspectorSheetContext } from "../layout/workspace-inspector-sheet";
96
import {
97
ThreadInspectorContentStack,
98
type ThreadInspectorMode,
@@ -547,16 +548,6 @@ function ThreadRouteContent(
548
const gitActionProgress = useGitActionProgress(gitActionProgressTarget);
549
550
const handleOpenGitInspector = () => {
550
- if (!fileInspector.supported) {
551
- if (selectedThread === null) {
552
- return;
553
- }
554
- navigation.navigate("GitOverview", {
555
- environmentId: String(selectedThread.environmentId),
556
- threadId: String(selectedThread.id),
557
- });
558
- return;
559
- }
551
navigation.setParams({ inspector: undefined });
552
setChosenInspectorMode("git");
553
showInspector();
@@ -565,13 +556,6 @@ function ThreadRouteContent(
556
if (selectedThread === null || selectedThreadCwd === null) {
557
return;
558
}
568
- if (!fileInspector.supported) {
569
- navigation.navigate("ThreadFiles", {
570
- environmentId: String(selectedThread.environmentId),
571
- threadId: String(selectedThread.id),
572
- });
573
- return;
574
- }
559
navigation.setParams({ inspector: undefined });
560
setChosenInspectorMode(props.renderInspector === undefined ? "files" : "route");
561
showInspector();
@@ -592,33 +576,46 @@ function ThreadRouteContent(
576
threadId: String(selectedThread.id),
577
path: path.split("/").filter((segment) => segment.length > 0),
578
};
595
- if (fileInspector.supported) {
596
- navigation.navigate("ThreadFile", params);
597
- return;
598
- }
579
navigation.navigate("ThreadFile", params);
580
};
601
- const safeAreaInsets = useSafeAreaInsets();
602
- const inspectorHeaderInset = Platform.OS === "ios" ? 0 : safeAreaInsets.top;
581
const renderGitInspector = () => (
604
- <GitOverviewSheet
605
- headerInset={inspectorHeaderInset}
606
- presentation="inspector"
607
- route={{ params: { environmentId: environmentId!, threadId: threadId! } }}
608
- />
582
+ <InspectorHeaderInset>
583
+ {(headerInset) => (
584
+ <GitOverviewSheet
585
+ headerInset={headerInset}
586
+ presentation="inspector"
587
+ route={{ params: { environmentId: environmentId!, threadId: threadId! } }}
588
+ />
589
+ )}
590
+ </InspectorHeaderInset>
591
);
592
const renderFilesInspector = () =>
593
selectedThread !== null && selectedThreadCwd !== null ? (
612
- <ThreadFileNavigatorPane
613
- cwd={selectedThreadCwd}
614
- environmentId={selectedThread.environmentId}
615
- headerInset={inspectorHeaderInset}
616
- projectName={selectedThreadProject?.title ?? "Files"}
617
- selectedPath={null}
618
- onSelectFile={handleSelectInspectorFile}
619
- />
594
+ <InspectorHeaderInset>
595
+ {(headerInset) => (
596
+ <InspectorSheetContext.Consumer>
597
+ {(closeInspectorSheet) => (
598
+ <ThreadFileNavigatorPane
599
+ cwd={selectedThreadCwd}
600
+ environmentId={selectedThread.environmentId}
601
+ headerInset={headerInset}
602
+ projectName={selectedThreadProject?.title ?? "Files"}
603
+ selectedPath={null}
604
+ onSelectFile={(path) =>
605
+ closeInspectorSheet
606
+ ? closeInspectorSheet(() => handleSelectInspectorFile(path))
607
+ : handleSelectInspectorFile(path)
608
+ }
609
+ />
610
+ )}
611
+ </InspectorSheetContext.Consumer>
612
+ )}
613
+ </InspectorHeaderInset>
614
+ ) : null;
615
+ const renderRouteInspector = () =>
616
+ props.renderInspector ? (
617
+ <InspectorHeaderInset>{props.renderInspector}</InspectorHeaderInset>
618
) : null;
621
- const renderRouteInspector = () => props.renderInspector?.(inspectorHeaderInset);
619
const renderPreviewInspector = () =>
620
previewTarget && panes.auxiliaryPaneVisible ? (
621
<ThreadInspectorPreview
@@ -797,9 +794,8 @@ function ThreadRouteContent(
794
onPress: handleToggleInspector,
795
}
796
: undefined,
800
- onOpenFilesInspector:
801
- fileInspector.supported && selectedThreadCwd !== null ? handleOpenFilesInspector : undefined,
802
- onOpenGitInspector: fileInspector.supported ? handleOpenGitInspector : undefined,
797
+ onOpenFilesInspector: selectedThreadCwd !== null ? handleOpenFilesInspector : undefined,
798
+ onOpenGitInspector: handleOpenGitInspector,
799
onMergeBack:
800
mergeBackTargetThreadId !== null && mergeBackRun !== null
801
? () => void handleMergeBack()
@@ -1115,6 +1111,12 @@ function ThreadRouteContent(
1111
);
1112
}
1113
1114
+/** The inspector's top inset where it renders: under an Android column's status bar, not a sheet's. */
1115
+function InspectorHeaderInset(props: { readonly children: (headerInset: number) => ReactNode }) {
1116
+ const insets = useSafeAreaInsets();
1117
+ return props.children(Platform.OS === "ios" ? 0 : insets.top);
1118
+}
1119
+
1120
export function FullscreenThreadRouteScreen(
1121
props: StaticScreenProps<{
1122
readonly environmentId: string;
apps/mobile/src/features/threads/git/GitOverviewSheet.tsx
+38
-24
@@ -16,7 +16,7 @@ import {
16
type StaticScreenProps,
17
} from "@react-navigation/native";
18
import { SymbolView } from "../../../components/ui/AppSymbol";
19
-import { useEffect, useState } from "react";
19
+import { use, useEffect, useState } from "react";
20
import { Platform, Pressable, RefreshControl, ScrollView, View } from "react-native";
21
22
import { ScreenStack } from "react-native-screens";
@@ -30,6 +30,7 @@ import { ListRow } from "../../../components/ui/ListRow";
30
import { ListSection } from "../../../components/ui/ListSection";
31
import { ScreenContent } from "../../../components/ui/ScreenContent";
32
import { useAdaptiveWorkspaceLayout } from "../../layout/AdaptiveWorkspaceLayout";
33
+import { InspectorSheetContext } from "../../layout/workspace-inspector-sheet";
34
import { AppText as Text } from "../../../components/ui/AppText";
35
import {
36
NativeStackScreenOptions,
@@ -77,6 +78,9 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
78
const insets = useSafeAreaInsets();
79
const presentation = props.presentation ?? "sheet";
80
const isInspector = presentation === "inspector";
81
+ const closeInspectorSheet = use(InspectorSheetContext);
82
+ const presentRoute = (present: () => void) =>
83
+ closeInspectorSheet ? closeInspectorSheet(present) : present();
84
const environmentId = EnvironmentId.make(props.route.params.environmentId);
85
const threadId = ThreadId.make(props.route.params.threadId);
86
const { selectedThread, selectedThreadProject, selectedEnvironmentRuntime } =
@@ -163,19 +167,23 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
167
!input.featureBranch &&
168
requiresDefaultBranchConfirmation(input.action, isDefaultRef)
169
) {
166
- navigation.navigate("GitConfirm", {
167
- environmentId: String(environmentId),
168
- threadId: String(threadId),
169
- confirmAction: confirmableAction,
170
- branchName,
171
- includesCommit: String(input.action === "commit_push" || input.action === "commit_push_pr"),
172
- });
170
+ presentRoute(() =>
171
+ navigation.navigate("GitConfirm", {
172
+ environmentId: String(environmentId),
173
+ threadId: String(threadId),
174
+ confirmAction: confirmableAction,
175
+ branchName,
176
+ includesCommit: String(
177
+ input.action === "commit_push" || input.action === "commit_push_pr",
178
+ ),
179
+ }),
180
+ );
181
return;
182
}
183
176
- if (!isInspector) {
177
- navigation.goBack();
178
- }
184
+ // Close a sheet so the thread shows the action's progress.
185
+ if (!isInspector) navigation.goBack();
186
+ else closeInspectorSheet?.();
187
await gitActions.onRunSelectedThreadGitAction(input);
188
};
189
@@ -187,10 +195,12 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
195
}
196
if (!canWriteSourceControl) return;
197
if (item.dialogAction === "commit") {
190
- navigation.navigate("GitCommit", {
191
- environmentId: String(environmentId),
192
- threadId: String(threadId),
193
- });
198
+ presentRoute(() =>
199
+ navigation.navigate("GitCommit", {
200
+ environmentId: String(environmentId),
201
+ threadId: String(threadId),
202
+ }),
203
+ );
204
return;
205
}
206
if (item.dialogAction === "push") {
@@ -281,11 +291,13 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
291
disabled={busy || !isRepo}
292
onPress={() => {
293
const params = { environmentId, threadId };
284
- navigation.dispatch(
285
- presentation === "sheet"
286
- ? StackActions.replace("ThreadReview", params)
287
- : CommonActions.navigate("ThreadReview", params),
288
- );
294
+ if (presentation === "sheet") {
295
+ navigation.dispatch(StackActions.replace("ThreadReview", params));
296
+ } else {
297
+ presentRoute(() =>
298
+ navigation.dispatch(CommonActions.navigate("ThreadReview", params)),
299
+ );
300
+ }
301
}}
302
/>
303
<ListRow
@@ -298,10 +310,12 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
310
}
311
disabled={busy || !isRepo}
312
onPress={() =>
301
- navigation.navigate("GitBranches", {
302
- environmentId: String(environmentId),
303
- threadId: String(threadId),
304
- })
313
+ presentRoute(() =>
314
+ navigation.navigate("GitBranches", {
315
+ environmentId: String(environmentId),
316
+ threadId: String(threadId),
317
+ }),
318
+ )
319
}
320
/>
321
{linkedPrActions.canLink ? (