fix(mobile): restore Android tablet thread controls, clean up header (#5385)

This commit is contained in:
Alex authored and GitHub committed 2026-08-24 02:52:26 -07:00
1 parent 9eba1252c1
commit 2d2efff28c
7 files changed
+73 -175

No files matched your search

@@ -33,6 +33,7 @@ export function brandTitleOffset(nativeLeadingItem: boolean): number {
*/
export function CompactBrandTitle(
props: {
readonly allowFontScaling?: boolean;
readonly nativeLeadingItem?: boolean;
} = {},
) {
@@ -57,6 +58,7 @@ export function CompactBrandTitle(
>
<T3Wordmark color={iconColor} height={15} />
<Text
allowFontScaling={props.allowFontScaling}
style={{
color: mutedColor,
fontFamily: "DMSans-Medium",
@@ -75,6 +77,7 @@ export function CompactBrandTitle(
}}
>
<Text
allowFontScaling={props.allowFontScaling}
style={{
color: mutedColor,
fontFamily: "DMSans-Bold",
@@ -91,7 +94,7 @@ export function CompactBrandTitle(
}
export function renderCompactBrandTitle() {
return <CompactBrandTitle />;
return <CompactBrandTitle allowFontScaling={Platform.OS === "ios"} />;
}
export function renderCompactBrandHeaderItems(): NativeStackHeaderItem[] {
@@ -6,8 +6,8 @@ import { SymbolView } from "../../components/AppSymbol";
import { useThemeColor } from "../../lib/useThemeColor";
/**
* Android-only wrapper that overlays a bottom-right new-task FAB on the home
* screen. Other platforms render children unchanged.
* Android-only wrapper that overlays a bottom-right new-task FAB on a thread
* list. Other platforms render children unchanged.
*/
export function AndroidHomeFabLayout(props: {
readonly onStartNewTask: () => void;
@@ -2,6 +2,7 @@ import * as Arr from "effect/Array";
import * as Order from "effect/Order";
import { useNavigation } from "@react-navigation/native";
import { useEffect, useMemo, useState } from "react";
import { Platform } from "react-native";
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
import { useProjects, useThreadShells } from "../../state/entities";
@@ -106,7 +107,11 @@ export function HomeRouteScreen() {
return (
<>
<NativeStackScreenOptions
options={{ title: "", headerTitle: "", unstable_headerLeftItems: () => [] }}
options={
Platform.OS === "android"
? { headerShown: false }
: { title: "", headerTitle: "", unstable_headerLeftItems: () => [] }
}
/>
<WorkspaceSidebarToolbar
afterSidebarButton={
@@ -129,18 +134,20 @@ export function HomeRouteScreen() {
onStartNewTask={() => navigation.navigate("NewTaskSheet", { screen: "NewTask" })}
>
<>
{/* Restore the compact title after the split branch blanks the detail
header. The brand slot doubles as the connection status surface:
while an environment reconnects, the lockup fades to a status label
in place (no layout shift in the list below). */}
{/* Restore the header after leaving split view; screen options are
shallow-merged. The brand slot also doubles as the connection
status surface while an environment reconnects. */}
<NativeStackScreenOptions
options={getConnectionAwareBrandHeaderOptions({
onOpenEnvironments: () =>
navigation.navigate("SettingsSheet", {
screen: "SettingsContent",
params: { screen: "SettingsEnvironments" },
}),
})}
options={{
...getConnectionAwareBrandHeaderOptions({
onOpenEnvironments: () =>
navigation.navigate("SettingsSheet", {
screen: "SettingsContent",
params: { screen: "SettingsEnvironments" },
}),
}),
headerShown: true,
}}
/>
<HomeHeader
environments={environments}
@@ -45,6 +45,7 @@ import {
parseActiveThreadPath,
useHardwareKeyboardCommand,
} from "../keyboard/hardwareKeyboardCommands";
import { AndroidHomeFabLayout } from "../home/AndroidHomeFab";
import { HomeListOptionsProvider } from "../home/home-list-options";
import { ThreadNavigationSidebar } from "../threads/ThreadNavigationSidebar";
import { WORKSPACE_PANE_TIMING } from "./workspace-pane-animation";
@@ -435,6 +436,10 @@ function AdaptiveWorkspaceLayoutContent(
});
}, [navigation]);
const handleStartNewTask = useCallback(() => {
navigation.navigate("NewTaskSheet", { screen: "NewTask" });
}, [navigation]);
// Minted here (root stack navigation) so the sidebar pane stays free of
// navigation hooks — on iOS it renders inside an independent nav tree.
const handleOpenEnvironmentSettings = useCallback(() => {
@@ -528,18 +533,22 @@ function AdaptiveWorkspaceLayoutContent(
pointerEvents={panes.primarySidebarVisible ? "auto" : "none"}
style={sidebarAnimatedStyle}
>
<ThreadNavigationSidebar
width={layout.listPaneWidth}
visible={panes.primarySidebarVisible}
onRequestVisibility={revealPrimarySidebar}
selectedThreadKey={selectedThreadKey}
onOpenSettings={handleOpenSettings}
onOpenEnvironmentSettings={handleOpenEnvironmentSettings}
onNewThreadInProject={handleNewThreadInProject}
onSelectThread={handleSelectThread}
onSearchQueryChange={setPrimarySidebarSearchQuery}
searchQuery={primarySidebarSearchQuery}
/>
<View className="flex-1" style={{ width: layout.listPaneWidth }}>
<AndroidHomeFabLayout onStartNewTask={handleStartNewTask}>
<ThreadNavigationSidebar
width={layout.listPaneWidth}
visible={panes.primarySidebarVisible}
onRequestVisibility={revealPrimarySidebar}
selectedThreadKey={selectedThreadKey}
onOpenSettings={handleOpenSettings}
onOpenEnvironmentSettings={handleOpenEnvironmentSettings}
onNewThreadInProject={handleNewThreadInProject}
onSelectThread={handleSelectThread}
onSearchQueryChange={setPrimarySidebarSearchQuery}
searchQuery={primarySidebarSearchQuery}
/>
</AndroidHomeFabLayout>
</View>
</Animated.View>
) : null}
<View className="flex-1 overflow-hidden bg-screen" collapsable={false}>
@@ -1,4 +1,3 @@
import { isLiquidGlassSupported, LiquidGlassView } from "@callstack/liquid-glass";
import type {
EnvironmentProject,
EnvironmentThreadShell,
@@ -14,16 +13,16 @@ import { AsyncResult } from "effect/unstable/reactivity";
import type { EnvironmentId } from "@t3tools/contracts";
import { sortPinnedThreadsByOrderKey } from "@t3tools/client-runtime/state/thread-sort";
import type { ChangeRequestSettleSource } from "@t3tools/client-runtime/state/thread-settled";
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
import type { LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent } from "react-native";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import type { LayoutChangeEvent } from "react-native";
import { Platform, Pressable, StyleSheet, TextInput, View } from "react-native";
import { Gesture, GestureDetector } from "react-native-gesture-handler";
import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import type { SearchBarCommands } from "react-native-screens";
import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
import { AppText as Text } from "../../components/AppText";
import { CompactBrandTitle } from "../../components/CompactBrandTitle";
import { ControlPillMenu } from "../../components/ControlPill";
import { SymbolView } from "../../components/AppSymbol";
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
@@ -40,7 +39,6 @@ import { usePendingNewTasks } from "../../state/use-pending-new-tasks";
import { useWorkspaceState } from "../../state/workspace";
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
import {
hasCustomHomeListOptions,
PROJECT_SORT_OPTIONS,
@@ -97,48 +95,7 @@ type SidebarListItem =
| ThreadListV2ListItem
| { readonly type: "v2-show-more"; readonly key: string; readonly hiddenCount: number };
/**
* Shared capsule behind the sidebar header buttons — a native liquid-glass
* surface on iOS 26+, a tinted pill everywhere else.
*/
function SidebarHeaderButtonGroup(props: {
readonly children: ReactNode;
readonly colorScheme: "light" | "dark";
}) {
const fallbackBackground = useThemeColor("--color-glass-surface");
const fallbackBorder = useThemeColor("--color-header-border");
if (isLiquidGlassSupported) {
return (
<LiquidGlassView
colorScheme={props.colorScheme}
effect="regular"
interactive
style={styles.headerButtonGroup}
>
{props.children}
</LiquidGlassView>
);
}
return (
<View
style={[
styles.headerButtonGroup,
{ backgroundColor: fallbackBackground, borderColor: fallbackBorder },
{ borderWidth: StyleSheet.hairlineWidth },
]}
>
{props.children}
</View>
);
}
const SIDEBAR_STICKY_HEADER_HEIGHT = 106;
const SIDEBAR_STICKY_HEADER_FADE_HEIGHT = 44;
const SIDEBAR_HEADER_WASH_OPACITY = {
dark: [0.22, 0.14, 0.04],
light: [0.46, 0.3, 0.08],
} as const;
interface ThreadNavigationSidebarProps {
readonly width: number;
@@ -195,16 +152,13 @@ function ThreadNavigationSidebarPane(
props: ThreadNavigationSidebarProps & { readonly nativeChrome: boolean },
) {
const insets = useSafeAreaInsets();
const { themeAppearance: colorScheme } = useAppearancePreferences();
const projects = useProjects();
const threads = useThreadShells();
const { environments: workspaceEnvironments, state: catalogState } = useWorkspaceState();
const { savedConnectionsById } = useSavedRemoteConnections();
const [headerIsOverContent, setHeaderIsOverContent] = useState(false);
const searchInputRef = useRef<TextInput>(null);
const searchBarRef = useRef<SearchBarCommands>(null);
const openSwipeableRef = useRef<SwipeableMethods | null>(null);
const headerIsOverContentRef = useRef(false);
const sidebarScrollGesture = useMemo(() => Gesture.Native(), []);
const {
archiveThread,
@@ -780,8 +734,6 @@ function ThreadNavigationSidebarPane(
const borderColor = useThemeColor("--color-border");
const mutedColor = useThemeColor("--color-foreground-muted");
const placeholderColor = useThemeColor("--color-placeholder");
const headerFadeColor = String(backgroundColor);
const headerWashOpacity = SIDEBAR_HEADER_WASH_OPACITY[colorScheme];
const [measuredHeaderHeight, setMeasuredHeaderHeight] = useState<number | null>(null);
// The sticky header (title row, search field, optional connection status)
// is measured so the list inset always matches its real height — no
@@ -810,19 +762,10 @@ function ThreadNavigationSidebarPane(
},
[props.onSelectThread],
);
const handleScroll = useCallback((event: NativeSyntheticEvent<NativeScrollEvent>) => {
const next = event.nativeEvent.contentOffset.y > 6;
if (headerIsOverContentRef.current === next) {
return;
}
headerIsOverContentRef.current = next;
setHeaderIsOverContent(next);
}, []);
const handleScrollBeginDrag = useCallback(() => {
openSwipeableRef.current?.close();
}, []);
const { swipeEnabled, scrollGateHandlers } = useSwipeableScrollGate({
onScroll: handleScroll,
onScrollBeginDrag: handleScrollBeginDrag,
});
// Project shells load after the first rows draw, so the maps they feed have
@@ -1321,7 +1264,10 @@ function ThreadNavigationSidebarPane(
contentContainerStyle={[
styles.threadListContent,
{
paddingBottom: 16 + insets.bottom,
paddingBottom:
Platform.OS === "android"
? Math.max(insets.bottom, 16) + 88 - insets.bottom
: 16 + insets.bottom,
paddingTop: topListInset,
},
]}
@@ -1340,65 +1286,34 @@ function ThreadNavigationSidebarPane(
<View
className="absolute inset-x-0 top-0 z-[4]"
collapsable={false}
onLayout={handleStickyHeaderLayout}
pointerEvents="box-none"
style={{ paddingTop: insets.top }}
pointerEvents="auto"
style={{
paddingTop: insets.top,
backgroundColor,
}}
>
<View
className="absolute inset-x-0 top-0"
pointerEvents="none"
accessibilityElementsHidden
importantForAccessibility="no-hide-descendants"
style={{ height: stickyHeaderHeight + SIDEBAR_STICKY_HEADER_FADE_HEIGHT }}
>
<Svg width="100%" height="100%">
<Defs>
<LinearGradient id="sidebar-header-wash" x1="0%" x2="0%" y1="0%" y2="100%">
<Stop
offset="0%"
stopColor={headerFadeColor}
stopOpacity={headerIsOverContent ? headerWashOpacity[0] : 0}
/>
<Stop
offset="58%"
stopColor={headerFadeColor}
stopOpacity={headerIsOverContent ? headerWashOpacity[1] : 0}
/>
<Stop
offset="88%"
stopColor={headerFadeColor}
stopOpacity={headerIsOverContent ? headerWashOpacity[2] : 0}
/>
<Stop offset="100%" stopColor={headerFadeColor} stopOpacity={0} />
</LinearGradient>
</Defs>
<Rect width="100%" height="100%" fill="url(#sidebar-header-wash)" />
</Svg>
</View>
<View className="h-[50px] flex-row items-end gap-0.5 pr-2 pl-5">
{/* Title slot doubles as the connection status surface: while an
environment reconnects, "Threads" fades to a status label in
environment reconnects, the brand fades to a status label in
place (no layout shift in the list below). */}
<WorkspaceConnectionTitle
grow
onPress={props.onOpenEnvironmentSettings}
size="pageTitle"
brand={
<Text className="flex-1 text-[34px] font-t3-bold text-foreground" numberOfLines={1}>
Threads
</Text>
<View className="h-11 flex-1 justify-center">
<CompactBrandTitle allowFontScaling={false} />
</View>
}
/>
<SidebarHeaderButtonGroup colorScheme={colorScheme}>
<View className="flex-row items-center gap-2.5">
<ControlPillMenu actions={listMenuActions} onPressAction={handleListMenuAction}>
<SidebarFilterButton
grouped
accessibilityLabel="Filter and sort threads"
icon={filterIcon}
/>
<SidebarFilterButton accessibilityLabel="Filter and sort threads" icon={filterIcon} />
</ControlPillMenu>
<SidebarHeaderActions grouped onOpenSettings={props.onOpenSettings} />
</SidebarHeaderButtonGroup>
<SidebarHeaderActions onOpenSettings={props.onOpenSettings} />
</View>
</View>
<View className="mx-4 mt-[9px] h-[38px] flex-row items-center gap-1.5 rounded-xl bg-sidebar-search pr-2.5 pl-[11px]">
@@ -1423,12 +1338,6 @@ function ThreadNavigationSidebarPane(
}
const styles = StyleSheet.create({
headerButtonGroup: {
alignItems: "center",
borderRadius: 22,
flexDirection: "row",
overflow: "hidden",
},
threadList: {
flex: 1,
},
@@ -1,5 +1,5 @@
import { SymbolView } from "../../components/AppSymbol";
import { Pressable, StyleSheet } from "react-native";
import { Pressable } from "react-native";
import { useThemeColor } from "../../lib/useThemeColor";
@@ -10,31 +10,17 @@ export type SidebarFilterButtonIcon =
export function SidebarFilterButton(props: {
readonly accessibilityLabel: string;
readonly icon: SidebarFilterButtonIcon;
/** Rendered inside a shared capsule group — no own background/border. */
readonly grouped?: boolean;
}) {
const iconColor = useThemeColor("--color-foreground");
const pressedBackgroundColor = useThemeColor("--color-subtle");
const idleBackgroundColor = useThemeColor("--color-glass-surface");
const borderColor = useThemeColor("--color-header-border");
return (
<Pressable
className="h-11 w-[50px] cursor-pointer items-center justify-center rounded-[22px]"
className="size-11 cursor-pointer items-center justify-center rounded-full bg-subtle active:opacity-70"
accessibilityLabel={props.accessibilityLabel}
accessibilityRole="button"
hitSlop={4}
style={({ pressed }) => [
props.grouped
? { backgroundColor: pressed ? pressedBackgroundColor : "transparent", borderWidth: 0 }
: {
backgroundColor: pressed ? pressedBackgroundColor : idleBackgroundColor,
borderColor,
borderWidth: StyleSheet.hairlineWidth,
},
]}
>
<SymbolView name={props.icon} size={20} tintColor={iconColor} type="monochrome" />
<SymbolView name={props.icon} size={16} tintColor={iconColor} type="monochrome" />
</Pressable>
);
}
@@ -1,43 +1,28 @@
import { SymbolView } from "../../components/AppSymbol";
import { Pressable, StyleSheet, View } from "react-native";
import { Pressable, View } from "react-native";
import { useThemeColor } from "../../lib/useThemeColor";
export interface SidebarHeaderActionsProps {
readonly onOpenSettings: () => void;
/** Rendered inside a shared capsule group — buttons drop their own chrome. */
readonly grouped?: boolean;
}
function FallbackHeaderButton(props: {
readonly accessibilityLabel: string;
readonly icon: "gearshape" | "square.and.pencil";
readonly grouped?: boolean;
readonly onPress: () => void;
}) {
const iconColor = useThemeColor("--color-foreground");
const pressedBackgroundColor = useThemeColor("--color-subtle");
const idleBackgroundColor = useThemeColor("--color-glass-surface");
const borderColor = useThemeColor("--color-header-border");
return (
<Pressable
className="h-11 w-[50px] items-center justify-center rounded-[22px]"
className="size-11 items-center justify-center rounded-full bg-subtle active:opacity-70"
accessibilityLabel={props.accessibilityLabel}
accessibilityRole="button"
hitSlop={4}
onPress={props.onPress}
style={({ pressed }) => [
props.grouped
? { backgroundColor: pressed ? pressedBackgroundColor : "transparent", borderWidth: 0 }
: {
backgroundColor: pressed ? pressedBackgroundColor : idleBackgroundColor,
borderColor,
borderWidth: StyleSheet.hairlineWidth,
},
]}
>
<SymbolView name={props.icon} size={20} tintColor={iconColor} type="monochrome" />
<SymbolView name={props.icon} size={18} tintColor={iconColor} type="monochrome" />
</Pressable>
);
}
@@ -47,7 +32,6 @@ export function SidebarHeaderActions(props: SidebarHeaderActionsProps) {
<View className="flex-row items-center gap-0.5">
<FallbackHeaderButton
accessibilityLabel="Open settings"
grouped={props.grouped}
icon="gearshape"
onPress={props.onOpenSettings}
/>