Skip to content

Commit fa4e4ca

Browse files
fix(mobile): remove inspector import cycle and isolate media tests
1 parent 40a0c06 commit fa4e4ca

4 files changed

Lines changed: 40 additions & 28 deletions

File tree

‎apps/mobile/src/Stack.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ import { ThreadPullRequestsSheet } from "./features/threads/ThreadPullRequestsSh
6565
import { ThreadAgentsSheet } from "./features/threads/ThreadAgentsSheet";
6666
import { ThreadBackgroundWorkSheet } from "./features/threads/ThreadBackgroundWorkSheet";
6767
import { ThreadQueueSheet } from "./features/threads/ThreadQueueControl";
68-
import { FullscreenThreadRouteScreen } from "./features/threads/thread-inspector-preview";
69-
import { ThreadRouteScreen } from "./features/threads/ThreadRouteScreen";
68+
import {
69+
FullscreenThreadRouteScreen,
70+
ThreadRouteScreen,
71+
} from "./features/threads/ThreadRouteScreen";
7072
import { McpAppFullscreenScreen } from "./features/threads/McpAppFullscreenScreen";
7173
import { ConnectionsRouteScreen } from "./features/connection/ConnectionsRouteScreen";
7274
import { ConnectionsNewRouteScreen } from "./features/connection/ConnectionsNewRouteScreen";

‎apps/mobile/src/features/threads/ThreadRouteScreen.tsx‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ import {
9595
} from "../workspace/useAndroidWorkspaceNavigation";
9696
import { openSettings } from "../settings/settings-navigation";
9797
import {
98+
InspectorContentScope,
9899
ThreadInspectorHeader,
99100
ThreadInspectorPreview,
100101
type ThreadInspectorPresentation,
@@ -580,6 +581,7 @@ function ThreadRouteContent(
580581
previewTarget && panes.auxiliaryPaneVisible ? (
581582
<ThreadInspectorPreview
582583
target={previewTarget}
584+
renderThread={(screen) => <ThreadRouteScreen {...screen} />}
583585
onClose={toggleAuxiliaryPane}
584586
onOpen={(inspector) => {
585587
if (
@@ -1073,3 +1075,20 @@ function ThreadRouteContent(
10731075
</>
10741076
);
10751077
}
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-preview.tsx‎

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
WorkspaceContentWidthContext,
2222
WorkspaceSettledContentWidthContext,
2323
} from "../layout/workspace-content-width";
24-
import { ThreadRouteScreen } from "./ThreadRouteScreen";
2524
import {
2625
ThreadInspectorNavigationContext,
2726
type ThreadInspectorTarget,
@@ -60,7 +59,7 @@ const PreviewStack = createV5StackNavigator<{
6059
Thread: { readonly environmentId: string; readonly threadId: string };
6160
}>();
6261

63-
function InspectorContentScope({ children }: { readonly children: ReactNode }) {
62+
export function InspectorContentScope({ children }: { readonly children: ReactNode }) {
6463
return (
6564
<WorkspaceSlotOptionsContext value={null}>
6665
<WorkspaceContentWidthContext value={null}>
@@ -76,6 +75,11 @@ export function ThreadInspectorPreview(props: {
7675
readonly target: ThreadInspectorTarget;
7776
readonly onClose: () => void;
7877
readonly onOpen: (target: ThreadInspectorTarget) => void;
78+
readonly renderThread: (
79+
props: StaticScreenProps<{ readonly environmentId: string; readonly threadId: string }> & {
80+
readonly inspectorPresentation: ThreadInspectorPresentation;
81+
},
82+
) => ReactNode;
7983
}) {
8084
const navigation = useNavigation();
8185
const focused = useIsFocused();
@@ -112,19 +116,19 @@ export function ThreadInspectorPreview(props: {
112116
screenOptions={{ headerBackVisible: false }}
113117
>
114118
<PreviewStack.Screen name="Thread" initialParams={target}>
115-
{(screen) => (
116-
<ThreadRouteScreen
117-
route={screen.route}
118-
inspectorPresentation={{
119+
{(screen) =>
120+
props.renderThread({
121+
route: screen.route,
122+
inspectorPresentation: {
119123
onClose: props.onClose,
120124
onMaximize: () =>
121125
navigation.navigate("ThreadInspectorFullscreen", {
122126
environmentId: screen.route.params.environmentId,
123127
threadId: screen.route.params.threadId,
124128
}),
125-
}}
126-
/>
127-
)}
129+
},
130+
})
131+
}
128132
</PreviewStack.Screen>
129133
</PreviewStack.Navigator>
130134
</NavigationContainer>
@@ -136,20 +140,3 @@ export function ThreadInspectorPreview(props: {
136140
</ThreadInspectorNavigationContext>
137141
);
138142
}
139-
140-
export function FullscreenThreadRouteScreen(
141-
props: StaticScreenProps<{
142-
readonly environmentId: string;
143-
readonly threadId: string;
144-
}>,
145-
) {
146-
const navigation = useNavigation();
147-
return (
148-
<InspectorContentScope>
149-
<ThreadRouteScreen
150-
route={props.route}
151-
inspectorPresentation={{ onClose: () => navigation.goBack() }}
152-
/>
153-
</InspectorContentScope>
154-
);
155-
}

‎apps/mobile/src/lib/filePreview.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ vi.mock("expo-audio", () => ({
6363
vi.mock("@react-navigation/native", () => ({
6464
useIsFocused: () => true,
6565
useNavigation: () => ({ navigate: audio.navigate }),
66+
useRoute: () => ({ name: "Thread", params: {} }),
6667
useFocusEffect: (callback: () => (() => void) | undefined) => useEffect(callback, [callback]),
6768
}));
6869
vi.mock("react-native", () => ({
@@ -264,6 +265,9 @@ vi.mock("../features/threads/CopyTextButton", () => ({ CopyTextButton: () => nul
264265
vi.mock("../features/threads/thread-work-log", () => ({ THREAD_DISCLOSURE_TRANSITION_MS: 100 }));
265266
vi.mock("../features/threads/HtmlRenderWebView", () => ({}));
266267
vi.mock("../features/threads/McpAppWebView", () => ({}));
268+
vi.mock("../features/layout/AdaptiveWorkspaceLayout", () => ({
269+
useAdaptiveWorkspaceLayout: () => ({ fileInspector: { supported: false } }),
270+
}));
267271
vi.mock("../features/threads/thread-workflow-opening", () => ({ useWorkflowOpening: () => null }));
268272
vi.mock("../features/threads/useFileChipShare", () => ({ useFileChipShare: () => vi.fn() }));
269273
vi.mock("../features/threads/ThreadMarkdownImage", async () => {

0 commit comments

Comments
 (0)