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