Open History to see the last commit
1import type {
2 EnvironmentProject,
3 EnvironmentThreadShell,
4} from "@t3tools/client-runtime/state/shell";
5import { EnvironmentId, ThreadId, type SidebarProjectGroupingMode } from "@t3tools/contracts";
6import { useAtomValue } from "@effect/atom-react";
7import { useFocusEffect } from "@react-navigation/native";
8import {
9 CommonActions,
10 NavigationContext,
11 NavigationRouteContext,
12 StackActions,
13 useNavigation,
14} from "@react-navigation/native";
15import {
16 createContext,
17 use,
18 useCallback,
19 useEffect,
20 useMemo,
21 useRef,
22 useState,
23 type ReactNode,
24} from "react";
25import { Platform, useWindowDimensions, View } from "react-native";
26import Animated, {
27 useAnimatedStyle,
28 useDerivedValue,
29 useSharedValue,
30 withTiming,
31} from "react-native-reanimated";
32import { AsyncResult } from "effect/reactivity";
33
34import {
35 deriveFileInspectorPaneLayout,
36 deriveLayout,
37 deriveWorkspacePaneLayout,
38 type FileInspectorPaneLayout,
39 type Layout,
40 type WorkspaceAuxiliaryPaneRole,
41 type WorkspacePaneLayout,
42} from "../../lib/layout";
43import {
44 resolveThreadSelectionNavigationAction,
45 resolveThreadSelectionOverlayState,
46} from "../../lib/adaptive-navigation";
47import { scopedThreadKey } from "../../lib/scopedEntities";
48import { mobilePreferencesAtom } from "../../state/preferences";
49import {
50 DEFAULT_MOBILE_PROJECT_GROUPING_SETTINGS,
51 resolveMobileProjectGroupingSettings,
52} from "../../state/project-grouping";
53import {
54 parseActiveThreadPath,
55 useHardwareKeyboardCommand,
56} from "../keyboard/hardwareKeyboardCommands";
57import { AndroidHomeFabLayout } from "../home/AndroidHomeFab";
58import { HomeListOptionsProvider } from "../home/home-list-options";
59import { ThreadNavigationSidebar } from "../threads/ThreadNavigationSidebar";
60import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary";
61import { WORKSPACE_PANE_TIMING } from "./workspace-pane-animation";
62import { WorkspaceInspectorPane } from "./workspace-inspector-pane";
63import { WorkspaceContentWidthContext } from "./workspace-content-width";
64import {
65 NativeWorkspaceModeContext,
66 NativeWorkspaceInspectorContext,
67} from "../../native/v5-workspace-context";
68
69interface AdaptiveWorkspaceContextValue {
70 readonly layout: Layout;
71 readonly panes: WorkspacePaneLayout;
72 readonly fileInspector: FileInspectorPaneLayout;
73 readonly primarySidebarSearchQuery: string;
74 readonly selectThread: (thread: EnvironmentThreadShell) => void;
75 readonly activateAuxiliaryPaneRole: (role: WorkspaceAuxiliaryPaneRole) => () => void;
76 /**
77 * Route screens hand their inspector pane content to the workspace so it
78 * renders BESIDE the navigator (outside the native stack header) instead of
79 * inside the route. Returns a deactivate callback: the pane animates closed
80 * (content kept mounted for the exit transition) unless a newer
81 * registration already took over — stale deactivates never clobber it.
82 * Prefer useRegisterWorkspaceInspector over calling this directly.
83 */
84 readonly registerWorkspaceInspector: (render: () => ReactNode) => () => void;
85 readonly setPrimarySidebarSearchQuery: (query: string) => void;
86 readonly showAuxiliaryPane: (role: WorkspaceAuxiliaryPaneRole) => void;
87 readonly toggleAuxiliaryPane: () => void;
88 readonly togglePrimarySidebar: () => void;
89 readonly setAuxiliaryPaneWidth: (width: number) => void;
90}
91
92const compactLayout = deriveLayout({ width: 0, height: 0 });
93const compactPanes = deriveWorkspacePaneLayout({
94 layout: compactLayout,
95 viewportWidth: 0,
96 primarySidebarPreferredVisible: true,
97 auxiliaryPanePreferredVisible: true,
98});
99const compactFileInspector = deriveFileInspectorPaneLayout({
100 layout: compactLayout,
101 viewportWidth: 0,
102});
103const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceContextValue>({
104 layout: compactLayout,
105 panes: compactPanes,
106 fileInspector: compactFileInspector,
107 primarySidebarSearchQuery: "",
108 selectThread: () => undefined,
109 activateAuxiliaryPaneRole: () => () => undefined,
110 registerWorkspaceInspector: () => () => undefined,
111 setPrimarySidebarSearchQuery: () => undefined,
112 showAuxiliaryPane: () => undefined,
113 toggleAuxiliaryPane: () => undefined,
114 togglePrimarySidebar: () => undefined,
115 setAuxiliaryPaneWidth: () => undefined,
116});
117
118export function useAdaptiveWorkspaceLayout(): AdaptiveWorkspaceContextValue {
119 return use(AdaptiveWorkspaceContext);
120}
121
122export function useAdaptiveWorkspacePaneRole(role: WorkspaceAuxiliaryPaneRole) {
123 const { activateAuxiliaryPaneRole } = useAdaptiveWorkspaceLayout();
124
125 useFocusEffect(
126 useCallback(() => activateAuxiliaryPaneRole(role), [activateAuxiliaryPaneRole, role]),
127 );
128}
129
130/**
131 * Register this screen's inspector pane content with the workspace column.
132 *
133 * The column renders BESIDE the navigator — outside any screen — so the
134 * registering screen's navigation and route contexts are captured here and
135 * re-provided around the portal content. Without them, useNavigation/useRoute
136 * inside the pane (e.g. GitOverviewSheet via useThreadSelection) throw
137 * "Couldn't find a route object".
138 *
139 * Registration is FOCUS-scoped, driven by navigation events rather than the
140 * screen's own render cycle: react-native-screens freezes blurred screens, so
141 * a cleanup that depends on the blurred subtree re-rendering never runs and
142 * would leak the pane into the next route. Blur deactivates the pane (it
143 * animates closed, or is replaced seamlessly when the next route registers in
144 * the same commit); focus re-registers it.
145 */
146export function useRegisterWorkspaceInspector(render: (() => ReactNode) | undefined) {
147 const { registerWorkspaceInspector } = useAdaptiveWorkspaceLayout();
148 // Raw context values (not the useNavigation/useRoute wrappers) so the
149 // portal re-provides exactly what this screen sees.
150 const navigation = use(NavigationContext);
151 const route = use(NavigationRouteContext);
152
153 const wrappedRender = useMemo(() => {
154 if (render === undefined) {
155 return undefined;
156 }
157 return () => (
158 <NavigationContext.Provider value={navigation}>
159 <NavigationRouteContext.Provider value={route}>{render()}</NavigationRouteContext.Provider>
160 </NavigationContext.Provider>
161 );
162 }, [navigation, render, route]);
163
164 const wrappedRenderRef = useRef(wrappedRender);
165 wrappedRenderRef.current = wrappedRender;
166 const focusedRef = useRef(false);
167 const deactivateRef = useRef<(() => void) | null>(null);
168
169 const syncRegistration = useCallback(() => {
170 if (!focusedRef.current || wrappedRenderRef.current === undefined) {
171 deactivateRef.current?.();
172 return;
173 }
174 deactivateRef.current = registerWorkspaceInspector(wrappedRenderRef.current);
175 }, [registerWorkspaceInspector]);
176
177 // Focus lifecycle. Blur/focus events fire even when the blurred subtree is
178 // frozen (events are navigation-driven, renders are not).
179 useFocusEffect(
180 useCallback(() => {
181 focusedRef.current = true;
182 syncRegistration();
183 return () => {
184 focusedRef.current = false;
185 syncRegistration();
186 };
187 }, [syncRegistration]),
188 );
189
190 // Content changes while focused re-register in place.
191 useEffect(() => {
192 if (focusedRef.current) {
193 syncRegistration();
194 }
195 }, [syncRegistration, wrappedRender]);
196
197 // Unmount: hand the pane back (owner-guarded, so a route that already
198 // took over is unaffected).
199 useEffect(
200 () => () => {
201 deactivateRef.current?.();
202 deactivateRef.current = null;
203 },
204 [],
205 );
206}
207
208export function AdaptiveWorkspaceLayout(props: {
209 readonly children: ReactNode;
210 readonly pathname: string;
211 readonly workspaceRouteKey: string | undefined;
212}) {
213 const preferencesResult = useAtomValue(mobilePreferencesAtom);
214 if (!AsyncResult.isSuccess(preferencesResult)) {
215 return AsyncResult.isFailure(preferencesResult) ? (
216 <AdaptiveWorkspaceLayoutContent
217 {...props}
218 projectGroupingMode={DEFAULT_MOBILE_PROJECT_GROUPING_SETTINGS.sidebarProjectGroupingMode}
219 />
220 ) : null;
221 }
222 const groupingSettings = resolveMobileProjectGroupingSettings(preferencesResult.value);
223 return (
224 <AdaptiveWorkspaceLayoutContent
225 {...props}
226 projectGroupingMode={groupingSettings.sidebarProjectGroupingMode}
227 />
228 );
229}
230
231function AdaptiveWorkspaceLayoutContent(
232 props: {
233 readonly children: ReactNode;
234 readonly pathname: string;
235 readonly workspaceRouteKey: string | undefined;
236 } & {
237 readonly projectGroupingMode: SidebarProjectGroupingMode;
238 },
239) {
240 const projectGroupingMode = props.projectGroupingMode;
241 const nativeWorkspace = use(NativeWorkspaceModeContext);
242 const { width, height } = useWindowDimensions();
243 const pathname = props.pathname;
244 const navigation = useNavigation();
245 const activeRoleOwner = useRef<symbol | null>(null);
246 const [primarySidebarPreferredVisible, setPrimarySidebarPreferredVisible] = useState(true);
247 const showPrimarySidebar = pathname === "/" || primarySidebarPreferredVisible;
248 const [supplementaryPanePreferredVisible, setSupplementaryPanePreferredVisible] = useState(true);
249 const [supplementaryPanePreferredWidth, setSupplementaryPanePreferredWidth] = useState<
250 number | null
251 >(null);
252 const [fileInspectorPreferredVisible, setFileInspectorPreferredVisible] = useState(true);
253 const [fileInspectorPreferredWidth, setFileInspectorPreferredWidth] = useState<number | null>(
254 null,
255 );
256 const [primarySidebarSearchQuery, setPrimarySidebarSearchQuery] = useState("");
257 const [focusedAuxiliaryPaneRole, setFocusedAuxiliaryPaneRole] =
258 useState<WorkspaceAuxiliaryPaneRole | null>(null);
259 const baseLayout = useMemo(() => deriveLayout({ width, height }), [height, width]);
260 const layout = baseLayout;
261 // In split layouts the sidebar IS the thread list — it renders on every
262 // route, including Home (which shows an empty-detail pane instead of the
263 // compact list).
264 const shouldRenderPrimarySidebar = layout.usesSplitView;
265 const fileInspector = useMemo(
266 () =>
267 deriveFileInspectorPaneLayout({
268 layout,
269 viewportWidth: width,
270 preferredWidth: fileInspectorPreferredWidth ?? undefined,
271 reservedLeadingWidth:
272 shouldRenderPrimarySidebar && showPrimarySidebar ? (layout.listPaneWidth ?? 0) : 0,
273 }),
274 [fileInspectorPreferredWidth, layout, showPrimarySidebar, shouldRenderPrimarySidebar, width],
275 );
276 const auxiliaryPaneRole: WorkspaceAuxiliaryPaneRole =
277 focusedAuxiliaryPaneRole ?? (/\/files(?:\/|$)/.test(pathname) ? "inspector" : "supplementary");
278 const auxiliaryPanePreferredVisible =
279 auxiliaryPaneRole === "inspector"
280 ? fileInspectorPreferredVisible
281 : supplementaryPanePreferredVisible;
282 const auxiliaryPanePreferredWidth =
283 auxiliaryPaneRole === "inspector"
284 ? fileInspectorPreferredWidth
285 : supplementaryPanePreferredWidth;
286 const panes = useMemo(
287 () =>
288 deriveWorkspacePaneLayout({
289 layout,
290 viewportWidth: width,
291 primarySidebarPreferredVisible: showPrimarySidebar,
292 auxiliaryPanePreferredVisible,
293 auxiliaryPaneRole,
294 auxiliaryPanePreferredWidth: auxiliaryPanePreferredWidth ?? undefined,
295 }),
296 [
297 auxiliaryPanePreferredVisible,
298 auxiliaryPaneRole,
299 auxiliaryPanePreferredWidth,
300 layout,
301 showPrimarySidebar,
302 width,
303 ],
304 );
305 const activeThread = parseActiveThreadPath(pathname);
306 const environmentId = activeThread?.environmentId ?? null;
307 const threadId = activeThread?.threadId ?? null;
308 const selectedThreadKey = useMemo(() => {
309 if (environmentId === null || threadId === null) {
310 return null;
311 }
312 try {
313 return scopedThreadKey(EnvironmentId.make(environmentId), ThreadId.make(threadId));
314 } catch {
315 return null;
316 }
317 }, [environmentId, threadId]);
318 // Wrapped in an object: bare functions in useState would be treated as
319 // lazy initializers/updaters. `active: false` keeps the outgoing route's
320 // content mounted so the pane can animate closed (or be replaced
321 // seamlessly by the next route's registration in the same commit).
322 const [workspaceInspector, setWorkspaceInspector] = useState<{
323 readonly render: () => ReactNode;
324 readonly active: boolean;
325 } | null>(null);
326 const workspaceInspectorOwner = useRef<symbol | null>(null);
327 const registerWorkspaceInspector = useCallback((render: () => ReactNode) => {
328 const owner = Symbol("workspace-inspector");
329 workspaceInspectorOwner.current = owner;
330 setWorkspaceInspector({ render, active: true });
331
332 return () => {
333 // During a push/replace the outgoing screen deactivates AFTER the
334 // incoming screen registered — only the current owner may deactivate.
335 if (workspaceInspectorOwner.current !== owner) {
336 return;
337 }
338 setWorkspaceInspector((current) => (current === null ? null : { ...current, active: false }));
339 };
340 }, []);
341 // Once the close animation settles, drop the stale content entirely.
342 const handleWorkspaceInspectorClosed = useCallback(() => {
343 setWorkspaceInspector((current) => (current !== null && !current.active ? null : current));
344 }, []);
345 const activateAuxiliaryPaneRole = useCallback((role: WorkspaceAuxiliaryPaneRole) => {
346 const owner = Symbol(role);
347 activeRoleOwner.current = owner;
348 setFocusedAuxiliaryPaneRole(role);
349
350 return () => {
351 if (activeRoleOwner.current !== owner) {
352 return;
353 }
354 activeRoleOwner.current = null;
355 setFocusedAuxiliaryPaneRole(null);
356 };
357 }, []);
358 const togglePrimarySidebar = useCallback(() => {
359 if (pathname === "/") {
360 return;
361 }
362 if (!panes.primarySidebarVisible && panes.primarySidebarSuppressedByAuxiliary) {
363 setFileInspectorPreferredVisible(false);
364 setPrimarySidebarPreferredVisible(true);
365 return;
366 }
367 setPrimarySidebarPreferredVisible((current) => !current);
368 }, [panes.primarySidebarSuppressedByAuxiliary, panes.primarySidebarVisible, pathname]);
369 const revealPrimarySidebar = useCallback(() => {
370 if (panes.primarySidebarSuppressedByAuxiliary) {
371 setFileInspectorPreferredVisible(false);
372 }
373 setPrimarySidebarPreferredVisible(true);
374 }, [panes.primarySidebarSuppressedByAuxiliary]);
375 const handleToggleSidebarCommand = useCallback(() => {
376 togglePrimarySidebar();
377 return true;
378 }, [togglePrimarySidebar]);
379 const sidebarCommands = useMemo(
380 () => (pathname === "/" ? [] : (["toggleSidebar"] as const)),
381 [pathname],
382 );
383 useHardwareKeyboardCommand(sidebarCommands, handleToggleSidebarCommand);
384 const showAuxiliaryPane = useCallback((role: WorkspaceAuxiliaryPaneRole) => {
385 if (role === "inspector") {
386 setFocusedAuxiliaryPaneRole("inspector");
387 setFileInspectorPreferredVisible(true);
388 return;
389 }
390 setFocusedAuxiliaryPaneRole("supplementary");
391 setSupplementaryPanePreferredVisible(true);
392 }, []);
393 const handleOpenFilesCommand = useCallback(() => {
394 const activeThread = parseActiveThreadPath(pathname);
395 if (!layout.usesSplitView || !fileInspector.supported || activeThread === null) {
396 return false;
397 }
398 showAuxiliaryPane("inspector");
399 if (/\/files(?:\/|$)/.test(pathname)) {
400 return true;
401 }
402 navigation.navigate("ThreadFiles", activeThread);
403 return true;
404 }, [fileInspector.supported, layout.usesSplitView, pathname, navigation, showAuxiliaryPane]);
405 useHardwareKeyboardCommand("files", handleOpenFilesCommand);
406 const toggleAuxiliaryPane = useCallback(() => {
407 if (auxiliaryPaneRole === "inspector") {
408 setFileInspectorPreferredVisible((current) => !current);
409 return;
410 }
411 setSupplementaryPanePreferredVisible((current) => !current);
412 }, [auxiliaryPaneRole]);
413 const setAuxiliaryPaneWidth = useCallback(
414 (nextWidth: number) => {
415 if (auxiliaryPaneRole === "inspector") {
416 setFileInspectorPreferredWidth(nextWidth);
417 return;
418 }
419 setSupplementaryPanePreferredWidth(nextWidth);
420 },
421 [auxiliaryPaneRole],
422 );
423 const handleOpenSettings = useCallback(() => {
424 navigation.navigate("SettingsSheet", {
425 screen: "SettingsContent",
426 params: { screen: "Settings" },
427 });
428 }, [navigation]);
429
430 const handleStartNewTask = useCallback(() => {
431 navigation.navigate("NewTaskSheet", { screen: "NewTask" });
432 }, [navigation]);
433
434 // Minted here (root stack navigation) so the sidebar pane stays free of
435 // navigation hooks — on iOS it renders inside an independent nav tree.
436 const handleOpenEnvironmentSettings = useCallback(() => {
437 navigation.navigate("SettingsSheet", {
438 screen: "SettingsContent",
439 params: { screen: "SettingsEnvironments" },
440 });
441 }, [navigation]);
442
443 const handleNewThreadOnBranch = useCallback(
444 (thread: EnvironmentThreadShell) => {
445 navigation.navigate("NewTaskSheet", {
446 screen: "NewTaskDraft",
447 params: {
448 environmentId: String(thread.environmentId),
449 projectId: String(thread.projectId),
450 branch: thread.branch,
451 worktreePath: thread.worktreePath,
452 },
453 });
454 },
455 [navigation],
456 );
457
458 const handleNewThreadInProject = useCallback(
459 (project: EnvironmentProject) => {
460 navigation.navigate("NewTaskSheet", {
461 screen: "NewTaskDraft",
462 params: {
463 environmentId: String(project.environmentId),
464 projectId: String(project.id),
465 title: project.title,
466 },
467 });
468 },
469 [navigation],
470 );
471
472 const renderedSidebarWidth = useSharedValue(
473 panes.primarySidebarVisible ? (layout.listPaneWidth ?? 0) : 0,
474 );
475 useEffect(() => {
476 if (nativeWorkspace) return;
477 const targetWidth = panes.primarySidebarVisible ? (layout.listPaneWidth ?? 0) : 0;
478 renderedSidebarWidth.value = withTiming(targetWidth, WORKSPACE_PANE_TIMING);
479 }, [nativeWorkspace, layout.listPaneWidth, panes.primarySidebarVisible, renderedSidebarWidth]);
480 const sidebarAnimatedStyle = useAnimatedStyle(() => ({
481 opacity: Math.min(1, renderedSidebarWidth.value / 80),
482 width: renderedSidebarWidth.value,
483 }));
484
485 // Freeze the content pane at its SETTLED width while the side panes
486 // animate. The navigator (native header + markdown feed) lays out ONCE per
487 // pane toggle instead of re-measuring on every animation frame — the
488 // animating columns merely clip/reveal it over a matching background.
489 // Continuously re-wrapping the chat feed was the main source of dropped
490 // frames during sidebar/inspector transitions.
491 const inspectorColumnTargetWidth =
492 workspaceInspector !== null && workspaceInspector.active && panes.auxiliaryPaneVisible
493 ? (panes.auxiliaryPaneWidth ?? 0)
494 : 0;
495 const contentSettledWidth = layout.usesSplitView
496 ? Math.max(0, panes.contentPaneWidth - inspectorColumnTargetWidth)
497 : null;
498 const renderedInspectorWidth = useSharedValue(inspectorColumnTargetWidth);
499 const renderedContentWidth = useDerivedValue(() =>
500 Math.max(0, width - renderedSidebarWidth.value - renderedInspectorWidth.value),
501 );
502
503 const handleSelectThread = useCallback(
504 (thread: EnvironmentThreadShell) => {
505 const params = {
506 environmentId: String(thread.environmentId),
507 threadId: String(thread.id),
508 };
509 const navigationAction = resolveThreadSelectionNavigationAction({
510 usesSplitView: layout.usesSplitView,
511 pathname,
512 });
513 const overlayState = resolveThreadSelectionOverlayState({
514 state: navigation.getState(),
515 workspaceRouteKey: props.workspaceRouteKey,
516 action: navigationAction,
517 params,
518 });
519 if (overlayState !== null) {
520 setFileInspectorPreferredVisible(false);
521 navigation.dispatch(CommonActions.reset(overlayState));
522 return;
523 }
524 if (navigationAction === "set-params") {
525 const nextThreadKey = scopedThreadKey(thread.environmentId, thread.id);
526 if (nextThreadKey === selectedThreadKey) {
527 return;
528 }
529 setFileInspectorPreferredVisible(false);
530 navigation.navigate("Thread", params);
531 return;
532 }
533 if (navigationAction === "replace") {
534 setFileInspectorPreferredVisible(false);
535 navigation.dispatch(StackActions.replace("Thread", params));
536 return;
537 }
538 navigation.navigate("Thread", params);
539 },
540 [layout.usesSplitView, pathname, navigation, selectedThreadKey, props.workspaceRouteKey],
541 );
542
543 const contextValue = useMemo(
544 () => ({
545 layout,
546 panes,
547 fileInspector,
548 primarySidebarSearchQuery,
549 selectThread: handleSelectThread,
550 activateAuxiliaryPaneRole,
551 registerWorkspaceInspector,
552 setPrimarySidebarSearchQuery,
553 showAuxiliaryPane,
554 toggleAuxiliaryPane,
555 togglePrimarySidebar,
556 setAuxiliaryPaneWidth,
557 }),
558 [
559 activateAuxiliaryPaneRole,
560 fileInspector,
561 handleSelectThread,
562 layout,
563 panes,
564 primarySidebarSearchQuery,
565 registerWorkspaceInspector,
566 showAuxiliaryPane,
567 setPrimarySidebarSearchQuery,
568 setAuxiliaryPaneWidth,
569 toggleAuxiliaryPane,
570 togglePrimarySidebar,
571 ],
572 );
573
574 if (nativeWorkspace) {
575 return (
576 <HomeListOptionsProvider projectGroupingMode={projectGroupingMode}>
577 <AdaptiveWorkspaceContext value={contextValue}>
578 <NativeWorkspaceInspectorContext
579 value={{ render: workspaceInspector?.render, visible: inspectorColumnTargetWidth > 0 }}
580 >
581 {props.children}
582 </NativeWorkspaceInspectorContext>
583 </AdaptiveWorkspaceContext>
584 </HomeListOptionsProvider>
585 );
586 }
587 return (
588 <HomeListOptionsProvider projectGroupingMode={projectGroupingMode}>
589 <AdaptiveWorkspaceContext.Provider value={contextValue}>
590 <View testID="adaptive-workspace-layout" className="flex-1 flex-row">
591 {shouldRenderPrimarySidebar && layout.listPaneWidth !== null ? (
592 <Animated.View
593 className="self-stretch overflow-hidden"
594 accessibilityElementsHidden={!panes.primarySidebarVisible}
595 collapsable={false}
596 importantForAccessibility={
597 panes.primarySidebarVisible ? "auto" : "no-hide-descendants"
598 }
599 pointerEvents={panes.primarySidebarVisible ? "auto" : "none"}
600 style={sidebarAnimatedStyle}
601 >
602 <View className="flex-1" style={{ width: layout.listPaneWidth }}>
603 <RenderErrorBoundary
604 renderFallback={(fallback) => (
605 <RenderFailureView
606 {...fallback}
607 title="The sidebar couldn't be displayed"
608 exit={{ label: "Open settings", onPress: handleOpenSettings }}
609 />
610 )}
611 >
612 <AndroidHomeFabLayout sidebar onStartNewTask={handleStartNewTask}>
613 <ThreadNavigationSidebar
614 width={layout.listPaneWidth}
615 visible={panes.primarySidebarVisible}
616 onRequestVisibility={revealPrimarySidebar}
617 selectedThreadKey={selectedThreadKey}
618 onOpenSettings={handleOpenSettings}
619 onOpenEnvironmentSettings={handleOpenEnvironmentSettings}
620 onNewThreadInProject={handleNewThreadInProject}
621 onNewThreadOnBranch={handleNewThreadOnBranch}
622 onSelectThread={handleSelectThread}
623 onSearchQueryChange={setPrimarySidebarSearchQuery}
624 searchQuery={primarySidebarSearchQuery}
625 />
626 </AndroidHomeFabLayout>
627 </RenderErrorBoundary>
628 </View>
629 </Animated.View>
630 ) : null}
631 <View
632 className={
633 Platform.OS === "android"
634 ? "flex-1 overflow-hidden bg-header"
635 : "flex-1 overflow-hidden bg-screen"
636 }
637 collapsable={false}
638 >
639 <View
640 collapsable={false}
641 style={
642 contentSettledWidth !== null
643 ? {
644 flex: 1,
645 width: contentSettledWidth,
646 }
647 : { flex: 1 }
648 }
649 >
650 <WorkspaceContentWidthContext
651 value={layout.usesSplitView ? renderedContentWidth : null}
652 >
653 {props.children}
654 </WorkspaceContentWidthContext>
655 </View>
656 </View>
657 <WorkspaceInspectorPane
658 pathname={props.pathname}
659 renderedInspectorWidth={renderedInspectorWidth}
660 active={workspaceInspector?.active ?? false}
661 panes={panes}
662 renderInspector={workspaceInspector?.render}
663 setAuxiliaryPaneWidth={setAuxiliaryPaneWidth}
664 onClosed={handleWorkspaceInspectorClosed}
665 />
666 </View>
667 </AdaptiveWorkspaceContext.Provider>
668 </HomeListOptionsProvider>
669 );
670}