fix(mobile): adapt workspace navigation and expand controls (#12551)

This commit is contained in:
Julius Marminge authored and GitHub committed 2026-09-18 23:58:18 -07:00
1 parent 803f94e787
commit 29a23fdf14
12 files changed
+109 -124

No files matched your search

+38 -23
View File
@@ -11,7 +11,14 @@ import {
type NativeStackNavigationOptions,
} from "@react-navigation/native-stack";
import { useEffect, useRef } from "react";
import { Platform, Pressable, ScrollView, StyleSheet, View } from "react-native";
import {
Platform,
Pressable,
ScrollView,
StyleSheet,
View,
useWindowDimensions,
} from "react-native";
import { useResolveClassNames } from "uniwind";
import { AppText as Text } from "./components/AppText";
@@ -93,6 +100,7 @@ import {
transitionIncomingSharePresentation,
} from "./features/sharing/incoming-share-presentation";
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "./native/native-glass";
import { deriveLayout } from "./lib/layout";
import { nativeHeaderScrollEdgeEffects } from "./native/StackHeader";
import { FORM_SHEET_PRESENTATION_OPTIONS } from "./native/sheet-surface";
import { useThreadOutboxDrain } from "./state/use-thread-outbox-drain";
@@ -339,9 +347,8 @@ const SettingsSheetStack = createNativeStackNavigator({
// the same deep-link URLs the nested config produced.
const THREAD_LINKING_PREFIX = "threads/:environmentId/:threadId";
// New-task / add-project flow: nested navigator inside the formSheet (Settings-sheet
// pattern — a plain formSheet screen cannot render a stack header; the header and
// in-sheet pushes come from this nested stack).
// New-task / add-project flow: the nested navigator owns the header and pushes
// whether the flow opens in the workspace or in a compact form sheet.
const NewTaskSheetStack = createNativeStackNavigator({
initialRouteName: "NewTask",
screenOptions: {
@@ -570,7 +577,7 @@ function NotFoundScreen() {
);
}
export const RootStack = createNativeStackNavigator({
const RootStackConfig = createNativeStackNavigator({
initialRouteName: "Home",
layout: RootStackLayout,
screenOptions: {
@@ -698,15 +705,6 @@ export const RootStack = createNativeStackNavigator({
options: {
gestureEnabled: true,
headerShown: false,
// Android pushes settings as a regular full page with an in-screen
// back header; iOS keeps the detented form sheet.
...(Platform.OS === "android"
? { presentation: "card" as const }
: {
...FORM_SHEET_PRESENTATION_OPTIONS,
sheetAllowedDetents: [0.92],
sheetGrabberVisible: true,
}),
},
}),
SettingsLegal: createNativeStackScreen({
@@ -770,15 +768,6 @@ export const RootStack = createNativeStackNavigator({
options: {
gestureEnabled: true,
headerShown: false,
// Android pushes the flow as a regular full page — the draft should
// read like a thread that just doesn't exist yet; iOS keeps the sheet.
...(Platform.OS === "android"
? { presentation: "card" as const }
: {
...FORM_SHEET_PRESENTATION_OPTIONS,
sheetAllowedDetents: [0.92],
sheetGrabberVisible: true,
}),
},
}),
NotFound: createNativeStackScreen({
@@ -787,6 +776,32 @@ export const RootStack = createNativeStackNavigator({
}),
},
});
export const RootStack = RootStackConfig.with(function AdaptiveRootStack({ Navigator }) {
const { width, height } = useWindowDimensions();
const usesWorkspaceFlowScreens =
Platform.OS === "android" || deriveLayout({ width, height }).usesSplitView;
return (
<Navigator
screenOptions={({ route }) => {
if (route.name !== "SettingsSheet" && route.name !== "NewTaskSheet") {
return {};
}
// Follow the workspace viewport as it resizes; compact iOS keeps sheets.
return usesWorkspaceFlowScreens
? { presentation: "card" }
: {
...FORM_SHEET_PRESENTATION_OPTIONS,
sheetAllowedDetents: [0.92],
sheetGrabberVisible: true,
};
}}
/>
);
});
type RootStackType = typeof RootStack;
const navigationPathConfig = {
@@ -25,13 +25,7 @@ export function AndroidHeaderIconButton(props: {
readonly disabled?: boolean;
readonly selected?: boolean;
}) {
return (
<MaterialIconButton
{...props}
tintColorClassName="accent-header-foreground"
variant={props.selected ? "tonal" : "standard"}
/>
);
return <MaterialIconButton {...props} tintColorClassName="accent-header-foreground" />;
}
export function AndroidScreenHeader(props: {
+2 -2
View File
@@ -19,7 +19,7 @@ import IconArrowUp from "@tabler/icons-react-native/IconArrowUp";
import IconArrowUpCircle from "@tabler/icons-react-native/IconArrowUpCircle";
import IconArrowUpRight from "@tabler/icons-react-native/IconArrowUpRight";
import IconArrowUpRightCircle from "@tabler/icons-react-native/IconArrowUpRightCircle";
import IconArrowsMaximize from "@tabler/icons-react-native/IconArrowsMaximize";
import IconArrowsDiagonal2 from "@tabler/icons-react-native/IconArrowsDiagonal2";
import IconArrowsMinimize from "@tabler/icons-react-native/IconArrowsMinimize";
import IconBellRinging from "@tabler/icons-react-native/IconBellRinging";
import IconBolt from "@tabler/icons-react-native/IconBolt";
@@ -122,7 +122,7 @@ const ANDROID_ICON_BY_SF_SYMBOL = {
"arrow.turn.left.up": IconArrowBackUp,
"arrow.up": IconArrowUp,
"arrow.up.circle": IconArrowUpCircle,
"arrow.up.left.and.arrow.down.right": IconArrowsMaximize,
"arrow.up.left.and.arrow.down.right": IconArrowsDiagonal2,
"arrow.down.right.and.arrow.up.left": IconArrowsMinimize,
"arrow.up.right": IconArrowUpRight,
"arrow.up.right.circle": IconArrowUpRightCircle,
+17 -13
View File
@@ -103,7 +103,7 @@ export function ScreenHeader(props: ScreenHeaderProps) {
...props.options,
}}
/>
{props.sidebar !== false && layout.usesSplitView ? (
{layout.usesSplitView && (props.sidebar !== false || props.backInSplitView) ? (
<NativeHeaderToolbar placement="left">
{props.backInSplitView && (props.backInSplitView.onPress || props.onBack) ? (
<ScreenHeaderButton
@@ -111,18 +111,22 @@ export function ScreenHeader(props: ScreenHeaderProps) {
onPress={props.backInSplitView.onPress ?? props.onBack}
/>
) : null}
<ScreenHeaderButton
accessibilityLabel={
panes.primarySidebarVisible ? `Maximize ${props.title.toLowerCase()}` : "Show threads"
}
icon={
panes.primarySidebarVisible ? "arrow.up.left.and.arrow.down.right" : "sidebar.left"
}
onPress={togglePrimarySidebar}
separateBackground={
props.backInSplitView ? props.backInSplitView.separateBackground : true
}
/>
{props.sidebar !== false ? (
<ScreenHeaderButton
accessibilityLabel={
panes.primarySidebarVisible
? `Maximize ${props.title.toLowerCase()}`
: "Show threads"
}
icon={
panes.primarySidebarVisible ? "arrow.up.left.and.arrow.down.right" : "sidebar.left"
}
onPress={togglePrimarySidebar}
separateBackground={
props.backInSplitView ? props.backInSplitView.separateBackground : true
}
/>
) : null}
</NativeHeaderToolbar>
) : null}
{(props.actions?.length ||
@@ -11,10 +11,6 @@ import { useWorkspaceState } from "../../state/workspace";
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import { WorkspaceEmptyDetail } from "../layout/WorkspaceEmptyDetail";
import {
AndroidWorkspaceSidebarButton,
WorkspaceSidebarToolbar,
} from "../layout/workspace-sidebar-toolbar";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { checkForAppUpdateOnLaunch, startAppUpdateForegroundRecheck } from "../updates/app-updates";
import { AndroidHomeFabLayout } from "./AndroidHomeFab";
@@ -121,18 +117,16 @@ export function HomeRouteScreen() {
: { title: "", headerTitle: "", unstable_headerLeftItems: () => [] }
}
/>
<WorkspaceSidebarToolbar
afterSidebarButton={
{Platform.OS === "ios" ? (
<NativeHeaderToolbar placement="left">
<NativeHeaderToolbar.Button
accessibilityLabel="New task"
icon="square.and.pencil"
onPress={() => navigation.navigate("NewTaskSheet", { screen: "NewTask" })}
/>
}
/>
{Platform.OS === "android" ? (
<AndroidScreenHeader title="Threads" leading={<AndroidWorkspaceSidebarButton />} />
</NativeHeaderToolbar>
) : null}
{Platform.OS === "android" ? <AndroidScreenHeader title="Threads" /> : null}
<WorkspaceEmptyDetail
onAddConnection={
Platform.OS === "android" && !catalogState.hasConnections
@@ -238,6 +238,7 @@ function AdaptiveWorkspaceLayoutContent(
const navigation = useNavigation();
const activeRoleOwner = useRef<symbol | null>(null);
const [primarySidebarPreferredVisible, setPrimarySidebarPreferredVisible] = useState(true);
const showPrimarySidebar = pathname === "/" || primarySidebarPreferredVisible;
const [supplementaryPanePreferredVisible, setSupplementaryPanePreferredVisible] = useState(true);
const [supplementaryPanePreferredWidth, setSupplementaryPanePreferredWidth] = useState<
number | null
@@ -262,17 +263,9 @@ function AdaptiveWorkspaceLayoutContent(
viewportWidth: width,
preferredWidth: fileInspectorPreferredWidth ?? undefined,
reservedLeadingWidth:
shouldRenderPrimarySidebar && primarySidebarPreferredVisible
? (layout.listPaneWidth ?? 0)
: 0,
shouldRenderPrimarySidebar && showPrimarySidebar ? (layout.listPaneWidth ?? 0) : 0,
}),
[
fileInspectorPreferredWidth,
layout,
primarySidebarPreferredVisible,
shouldRenderPrimarySidebar,
width,
],
[fileInspectorPreferredWidth, layout, showPrimarySidebar, shouldRenderPrimarySidebar, width],
);
const auxiliaryPaneRole: WorkspaceAuxiliaryPaneRole =
focusedAuxiliaryPaneRole ?? (/\/files(?:\/|$)/.test(pathname) ? "inspector" : "supplementary");
@@ -289,7 +282,7 @@ function AdaptiveWorkspaceLayoutContent(
deriveWorkspacePaneLayout({
layout,
viewportWidth: width,
primarySidebarPreferredVisible,
primarySidebarPreferredVisible: showPrimarySidebar,
auxiliaryPanePreferredVisible,
auxiliaryPaneRole,
auxiliaryPanePreferredWidth: auxiliaryPanePreferredWidth ?? undefined,
@@ -299,7 +292,7 @@ function AdaptiveWorkspaceLayoutContent(
auxiliaryPaneRole,
auxiliaryPanePreferredWidth,
layout,
primarySidebarPreferredVisible,
showPrimarySidebar,
width,
],
);
@@ -357,13 +350,16 @@ function AdaptiveWorkspaceLayoutContent(
};
}, []);
const togglePrimarySidebar = useCallback(() => {
if (pathname === "/") {
return;
}
if (!panes.primarySidebarVisible && panes.primarySidebarSuppressedByAuxiliary) {
setFileInspectorPreferredVisible(false);
setPrimarySidebarPreferredVisible(true);
return;
}
setPrimarySidebarPreferredVisible((current) => !current);
}, [panes.primarySidebarSuppressedByAuxiliary, panes.primarySidebarVisible]);
}, [panes.primarySidebarSuppressedByAuxiliary, panes.primarySidebarVisible, pathname]);
const revealPrimarySidebar = useCallback(() => {
if (panes.primarySidebarSuppressedByAuxiliary) {
setFileInspectorPreferredVisible(false);
@@ -374,7 +370,11 @@ function AdaptiveWorkspaceLayoutContent(
togglePrimarySidebar();
return true;
}, [togglePrimarySidebar]);
useHardwareKeyboardCommand("toggleSidebar", handleToggleSidebarCommand);
const sidebarCommands = useMemo(
() => (pathname === "/" ? [] : (["toggleSidebar"] as const)),
[pathname],
);
useHardwareKeyboardCommand(sidebarCommands, handleToggleSidebarCommand);
const showAuxiliaryPane = useCallback((role: WorkspaceAuxiliaryPaneRole) => {
if (role === "inspector") {
setFocusedAuxiliaryPaneRole("inspector");
@@ -1,5 +1,3 @@
import { NativeHeaderToolbar } from "../../native/StackHeader";
import type { ReactNode } from "react";
import { Platform } from "react-native";
import { AndroidHeaderIconButton } from "../../components/AndroidScreenHeader";
@@ -12,39 +10,9 @@ export function AndroidWorkspaceSidebarButton() {
return (
<AndroidHeaderIconButton
accessibilityLabel={
panes.primarySidebarVisible ? "Hide thread sidebar" : "Show thread sidebar"
}
icon="sidebar.left"
selected={panes.primarySidebarVisible}
accessibilityLabel={panes.primarySidebarVisible ? "Maximize content" : "Show thread sidebar"}
icon={panes.primarySidebarVisible ? "arrow.up.left.and.arrow.down.right" : "sidebar.left"}
onPress={togglePrimarySidebar}
/>
);
}
export function WorkspaceSidebarToolbar(
props: {
readonly children?: ReactNode;
readonly afterSidebarButton?: ReactNode;
} = {},
) {
const { layout, panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
if (Platform.OS === "android" || !layout.usesSplitView) {
return null;
}
return (
<NativeHeaderToolbar placement="left">
{props.children}
<NativeHeaderToolbar.Button
accessibilityLabel={
panes.primarySidebarVisible ? "Maximize content" : "Show thread sidebar"
}
icon={panes.primarySidebarVisible ? "arrow.up.left.and.arrow.down.right" : "sidebar.left"}
onPress={togglePrimarySidebar}
/>
{props.afterSidebarButton}
</NativeHeaderToolbar>
);
}
@@ -6,7 +6,8 @@ import { deriveProjectGroupLabel } from "@t3tools/client-runtime/state/project-g
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { hasCloudPublicConfig } from "../cloud/publicConfig";
import { WorkspaceSidebarToolbar } from "../layout/workspace-sidebar-toolbar";
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import { NativeHeaderToolbar } from "../../native/StackHeader";
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
import { SettingsRow } from "./components/SettingsRow";
import { SettingsSection } from "./components/SettingsSection";
@@ -18,6 +19,8 @@ import {
import { useSettingsEnvironmentFilter } from "./settings-environment-filter";
export function SettingsRouteScreen() {
const navigation = useNavigation();
const { layout } = useAdaptiveWorkspaceLayout();
const content = hasCloudPublicConfig() ? (
<ConfiguredSettingsRouteScreen />
) : (
@@ -26,7 +29,15 @@ export function SettingsRouteScreen() {
return (
<>
<WorkspaceSidebarToolbar />
{Platform.OS === "ios" && layout.usesSplitView ? (
<NativeHeaderToolbar placement="left">
<NativeHeaderToolbar.Button
accessibilityLabel="Go back"
icon="chevron.left"
onPress={() => navigation.goBack()}
/>
</NativeHeaderToolbar>
) : null}
<SettingsEnvironmentFilterHeader closeSettings />
{Platform.OS === "android" ? (
<SettingsScreen title="Settings" trailing={<AndroidSettingsEnvironmentFilter />}>
@@ -5,10 +5,13 @@ import { ControlPillMenu } from "../../../components/ControlPill";
import { SymbolView } from "../../../components/AppSymbol";
import { NativeStackScreenOptions } from "../../../native/StackHeader";
import { withNativeGlassHeaderItem } from "../../layout/native-glass-header-items";
import { useAdaptiveWorkspaceLayout } from "../../layout/AdaptiveWorkspaceLayout";
import { useSettingsEnvironmentFilter } from "../settings-environment-filter";
export function SettingsEnvironmentFilterHeader(props: { readonly closeSettings?: boolean }) {
const navigation = useNavigation();
const { layout } = useAdaptiveWorkspaceLayout();
const closeSettings = props.closeSettings === true && !layout.usesSplitView;
const {
availableTargets,
selectedTargets,
@@ -26,6 +29,7 @@ export function SettingsEnvironmentFilterHeader(props: { readonly closeSettings?
? "line.3.horizontal.decrease"
: "line.3.horizontal.decrease.circle.fill";
const filterVersion = JSON.stringify({
closeSettings,
selection: selectedIds === null ? null : [...selectedIds].sort(),
targets: availableTargets.map((entry) => [entry.environmentId, entry.label, entry.displayUrl]),
project: selectedProjectKey,
@@ -94,7 +98,7 @@ export function SettingsEnvironmentFilterHeader(props: { readonly closeSettings?
],
},
}),
...(props.closeSettings
...(closeSettings
? [
withNativeGlassHeaderItem({
accessibilityLabel: "Close settings",
@@ -23,7 +23,7 @@ export function SettingsScreen(
title={props.title}
actions={props.actions}
trailing={Platform.OS === "android" ? props.trailing : undefined}
sidebar={Platform.OS === "android" && !props.formSheet}
sidebar={false}
onBack={() => navigation.goBack()}
hideBottomBorder={!props.formSheet}
/>
@@ -100,9 +100,8 @@ function TerminalHeader(props: {
subtitle={props.subtitle}
onBack={props.onCloseTerminal}
backInSplitView={{
accessibilityLabel: "Close terminal",
icon: "xmark",
separateBackground: true,
accessibilityLabel: "Back to chat",
icon: "chevron.left",
}}
menus={
props.isEnvironmentReady
@@ -98,28 +98,24 @@ function NewTaskHeader(props: {
title={props.title}
subtitle={props.subtitle ?? undefined}
sidebar={false}
backInSplitView={{
accessibilityLabel: "Go back",
icon: "chevron.left",
}}
options={{ headerBackVisible: !layout.usesSplitView }}
hideBottomBorder
onBack={() => navigation.goBack()}
actions={[
...(Platform.OS === "ios" && layout.usesSplitView
? [
{
accessibilityLabel: "Close new task",
icon: "xmark" as const,
onPress: () => navigation.goBack(),
},
]
: []),
...(props.canAddProject
actions={
props.canAddProject
? [
{
accessibilityLabel: "Add project",
icon: "plus" as const,
icon: "plus",
onPress: () => navigation.dispatch(StackActions.push("AddProject")),
},
]
: []),
]}
: []
}
search={{
value: props.searchText,
onChangeText: props.onSearchTextChange,