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, 17:00 UTC
feat(mobile): open threads and devices in a resizable iOS inspector (#24985)
Julius Marminge committed
Oct 25, 2026 at 15:23 UTC
92125d612d114c348da1f3883a34aab139c471c6
23 files changed
+687
-90
apps/mobile/src/Stack.tsx
+11
-1
@@ -65,7 +65,10 @@ import { ThreadPullRequestsSheet } from "./features/threads/ThreadPullRequestsSh
65
import { ThreadAgentsSheet } from "./features/threads/ThreadAgentsSheet";
66
import { ThreadBackgroundWorkSheet } from "./features/threads/ThreadBackgroundWorkSheet";
67
import { ThreadQueueSheet } from "./features/threads/ThreadQueueControl";
68
-import { ThreadRouteScreen } from "./features/threads/ThreadRouteScreen";
68
+import {
69
+ FullscreenThreadRouteScreen,
70
+ ThreadRouteScreen,
71
+} from "./features/threads/ThreadRouteScreen";
72
import { McpAppFullscreenScreen } from "./features/threads/McpAppFullscreenScreen";
73
import { ConnectionsRouteScreen } from "./features/connection/ConnectionsRouteScreen";
74
import { ConnectionsNewRouteScreen } from "./features/connection/ConnectionsNewRouteScreen";
@@ -813,6 +816,13 @@ const RootStackConfig = createWorkspaceStackNavigator({
816
linking: `${THREAD_LINKING_PREFIX}/terminal`,
817
options: SOLID_HEADER_OPTIONS,
818
}),
819
+ ThreadInspectorFullscreen: createNativeStackScreen({
820
+ screen: FullscreenThreadRouteScreen,
821
+ options: {
822
+ ...THREAD_HEADER_OPTIONS,
823
+ presentation: "fullScreenModal",
824
+ },
825
+ }),
826
ThreadDevicePreview: createNativeStackScreen({
827
screen: DevicePreviewRouteScreen,
828
linking: `${THREAD_LINKING_PREFIX}/devices`,
apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx
+52
-13
@@ -9,7 +9,7 @@ import {
9
import { useIsFocused, useNavigation, type StaticScreenProps } from "@react-navigation/native";
10
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
11
import * as Cause from "effect/Cause";
12
-import { useEffect, useRef, useState, type RefObject } from "react";
12
+import { useCallback, useEffect, useRef, useState, type RefObject } from "react";
13
import * as Haptics from "expo-haptics";
14
import { Accelerometer } from "expo-sensors";
15
import { AppState, BackHandler, Pressable, StatusBar, View } from "react-native";
@@ -47,6 +47,7 @@ const OVERLAY_EXITING = FadeOut.duration(120).reduceMotion(ReduceMotion.System);
47
type DevicePreviewRouteScreenProps = StaticScreenProps<{
48
readonly environmentId: string;
49
readonly threadId: string;
50
+ readonly deviceKey?: string;
51
}>;
52
53
export function DevicePreviewRouteScreen({ route }: DevicePreviewRouteScreenProps) {
@@ -62,27 +63,33 @@ export function DevicePreviewRouteScreen({ route }: DevicePreviewRouteScreenProp
63
<DevicePreviewScreen
64
environmentId={EnvironmentId.make(environmentId)}
65
threadId={ThreadId.make(threadId)}
66
+ initialDeviceKey={route.params.deviceKey}
67
onClose={onClose}
68
/>
69
);
70
}
71
70
-function DevicePreviewScreen({
72
+export function DevicePreviewScreen({
73
environmentId,
74
threadId,
75
onClose,
76
+ onMaximize,
77
+ initialDeviceKey,
78
}: {
79
readonly environmentId: EnvironmentId;
80
readonly threadId: ThreadId;
81
readonly onClose: () => void;
82
+ readonly onMaximize?: (deviceKey: string | null) => void;
83
+ readonly initialDeviceKey?: string;
84
}) {
85
+ const embedded = onMaximize !== undefined;
86
const insets = useSafeAreaInsets();
87
// NativeColumnContent already insets the sides, so only a book fold moves the reveal handle.
88
const handleBounds = deriveBottomControlInsets(useNativeColumnLayoutMetrics());
89
const { themeVariables } = useAppearancePreferences();
90
const focused = useIsFocused();
91
const [foreground, setForeground] = useState(AppState.currentState !== "background");
85
- const [selectedKey, setSelectedKey] = useState<string | null>(null);
92
+ const [selectedKey, setSelectedKey] = useState<string | null>(initialDeviceKey ?? null);
93
const [inputConnected, setInputConnected] = useState(false);
94
const [streamAttempt, setStreamAttempt] = useState(0);
95
const [shuttingDown, setShuttingDown] = useState(false);
@@ -93,10 +100,13 @@ function DevicePreviewScreen({
100
const state = useEnvironmentQuery(deviceEnvironment.state({ environmentId, input: {} }));
101
const previews = threadDevicePreviews(state.data, threadId);
102
const preview = selectedThreadDevicePreview(previews, selectedKey);
96
- const onInputConnected = async (connected: boolean) => {
97
- setInputConnected(connected);
98
- if (connected) setControlsVisible(false);
99
- };
103
+ const onInputConnected = useCallback(
104
+ async (connected: boolean) => {
105
+ setInputConnected(connected);
106
+ if (connected && !embedded) setControlsVisible(false);
107
+ },
108
+ [embedded],
109
+ );
110
useEffect(() => {
111
const subscription = AppState.addEventListener("change", (state) =>
112
setForeground(state !== "background"),
@@ -107,7 +117,7 @@ function DevicePreviewScreen({
117
if (focused && state.data !== null && previews.length === 0) onClose();
118
}, [focused, state.data, previews.length, onClose]);
119
useEffect(() => {
110
- if (!focused || !foreground) return;
120
+ if (!focused || !foreground || embedded) return;
121
const shaken = createShakeDetector();
122
Accelerometer.setUpdateInterval(50);
123
const subscription = Accelerometer.addListener((sample) => {
@@ -116,7 +126,7 @@ function DevicePreviewScreen({
126
setControlsVisible((visible) => !visible);
127
});
128
return () => subscription.remove();
119
- }, [focused, foreground]);
129
+ }, [focused, foreground, embedded]);
130
useEffect(() => {
131
if (controlsVisible) return;
132
const subscription = BackHandler.addEventListener("hardwareBackPress", () => {
@@ -260,7 +270,23 @@ function DevicePreviewScreen({
270
];
271
return (
272
<View className="flex-1" style={{ backgroundColor: themeVariables["--color-sheet-solid"] }}>
263
- <StatusBar hidden animated />
273
+ {!embedded ? <StatusBar hidden animated /> : null}
274
+ {embedded ? (
275
+ <View
276
+ className="flex-row items-center gap-1 px-2 pb-2"
277
+ style={{ paddingTop: Math.max(insets.top, 8) }}
278
+ >
279
+ <SheetCloseButton accessibilityLabel="Close device preview" onClose={onClose} />
280
+ <AppText numberOfLines={1} className="min-w-0 flex-1 font-t3-medium text-sm">
281
+ {preview?.name ?? "Devices"}
282
+ </AppText>
283
+ <ControlPill
284
+ accessibilityLabel="Maximize device"
285
+ icon="arrow.up.left.and.arrow.down.right"
286
+ onPress={() => onMaximize(preview?.key ?? null)}
287
+ />
288
+ </View>
289
+ ) : null}
290
{preview && focused && foreground ? (
291
<OpenDevicePreview
292
key={`${preview.key}:${streamAttempt}`}
@@ -285,7 +311,20 @@ function DevicePreviewScreen({
311
) : null}
312
</View>
313
)}
288
- {controlsVisible ? (
314
+ {embedded ? (
315
+ <View
316
+ className="flex-row items-center justify-center gap-2 px-3 py-2"
317
+ style={{ paddingBottom: Math.max(insets.bottom, 8) }}
318
+ >
319
+ <ControlPill
320
+ accessibilityLabel="Home"
321
+ icon="house"
322
+ disabled={!inputConnected}
323
+ onPress={pressHome}
324
+ />
325
+ <DeviceOptionsMenu items={menuItems} />
326
+ </View>
327
+ ) : controlsVisible ? (
328
<Animated.View
329
entering={OVERLAY_ENTERING}
330
exiting={OVERLAY_EXITING}
@@ -321,9 +360,9 @@ function DevicePreviewScreen({
360
accessibilityLabel="Show device controls"
361
accessibilityHint="Shaking the phone also shows them"
362
hitSlop={12}
324
- className="absolute h-6 w-16 items-center justify-center self-center"
363
+ className="absolute h-11 w-16 items-center justify-center self-center"
364
style={{
326
- top: Math.max(insets.top - 18, 4),
365
+ top: Math.max(insets.top, 12),
366
transform: [{ translateX: (handleBounds.left - handleBounds.right) / 2 }],
367
}}
368
onPress={() => setControlsVisible(true)}
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+2
@@ -324,6 +324,7 @@ function AdaptiveWorkspaceLayoutContent(
324
deriveWorkspacePaneLayout({
325
layout,
326
viewportWidth: width,
327
+ nativeWorkspace,
328
primarySidebarPreferredVisible: showPrimarySidebar,
329
auxiliaryPanePreferredVisible,
330
auxiliaryPaneRole,
@@ -334,6 +335,7 @@ function AdaptiveWorkspaceLayoutContent(
335
auxiliaryPaneRole,
336
auxiliaryPanePreferredWidth,
337
layout,
338
+ nativeWorkspace,
339
showPrimarySidebar,
340
width,
341
],
apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx
+56
-2
@@ -29,8 +29,10 @@ import {
29
useState,
30
type ComponentProps,
31
} from "react";
32
-import { View } from "react-native";
32
+import { StyleSheet, useWindowDimensions, View } from "react-native";
33
import { Split, type SplitHostCommands } from "react-native-screens";
34
+import { SafeAreaView } from "react-native-safe-area-context";
35
+import { GestureHandlerRootView } from "react-native-gesture-handler";
36
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
37
import { scopedThreadKey } from "../../lib/scopedEntities";
38
import { WorkspaceTabsProvider, useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
@@ -42,6 +44,7 @@ import { setNativelyPoppingWorkspaceRoute } from "../workspace/workspace-detail-
44
import { useDeviceType, useNativeLayoutMetrics } from "../../native/native-layout-metrics";
45
46
import { useAdaptiveWorkspaceLayout } from "./AdaptiveWorkspaceLayout";
47
+import { WorkspacePaneDivider } from "./workspace-pane-divider";
48
import { WorkspaceEmptyDetail } from "./WorkspaceEmptyDetail";
49
import { NativeColumnContent as ColumnContent } from "../../native/NativeColumnContent.ios";
50
import {
@@ -185,6 +188,15 @@ function WorkspaceColumns(
188
sidebarByOrientation,
189
} = useAdaptiveWorkspaceLayout();
190
const deviceType = useDeviceType();
191
+ const windowDimensions = useWindowDimensions();
192
+ const nativeMetrics = useNativeLayoutMetrics();
193
+ const viewportWidth = nativeMetrics?.width ?? windowDimensions.width;
194
+ const [inspectorWidthFraction, setInspectorWidthFraction] = useState(0.4);
195
+ const inspectorWidth = Math.max(
196
+ 260,
197
+ Math.min(viewportWidth * 0.6, viewportWidth * inspectorWidthFraction),
198
+ );
199
+ const resizeStartWidth = useRef(inspectorWidth);
200
const settingsDetailIn = (detail: readonly Route[]) =>
201
layout.usesSplitView && detail[0] && isSettingsRoute(detail[0].name) ? detail[0] : undefined;
202
// Split screens must remain mounted while UIKit animates a detached route away.
@@ -361,6 +373,10 @@ function WorkspaceColumns(
373
maximumPrimaryColumnWidth: Math.max(380, layout.listPaneWidth ?? 0),
374
preferredPrimaryColumnWidthOrFraction: layout.listPaneWidth ?? 320,
375
minimumSecondaryColumnWidth: 320,
376
+ // UIKit can retain its automatic width despite a new preference; constrain both edges.
377
+ minimumInspectorColumnWidth: inspectorWidth,
378
+ maximumInspectorColumnWidth: inspectorWidth,
379
+ preferredInspectorColumnWidthOrFraction: inspectorWidth,
380
}}
381
>
382
<Split.Column>
@@ -433,7 +449,45 @@ function WorkspaceColumns(
449
{/* Inspector panes host their own native stacks, which UIKit insets for the Duo's
450
vertical bar wherever they sit, so each pane insets its own content instead. */}
451
<ColumnContent insetHorizontally={false}>
436
- <View className="flex-1 bg-screen">{inspector.render?.()}</View>
452
+ <View className="flex-1 bg-screen">
453
+ {inspector.render?.()}
454
+ {inspector.visible ? (
455
+ <GestureHandlerRootView
456
+ style={[StyleSheet.absoluteFill, { zIndex: 100 }]}
457
+ pointerEvents="box-none"
458
+ collapsable={false}
459
+ >
460
+ <SafeAreaView
461
+ style={{ flex: 1 }}
462
+ edges={["left", "right"]}
463
+ pointerEvents="box-none"
464
+ >
465
+ <View className="flex-1" pointerEvents="box-none">
466
+ <View
467
+ className="absolute inset-y-0 left-0 w-[22px] flex-row"
468
+ pointerEvents="box-none"
469
+ >
470
+ <WorkspacePaneDivider
471
+ accessibilityLabel="Resize inspector"
472
+ currentWidth={inspectorWidth}
473
+ resizeDirection={-1}
474
+ onResizeStart={() => {
475
+ resizeStartWidth.current = inspectorWidth;
476
+ }}
477
+ onResizeBy={(delta) => {
478
+ const width = Math.max(
479
+ 260,
480
+ Math.min(viewportWidth * 0.6, resizeStartWidth.current + delta),
481
+ );
482
+ setInspectorWidthFraction(width / viewportWidth);
483
+ }}
484
+ />
485
+ </View>
486
+ </View>
487
+ </SafeAreaView>
488
+ </GestureHandlerRootView>
489
+ ) : null}
490
+ </View>
491
</ColumnContent>
492
</Split.Inspector>
493
</Split.Host>
apps/mobile/src/features/layout/workspace-pane-divider.tsx
+1
-1
@@ -56,7 +56,7 @@ export function WorkspacePaneDivider(props: WorkspacePaneDividerProps) {
56
return (
57
<GestureDetector gesture={resizeGesture}>
58
<Pressable
59
- className="relative z-[100] -mx-[22px] w-11 self-stretch justify-center"
59
+ className="relative z-[100] -mx-[22px] w-[44px] self-stretch justify-center"
60
accessibilityActions={[
61
{ name: "increment", label: "Make pane wider" },
62
{ name: "decrement", label: "Make pane narrower" },
apps/mobile/src/features/threads/ThreadAgentsSheet.tsx
+11
@@ -25,6 +25,8 @@ import { SubagentRow } from "./SubagentRow";
25
import { ScreenContent } from "../../components/ui/ScreenContent";
26
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
27
28
+import { useOpenThreadInspector } from "./thread-inspector-navigation";
29
+
30
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
31
32
type AgentsTarget = { readonly environmentId: EnvironmentId; readonly threadId: ThreadId };
@@ -45,6 +47,7 @@ export function ThreadAgentsSheet({ route }: StaticScreenProps<AgentsTarget>) {
47
const { layout } = useAdaptiveWorkspaceLayout();
48
const target = route.params;
49
const navigation = useNavigation();
50
+ const openInspector = useOpenThreadInspector();
51
const insets = useSafeAreaInsets();
52
const turn = useThreadTurnSubagents(target);
53
const subagents = turn?.subagents ?? [];
@@ -52,6 +55,14 @@ export function ThreadAgentsSheet({ route }: StaticScreenProps<AgentsTarget>) {
55
56
const openChildThread = (childThreadId: ThreadId) => {
57
void Haptics.selectionAsync();
58
+ if (
59
+ openInspector(target, {
60
+ type: "thread",
61
+ environmentId: target.environmentId,
62
+ threadId: childThreadId,
63
+ })
64
+ )
65
+ return;
66
// Replace this leaf sheet so the child enters the workspace stack expected by Home's Back button.
67
navigation.dispatch(
68
StackActions.replace("Thread", {
apps/mobile/src/features/threads/ThreadDetailScreen.tsx
+11
-7
@@ -1,3 +1,4 @@
1
+import { useOpenThreadInspector } from "./thread-inspector-navigation";
2
import { useSidebarWorkspaceTabs } from "../workspace/useSystemWorkspaceTabBar";
3
import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
4
import {
@@ -15,7 +16,7 @@ import {
16
} from "../../state/entities";
17
import { UsageLimitRecoveryCard } from "./UsageLimitRecoveryCard";
18
import { ChatGptUsageLimitNotice } from "./ChatGptUsageLimitNotice";
18
-import { StackActions, useFocusEffect, useNavigation } from "@react-navigation/native";
19
+import { useFocusEffect, useNavigation } from "@react-navigation/native";
20
import {
21
effectiveSnoozed,
22
threadWokeAt,
@@ -515,6 +516,7 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
516
if (sidebarSearchActive && composerOwnsKeyboard) setComposerOwnsKeyboard(false);
517
const navigation = useNavigation();
518
const openLinkedThread = useOpenLinkedThread();
519
+ const openInspector = useOpenThreadInspector();
520
const { session: voiceInputSession } = useGlobalVoiceInput();
521
const reportedModelSelection = useThreadReportedModelSelection(props.selectedThreadDetailRef);
522
const deviceState = useEnvironmentQuery(
@@ -523,6 +525,13 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
525
const devicePreviews = threadDevicePreviews(deviceState.data, props.selectedThread.id);
526
const openDevicePreview = () => {
527
Keyboard.dismiss();
528
+ if (
529
+ openInspector(
530
+ { environmentId: props.environmentId, threadId: props.selectedThread.id },
531
+ { type: "device", environmentId: props.environmentId, threadId: props.selectedThread.id },
532
+ )
533
+ )
534
+ return;
535
navigation.navigate("ThreadDevicePreview", {
536
environmentId: props.environmentId,
537
threadId: props.selectedThread.id,
@@ -789,12 +798,7 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
798
accessibilityLabel: `Open ${childInput.hasPendingApprovals ? "approval" : "question"} from ${childInput.title}`,
799
onPress: () => {
800
Keyboard.dismiss();
792
- navigation.dispatch(
793
- StackActions.push("Thread", {
794
- environmentId: props.environmentId,
795
- threadId: childInput.id,
796
- }),
797
- );
801
+ openLinkedThread({ environmentId: props.environmentId, threadId: childInput.id });
802
},
803
};
804
}
apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+95
-35
@@ -5,13 +5,8 @@ import { buildProjectThreadStartTurnInput } from "../../lib/projectThreadStartTu
5
import { useWorktreeSetup } from "./use-worktree-setup";
6
import { worktreeSetupAgentStarted } from "@t3tools/client-runtime/worktree-setup";
7
import { AppBar } from "../../components/ui/AppBar";
8
-import {
9
- StackActions,
10
- useFocusEffect,
11
- useNavigation,
12
- type StaticScreenProps,
13
-} from "@react-navigation/native";
14
-import { useEffect, useRef, useState, type ReactNode } from "react";
8
+import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
9
+import { useEffect, useEffectEvent, useRef, useState, type ReactNode } from "react";
10
import * as Option from "effect/Option";
11
import {
12
AuthOrchestrationOperateScope,
@@ -99,6 +94,13 @@ import {
94
useWorkspaceBackNavigation,
95
} from "../workspace/useAndroidWorkspaceNavigation";
96
import { openSettings } from "../settings/settings-navigation";
97
+import {
98
+ InspectorContentScope,
99
+ ThreadInspectorHeader,
100
+ ThreadInspectorPreview,
101
+ type ThreadInspectorPresentation,
102
+} from "./thread-inspector-preview";
103
+import type { ThreadInspectorTarget } from "./thread-inspector-navigation";
104
import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";
105
106
interface ThreadInspectorSelection {
@@ -152,10 +154,12 @@ type ThreadRouteScreenRouteProps = StaticScreenProps<{
154
readonly environmentId?: string;
155
readonly threadId?: string;
156
readonly draft?: NewTaskDraftRouteParams;
157
+ readonly inspector?: ThreadInspectorTarget;
158
readonly prompt?: string | string[];
159
}>;
160
161
interface ThreadRouteScreenProps extends ThreadRouteScreenRouteProps {
162
+ readonly inspectorPresentation?: ThreadInspectorPresentation;
163
readonly onReturnToThread?: () => void;
164
readonly renderInspector?: (headerInset: number) => ReactNode;
165
}
@@ -233,13 +237,26 @@ function LiveThreadRouteController(props: ThreadRouteScreenProps) {
237
: scopedThreadKey(selectedThread.environmentId, selectedThread.id);
238
const selectedThreadDetailState = useSelectedThreadDetailState();
239
useThreadPromptLink(params, routeThreadKey);
240
+ const withInspectorHeader = (content: ReactNode) => (
241
+ <>
242
+ {props.inspectorPresentation ? (
243
+ <ThreadInspectorHeader
244
+ title={selectedThread?.title ?? "Thread"}
245
+ {...props.inspectorPresentation}
246
+ />
247
+ ) : null}
248
+ {content}
249
+ </>
250
+ );
251
252
if (environmentId === null || threadIdRaw === null) {
238
- return <OpeningThreadLoadingScreen />;
253
+ return withInspectorHeader(<OpeningThreadLoadingScreen />);
254
}
255
256
if (selectedThread !== null && selectedThreadKey === routeThreadKey) {
242
- return <ThreadRouteContent {...props} selectedThreadDetailState={selectedThreadDetailState} />;
257
+ return withInspectorHeader(
258
+ <ThreadRouteContent {...props} selectedThreadDetailState={selectedThreadDetailState} />,
259
+ );
260
}
261
262
const stillHydrating = threadRouteIsHydrating({
@@ -252,10 +269,10 @@ function LiveThreadRouteController(props: ThreadRouteScreenProps) {
269
});
270
271
if (stillHydrating) {
255
- return <OpeningThreadLoadingScreen />;
272
+ return withInspectorHeader(<OpeningThreadLoadingScreen />);
273
}
274
258
- return (
275
+ return withInspectorHeader(
276
<ThreadUnavailableScreen
277
actionLabel={
278
routeEnvironmentRuntime === null ? "Manage environments" : "Reconnect environment"
@@ -267,7 +284,7 @@ function LiveThreadRouteController(props: ThreadRouteScreenProps) {
284
}
285
openSettings(navigation, "SettingsEnvironments");
286
}}
270
- />
287
+ />,
288
);
289
}
290
@@ -383,7 +400,9 @@ function ThreadRouteContent(
400
const [inspectorSelection, setInspectorSelection] = useState<ThreadInspectorSelection | null>(
401
() => (props.renderInspector ? { routeThreadIdentity, mode: "route" } : null),
402
);
403
+ const previewTarget = props.inspectorPresentation ? undefined : params.inspector;
404
const inspectorMode = (() => {
405
+ if (previewTarget) return "preview";
406
if (inspectorSelection?.routeThreadIdentity === routeThreadIdentity) {
407
if (inspectorSelection.mode === "files" && selectedThreadCwd === null) {
408
return null;
@@ -394,6 +413,7 @@ function ThreadRouteContent(
413
})();
414
useEffect(() => {
415
if (
416
+ props.inspectorPresentation === undefined &&
417
fileInspector.supported &&
418
selectedThreadCwd === null &&
419
inspectorMode === null &&
@@ -405,6 +425,7 @@ function ThreadRouteContent(
425
fileInspector.supported,
426
inspectorMode,
427
panes.auxiliaryPaneVisible,
428
+ props.inspectorPresentation,
429
selectedThreadCwd,
430
toggleAuxiliaryPane,
431
]);
@@ -426,13 +447,10 @@ function ThreadRouteContent(
447
});
448
}, [props.renderInspector, routeThreadIdentity]);
449
429
- useFocusEffect(() => {
430
- return () => {
431
- if (props.renderInspector === undefined) {
432
- setInspectorSelection(null);
433
- }
434
- };
435
- });
450
+ const revealPreview = useEffectEvent(() => showAuxiliaryPane("inspector"));
451
+ useEffect(() => {
452
+ if (previewTarget) revealPreview();
453
+ }, [previewTarget]);
454
const routeEnvironmentRuntime = useRemoteEnvironmentRuntime(environmentId);
455
const routeConnectionState =
456
routeEnvironmentRuntime?.connectionState ?? (environmentId ? "available" : connectionState);
@@ -494,6 +512,7 @@ function ThreadRouteContent(
512
});
513
return;
514
}
515
+ navigation.setParams({ inspector: undefined });
516
setInspectorSelection({ routeThreadIdentity, mode: "git" });
517
showAuxiliaryPane("inspector");
518
};
@@ -508,6 +527,7 @@ function ThreadRouteContent(
527
});
528
return;
529
}
530
+ navigation.setParams({ inspector: undefined });
531
setInspectorSelection({
532
routeThreadIdentity,
533
mode: props.renderInspector === undefined ? "files" : "route",
@@ -557,9 +577,29 @@ function ThreadRouteContent(
577
/>
578
) : null;
579
const RouteInspector = () => props.renderInspector?.(inspectorHeaderInset);
580
+ const renderPreviewInspector = () =>
581
+ previewTarget && panes.auxiliaryPaneVisible ? (
582
+ <ThreadInspectorPreview
583
+ target={previewTarget}
584
+ renderThread={(screen) => <ThreadRouteScreen {...screen} />}
585
+ onClose={toggleAuxiliaryPane}
586
+ onOpen={(inspector) => {
587
+ if (
588
+ inspector.type === "thread" &&
589
+ inspector.environmentId === environmentId &&
590
+ inspector.threadId === threadId
591
+ ) {
592
+ toggleAuxiliaryPane();
593
+ return;
594
+ }
595
+ navigation.setParams({ inspector });
596
+ }}
597
+ />
598
+ ) : null;
599
const renderInspectorStack = () =>
600
inspectorMode === null ? null : (
601
<ThreadInspectorContentStack
602
+ renderPreview={renderPreviewInspector}
603
renderFiles={FilesInspector}
604
renderGit={GitInspector}
605
mode={inspectorMode}
@@ -567,7 +607,8 @@ function ThreadRouteContent(
607
renderRoute={props.renderInspector ? RouteInspector : undefined}
608
/>
609
);
570
- const activeInspectorRenderer = inspectorMode === null ? undefined : renderInspectorStack;
610
+ const activeInspectorRenderer =
611
+ props.inspectorPresentation || inspectorMode === null ? undefined : renderInspectorStack;
612
useRegisterWorkspaceInspector(activeInspectorRenderer);
613
614
const handleOpenConnectionEditor = () => {
@@ -908,21 +949,23 @@ function ThreadRouteContent(
949
<>
950
<ThreadScreenBinding
951
header={
911
- <ThreadHeader
912
- title={selectedThread.title}
913
- subtitle={headerSubtitle}
914
- headerColor={headerColor}
915
- usesNativeHeaderGlass={usesNativeHeaderGlass}
916
- gitControls={threadGitControlProps}
917
- hasThreadCwd={selectedThreadCwd !== null}
918
- hasWorkspaceRoot={Boolean(selectedThreadProject?.workspaceRoot)}
919
- fileInspectorSupported={fileInspector.supported}
920
- inspectorMode={inspectorMode}
921
- onToggleInspector={handleToggleInspector}
922
- onOpenGitInspector={handleOpenGitInspector}
923
- onOpenFilesInspector={handleOpenFilesInspector}
924
- onReturnToThread={props.onReturnToThread}
925
- />
952
+ props.inspectorPresentation ? null : (
953
+ <ThreadHeader
954
+ title={selectedThread.title}
955
+ subtitle={headerSubtitle}
956
+ headerColor={headerColor}
957
+ usesNativeHeaderGlass={usesNativeHeaderGlass}
958
+ gitControls={threadGitControlProps}
959
+ hasThreadCwd={selectedThreadCwd !== null}
960
+ hasWorkspaceRoot={Boolean(selectedThreadProject?.workspaceRoot)}
961
+ fileInspectorSupported={fileInspector.supported}
962
+ inspectorMode={inspectorMode}
963
+ onToggleInspector={handleToggleInspector}
964
+ onOpenGitInspector={handleOpenGitInspector}
965
+ onOpenFilesInspector={handleOpenFilesInspector}
966
+ onReturnToThread={props.onReturnToThread}
967
+ />
968
+ )
969
}
970
canOperateThread={canOperateThread}
971
selectedThread={selectedThreadWithDraftSettings ?? selectedThread}
@@ -1032,3 +1075,20 @@ function ThreadRouteContent(
1075
</>
1076
);
1077
}
1078
+
1079
+export function FullscreenThreadRouteScreen(
1080
+ props: StaticScreenProps<{
1081
+ readonly environmentId: string;
1082
+ readonly threadId: string;
1083
+ }>,
1084
+) {
1085
+ const navigation = useNavigation();
1086
+ return (
1087
+ <InspectorContentScope>
1088
+ <ThreadRouteScreen
1089
+ route={props.route}
1090
+ inspectorPresentation={{ onClose: () => navigation.goBack() }}
1091
+ />
1092
+ </InspectorContentScope>
1093
+ );
1094
+}
apps/mobile/src/features/threads/thread-inspector-content-stack.tsx
+8
-2
@@ -4,7 +4,7 @@ import { View } from "react-native";
4
import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary";
5
import { NativeInspectorContent } from "../../native/NativeInspectorContent";
6
7
-export type ThreadInspectorMode = "route" | "git" | "files";
7
+export type ThreadInspectorMode = "route" | "git" | "files" | "preview";
8
9
const INSPECTOR_PREWARM_DELAY_MS = 350;
10
@@ -46,6 +46,7 @@ function InspectorContentPane(props: {
46
}
47
48
export function ThreadInspectorContentStack(props: {
49
+ readonly renderPreview?: () => ReactNode;
50
readonly renderFiles: () => ReactNode;
51
readonly renderGit?: () => ReactNode;
52
readonly mode: ThreadInspectorMode;
@@ -64,7 +65,7 @@ export function ThreadInspectorContentStack(props: {
65
return new Set([...current, props.mode]);
66
});
67
67
- if (props.mode === "route") {
68
+ if (props.mode === "route" || props.mode === "preview") {
69
return;
70
}
71
@@ -84,6 +85,11 @@ export function ThreadInspectorContentStack(props: {
85
86
return (
87
<View className="flex-1">
88
+ {props.mode === "preview" && props.renderPreview ? (
89
+ <InspectorContentPane mounted resetKeys={props.resetKeys} visible>
90
+ <InspectorRenderer render={props.renderPreview} />
91
+ </InspectorContentPane>
92
+ ) : null}
93
<InspectorContentPane
94
mounted={mountedModes.has("files") || props.mode === "files"}
95
resetKeys={props.resetKeys}
apps/mobile/src/features/threads/thread-inspector-navigation.test.tsx
new
+169
@@ -0,0 +1,169 @@
1
+import * as NodeModule from "node:module";
2
+import { act, useLayoutEffect } from "react";
3
+import { createRoot } from "react-dom/client";
4
+import { expect, it, vi } from "vite-plus/test";
5
+
6
+const harness = vi.hoisted(() => ({
7
+ dispatch: (_action: unknown) => {},
8
+ getState: (): unknown => undefined,
9
+ getRoute: (): unknown => undefined,
10
+}));
11
+
12
+vi.mock("react-native", () => ({ Platform: { OS: "ios" } }));
13
+vi.mock("../layout/AdaptiveWorkspaceLayout", () => ({
14
+ useAdaptiveWorkspaceLayout: () => ({ fileInspector: { supported: true } }),
15
+}));
16
+vi.mock("@react-navigation/native", async () => {
17
+ const { createRequire } = await import("node:module");
18
+ const requireNavigation = createRequire(
19
+ createRequire(import.meta.url).resolve("@react-navigation/native/package.json"),
20
+ );
21
+ return {
22
+ StackActions: requireNavigation("@react-navigation/routers").StackActions,
23
+ useNavigation: () => ({ dispatch: harness.dispatch, getState: harness.getState }),
24
+ useRoute: () => harness.getRoute(),
25
+ };
26
+});
27
+
28
+import { useOpenThreadInspector } from "./thread-inspector-navigation";
29
+import { useOpenLinkedThread } from "./useOpenLinkedThread";
30
+
31
+const requireNavigation = NodeModule.createRequire(
32
+ NodeModule.createRequire(import.meta.url).resolve("@react-navigation/native/package.json"),
33
+);
34
+const { StackRouter, StackActions } = requireNavigation("@react-navigation/routers") as {
35
+ StackRouter: typeof import("@react-navigation/native").StackRouter;
36
+ StackActions: typeof import("@react-navigation/native").StackActions;
37
+};
38
+
39
+function setup(fromAgents: boolean, fullscreen = false) {
40
+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
41
+ const router = StackRouter({});
42
+ const options = {
43
+ routeNames: ["Home", "Thread", "ThreadAgents", "ThreadInspectorFullscreen"],
44
+ routeParamList: {},
45
+ routeGetIdList: {},
46
+ };
47
+ let state = router.getInitialState(options);
48
+ const dispatch = (action: Parameters<typeof router.getStateForAction>[1]) => {
49
+ const next = router.getStateForAction(state, action, options);
50
+ if (!next) throw new Error(`Rejected ${action.type}`);
51
+ state = router.getRehydratedState(next, options);
52
+ };
53
+ harness.dispatch = (action) => dispatch(action as Parameters<typeof dispatch>[0]);
54
+ harness.getState = () => state;
55
+ harness.getRoute = () => state.routes.at(-1);
56
+ const source = { environmentId: "remote-environment", threadId: "parent" };
57
+ dispatch(StackActions.push("Thread", { ...source, prompt: "retained prompt" }));
58
+ const parentKey = state.routes.at(-1)!.key;
59
+ if (fullscreen)
60
+ dispatch(StackActions.push("ThreadInspectorFullscreen", { ...source, threadId: "child" }));
61
+ if (fromAgents)
62
+ dispatch(
63
+ StackActions.push("ThreadAgents", fullscreen ? { ...source, threadId: "child" } : source),
64
+ );
65
+ let openInspector: ReturnType<typeof useOpenThreadInspector>;
66
+ let openLinkedThread: ReturnType<typeof useOpenLinkedThread>;
67
+ function Probe() {
68
+ const open = useOpenThreadInspector();
69
+ const openLinked = useOpenLinkedThread();
70
+ useLayoutEffect(() => {
71
+ openInspector = open;
72
+ openLinkedThread = openLinked;
73
+ });
74
+ return null;
75
+ }
76
+ const root = createRoot(document.createElement("div"));
77
+ act(() => root.render(<Probe />));
78
+ return {
79
+ source,
80
+ parentKey,
81
+ dispatch,
82
+ get state() {
83
+ return state;
84
+ },
85
+ open(target: Parameters<typeof openInspector>[1], from = source) {
86
+ let opened = false;
87
+ act(() => {
88
+ opened = openInspector(from, target);
89
+ });
90
+ return opened;
91
+ },
92
+ openLinked(threadId: string) {
93
+ act(() => openLinkedThread({ environmentId: source.environmentId, threadId }));
94
+ },
95
+ [Symbol.dispose]() {
96
+ act(() => root.unmount());
97
+ },
98
+ };
99
+}
100
+
101
+it("opens a subagent from the Agents sheet without replacing the parent thread", () => {
102
+ using screen = setup(true);
103
+ const inspector = {
104
+ type: "thread",
105
+ environmentId: screen.source.environmentId,
106
+ threadId: "child",
107
+ } as const;
108
+ screen.open(inspector);
109
+ expect(screen.state.routes.map((route) => route.name)).toEqual(["Home", "Thread"]);
110
+ expect(screen.state.routes.at(-1)).toMatchObject({
111
+ key: screen.parentKey,
112
+ params: { ...screen.source, prompt: "retained prompt", inspector },
113
+ });
114
+ screen.dispatch(StackActions.push("ThreadInspectorFullscreen", inspector));
115
+ screen.dispatch(StackActions.pop());
116
+ expect(screen.state.routes.at(-1)).toMatchObject({
117
+ key: screen.parentKey,
118
+ params: { ...screen.source, inspector },
119
+ });
120
+});
121
+
122
+it("opens a completion link in the parent inspector", () => {
123
+ using screen = setup(false);
124
+ screen.openLinked("child");
125
+ expect(screen.state.routes).toHaveLength(2);
126
+ expect(screen.state.routes.at(-1)).toMatchObject({
127
+ key: screen.parentKey,
128
+ params: {
129
+ ...screen.source,
130
+ inspector: { type: "thread", environmentId: screen.source.environmentId, threadId: "child" },
131
+ },
132
+ });
133
+});
134
+
135
+it("switches between subagents and devices in the same parent route", () => {
136
+ using screen = setup(false);
137
+ screen.open({ type: "thread", environmentId: screen.source.environmentId, threadId: "child" });
138
+ const inspector = { type: "device", ...screen.source } as const;
139
+ screen.open(inspector);
140
+ expect(screen.state.routes).toHaveLength(2);
141
+ expect(screen.state.routes.at(-1)).toMatchObject({
142
+ key: screen.parentKey,
143
+ params: { ...screen.source, inspector },
144
+ });
145
+});
146
+
147
+it.each(["thread", "device"] as const)(
148
+ "keeps the parent when a maximized child opens a %s preview",
149
+ (type) => {
150
+ using screen = setup(false, true);
151
+ const child = { ...screen.source, threadId: "child" };
152
+ const originalState = screen.state;
153
+ expect(screen.open({ type, ...child, threadId: "grandchild" }, child)).toBe(false);
154
+ expect(screen.state).toEqual(originalState);
155
+ screen.dispatch(StackActions.pop());
156
+ expect(screen.state.routes.at(-1)).toMatchObject({
157
+ key: screen.parentKey,
158
+ params: screen.source,
159
+ });
160
+ },
161
+);
162
+
163
+it("keeps the parent when the maximized child's Agents sheet opens another child", () => {
164
+ using screen = setup(true, true);
165
+ const child = { ...screen.source, threadId: "child" };
166
+ const originalState = screen.state;
167
+ expect(screen.open({ type: "thread", ...child, threadId: "grandchild" }, child)).toBe(false);
168
+ expect(screen.state).toEqual(originalState);
169
+});
apps/mobile/src/features/threads/thread-inspector-navigation.ts
new
+44
@@ -0,0 +1,44 @@
1
+import { StackActions, useNavigation } from "@react-navigation/native";
2
+import { createContext, use } from "react";
3
+import { Platform } from "react-native";
4
+
5
+import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
6
+
7
+export type ThreadInspectorTarget = {
8
+ readonly type: "thread" | "device";
9
+ readonly environmentId: string;
10
+ readonly threadId: string;
11
+ readonly deviceKey?: string;
12
+};
13
+
14
+export const ThreadInspectorNavigationContext = createContext<
15
+ ((target: ThreadInspectorTarget) => void) | null
16
+>(null);
17
+
18
+export function useOpenThreadInspector() {
19
+ const navigation = useNavigation();
20
+ const { fileInspector } = useAdaptiveWorkspaceLayout();
21
+ const openInInspector = use(ThreadInspectorNavigationContext);
22
+ return (
23
+ source: { readonly environmentId: string; readonly threadId: string },
24
+ target: ThreadInspectorTarget,
25
+ ) => {
26
+ if (Platform.OS !== "ios" || !fileInspector.supported) return false;
27
+ if (openInInspector) openInInspector(target);
28
+ else {
29
+ const parent = navigation.getState()?.routes.findLast((route) => route.name === "Thread");
30
+ if (
31
+ !parent?.params ||
32
+ !("environmentId" in parent.params) ||
33
+ parent.params.environmentId !== source.environmentId ||
34
+ !("threadId" in parent.params) ||
35
+ parent.params.threadId !== source.threadId
36
+ )
37
+ return false;
38
+ navigation.dispatch(
39
+ StackActions.popTo("Thread", { ...source, inspector: target }, { merge: true }),
40
+ );
41
+ }
42
+ return true;
43
+ };
44
+}
apps/mobile/src/features/threads/thread-inspector-preview.tsx
new
+142
@@ -0,0 +1,142 @@
1
+import {
2
+ NavigationContainer,
3
+ NavigationIndependentTree,
4
+ useIsFocused,
5
+ useNavigation,
6
+ type StaticScreenProps,
7
+} from "@react-navigation/native";
8
+import { EnvironmentId, ThreadId } from "@t3tools/contracts";
9
+import { type ReactNode } from "react";
10
+import { View } from "react-native";
11
+
12
+import { IconButton } from "../../components/ui/IconButton";
13
+import { SheetHeader } from "../../components/ui/SheetHeader";
14
+import { NativeInspectorContent } from "../../native/NativeInspectorContent";
15
+import { createV5StackNavigator } from "../../native/createV5StackNavigator";
16
+import { NativeStackScreenOptions } from "../../native/StackHeader";
17
+import { WorkspaceSlotOptionsContext } from "../../native/v5-workspace-context";
18
+import { useMobileNavigationTheme } from "../../lib/useMobileNavigationTheme";
19
+import { DevicePreviewScreen } from "../devices/DevicePreviewRouteScreen";
20
+import {
21
+ WorkspaceContentWidthContext,
22
+ WorkspaceSettledContentWidthContext,
23
+} from "../layout/workspace-content-width";
24
+import {
25
+ ThreadInspectorNavigationContext,
26
+ type ThreadInspectorTarget,
27
+} from "./thread-inspector-navigation";
28
+
29
+export interface ThreadInspectorPresentation {
30
+ readonly onClose: () => void;
31
+ readonly onMaximize?: () => void;
32
+}
33
+
34
+export function ThreadInspectorHeader(
35
+ props: ThreadInspectorPresentation & { readonly title: string },
36
+) {
37
+ return (
38
+ <>
39
+ <NativeStackScreenOptions options={{ headerShown: true, headerTransparent: true }} />
40
+ <SheetHeader
41
+ title={props.title}
42
+ onClose={props.onClose}
43
+ accessibilityLabel="Close thread preview"
44
+ trailing={
45
+ props.onMaximize ? (
46
+ <IconButton
47
+ icon="arrow.up.left.and.arrow.down.right"
48
+ accessibilityLabel="Maximize thread"
49
+ onPress={props.onMaximize}
50
+ />
51
+ ) : undefined
52
+ }
53
+ />
54
+ </>
55
+ );
56
+}
57
+
58
+const PreviewStack = createV5StackNavigator<{
59
+ Thread: { readonly environmentId: string; readonly threadId: string };
60
+}>();
61
+
62
+export function InspectorContentScope({ children }: { readonly children: ReactNode }) {
63
+ return (
64
+ <WorkspaceSlotOptionsContext value={null}>
65
+ <WorkspaceContentWidthContext value={null}>
66
+ <WorkspaceSettledContentWidthContext value={null}>
67
+ {children}
68
+ </WorkspaceSettledContentWidthContext>
69
+ </WorkspaceContentWidthContext>
70
+ </WorkspaceSlotOptionsContext>
71
+ );
72
+}
73
+
74
+export function ThreadInspectorPreview(props: {
75
+ readonly target: ThreadInspectorTarget;
76
+ readonly onClose: () => void;
77
+ readonly onOpen: (target: ThreadInspectorTarget) => void;
78
+ readonly renderThread: (
79
+ props: StaticScreenProps<{ readonly environmentId: string; readonly threadId: string }> & {
80
+ readonly inspectorPresentation: ThreadInspectorPresentation;
81
+ },
82
+ ) => ReactNode;
83
+}) {
84
+ const navigation = useNavigation();
85
+ const focused = useIsFocused();
86
+ const theme = useMobileNavigationTheme();
87
+ const { target } = props;
88
+ const maximizeDevice = (deviceKey: string | null) => {
89
+ props.onOpen({ ...target, deviceKey: deviceKey ?? undefined });
90
+ navigation.navigate("ThreadDevicePreview", {
91
+ environmentId: target.environmentId,
92
+ threadId: target.threadId,
93
+ deviceKey: deviceKey ?? undefined,
94
+ });
95
+ };
96
+ if (!focused) return null;
97
+ return (
98
+ <ThreadInspectorNavigationContext value={props.onOpen}>
99
+ <InspectorContentScope>
100
+ <NativeInspectorContent>
101
+ {target.type === "device" ? (
102
+ <DevicePreviewScreen
103
+ key={`${target.environmentId}:${target.threadId}`}
104
+ environmentId={EnvironmentId.make(target.environmentId)}
105
+ threadId={ThreadId.make(target.threadId)}
106
+ initialDeviceKey={target.deviceKey}
107
+ onClose={props.onClose}
108
+ onMaximize={maximizeDevice}
109
+ />
110
+ ) : (
111
+ <View className="flex-1 bg-screen">
112
+ <NavigationIndependentTree>
113
+ <NavigationContainer theme={theme} onUnhandledAction={navigation.dispatch}>
114
+ <PreviewStack.Navigator
115
+ key={`${target.environmentId}:${target.threadId}`}
116
+ screenOptions={{ headerBackVisible: false }}
117
+ >
118
+ <PreviewStack.Screen name="Thread" initialParams={target}>
119
+ {(screen) =>
120
+ props.renderThread({
121
+ route: screen.route,
122
+ inspectorPresentation: {
123
+ onClose: props.onClose,
124
+ onMaximize: () =>
125
+ navigation.navigate("ThreadInspectorFullscreen", {
126
+ environmentId: screen.route.params.environmentId,
127
+ threadId: screen.route.params.threadId,
128
+ }),
129
+ },
130
+ })
131
+ }
132
+ </PreviewStack.Screen>
133
+ </PreviewStack.Navigator>
134
+ </NavigationContainer>
135
+ </NavigationIndependentTree>
136
+ </View>
137
+ )}
138
+ </NativeInspectorContent>
139
+ </InspectorContentScope>
140
+ </ThreadInspectorNavigationContext>
141
+ );
142
+}
apps/mobile/src/features/threads/thread-subagent-group.tsx
+17
-8
@@ -22,6 +22,8 @@ import { subagentCardElapsed } from "./subagent-card-presentation";
22
import { SubagentRow } from "./SubagentRow";
23
import { WorkLogBlock } from "./work-log-layout";
24
25
+import { useOpenThreadInspector } from "./thread-inspector-navigation";
26
+
27
type SubagentItem = Extract<OrchestrationV2TurnItem, { type: "subagent" }>;
28
type AgentTiming = Pick<OrchestrationV2Subagent, "status" | "startedAt" | "completedAt">;
29
@@ -71,6 +73,7 @@ export function ThreadSubagentGroup(props: {
73
}) {
74
const config = useAtomValue(serverEnvironment.configValueAtom(props.environmentId));
75
const navigation = useNavigation();
76
+ const openInspector = useOpenThreadInspector();
77
const members = props.activities.flatMap(({ projectedItem }) =>
78
projectedItem.item.type === "subagent" ? [projectedItem.item] : [],
79
);
@@ -158,14 +161,20 @@ export function ThreadSubagentGroup(props: {
161
}
162
disabled={threadId === null}
163
onPress={() => {
161
- // Push preserves Back to the parent; navigate would reuse this Thread route.
162
- if (threadId !== null)
163
- navigation.dispatch(
164
- StackActions.push("Thread", {
165
- environmentId: String(props.environmentId),
166
- threadId: String(threadId),
167
- }),
168
- );
164
+ if (threadId === null) return;
165
+ if (
166
+ openInspector(
167
+ { environmentId: props.environmentId, threadId: members[0]!.threadId },
168
+ { type: "thread", environmentId: props.environmentId, threadId },
169
+ )
170
+ )
171
+ return;
172
+ navigation.dispatch(
173
+ StackActions.push("Thread", {
174
+ environmentId: String(props.environmentId),
175
+ threadId: String(threadId),
176
+ }),
177
+ );
178
}}
179
className="rounded-lg px-3 py-3 active:bg-subtle"
180
>
apps/mobile/src/features/threads/thread-work-log.tsx
+7
-9
@@ -21,7 +21,7 @@ import { type AppSymbolName, SymbolView } from "../../components/ui/AppSymbol";
21
import { MaskedView } from "@expo/ui/community/masked-view";
22
import type { LegendListRef } from "@legendapp/list/react-native";
23
import { AnimatedLegendList } from "@legendapp/list/reanimated";
24
-import { StackActions, useIsFocused, useNavigation } from "@react-navigation/native";
24
+import { useIsFocused } from "@react-navigation/native";
25
import {
26
useEffect,
27
useEffectEvent,
@@ -105,6 +105,7 @@ import Animated, {
105
} from "react-native-reanimated";
106
import { useAssetUrl } from "../../state/assets";
107
import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
108
+import { useOpenLinkedThread } from "./useOpenLinkedThread";
109
110
const SHIMMER_WIDTH = 72;
111
const SHIMMER_SWEEP_MS = 1_350;
@@ -882,7 +883,7 @@ const ThreadWorkLogRow = function ThreadWorkLogRow(
883
},
884
) {
885
const { row, expanded } = props;
885
- const navigation = useNavigation();
886
+ const openLinkedThread = useOpenLinkedThread();
887
const streamsOutput =
888
useCommandOutputStreaming(props.environmentId) &&
889
row.projectedItem.item.type === "command_execution";
@@ -1056,13 +1057,10 @@ const ThreadWorkLogRow = function ThreadWorkLogRow(
1057
accessibilityState={canExpand ? { expanded } : undefined}
1058
onPress={() => {
1059
if (notifiedSubagentThreadId !== undefined) {
1059
- // Push rather than navigate so Back returns to the parent thread instead of Home.
1060
- navigation.dispatch(
1061
- StackActions.push("Thread", {
1062
- environmentId: String(props.environmentId),
1063
- threadId: String(notifiedSubagentThreadId),
1064
- }),
1065
- );
1060
+ openLinkedThread({
1061
+ environmentId: String(props.environmentId),
1062
+ threadId: String(notifiedSubagentThreadId),
1063
+ });
1064
return;
1065
}
1066
if (canExpand) {
apps/mobile/src/features/threads/thread-workflow-opening.tsx
+3
-8
@@ -1,5 +1,4 @@
1
import { useAtomValue } from "@effect/atom-react";
2
-import { StackActions, useNavigation } from "@react-navigation/native";
2
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
3
import {
4
resolveWorkflowOpening,
@@ -17,6 +16,7 @@ import { useAppearancePreferences } from "../settings/appearance/AppearancePrefe
16
import { useMarkdownCodeHighlight } from "./markdownCodeHighlightState";
17
import { SubagentRow } from "./SubagentRow";
18
import { WorkLogBlock } from "./work-log-layout";
19
+import { useOpenLinkedThread } from "./useOpenLinkedThread";
20
21
const FOLDED_SCRIPT_LINES = 10;
22
@@ -74,7 +74,7 @@ export function ThreadWorkflowOpening(props: {
74
readonly threadId: ThreadId;
75
readonly opening: WorkflowOpeningValue;
76
}) {
77
- const navigation = useNavigation();
77
+ const openLinkedThread = useOpenLinkedThread();
78
const { opening } = props;
79
const headline = workflowOpeningHeadline(opening);
80
const canListMembers = opening.driver !== null && opening.providerInstanceId !== null;
@@ -90,12 +90,7 @@ export function ThreadWorkflowOpening(props: {
90
disabled={threadId === null}
91
onPress={() => {
92
if (threadId !== null)
93
- navigation.dispatch(
94
- StackActions.push("Thread", {
95
- environmentId: String(props.environmentId),
96
- threadId,
97
- }),
98
- );
93
+ openLinkedThread({ environmentId: String(props.environmentId), threadId });
94
}}
95
className="rounded-lg px-3 py-3 active:bg-subtle"
96
>
apps/mobile/src/features/threads/useOpenLinkedThread.ts
+25
-3
@@ -1,16 +1,38 @@
1
-import { StackActions, useNavigation } from "@react-navigation/native";
2
-import { useCallback } from "react";
1
+import { StackActions, useNavigation, useRoute, type Route } from "@react-navigation/native";
2
+import { use, useCallback } from "react";
3
import { linkedThreadStep } from "../../lib/android-workspace-navigation";
4
+import {
5
+ ThreadInspectorNavigationContext,
6
+ useOpenThreadInspector,
7
+} from "./thread-inspector-navigation";
8
9
export function useOpenLinkedThread() {
10
const navigation = useNavigation();
11
+ const route = useRoute<Route<string, { environmentId?: string; threadId?: string }>>();
12
+ const openInspector = useOpenThreadInspector();
13
+ const openInInspector = use(ThreadInspectorNavigationContext);
14
return useCallback(
15
(target: { readonly environmentId: string; readonly threadId: string }) => {
16
+ if (openInInspector) {
17
+ openInInspector({ type: "thread", ...target });
18
+ return;
19
+ }
20
const state = navigation.getState();
21
const step = state ? linkedThreadStep(state, target) : "push";
22
+ if (
23
+ step === "push" &&
24
+ route.name === "Thread" &&
25
+ route.params?.environmentId &&
26
+ route.params.threadId &&
27
+ openInspector(
28
+ { environmentId: route.params.environmentId, threadId: route.params.threadId },
29
+ { type: "thread", ...target },
30
+ )
31
+ )
32
+ return;
33
if (step === "pop") navigation.dispatch(StackActions.pop());
34
else if (step === "push") navigation.dispatch(StackActions.push("Thread", target));
35
},
14
- [navigation],
36
+ [navigation, openInInspector, openInspector, route],
37
);
38
}
apps/mobile/src/lib/filePreview.test.ts
+4
@@ -63,6 +63,7 @@ vi.mock("expo-audio", () => ({
63
vi.mock("@react-navigation/native", () => ({
64
useIsFocused: () => true,
65
useNavigation: () => ({ navigate: audio.navigate }),
66
+ useRoute: () => ({ name: "Thread", params: {} }),
67
useFocusEffect: (callback: () => (() => void) | undefined) => useEffect(callback, [callback]),
68
}));
69
vi.mock("react-native", () => ({
@@ -264,6 +265,9 @@ vi.mock("../features/threads/CopyTextButton", () => ({ CopyTextButton: () => nul
265
vi.mock("../features/threads/thread-work-log", () => ({ THREAD_DISCLOSURE_TRANSITION_MS: 100 }));
266
vi.mock("../features/threads/HtmlRenderWebView", () => ({}));
267
vi.mock("../features/threads/McpAppWebView", () => ({}));
268
+vi.mock("../features/layout/AdaptiveWorkspaceLayout", () => ({
269
+ useAdaptiveWorkspaceLayout: () => ({ fileInspector: { supported: false } }),
270
+}));
271
vi.mock("../features/threads/thread-workflow-opening", () => ({ useWorkflowOpening: () => null }));
272
vi.mock("../features/threads/useFileChipShare", () => ({ useFileChipShare: () => vi.fn() }));
273
vi.mock("../features/threads/ThreadMarkdownImage", async () => {
apps/mobile/src/lib/layout.test.ts
+20
@@ -128,6 +128,26 @@ describe("isPrimarySidebarPinned", () => {
128
});
129
130
describe("deriveWorkspacePaneLayout", () => {
131
+ it("lets UIKit keep the sidebar independent of the inspector in landscape", () => {
132
+ const layout = deriveLayout({ width: 1_194, height: 834 });
133
+ for (const primarySidebarPreferredVisible of [true, false]) {
134
+ expect(
135
+ deriveWorkspacePaneLayout({
136
+ layout,
137
+ viewportWidth: 1_194,
138
+ nativeWorkspace: true,
139
+ primarySidebarPreferredVisible,
140
+ auxiliaryPanePreferredVisible: true,
141
+ auxiliaryPaneRole: "inspector",
142
+ }),
143
+ ).toMatchObject({
144
+ primarySidebarVisible: primarySidebarPreferredVisible,
145
+ primarySidebarSuppressedByAuxiliary: false,
146
+ auxiliaryPaneVisible: true,
147
+ });
148
+ }
149
+ });
150
+
151
it("keeps an explicitly hidden thread sidebar hidden when the file inspector is visible", () => {
152
const layout = deriveLayout({ width: 1_024, height: 1_366 });
153
apps/mobile/src/lib/layout.ts
+2
@@ -189,6 +189,7 @@ export function isPrimarySidebarPinned(input: {
189
export function deriveWorkspacePaneLayout(input: {
190
readonly layout: Layout;
191
readonly viewportWidth: number;
192
+ readonly nativeWorkspace?: boolean;
193
readonly primarySidebarPreferredVisible: boolean;
194
readonly auxiliaryPanePreferredVisible: boolean;
195
readonly auxiliaryPaneRole?: WorkspaceAuxiliaryPaneRole;
@@ -212,6 +213,7 @@ export function deriveWorkspacePaneLayout(input: {
213
});
214
const auxiliaryPaneVisible = fileInspector.supported && input.auxiliaryPanePreferredVisible;
215
const primarySidebarSuppressedByAuxiliary =
216
+ !input.nativeWorkspace &&
217
preferredPrimarySidebarVisible &&
218
!input.layout.primarySidebarOverlaysContent &&
219
auxiliaryPaneVisible &&
apps/mobile/vite.config.ts
+1
@@ -4,6 +4,7 @@ import "vite-plus/test/config";
4
const reactTests = [
5
"src/features/pull-requests/usePullRequestEnvironmentFallback.test.tsx",
6
"src/lib/filePreview.test.ts",
7
+ "src/features/threads/thread-inspector-navigation.test.tsx",
8
"src/features/diffs/nativeReviewDiffSurface.test.tsx",
9
"src/features/pull-requests/usePullRequestDiff.test.tsx",
10
"src/components/ui/Dialog.android.test.tsx",
docs/user/devices.md
+2
@@ -73,6 +73,8 @@ connected to the thread, the same way an agent-driven browser does. Turn off
73
**Auto-show floating preview** in **Settings → Integrations → Browser** to open a
74
right-panel tab instead. In the mobile app, open the agent's thread and tap the
75
device button above the composer to watch the live screen and control it.
76
+On iOS layouts with an inspector, the device opens beside the thread. Maximize
77
+it to fill the screen; closing the full-screen view returns to the inspector.
78
If the thread has several devices open, choose one in the viewer. Closing the
79
viewer stops streaming and leaves the device available to the agent. Device
80
activity also appears in the thread timeline.
docs/user/thread-sidebar.md
+3
@@ -230,6 +230,9 @@ snooze limit stops by default. Providers without a reset time offer manual
230
retry and the normal snooze choices.
231
232
On web and desktop, use **Agents** to follow work delegated to subagents.
233
+On mobile, open a subagent from its conversation card or **Agents**. On iOS
234
+layouts with an inspector, its thread opens beside the parent. Maximize it to
235
+fill the screen; close the full-screen view to return to the parent and inspector.
236
Stop on a thread also stops the subagents it delegated to.
237
238
Subagent threads started by the agent can't take messages; message the parent
scripts/effect-budget.json
+1
-1
@@ -118,7 +118,7 @@
118
"apps/mobile/src/features/threads/ThreadMarkdownImage.tsx": 3,
119
"apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx": 3,
120
"apps/mobile/src/features/threads/ThreadQueueControl.tsx": 2,
121
- "apps/mobile/src/features/threads/ThreadRouteScreen.tsx": 2,
121
+ "apps/mobile/src/features/threads/ThreadRouteScreen.tsx": 3,
122
"apps/mobile/src/features/threads/ThreadScreenHost.tsx": 2,
123
"apps/mobile/src/features/threads/ThreadSettingsSheet.tsx": 2,
124
"apps/mobile/src/features/threads/UsageLimitRecoveryCard.tsx": 1,