From 89139e939450543d0fa4fc7989d16fc36ce0a5cd Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 29 Jun 2026 18:28:10 -0700 Subject: [PATCH] Stabilize iPad thread header controls --- .../features/threads/ThreadRouteScreen.tsx | 88 +++++++++++++------ 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx index 8f9af0135a..85698b824a 100644 --- a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx @@ -1,4 +1,5 @@ import { Stack, useFocusEffect, useLocalSearchParams, useRouter } from "expo-router"; +import type { NativeStackNavigationOptions } from "expo-router/build/react-navigation/native-stack/types"; import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react"; import * as Option from "effect/Option"; import { EnvironmentId, ThreadId, type ProjectScript } from "@t3tools/contracts"; @@ -43,7 +44,7 @@ import { } from "../terminal/terminalLaunchContext"; import { terminalDebugLog } from "../terminal/terminalDebugLog"; import { ThreadDetailScreen } from "./ThreadDetailScreen"; -import { ThreadGitControls, useThreadGitCenterHeaderItems } from "./ThreadGitControls"; +import { ThreadGitControls, useThreadGitRightHeaderItems } from "./ThreadGitControls"; import { GitOverviewSheet } from "./git/GitOverviewSheet"; import { ThreadNavigationDrawer } from "./ThreadNavigationDrawer"; import { useAtomCommand } from "../../state/use-atom-command"; @@ -59,7 +60,6 @@ import { useAdaptiveWorkspaceLayout, useAdaptiveWorkspacePaneRole, } from "../layout/AdaptiveWorkspaceLayout"; -import { WorkspaceSidebarToolbar } from "../layout/workspace-sidebar-toolbar"; import { ThreadFileNavigatorPane } from "../files/thread-file-navigator-pane"; import { ThreadInspectorContentStack, @@ -72,6 +72,10 @@ interface ThreadInspectorSelection { readonly mode: ThreadInspectorMode; } +type NativeHeaderItems = ReturnType< + NonNullable +>; + const TOP_SCROLL_EDGE_EFFECT = nativeTopScrollEdgeEffect(Platform.OS, Platform.Version); function InspectorPaneRoleActivation() { @@ -213,8 +217,14 @@ function ThreadRouteContent( readonly selectedThreadDetailState: ReturnType; }, ) { - const { fileInspector, layout, panes, showAuxiliaryPane, toggleAuxiliaryPane } = - useAdaptiveWorkspaceLayout(); + const { + fileInspector, + layout, + panes, + showAuxiliaryPane, + toggleAuxiliaryPane, + togglePrimarySidebar, + } = useAdaptiveWorkspaceLayout(); const { connectionState } = useRemoteConnectionStatus(); const { onReconnectEnvironment } = useRemoteConnections(); const { selectedThread, selectedThreadProject, selectedEnvironmentConnection } = @@ -619,7 +629,48 @@ function ThreadRouteContent( onPull: gitActions.onPullSelectedThreadBranch, onRunAction: gitActions.onRunSelectedThreadGitAction, }; - const threadCenterHeaderItems = useThreadGitCenterHeaderItems(threadGitControlProps); + const threadRightHeaderItems = useThreadGitRightHeaderItems(threadGitControlProps); + const splitLeftHeaderItems = useMemo( + () => [ + ...(props.onReturnToThread + ? [ + { + accessibilityLabel: "Return to chat", + icon: { name: "chevron.left", type: "sfSymbol" as const }, + identifier: "thread-left-return", + onPress: props.onReturnToThread, + sharesBackground: true, + type: "button" as const, + width: 58, + }, + ] + : []), + { + accessibilityLabel: panes.primarySidebarVisible + ? "Maximize content" + : "Show thread sidebar", + icon: { + name: panes.primarySidebarVisible ? "arrow.up.left.and.arrow.down.right" : "sidebar.left", + type: "sfSymbol" as const, + }, + identifier: "thread-left-sidebar", + onPress: togglePrimarySidebar, + sharesBackground: true, + type: "button" as const, + width: 58, + }, + { + accessibilityLabel: "New task", + icon: { name: "square.and.pencil", type: "sfSymbol" as const }, + identifier: "thread-left-new-task", + onPress: () => router.push("/new"), + sharesBackground: true, + type: "button" as const, + width: 58, + }, + ], + [panes.primarySidebarVisible, props.onReturnToThread, router, togglePrimarySidebar], + ); if (!environmentId || !threadId) { return ; @@ -678,9 +729,11 @@ function ThreadRouteContent( placement: "integratedButton", } : undefined, - unstable_headerCenterItems: - layout.usesSplitView && Platform.OS === "ios" && !activeInspectorRenderer - ? () => threadCenterHeaderItems + unstable_headerLeftItems: + layout.usesSplitView && Platform.OS === "ios" ? () => splitLeftHeaderItems : undefined, + unstable_headerRightItems: + layout.usesSplitView && Platform.OS === "ios" + ? () => threadRightHeaderItems : undefined, unstable_navigationItemStyle: usesNativeHeaderGlass ? "editor" : undefined, }} @@ -697,25 +750,6 @@ function ThreadRouteContent( )} - router.push("/new")} - separateBackground - /> - } - > - {props.onReturnToThread ? ( - - ) : null} - -