@devries-cameron20 / t3code Mirror · read-only / commits / 9318fdbe30
Fork 0

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, 00:45 UTC

fix(mobile): Android sidebar and composer transitions no longer reflow at rest (#33599)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 9, 2026 at 17:53 UTC 9318fdbe303e59263b842b88e2b997b5791527bd
23 files changed +201 -315
apps/mobile/src/components/ui/AndroidScreenHeader.android.tsx
+1 -25
@@ -1,6 +1,5 @@
1 import { AppActivityIndicator } from "./AppActivityIndicator";
2 -import { Column, Row, Text as NativeText, RNHostView } from "@expo/ui/jetpack-compose";
3 -import { weight } from "@expo/ui/jetpack-compose/modifiers";
2 +import { Column, Text as NativeText, RNHostView } from "@expo/ui/jetpack-compose";
3 import { use, useState, type ReactNode } from "react";
4 import { View } from "react-native";
5
@@ -46,8 +45,6 @@ export function AndroidScreenHeader(props: {
45 readonly onBack?: () => void;
46 readonly embedded?: boolean;
47 readonly hideBottomBorder?: boolean;
49 - /** One row with the subtitle after the title, for screens short on height. */
50 - readonly compact?: boolean;
48 }) {
49 const { colors } = useControlTheme();
50 const titleTypography = useScaledTextRole("title");
@@ -77,7 +74,6 @@ export function AndroidScreenHeader(props: {
74 />
75 ) : null}
76 <NativeAppBar
80 - singleLine={props.compact}
77 navigationIcon={
78 props.onBack || props.leading ? (
79 <View collapsable={false} className="flex-row items-center">
@@ -108,26 +104,6 @@ export function AndroidScreenHeader(props: {
104 >
105 {props.title}
106 </NativeText>
111 - ) : props.compact ? (
112 - <Row verticalAlignment="center" horizontalArrangement={{ spacedBy: 8 }}>
113 - <NativeText
114 - color={colors["--color-header-foreground"]}
115 - maxLines={1}
116 - overflow="ellipsis"
117 - style={titleTypography}
118 - >
119 - {props.title}
120 - </NativeText>
121 - <NativeText
122 - color={colors["--color-foreground-muted"]}
123 - maxLines={1}
124 - overflow="ellipsis"
125 - style={subtitleTypography}
126 - modifiers={[weight(1)]}
127 - >
128 - {props.subtitle}
129 - </NativeText>
130 - </Row>
107 ) : (
108 <Column>
109 <NativeText
apps/mobile/src/components/ui/AppBar.android.tsx
-1
@@ -204,7 +204,6 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
204 }
205 embedded={props.sheet}
206 hideBottomBorder={props.hideBottomBorder}
207 - compact={props.compact}
207 actions={
208 search && !inline
209 ? [
apps/mobile/src/components/ui/AppBar.types.ts
-2
@@ -120,8 +120,6 @@ export interface AppBarProps {
120 readonly onPress?: () => void;
121 };
122 readonly hideBottomBorder?: boolean;
123 - /** Android: one title row with the subtitle inline. iOS ignores it. */
124 - readonly compact?: boolean;
123 readonly trailing?: ReactNode;
124 readonly matchSearchSurface?: boolean;
125 readonly optionsVersion?: unknown;
apps/mobile/src/components/ui/NativeAppBar.android.tsx
+1 -3
@@ -12,11 +12,9 @@ export function NativeAppBar(props: {
12 readonly actions?: ReactElement;
13 /** Compose nodes laid out by the bar itself, so they never wait on a React Native measure. */
14 readonly nativeActions?: ReactElement;
15 - /** Shorter bar for a one-row title. */
16 - readonly singleLine?: boolean;
15 }) {
16 const { colors } = useControlTheme();
19 - const layout = useToolbarLayout(false, props.singleLine);
17 + const layout = useToolbarLayout();
18 return (
19 // The bar's height is fixed, so React Native lays out the screen below it from the first frame
20 // instead of at zero height until Compose has measured and reported the bar.
apps/mobile/src/components/ui/useToolbarLayout.ts
+3 -8
@@ -4,11 +4,8 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
4 import { useScaledTextRole } from "../../features/settings/appearance/useScaledTextRole";
5 import { useAndroidControlSizing } from "./useAndroidControlSizing";
6
7 -/**
8 - * Shared Android header geometry; class-based spacing uses the app's 14dp rem.
9 - * `singleLine` sizes the toolbar for a title row with the subtitle inline.
10 - */
11 -export function useToolbarLayout(embedded = false, singleLine = false) {
7 +/** Shared Android header geometry; class-based spacing uses the app's 14dp rem. */
8 +export function useToolbarLayout(embedded = false) {
9 const insets = useSafeAreaInsets();
10 const title = useScaledTextRole("title");
11 const subtitle = useScaledTextRole("label");
@@ -16,9 +13,7 @@ export function useToolbarLayout(embedded = false, singleLine = false) {
13 const { fontScale } = useWindowDimensions();
14 return {
15 height: Math.ceil(
19 - singleLine
20 - ? Math.max(48, 48 * scale, title.lineHeight * fontScale + 1)
21 - : Math.max(48, 56 * scale, (title.lineHeight + subtitle.lineHeight) * fontScale + 1),
16 + Math.max(48, 56 * scale, (title.lineHeight + subtitle.lineHeight) * fontScale + 1),
17 ),
18 paddingTop: embedded ? 8 * scale : Math.max(insets.top, 12 * scale),
19 paddingBottom: 7 * scale,
apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx
+9 -4
@@ -40,7 +40,11 @@ import { useEnvironmentQuery } from "../../state/query";
40 import { useEnvironmentPresentation } from "../../state/presentation";
41 import { projectEnvironment } from "../../state/projects";
42 import type { AssetUrlFailureReason } from "../../state/asset-url-state";
43 -import { Inspector, useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
43 +import {
44 + Inspector,
45 + useAdaptiveWorkspaceLayout,
46 + useWorkspacePaneState,
47 +} from "../layout/AdaptiveWorkspaceLayout";
48 import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
49 import { ThreadRouteScreen } from "../threads/ThreadRouteScreen";
50 import { FilePreviewLoading, FilePreviewNotice } from "./FilePreviewFeedback";
@@ -111,7 +115,8 @@ function FileHeader(props: {
115 readonly onPress: () => unknown;
116 }>;
117 }) {
114 - const { panes, toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout();
118 + const { toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout();
119 + const { panes } = useWorkspacePaneState();
120 const modes = props.actions.filter(({ inline }) => inline);
121 return (
122 <AppBar
@@ -453,7 +458,7 @@ function FilesToolbarBottomFade() {
458
459 export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
460 const navigation = useNavigation();
456 - const { fileInspector } = useAdaptiveWorkspaceLayout();
461 + const { fileInspector } = useWorkspacePaneState();
462 const [searchQuery, setSearchQuery] = useState("");
463 const { themeAppearance: highlightTheme } = useAppearancePreferences();
464 const { cwd, environmentId, projectName, selectedThread, threadId } = useThreadFilesWorkspace(
@@ -609,7 +614,7 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
614
615 export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
616 const navigation = useNavigation();
612 - const { fileInspector } = useAdaptiveWorkspaceLayout();
617 + const { fileInspector } = useWorkspacePaneState();
618 const { appearance, setCodeWordBreak } = useAppearancePreferences();
619 const params = props.route.params;
620 const targetLine = normalizeRouteLine(firstRouteParam(params.line));
apps/mobile/src/features/home/HomeRouteScreen.tsx
+6 -3
@@ -19,7 +19,10 @@ import { environmentThreadShells } from "../../state/threads";
19 import { usePendingNewTasks } from "../../state/use-pending-new-tasks";
20 import { useWorkspaceState } from "../../state/workspace";
21 import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
22 -import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
22 +import {
23 + useAdaptiveWorkspaceLayout,
24 + useWorkspacePaneState,
25 +} from "../layout/AdaptiveWorkspaceLayout";
26 import { AndroidHomeFabLayout } from "./AndroidHomeFab";
27 import { HomeScreen } from "./HomeScreen";
28 import { useHomeListOptions } from "./home-list-options";
@@ -37,8 +40,8 @@ import { buildHomeListFilterMenuItems } from "./home-list-filter-menu";
40
41 export function HomeRouteScreen() {
42 const nativePrimaryColumn = use(NativePrimaryColumnContext);
40 - const { layout, primarySidebarSearchQuery, setPrimarySidebarSearchQuery, startNewTask } =
41 - useAdaptiveWorkspaceLayout();
43 + const { layout, setPrimarySidebarSearchQuery, startNewTask } = useAdaptiveWorkspaceLayout();
44 + const { primarySidebarSearchQuery } = useWorkspacePaneState();
45 const selectDetail = useSelectWorkspaceDetail();
46 const projects = useProjects();
47 // Stop rebuilding the streaming thread list while Thread covers Home.
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+95 -198
@@ -3,20 +3,24 @@ import {
3 WorkspacePresentationHostContext,
4 } from "./workspace-presentation-context";
5 import { useAndroidFloatingTabs } from "../settings/appearance/AppearancePreferencesProvider";
6 -import { useSoftKeyboardShowing } from "../keyboard/useSoftKeyboardShowing";
6 import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
8 -import { AdaptiveWorkspaceContext, useAdaptiveWorkspaceLayout } from "./adaptive-workspace-context";
7 +import {
8 + AdaptiveWorkspaceContext,
9 + WorkspacePaneStateContext,
10 + useAdaptiveWorkspaceLayout,
11 + useWorkspacePaneState,
12 + type AdaptiveWorkspaceActions,
13 +} from "./adaptive-workspace-context";
14 import { threadSelectionDeferral } from "./deferred-navigation";
15 import { uuidv4 } from "../../lib/uuid";
11 -import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
16 import { EnvironmentId, ThreadId, type SidebarProjectGroupingMode } from "@t3tools/contracts";
17 import { useAtomValue } from "@effect/atom-react";
18 import { NavigationContext, NavigationRouteContext, useNavigation } from "@react-navigation/native";
19 import {
20 use,
17 - useDeferredValue,
21 useEffect,
22 useEffectEvent,
23 + useLayoutEffect,
24 useMemo,
25 useRef,
26 useState,
@@ -30,11 +34,6 @@ import {
34 useWindowDimensions,
35 View,
36 } from "react-native";
33 -import {
34 - KeyboardController,
35 - useKeyboardContext,
36 - useKeyboardState,
37 -} from "react-native-keyboard-controller";
37 import Animated, {
38 runOnJS,
39 useAnimatedStyle,
@@ -118,7 +117,7 @@ import { workspaceRoutesOf } from "./workspace-overlay-routes";
117 import { SettingsWorkspaceLayout } from "../settings/SettingsWorkspaceLayout";
118 import { WorkspaceThreadSidebar } from "./workspace/WorkspaceThreadSidebar";
119
121 -export { useAdaptiveWorkspaceLayout };
120 +export { useAdaptiveWorkspaceLayout, useWorkspacePaneState };
121
122 /**
123 * Shows these panes in the workspace's inspector while this screen is focused. Register on focus
@@ -191,6 +190,34 @@ export function Inspector(props: {
190 return null;
191 }
192
193 +/**
194 + * Actions whose identities never change, so a pane toggle doesn't re-render every screen that
195 + * holds one. Each call runs the latest render's handler.
196 + */
197 +function useStableActions(actions: Required<AdaptiveWorkspaceActions>): AdaptiveWorkspaceActions {
198 + const latest = useRef(actions);
199 + // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- points the stable actions at the handlers this commit rendered
200 + useLayoutEffect(() => {
201 + latest.current = actions;
202 + });
203 + const [stable] = useState((): AdaptiveWorkspaceActions => ({
204 + startNewTask: () => latest.current.startNewTask(),
205 + selectDetail: (detail, sheet) => latest.current.selectDetail(detail, sheet),
206 + registerWorkspaceInspector: (content, routeKey, revealKey) =>
207 + latest.current.registerWorkspaceInspector(content, routeKey, revealKey),
208 + setPrimarySidebarSearchQuery: (query) => latest.current.setPrimarySidebarSearchQuery(query),
209 + showInspector: () => latest.current.showInspector(),
210 + toggleAuxiliaryPane: () => latest.current.toggleAuxiliaryPane(),
211 + togglePrimarySidebar: () => latest.current.togglePrimarySidebar(),
212 + revealPrimarySidebar: () => latest.current.revealPrimarySidebar(),
213 + setPrimarySidebarVisible: (visible) => latest.current.setPrimarySidebarVisible(visible),
214 + openWorkspaceTab: (tab, options) => latest.current.openWorkspaceTab(tab, options),
215 + setAuxiliaryPaneWidth: (width) => latest.current.setAuxiliaryPaneWidth(width),
216 + setNativeInspectorWidth: (width) => latest.current.setNativeInspectorWidth(width),
217 + }));
218 + return stable;
219 +}
220 +
221 export function AdaptiveWorkspaceLayout(props: {
222 readonly children: ReactNode;
223 readonly pathname: string;
@@ -292,37 +319,11 @@ function AdaptiveWorkspaceLayoutContent(
319 nativeWorkspace,
320 usesSplitView: baseLayout.usesSplitView,
321 });
295 - const [composerEditing, setComposerEditing] = useState(false);
296 - const softKeyboardVisible = useSoftKeyboardShowing();
297 - // Keyed on the soft keyboard, not focus: a hardware keyboard leaves room for the sidebar, and
298 - // Back closes the keyboard while the editor keeps focus. The sidebar returns as the keyboard
299 - // starts hiding, not after. Deferred so the composer commits its keyboard render first;
300 - // relaying out in the same commit held it behind the keyboard.
301 - const composerKeyboardActive = useDeferredValue(
302 - Platform.OS === "android" && baseLayout.usesSplitView && composerEditing && softKeyboardVisible,
303 - );
304 - const sidebarWithoutKeyboard =
305 - !workspacePage && (primarySidebarPinned || preferredSidebarVisible);
306 - const showPrimarySidebar =
307 - sidebarWithoutKeyboard && (primarySidebarPinned || !composerKeyboardActive);
322 + const showPrimarySidebar = !workspacePage && (primarySidebarPinned || preferredSidebarVisible);
323 // Medium windows float the sidebar over a page; beside a list it keeps its room.
324 const sidebarFloats =
325 baseLayout.variant === "medium" &&
326 (nativeWorkspace || (!primarySidebarPinned && !workspacePage));
312 - // While the composer edits, the sidebar's width follows the keyboard's own progress, so it
313 - // leaves and returns in step with the keyboard instead of on a timer of its own.
314 - const keyboardHoldsSidebar =
315 - Platform.OS === "android" &&
316 - baseLayout.usesSplitView &&
317 - !workspacePage &&
318 - !primarySidebarPinned &&
319 - !sidebarFloats &&
320 - (composerEditing || composerKeyboardActive);
321 - const keyboardProgress = useKeyboardContext().reanimated.progress;
322 - // From the moment the keyboard starts showing until it has fully hidden. The detail pane keeps
323 - // the sidebar's room for that whole span, so on the way back the sidebar pushes the wide pane
324 - // aside instead of arriving beside one that already shrank.
325 - const keyboardOnScreen = useKeyboardState((state) => state.isVisible);
327 const shouldRenderNavigationRail =
328 Platform.OS === "android" && baseLayout.usesSplitView && !floatingTabsEnabled;
329 const enabledTabs = useEnabledNavigationTabs();
@@ -429,39 +430,6 @@ function AdaptiveWorkspaceLayoutContent(
430 workspacePage,
431 ],
432 );
432 - // Whether the sidebar is open once the keyboard is gone; the keyboard's progress scales it.
433 - const sidebarRestsOpen = useMemo(
434 - () =>
435 - showPrimarySidebar === sidebarWithoutKeyboard
436 - ? panes.primarySidebarVisible
437 - : deriveWorkspacePaneLayout({
438 - layout,
439 - viewportWidth: width,
440 - horizontalSafeArea,
441 - nativeWorkspace,
442 - primarySidebarFloats: sidebarFloats,
443 - primarySidebarPreferredVisible: sidebarWithoutKeyboard,
444 - auxiliaryPanePreferredVisible:
445 - !workspacePage && inspectorActive && fileInspectorPreferredVisible,
446 - auxiliaryPanePreferredWidth: fileInspectorPreferredWidth ?? undefined,
447 - nativeInspectorWidth,
448 - }).primarySidebarVisible,
449 - [
450 - nativeInspectorWidth,
451 - horizontalSafeArea,
452 - fileInspectorPreferredVisible,
453 - fileInspectorPreferredWidth,
454 - inspectorActive,
455 - layout,
456 - nativeWorkspace,
457 - panes.primarySidebarVisible,
458 - showPrimarySidebar,
459 - sidebarFloats,
460 - sidebarWithoutKeyboard,
461 - width,
462 - workspacePage,
463 - ],
464 - );
433 // Routes still on the stack remember their reveal, so going back to one keeps the user's choice.
434 const revealedInspectors = useRef<ReadonlyMap<string, string>>(new Map());
435 const workspaceInspectorOwner = useRef<symbol | null>(null);
@@ -510,12 +478,6 @@ function AdaptiveWorkspaceLayoutContent(
478 if (primarySidebarPinned) {
479 return;
480 }
513 - // A sidebar the keyboard set aside returns with the keyboard; the user's preference stays
514 - // intact. One the user had hidden still opens.
515 - if (composerKeyboardActive) {
516 - void KeyboardController.dismiss();
517 - if (preferredSidebarVisible) return;
518 - }
481 if (!panes.primarySidebarVisible && panes.primarySidebarSuppressedByAuxiliary) {
482 setFileInspectorPreferredVisible(false);
483 setPrimarySidebarPreferredVisible(true);
@@ -524,7 +486,6 @@ function AdaptiveWorkspaceLayoutContent(
486 setPrimarySidebarVisible(!preferredSidebarVisible);
487 };
488 const revealPrimarySidebar = () => {
527 - if (composerKeyboardActive) void KeyboardController.dismiss();
489 if (panes.primarySidebarSuppressedByAuxiliary) {
490 setFileInspectorPreferredVisible(false);
491 }
@@ -671,8 +632,6 @@ function AdaptiveWorkspaceLayoutContent(
632 const contentEndGap = Platform.OS === "android" && layout.usesSplitView ? 4 : 0;
633 // Android's split is one strip: a sidebar slot of fixed width, then the detail pane. The
634 // sidebar never resizes; both slide by one offset, so together they always fill the width.
674 - // The pane spans the sidebar's room too unless the sidebar has finished arriving: a sidebar on
675 - // its way in pushes the wide pane past the edge, and one leaving uncovers it.
635 const stripSidebar =
636 Platform.OS === "android" &&
637 layout.usesSplitView &&
@@ -680,27 +639,9 @@ function AdaptiveWorkspaceLayoutContent(
639 !workspacePage &&
640 !sidebarFloats;
641 const sidebarSlotWidth = (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0);
683 - const sidebarTargetOpen = keyboardHoldsSidebar ? sidebarRestsOpen : panes.primarySidebarVisible;
684 - const [sidebarMotion, setSidebarMotion] = useState({
685 - strip: stripSidebar,
686 - settledOpen: sidebarTargetOpen,
687 - });
688 - if (sidebarMotion.strip !== stripSidebar) {
689 - // Entering or leaving the strip (a workspace page, a fold) snaps the sidebar into place.
690 - setSidebarMotion({ strip: stripSidebar, settledOpen: sidebarTargetOpen });
691 - } else if (sidebarMotion.settledOpen && !sidebarTargetOpen) {
692 - setSidebarMotion({ strip: stripSidebar, settledOpen: false });
693 - }
694 - const sidebarSettledOpen =
695 - sidebarMotion.strip === stripSidebar ? sidebarMotion.settledOpen : sidebarTargetOpen;
696 - const markSidebarSettled = (open: boolean) =>
697 - setSidebarMotion((current) =>
698 - current.settledOpen === open ? current : { ...current, settledOpen: open },
699 - );
700 - // The keyboard covers the sidebar's share from the moment it starts showing until it is gone.
701 - const contentSpansSidebar =
702 - stripSidebar &&
703 - (!sidebarSettledOpen || !sidebarTargetOpen || (keyboardHoldsSidebar && keyboardOnScreen));
642 + // The pane takes its new width in the commit that starts the sidebar moving, so it rewraps as
643 + // the strip starts to slide rather than after it lands.
644 + const contentSpansSidebar = stripSidebar && !panes.primarySidebarVisible;
645 const contentTargetWidth = !layout.usesSplitView
646 ? null
647 : Math.max(
@@ -811,16 +752,12 @@ function AdaptiveWorkspaceLayoutContent(
752 panes.primarySidebarVisible ? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0) : 0,
753 );
754 const renderedRailWidth = useSharedValue(navigationRailWidth);
814 - const keyboardHold = useSharedValue(keyboardHoldsSidebar);
755 const leavingWorkspacePage = useRef(false);
756 + // The slide starts after the commit that lays the pane out, not in the press handler: Reanimated
757 + // commits the shadow tree every frame, and that starves a large React commit until it stops.
758 // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- animates the Reanimated rail and sidebar width shared values toward the layout's targets
759 useEffect(() => {
760 if (nativeWorkspace) return;
819 - // Released mid-keyboard (the composer blurred), the timing starts where the sidebar is drawn.
820 - if (keyboardHold.get() && !keyboardHoldsSidebar) {
821 - renderedSidebarWidth.set(renderedSidebarWidth.get() * (1 - keyboardProgress.get()));
822 - }
823 - keyboardHold.set(keyboardHoldsSidebar);
761 renderedRailWidth.set(withTiming(navigationRailWidth, WORKSPACE_PANE_TIMING));
762 // A workspace page hides the sidebar through React instead, in the same commit that mounts
763 // the page. Animating it here would hide it a few frames before the page appears.
@@ -830,15 +767,15 @@ function AdaptiveWorkspaceLayoutContent(
767 }
768 const snap = leavingWorkspacePage.current;
769 leavingWorkspacePage.current = false;
833 - const targetWidth = (keyboardHoldsSidebar ? sidebarRestsOpen : panes.primarySidebarVisible)
770 + const targetWidth = panes.primarySidebarVisible
771 ? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0)
772 : 0;
773 // The content beside it already took its final width when the page closed.
774 renderedSidebarWidth.set(
775 withTiming(targetWidth, snap ? { duration: 0 } : WORKSPACE_PANE_TIMING, (finished) => {
839 - if (finished && Platform.OS === "android") {
776 + // Only a hinge resize widens the list's span; a toggle has nothing to settle.
777 + if (finished && Platform.OS === "android" && listPaneFloor !== listPaneCeiling) {
778 runOnJS(settleListPane)(listPaneRevision);
841 - runOnJS(markSidebarSettled)(targetWidth > 0);
779 }
780 }),
781 );
@@ -848,14 +785,11 @@ function AdaptiveWorkspaceLayoutContent(
785 layout.listPaneWidth,
786 layout.listPaneGap,
787 panes.primarySidebarVisible,
851 - keyboardHoldsSidebar,
852 - keyboardHold,
853 - keyboardProgress,
854 - sidebarRestsOpen,
788 renderedSidebarWidth,
789 renderedRailWidth,
790 settleListPane,
858 - markSidebarSettled,
791 + listPaneFloor,
792 + listPaneCeiling,
793 listPaneRevision,
794 workspacePage,
795 ]);
@@ -886,45 +820,29 @@ function AdaptiveWorkspaceLayoutContent(
820 // Showing or hiding the sidebar clips a fixed-width list. A hinge resize instead tracks the
821 // animated edge, so the header actions slide with it rather than jumping or being covered.
822 const listPaneGap = layout.listPaneGap ?? 0;
889 - const keyboardSidebarRest = sidebarRestsOpen
890 - ? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0)
891 - : 0;
892 - const drawnSidebarWidth = useDerivedValue(
893 - () => renderedSidebarWidth.value * (keyboardHold.value ? 1 - keyboardProgress.value : 1),
894 - );
823 const listPaneAnimatedStyle = useAnimatedStyle(() => ({
824 width: Math.min(
825 listPaneCeiling,
826 Math.max(
827 listPaneFloor,
900 - (stripSidebar ? sidebarSlotWidth : drawnSidebarWidth.value) - listPaneGap,
828 + (stripSidebar ? sidebarSlotWidth : renderedSidebarWidth.value) - listPaneGap,
829 ),
830 ),
831 }));
832 // How far the strip has slid: 0 with the sidebar shown, minus its width with it gone.
833 const stripOffset = useDerivedValue(() =>
906 - stripSidebar ? drawnSidebarWidth.value - sidebarSlotWidth : 0,
834 + stripSidebar ? renderedSidebarWidth.value - sidebarSlotWidth : 0,
835 );
836 const sidebarAnimatedStyle = useAnimatedStyle(() => ({
837 // Fading a UIKit glass ancestor can leave remounted header effects missing.
838 opacity:
839 stripSidebar || Platform.OS === "ios" || floatingTabsEnabled
840 ? 1
913 - : Math.min(1, drawnSidebarWidth.value / 80),
914 - width: stripSidebar ? sidebarSlotWidth : drawnSidebarWidth.value,
841 + : Math.min(1, renderedSidebarWidth.value / 80),
842 + width: stripSidebar ? sidebarSlotWidth : renderedSidebarWidth.value,
843 flexShrink: stripSidebar ? 0 : 1,
844 transform: [{ translateX: stripOffset.value }],
845 }));
918 - // The content keeps the width React laid it out at and rides the sidebar's edge, so a keyboard
919 - // transition relays nothing out per frame, the way UIKit animates the iOS split view.
920 - // Until React commits the wider layout, the detail card continues past its right edge, so the
921 - // strip the narrower column leaves shows the card instead of the row behind it.
922 - const contentOverhangStyle = useAnimatedStyle(() => ({
923 - opacity: keyboardHold.value && keyboardProgress.value > 0 ? 1 : 0,
924 - }));
925 - const threadHeader = useToolbarLayout(false, composerKeyboardActive);
926 - const threadHeaderHeight =
927 - threadHeader.paddingTop + threadHeader.height + threadHeader.paddingBottom;
846
847 // Clip the navigator at its settled width so native headers and markdown reflow only once per pane toggle.
848 const renderedInspectorWidth = useSharedValue(inspectorColumnTargetWidth);
@@ -933,7 +851,7 @@ function AdaptiveWorkspaceLayoutContent(
851 0,
852 viewportWidth -
853 (sidebarFloats ? 0 : renderedRailWidth.value) -
936 - (workspacePage || sidebarFloats ? 0 : drawnSidebarWidth.value) -
854 + (workspacePage || sidebarFloats ? 0 : renderedSidebarWidth.value) -
855 renderedInspectorWidth.value,
856 ),
857 );
@@ -988,32 +906,36 @@ function AdaptiveWorkspaceLayoutContent(
906 [sidebarInLandscape, sidebarInPortrait, sidebarOverRotates],
907 );
908
991 - const contextValue = {
992 - layout,
993 - panes,
994 - fileInspector,
995 - primarySidebarSearchQuery,
909 + const actions = useStableActions({
910 startNewTask: handleStartNewTask,
911 selectDetail: handleSelectDetail,
912 registerWorkspaceInspector,
913 setPrimarySidebarSearchQuery,
914 showInspector,
915 toggleAuxiliaryPane,
1002 - sidebarToggleable: layout.usesSplitView && !primarySidebarPinned && !workspacePage,
916 togglePrimarySidebar,
917 revealPrimarySidebar,
918 setPrimarySidebarVisible,
919 openWorkspaceTab,
920 setAuxiliaryPaneWidth: setFileInspectorPreferredWidth,
1008 - nativeInspectorWidth,
921 setNativeInspectorWidth: (width: number) =>
922 setNativeInspectorWidthFraction(inspectorWidthFor(width / viewportWidth) / viewportWidth),
1011 - composerKeyboardActive,
1012 - keyboardHoldsSidebar,
1013 - setComposerEditing,
1014 - sidebarByOrientation,
1015 - workspacePageWidth,
1016 - };
923 + });
924 + const contextValue = useMemo(
925 + () => ({ ...actions, layout, nativeInspectorWidth, workspacePageWidth }),
926 + [actions, layout, nativeInspectorWidth, workspacePageWidth],
927 + );
928 + const sidebarToggleable = layout.usesSplitView && !primarySidebarPinned && !workspacePage;
929 + const paneState = useMemo(
930 + () => ({
931 + panes,
932 + fileInspector,
933 + primarySidebarSearchQuery,
934 + sidebarToggleable,
935 + sidebarByOrientation,
936 + }),
937 + [panes, fileInspector, primarySidebarSearchQuery, sidebarToggleable, sidebarByOrientation],
938 + );
939
940 const inspectorSheet = (
941 <WorkspaceInspectorSheet
@@ -1029,16 +951,18 @@ function AdaptiveWorkspaceLayoutContent(
951 savedFilters={props.savedThreadListFilters}
952 >
953 <AdaptiveWorkspaceContext value={contextValue}>
1032 - <NativeWorkspaceInspectorContext
1033 - value={{
1034 - // Without a column the sheet shows it; the hidden native column must not mount it too.
1035 - content: fileInspector.supported ? workspaceInspector?.content : undefined,
1036 - visible: inspectorColumnTargetWidth > 0,
1037 - }}
1038 - >
1039 - {props.children}
1040 - {inspectorSheet}
1041 - </NativeWorkspaceInspectorContext>
954 + <WorkspacePaneStateContext value={paneState}>
955 + <NativeWorkspaceInspectorContext
956 + value={{
957 + // Without a column the sheet shows it; the hidden native column must not mount it too.
958 + content: fileInspector.supported ? workspaceInspector?.content : undefined,
959 + visible: inspectorColumnTargetWidth > 0,
960 + }}
961 + >
962 + {props.children}
963 + {inspectorSheet}
964 + </NativeWorkspaceInspectorContext>
965 + </WorkspacePaneStateContext>
966 </AdaptiveWorkspaceContext>
967 </HomeListOptionsProvider>
968 );
@@ -1174,35 +1098,6 @@ function AdaptiveWorkspaceLayoutContent(
1098 </WorkspaceSettledContentWidthContext>
1099 </WorkspaceContentWidthContext>
1100 </Animated.View>
1177 - {keyboardHoldsSidebar && contentTargetWidth !== null ? (
1178 - <>
1179 - <Animated.View
1180 - pointerEvents="none"
1181 - className="absolute top-0 bg-header"
1182 - style={[
1183 - {
1184 - left: contentTargetWidth,
1185 - width: keyboardSidebarRest + contentEndGap,
1186 - height: threadHeaderHeight,
1187 - },
1188 - contentOverhangStyle,
1189 - ]}
1190 - />
1191 - <Animated.View
1192 - pointerEvents="none"
1193 - className="absolute bottom-0 rounded-tr-[28px] bg-thread-canvas"
1194 - style={[
1195 - {
1196 - // Starts under the card's rounded corner so the two read as one card.
1197 - left: contentTargetWidth - 28,
1198 - width: keyboardSidebarRest + 28,
1199 - top: threadHeaderHeight,
1200 - },
1201 - contentOverhangStyle,
1202 - ]}
1203 - />
1204 - </>
1205 - ) : null}
1101 </Animated.View>
1102 {sidebarFloats ? (
1103 <Animated.View
@@ -1256,17 +1151,19 @@ function AdaptiveWorkspaceLayoutContent(
1151 projectGroupingMode={projectGroupingMode}
1152 savedFilters={props.savedThreadListFilters}
1153 >
1259 - <AdaptiveWorkspaceContext.Provider value={contextValue}>
1260 - <WindowHingeContext value={windowHinge}>
1261 - {usesPresentationHost ? (
1262 - <WorkspaceColumnsRendererContext value={renderColumns}>
1263 - {props.children}
1264 - </WorkspaceColumnsRendererContext>
1265 - ) : (
1266 - renderColumns(props.children)
1267 - )}
1268 - </WindowHingeContext>
1269 - </AdaptiveWorkspaceContext.Provider>
1154 + <AdaptiveWorkspaceContext value={contextValue}>
1155 + <WorkspacePaneStateContext value={paneState}>
1156 + <WindowHingeContext value={windowHinge}>
1157 + {usesPresentationHost ? (
1158 + <WorkspaceColumnsRendererContext value={renderColumns}>
1159 + {props.children}
1160 + </WorkspaceColumnsRendererContext>
1161 + ) : (
1162 + renderColumns(props.children)
1163 + )}
1164 + </WindowHingeContext>
1165 + </WorkspacePaneStateContext>
1166 + </AdaptiveWorkspaceContext>
1167 </HomeListOptionsProvider>
1168 );
1169 }
apps/mobile/src/features/layout/adaptive-workspace-context.ts
+34 -28
@@ -11,11 +11,8 @@ import {
11 type WorkspacePaneLayout,
12 } from "../../lib/layout";
13
14 -interface AdaptiveWorkspaceContextValue {
15 - readonly layout: Layout;
16 - readonly panes: WorkspacePaneLayout;
17 - readonly fileInspector: FileInspectorPaneLayout;
18 - readonly primarySidebarSearchQuery: string;
14 +/** The workspace's actions; their identities never change. */
15 +export interface AdaptiveWorkspaceActions {
16 readonly startNewTask: () => void;
17 /** Use `useSelectWorkspaceDetail`, which also works outside the layout. */
18 readonly selectDetail?: (detail: WorkspaceDetail, sheet?: WorkspaceDetailSheet) => void;
@@ -28,11 +25,6 @@ interface AdaptiveWorkspaceContextValue {
25 /** Opens the inspector: its column where the window has one, otherwise a sheet. */
26 readonly showInspector: () => void;
27 readonly toggleAuxiliaryPane: () => void;
31 - /**
32 - * Whether the content pane offers a sidebar button: false without columns, on a list that keeps
33 - * its sidebar, and on a workspace page (Android Settings, Usage) that covers it.
34 - */
35 - readonly sidebarToggleable: boolean;
28 readonly togglePrimarySidebar: () => void;
29 /** Shows the sidebar, setting aside the keyboard or an inspector that took its room. */
30 readonly revealPrimarySidebar: () => void;
@@ -43,24 +35,32 @@ interface AdaptiveWorkspaceContextValue {
35 options?: { readonly columns?: boolean },
36 ) => void;
37 readonly setAuxiliaryPaneWidth: (width: number) => void;
46 - readonly nativeInspectorWidth: number;
38 readonly setNativeInspectorWidth: (width: number) => void;
39 +}
40 +
41 +/** Changes only with the window (size, fold, hinge), never with a pane toggle or the keyboard. */
42 +interface AdaptiveWorkspaceLayoutValue extends AdaptiveWorkspaceActions {
43 + readonly layout: Layout;
44 + readonly nativeInspectorWidth: number;
45 + /** Android split: the width a workspace page (Usage) opens at; null without columns. */
46 + readonly workspacePageWidth?: number | null;
47 +}
48 +
49 +/** Changes as panes toggle and the keyboard comes and goes; read it only where that shows. */
50 +interface WorkspacePaneStateValue {
51 + readonly panes: WorkspacePaneLayout;
52 + readonly fileInspector: FileInspectorPaneLayout;
53 + readonly primarySidebarSearchQuery: string;
54 /**
49 - * Android split view while the thread composer has the soft keyboard: the
50 - * sidebar and rail step aside and the thread header drops to one line.
55 + * Whether the content pane offers a sidebar button: false without columns, on a list that keeps
56 + * its sidebar, and on a workspace page (Android Settings, Usage) that covers it.
57 */
52 - readonly composerKeyboardActive: boolean;
58 + readonly sidebarToggleable: boolean;
59 /**
60 * Whether the sidebar shows in each orientation, where it floats over the content in portrait
61 * (the unfolded Duo). The native split switches between them as a rotation starts.
62 */
63 readonly sidebarByOrientation: { readonly landscape: boolean; readonly portrait: boolean } | null;
58 - /** Android split: the composer's keyboard slides the sidebar, from focus until it lets go. */
59 - readonly keyboardHoldsSidebar?: boolean;
60 - /** Android split: the width a workspace page (Usage) opens at; null without columns. */
61 - readonly workspacePageWidth?: number | null;
62 - /** The thread composer reports its focus so the layout can make room for typing. */
63 - readonly setComposerEditing: (editing: boolean) => void;
64 }
65
66 const compactLayout = deriveLayout({ width: 0, height: 0 });
@@ -74,17 +74,13 @@ const compactFileInspector = deriveFileInspectorPaneLayout({
74 layout: compactLayout,
75 viewportWidth: 0,
76 });
77 -export const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceContextValue>({
77 +export const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceLayoutValue>({
78 layout: compactLayout,
79 - panes: compactPanes,
80 - fileInspector: compactFileInspector,
81 - primarySidebarSearchQuery: "",
79 startNewTask: () => undefined,
80 registerWorkspaceInspector: () => () => undefined,
81 setPrimarySidebarSearchQuery: () => undefined,
82 showInspector: () => undefined,
83 toggleAuxiliaryPane: () => undefined,
87 - sidebarToggleable: false,
84 togglePrimarySidebar: () => undefined,
85 revealPrimarySidebar: () => undefined,
86 setPrimarySidebarVisible: () => undefined,
@@ -92,11 +88,21 @@ export const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceContextVa
88 setAuxiliaryPaneWidth: () => undefined,
89 nativeInspectorWidth: 0,
90 setNativeInspectorWidth: () => undefined,
95 - composerKeyboardActive: false,
91 +});
92 +export const WorkspacePaneStateContext = createContext<WorkspacePaneStateValue>({
93 + panes: compactPanes,
94 + fileInspector: compactFileInspector,
95 + primarySidebarSearchQuery: "",
96 + sidebarToggleable: false,
97 sidebarByOrientation: null,
97 - setComposerEditing: () => undefined,
98 });
99
100 -export function useAdaptiveWorkspaceLayout(): AdaptiveWorkspaceContextValue {
100 +/** The window's layout and the workspace's actions. Toggling a pane doesn't re-render readers. */
101 +export function useAdaptiveWorkspaceLayout(): AdaptiveWorkspaceLayoutValue {
102 return use(AdaptiveWorkspaceContext);
103 }
104 +
105 +/** Which panes show, and the keyboard's hold on them. Re-renders on every pane toggle. */
106 +export function useWorkspacePaneState(): WorkspacePaneStateValue {
107 + return use(WorkspacePaneStateContext);
108 +}
apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx
+2 -3
@@ -46,7 +46,7 @@ import { workspaceRoutesOf } from "./workspace-overlay-routes";
46 import { setNativelyPoppingWorkspaceRoute } from "./workspace/workspace-detail-selection";
47 import { useDeviceType, useNativeLayoutMetrics } from "../../native/native-layout-metrics";
48
49 -import { useAdaptiveWorkspaceLayout } from "./AdaptiveWorkspaceLayout";
49 +import { useAdaptiveWorkspaceLayout, useWorkspacePaneState } from "./AdaptiveWorkspaceLayout";
50 import { WorkspacePaneDivider } from "./workspace-pane-divider";
51 import { WorkspaceEmptyDetail } from "./WorkspaceEmptyDetail";
52 import { NativeColumnContent as ColumnContent } from "../../native/NativeColumnContent.ios";
@@ -205,15 +205,14 @@ function WorkspaceColumns(
205 ) {
206 const {
207 layout,
208 - panes,
208 setPrimarySidebarVisible,
209 toggleAuxiliaryPane,
210 startNewTask,
211 openWorkspaceTab,
213 - sidebarByOrientation,
212 nativeInspectorWidth,
213 setNativeInspectorWidth,
214 } = useAdaptiveWorkspaceLayout();
215 + const { panes, sidebarByOrientation } = useWorkspacePaneState();
216 const deviceType = useDeviceType();
217 const inspectorWidth = nativeInspectorWidth;
218 const resizeStartWidth = useRef(inspectorWidth);
apps/mobile/src/features/layout/useSidebarToggle.ts
+3 -2
@@ -1,10 +1,11 @@
1 import { usePaneRole } from "../../components/ui/Pane";
2 -import { useAdaptiveWorkspaceLayout } from "./adaptive-workspace-context";
2 +import { useAdaptiveWorkspaceLayout, useWorkspacePaneState } from "./adaptive-workspace-context";
3
4 /** The content pane's sidebar button, or null where there's no sidebar beside it to toggle. */
5 export function useSidebarToggle() {
6 const role = usePaneRole();
7 - const { layout, panes, sidebarToggleable, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
7 + const { layout, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
8 + const { panes, sidebarToggleable } = useWorkspacePaneState();
9 if (role !== "content" || !sidebarToggleable) return null;
10 const maximizes = panes.primarySidebarVisible && layout.variant !== "medium";
11 return {
apps/mobile/src/features/layout/workspace/AndroidWorkspaceNavigation.android.tsx
+2 -3
@@ -81,7 +81,7 @@ export function AndroidWorkspaceNavigation(props: {
81 const toolbar = useToolbarLayout();
82 const connectionState = useWorkspaceConnectionState();
83 const keyboardVisible = useSoftKeyboardShowing();
84 - const { layout, keyboardHoldsSidebar } = useAdaptiveWorkspaceLayout();
84 + const { layout } = useAdaptiveWorkspaceLayout();
85 const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
86 const { scale, fabSize } = useAndroidControlSizing();
87 const window = useWindowDimensions();
@@ -102,8 +102,7 @@ export function AndroidWorkspaceNavigation(props: {
102 (props.paneWidth ?? window.width) -
103 (Math.max(insets.left, FLOATING_TABS.edge) - FLOATING_TABS.edge);
104 const metrics = floatingTabsMetrics(tabs.length, scale, fabSize, barWidth, props.fillWidth);
105 - // The composer's keyboard slides the sidebar away with the bar on it; other keyboards don't.
106 - if (!rail && keyboardVisible && !keyboardHoldsSidebar) return null;
105 + if (!rail && keyboardVisible) return null;
106
107 return (
108 <View
apps/mobile/src/features/layout/workspace/WorkspaceListEmptyDetail.tsx
+2 -2
@@ -3,7 +3,7 @@ import { Platform } from "react-native";
3 import { AppBar } from "../../../components/ui/AppBar";
4 import { Toolbar } from "../../../components/ui/Toolbar";
5 import { NativeStackScreenOptions } from "../../../native/StackHeader";
6 -import { useAdaptiveWorkspaceLayout } from "../adaptive-workspace-context";
6 +import { useWorkspacePaneState } from "../adaptive-workspace-context";
7 import { WorkspaceEmptyDetail } from "../WorkspaceEmptyDetail";
8
9 /**
@@ -15,7 +15,7 @@ export function WorkspaceListEmptyDetail(props: {
15 readonly onAddConnection: () => void;
16 readonly onStartNewTask: () => void;
17 }) {
18 - const { panes } = useAdaptiveWorkspaceLayout();
18 + const { panes } = useWorkspacePaneState();
19 return (
20 <>
21 <NativeStackScreenOptions
apps/mobile/src/features/layout/workspace/WorkspaceNativeTabs.ios.tsx
+3 -2
@@ -26,7 +26,7 @@ import {
26 import { useControlTheme } from "../../../components/ui/useControlTheme";
27 import { useDeviceType } from "../../../native/native-layout-metrics";
28 import { WorkspaceSidebarTabs } from "./WorkspaceSidebarTabs";
29 -import { useAdaptiveWorkspaceLayout } from "../AdaptiveWorkspaceLayout";
29 +import { useAdaptiveWorkspaceLayout, useWorkspacePaneState } from "../AdaptiveWorkspaceLayout";
30 import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab";
31
32 const PULL_REQUEST_ICON = require("../../../../assets/icons/pull-request.png");
@@ -85,7 +85,8 @@ export function WorkspaceNativeTabs(props: {
85 const systemTabBar = useSystemWorkspaceTabBar();
86 const deviceType = useDeviceType();
87 const compactTabs = useCompactWorkspaceTabs();
88 - const { layout, panes } = useAdaptiveWorkspaceLayout();
88 + const { layout } = useAdaptiveWorkspaceLayout();
89 + const { panes } = useWorkspacePaneState();
90 // The tabs belong to the sidebar; over a page with the sidebar hidden they'd cover the composer.
91 const hiddenWithSidebar =
92 deviceType === "pad" &&
apps/mobile/src/features/layout/workspace/WorkspaceThreadSidebar.tsx
+4 -9
@@ -8,7 +8,7 @@ import { useNavigation, useNavigationState } from "@react-navigation/native";
8 import { scopedThreadKey } from "../../../lib/scopedEntities";
9 import { uuidv4 } from "../../../lib/uuid";
10 import { usePendingTaskListActions } from "../../home/usePendingTaskListActions";
11 -import { useAdaptiveWorkspaceLayout } from "../adaptive-workspace-context";
11 +import { useAdaptiveWorkspaceLayout, useWorkspacePaneState } from "../adaptive-workspace-context";
12 import { openSettings } from "../../settings/settings-navigation";
13 import { ThreadNavigationSidebar } from "../../threads/ThreadNavigationSidebar";
14 import { useOpenThreadPullRequests } from "../../threads/use-open-thread-pull-requests";
@@ -42,14 +42,9 @@ function selectedThreadKey(state: { readonly index: number; readonly routes: rea
42 /** The thread list in the workspace's sidebar column. */
43 export function WorkspaceThreadSidebar() {
44 const navigation = useNavigation();
45 - const {
46 - layout,
47 - panes,
48 - primarySidebarSearchQuery,
49 - setPrimarySidebarSearchQuery,
50 - revealPrimarySidebar,
51 - openWorkspaceTab,
52 - } = useAdaptiveWorkspaceLayout();
45 + const { layout, setPrimarySidebarSearchQuery, revealPrimarySidebar, openWorkspaceTab } =
46 + useAdaptiveWorkspaceLayout();
47 + const { panes, primarySidebarSearchQuery } = useWorkspacePaneState();
48 const selectDetail = useSelectWorkspaceDetail();
49 const openThreadPullRequests = useOpenThreadPullRequests();
50 const selectedThread = useNavigationState(selectedThreadKey);
apps/mobile/src/features/layout/workspace/WorkspaceToolbar.tsx
+3 -2
@@ -15,7 +15,7 @@ import {
15 NativeWorkspaceTabActivityContext,
16 } from "../../../native/v5-workspace-context";
17 import { useHardwareKeyboardCommand } from "../../keyboard/hardwareKeyboardCommands";
18 -import { useAdaptiveWorkspaceLayout } from "../AdaptiveWorkspaceLayout";
18 +import { useAdaptiveWorkspaceLayout, useWorkspacePaneState } from "../AdaptiveWorkspaceLayout";
19 import { useWorkspaceTabs } from "./WorkspaceTabsContext";
20 import { shouldRestoreNativeSearch } from "./workspace-tabs-state";
21 import { useFloatingWorkspaceTabs, useSidebarWorkspaceTabs } from "./useSystemWorkspaceTabBar";
@@ -46,7 +46,8 @@ export function WorkspaceToolbar(props: {
46 activeNewTask === null;
47 const tabActive = use(NativeWorkspaceTabActivityContext)?.active ?? true;
48 const focused = useIsFocused();
49 - const { layout, panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
49 + const { layout, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
50 + const { panes } = useWorkspacePaneState();
51 const searchRef = useRef<SearchBarCommands>(null);
52 const settingsMenu = useSettingsEnvironmentMenu();
53 // The Settings list takes the selected tab's place, so search follows it.
apps/mobile/src/features/review/ReviewSheet.tsx
+8 -3
@@ -35,7 +35,11 @@ import { useAtomCommand } from "../../state/use-atom-command";
35 import { useThreadDraftForThread } from "../../state/use-thread-composer-state";
36 import { EnvironmentConnectionNotice } from "../connection/EnvironmentConnectionNotice";
37 import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
38 -import { Inspector, useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
38 +import {
39 + Inspector,
40 + useAdaptiveWorkspaceLayout,
41 + useWorkspacePaneState,
42 +} from "../layout/AdaptiveWorkspaceLayout";
43 import { useSelectedThreadWorktree } from "../../state/use-selected-thread-worktree";
44 import { useReviewCacheForThread } from "./reviewState";
45 import {
@@ -66,7 +70,8 @@ function ReviewHeader(
70 readonly onReturnToThread: () => void;
71 },
72 ) {
69 - const { panes, toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout();
73 + const { toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout();
74 + const { panes } = useWorkspacePaneState();
75 const presentation = useReviewHeaderPresentation(props);
76 const sectionAction = (section: ReviewSectionItem | null, title: string): AppBarMenuItem => ({
77 id: section ? `section:${section.id}` : `unavailable:${title}`,
@@ -358,7 +363,7 @@ type ReviewSheetProps = StaticScreenProps<{
363 export function ReviewSheet(props: ReviewSheetProps) {
364 const reduceMotion = useReduceMotionEnabled();
365 const { nativeReviewDiffStyle } = useAppearanceCodeSurface();
361 - const { panes } = useAdaptiveWorkspaceLayout();
366 + const { panes } = useWorkspacePaneState();
367 const navigation = useNavigation();
368 const selectDetail = useSelectWorkspaceDetail();
369 const insets = useSafeAreaInsets();
apps/mobile/src/features/threads/ThreadComposer.tsx
+1 -5
@@ -588,7 +588,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
588 );
589 const isVoiceInputPresented = voicePresentation.statusKind === "active";
590 const isExpanded = isFocused || settingsSheetPresentation.keepsComposerExpanded;
591 - const { layout, setComposerEditing } = useAdaptiveWorkspaceLayout();
591 + const { layout } = useAdaptiveWorkspaceLayout();
592 const floatingSidebarComposer = useAndroidFloatingTabs() && layout.usesSplitView;
593 const sidebarWorkspaceTabs = useSidebarWorkspaceTabs();
594 const deviceType = useDeviceType();
@@ -623,8 +623,6 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
623 sendBlockedReason === null &&
624 !modelUnavailable;
625
626 - // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- clears the workspace layout's composer-editing flag when the composer unmounts
627 - useEffect(() => () => setComposerEditing(false), [setComposerEditing]);
626 // A pending sheet presentation or focus restore has no composer left to act on.
627 // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- disposes the pending settings sheet presentation and focus restore on unmount
628 useEffect(() => () => disposeSettingsSheetPresentation(), []);
@@ -662,14 +660,12 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
660 setIsFocused(true);
661 settingsSheetPresentation.onEditorFocusChange(true);
662 onEditorFocusChange?.(true);
665 - setComposerEditing(true);
663 };
664
665 const handleBlur = () => {
666 setIsFocused(false);
667 settingsSheetPresentation.onEditorFocusChange(false);
668 onEditorFocusChange?.(false);
672 - setComposerEditing(false);
669 };
670 const handleSend = async (followUp?: ActiveTurnComposerAction) => {
671 if (
apps/mobile/src/features/threads/ThreadHeader.tsx
+6 -4
@@ -1,6 +1,9 @@
1 import { AppBar } from "../../components/ui/AppBar";
2 import type { AppBarAction, AppBarMenu } from "../../components/ui/AppBar.types";
3 -import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
3 +import {
4 + useAdaptiveWorkspaceLayout,
5 + useWorkspacePaneState,
6 +} from "../layout/AdaptiveWorkspaceLayout";
7 import type { ThreadInspectorMode } from "./thread-inspector-navigation";
8 import { useWorkspaceBackNavigation } from "../layout/workspace/useAndroidWorkspaceNavigation";
9 import {
@@ -20,8 +23,8 @@ export function ThreadHeader(props: {
23 readonly onOpenFilesInspector: () => void;
24 }) {
25 const goBack = useWorkspaceBackNavigation("threads");
23 - const { panes, toggleAuxiliaryPane, composerKeyboardActive, startNewTask } =
24 - useAdaptiveWorkspaceLayout();
26 + const { toggleAuxiliaryPane, startNewTask } = useAdaptiveWorkspaceLayout();
27 + const { panes } = useWorkspacePaneState();
28 const gitMenu = useThreadGitMenuDefinition(props.gitControls);
29 const terminalMenu = threadTerminalMenu(props.gitControls);
30 const filesVisible = props.inspectorMode === "files" && panes.auxiliaryPaneVisible;
@@ -57,7 +60,6 @@ export function ThreadHeader(props: {
60 actions={actions}
61 menus={menus}
62 hideBottomBorder
60 - compact={composerKeyboardActive}
63 />
64 );
65 }
apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+14 -4
@@ -95,7 +95,11 @@ import { threadEnvironment } from "../../state/threads";
95 import { EMPTY_ENVIRONMENT_THREAD_STATE } from "@t3tools/client-runtime/state/threads";
96 import { useProjects } from "../../state/entities";
97 import { projectThreadContentPresentation } from "./threadContentPresentation";
98 -import { Inspector, useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
98 +import {
99 + Inspector,
100 + useAdaptiveWorkspaceLayout,
101 + useWorkspacePaneState,
102 +} from "../layout/AdaptiveWorkspaceLayout";
103 import { ThreadFileNavigatorPane } from "../files/thread-file-navigator-pane";
104 import { InspectorSheetContext } from "../layout/workspace-inspector-sheet";
105 import type { InspectorContent } from "../layout/inspector-panes";
@@ -342,7 +346,7 @@ function ThreadRouteContent(
346 readonly selectedThreadDetailState: ReturnType<typeof useSelectedThreadDetailState>;
347 },
348 ) {
345 - const { layout, panes, showInspector, toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout();
349 + const { layout, showInspector, toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout();
350 const { connectionState } = useRemoteConnectionStatus();
351 const { onReconnectEnvironment } = useRemoteConnections();
352 const {
@@ -593,8 +597,8 @@ function ThreadRouteContent(
597 </InspectorSheetContext.Consumer>
598 ) : null;
599 const renderPreviewInspector = () =>
596 - previewTarget && panes.auxiliaryPaneVisible ? (
597 - <ThreadInspectorPreview
600 + previewTarget ? (
601 + <ThreadInspectorPreviewWhileVisible
602 target={previewTarget}
603 renderThread={(screen) => <ThreadRouteScreen {...screen} />}
604 onClose={toggleAuxiliaryPane}
@@ -1098,3 +1102,9 @@ export function FullscreenThreadRouteScreen(
1102 </InspectorContentScope>
1103 );
1104 }
1105 +
1106 +/** Reads the pane state itself, so a sidebar toggle doesn't re-render the whole thread screen. */
1107 +function ThreadInspectorPreviewWhileVisible(props: Parameters<typeof ThreadInspectorPreview>[0]) {
1108 + const { panes } = useWorkspacePaneState();
1109 + return panes.auxiliaryPaneVisible ? <ThreadInspectorPreview {...props} /> : null;
1110 +}
apps/mobile/src/features/threads/thread-inspector-navigation.test.tsx
+1 -1
@@ -13,7 +13,7 @@ const harness = vi.hoisted(() => ({
13
14 vi.mock("react-native", () => ({ Platform: { OS: "ios" } }));
15 vi.mock("../layout/AdaptiveWorkspaceLayout", () => ({
16 - useAdaptiveWorkspaceLayout: () => ({ fileInspector: { supported: true } }),
16 + useWorkspacePaneState: () => ({ fileInspector: { supported: true } }),
17 }));
18 vi.mock("@react-navigation/native", async () => {
19 const { createRequire } = await import("node:module");
apps/mobile/src/features/threads/thread-inspector-navigation.ts
+2 -2
@@ -2,7 +2,7 @@ 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";
5 +import { useWorkspacePaneState } from "../layout/AdaptiveWorkspaceLayout";
6
7 export type ThreadInspectorMode = "route" | "git" | "files" | "preview";
8
@@ -19,7 +19,7 @@ export const ThreadInspectorNavigationContext = createContext<
19
20 export function useOpenThreadInspector() {
21 const navigation = useNavigation();
22 - const { fileInspector } = useAdaptiveWorkspaceLayout();
22 + const { fileInspector } = useWorkspacePaneState();
23 const openInInspector = use(ThreadInspectorNavigationContext);
24 return (
25 source: { readonly environmentId: string; readonly threadId: string },
apps/mobile/src/lib/filePreview.test.ts
+1 -1
@@ -286,7 +286,7 @@ vi.mock("../features/threads/thread-work-log", () => ({ THREAD_DISCLOSURE_TRANSI
286 vi.mock("../features/threads/HtmlRenderWebView", () => ({}));
287 vi.mock("../features/threads/McpAppWebView", () => ({}));
288 vi.mock("../features/layout/AdaptiveWorkspaceLayout", () => ({
289 - useAdaptiveWorkspaceLayout: () => ({ fileInspector: { supported: false } }),
289 + useWorkspacePaneState: () => ({ fileInspector: { supported: false } }),
290 }));
291 vi.mock("../features/threads/thread-workflow-opening", () => ({ useWorkflowOpening: () => null }));
292 vi.mock("../features/threads/useFileChipShare", () => ({ useFileChipShare: () => vi.fn() }));