Refine mobile layout for iPad and native glass headers
- add thread selection context for split-view routing - switch thread feeds to automatic content insets on iOS glass headers - add native scroll-edge effect helper and app domain config
This commit is contained in:
1 parent
d353476417
commit
8351e7ca31
13 files changed
+361
-231
No files matched your search
@@ -17,6 +17,7 @@ const VARIANT_CONFIG: Record<
|
||||
readonly iosIcon: string;
|
||||
readonly iosBundleIdentifier: string;
|
||||
readonly androidPackage: string;
|
||||
readonly relyingParty?: string;
|
||||
}
|
||||
> = {
|
||||
development: {
|
||||
@@ -25,6 +26,7 @@ const VARIANT_CONFIG: Record<
|
||||
iosIcon: "./assets/icon-composer-dev.icon",
|
||||
iosBundleIdentifier: "com.t3tools.t3code.dev",
|
||||
androidPackage: "com.t3tools.t3code.dev",
|
||||
relyingParty: "clerk.t3.codes",
|
||||
},
|
||||
preview: {
|
||||
appName: "T3 Code Preview",
|
||||
@@ -32,6 +34,7 @@ const VARIANT_CONFIG: Record<
|
||||
iosIcon: "./assets/icon-composer-prod.icon",
|
||||
iosBundleIdentifier: "com.t3tools.t3code.preview",
|
||||
androidPackage: "com.t3tools.t3code.preview",
|
||||
relyingParty: "clerk.t3.codes",
|
||||
},
|
||||
production: {
|
||||
appName: "T3 Code",
|
||||
@@ -39,6 +42,7 @@ const VARIANT_CONFIG: Record<
|
||||
iosIcon: "./assets/icon-composer-prod.icon",
|
||||
iosBundleIdentifier: "com.t3tools.t3code",
|
||||
androidPackage: "com.t3tools.t3code",
|
||||
relyingParty: "clerk.t3.codes",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -64,7 +68,7 @@ const config: ExpoConfig = {
|
||||
runtimeVersion: {
|
||||
policy: process.env.MOBILE_VERSION_POLICY ?? "appVersion",
|
||||
},
|
||||
orientation: "default",
|
||||
orientation: "portrait",
|
||||
icon: "./assets/icon.png",
|
||||
userInterfaceStyle: "automatic",
|
||||
updates: {
|
||||
@@ -77,6 +81,10 @@ const config: ExpoConfig = {
|
||||
icon: variant.iosIcon,
|
||||
supportsTablet: true,
|
||||
bundleIdentifier: variant.iosBundleIdentifier,
|
||||
associatedDomains: [
|
||||
`applinks:${variant.relyingParty}`,
|
||||
`webcredentials:${variant.relyingParty}`,
|
||||
],
|
||||
infoPlist: {
|
||||
NSAppTransportSecurity: {
|
||||
NSAllowsArbitraryLoads: true,
|
||||
|
||||
@@ -95,7 +95,7 @@ function WorkspaceNavigator() {
|
||||
};
|
||||
const settingsScreenOptions = layout.usesSplitView
|
||||
? {
|
||||
animation: "fade" as const,
|
||||
animation: "none" as const,
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: false,
|
||||
headerShown: false,
|
||||
|
||||
@@ -2,6 +2,7 @@ import Stack from "expo-router/stack";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { useResolveClassNames } from "uniwind";
|
||||
import { useAdaptiveWorkspaceLayout } from "../../../../features/layout/AdaptiveWorkspaceLayout";
|
||||
import { ThreadSelectionProvider } from "../../../../state/use-thread-selection";
|
||||
|
||||
export default function ThreadLayout() {
|
||||
const { fileInspector } = useAdaptiveWorkspaceLayout();
|
||||
@@ -11,101 +12,102 @@ export default function ThreadLayout() {
|
||||
};
|
||||
|
||||
return (
|
||||
<Stack screenOptions={{ headerShown: false }}>
|
||||
<Stack.Screen
|
||||
name="index"
|
||||
options={{
|
||||
contentStyle: { backgroundColor: "transparent" },
|
||||
headerShown: true,
|
||||
headerTransparent: true,
|
||||
headerShadowVisible: false,
|
||||
headerTitle: "",
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="git"
|
||||
options={{
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerShown: false,
|
||||
presentation: "formSheet" as const,
|
||||
sheetAllowedDetents: [0.85],
|
||||
sheetGrabberVisible: true,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="git-confirm"
|
||||
options={{
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerShown: false,
|
||||
presentation: "formSheet" as const,
|
||||
sheetAllowedDetents: [0.4],
|
||||
sheetGrabberVisible: true,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="review"
|
||||
options={{
|
||||
animation: "slide_from_right",
|
||||
contentStyle: sheetStyle,
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
headerShown: true,
|
||||
headerTitle: "Files changed",
|
||||
headerBackTitle: "",
|
||||
headerShadowVisible: false,
|
||||
headerStyle: headerBg,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="files/index"
|
||||
options={{
|
||||
animation: fileInspector.supported ? "none" : "slide_from_right",
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
headerShown: true,
|
||||
headerTitle: "Files",
|
||||
headerBackTitle: "",
|
||||
headerShadowVisible: false,
|
||||
headerStyle: headerBg,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="files/[...path]"
|
||||
options={{
|
||||
animation: fileInspector.supported ? "none" : "slide_from_right",
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
headerShown: true,
|
||||
headerTitle: "File",
|
||||
headerBackTitle: "",
|
||||
headerShadowVisible: false,
|
||||
headerStyle: headerBg,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="review-comment"
|
||||
options={{
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerShown: false,
|
||||
presentation: "formSheet" as const,
|
||||
sheetAllowedDetents: [0.72, 0.92],
|
||||
sheetGrabberVisible: true,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="terminal"
|
||||
options={{
|
||||
animation: "slide_from_right",
|
||||
contentStyle: { backgroundColor: "#050505" },
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
headerShown: true,
|
||||
headerShadowVisible: false,
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
<ThreadSelectionProvider>
|
||||
<Stack screenOptions={{ headerShown: false }}>
|
||||
<Stack.Screen
|
||||
name="index"
|
||||
options={{
|
||||
contentStyle: { backgroundColor: "transparent" },
|
||||
headerShown: true,
|
||||
headerTransparent: true,
|
||||
headerTitle: "",
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="git"
|
||||
options={{
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerShown: false,
|
||||
presentation: "formSheet" as const,
|
||||
sheetAllowedDetents: [0.85],
|
||||
sheetGrabberVisible: true,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="git-confirm"
|
||||
options={{
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerShown: false,
|
||||
presentation: "formSheet" as const,
|
||||
sheetAllowedDetents: [0.4],
|
||||
sheetGrabberVisible: true,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="review"
|
||||
options={{
|
||||
animation: "slide_from_right",
|
||||
contentStyle: sheetStyle,
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
headerShown: true,
|
||||
headerTitle: "Files changed",
|
||||
headerBackTitle: "",
|
||||
headerShadowVisible: false,
|
||||
headerStyle: headerBg,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="files/index"
|
||||
options={{
|
||||
animation: fileInspector.supported ? "none" : "slide_from_right",
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
headerShown: true,
|
||||
headerTitle: "Files",
|
||||
headerBackTitle: "",
|
||||
headerShadowVisible: false,
|
||||
headerStyle: headerBg,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="files/[...path]"
|
||||
options={{
|
||||
animation: fileInspector.supported ? "none" : "slide_from_right",
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
headerShown: true,
|
||||
headerTitle: "File",
|
||||
headerBackTitle: "",
|
||||
headerShadowVisible: false,
|
||||
headerStyle: headerBg,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="review-comment"
|
||||
options={{
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerShown: false,
|
||||
presentation: "formSheet" as const,
|
||||
sheetAllowedDetents: [0.72, 0.92],
|
||||
sheetGrabberVisible: true,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="terminal"
|
||||
options={{
|
||||
animation: "slide_from_right",
|
||||
contentStyle: { backgroundColor: "#050505" },
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
headerShown: true,
|
||||
headerShadowVisible: false,
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
</ThreadSelectionProvider>
|
||||
);
|
||||
}
|
||||
@@ -1,18 +1,8 @@
|
||||
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
|
||||
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
|
||||
import { useFocusEffect, useGlobalSearchParams, usePathname, useRouter } from "expo-router";
|
||||
import {
|
||||
createContext,
|
||||
use,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
import { createContext, use, useCallback, useMemo, useRef, useState, type ReactNode } from "react";
|
||||
import { useWindowDimensions, View } from "react-native";
|
||||
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
||||
|
||||
import {
|
||||
deriveFileInspectorPaneLayout,
|
||||
@@ -27,7 +17,6 @@ import { resolveThreadSelectionNavigationAction } from "../../lib/adaptive-navig
|
||||
import { buildThreadRoutePath } from "../../lib/routes";
|
||||
import { scopedThreadKey } from "../../lib/scopedEntities";
|
||||
import { ThreadNavigationSidebar } from "../threads/ThreadNavigationSidebar";
|
||||
import { WORKSPACE_PANE_LAYOUT_TRANSITION } from "./workspace-pane-transition";
|
||||
|
||||
interface AdaptiveWorkspaceContextValue {
|
||||
readonly layout: Layout;
|
||||
@@ -86,7 +75,6 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode })
|
||||
const [fileInspectorPreferredVisible, setFileInspectorPreferredVisible] = useState(true);
|
||||
const [focusedAuxiliaryPaneRole, setFocusedAuxiliaryPaneRole] =
|
||||
useState<WorkspaceAuxiliaryPaneRole | null>(null);
|
||||
const sidebarProgress = useSharedValue(1);
|
||||
const params = useGlobalSearchParams<{
|
||||
environmentId?: string | string[];
|
||||
threadId?: string | string[];
|
||||
@@ -181,13 +169,12 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode })
|
||||
],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
sidebarProgress.value = withTiming(panes.primarySidebarVisible ? 1 : 0, { duration: 220 });
|
||||
}, [panes.primarySidebarVisible, sidebarProgress]);
|
||||
const sidebarStyle = useAnimatedStyle(() => ({
|
||||
opacity: sidebarProgress.value,
|
||||
transform: [{ translateX: (sidebarProgress.value - 1) * 24 }],
|
||||
}));
|
||||
const handleOpenSettings = useCallback(() => {
|
||||
router.push("/settings");
|
||||
}, [router]);
|
||||
const handleStartNewTask = useCallback(() => {
|
||||
router.push("/new");
|
||||
}, [router]);
|
||||
|
||||
const handleSelectThread = useCallback(
|
||||
(thread: EnvironmentThreadShell) => {
|
||||
@@ -197,8 +184,10 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode })
|
||||
pathname,
|
||||
});
|
||||
if (navigationAction === "set-params") {
|
||||
// Auxiliary content belongs to the current thread. Close it before
|
||||
// reusing the current native detail screen for a peer thread selection.
|
||||
const nextThreadKey = scopedThreadKey(thread.environmentId, thread.id);
|
||||
if (nextThreadKey === selectedThreadKey) {
|
||||
return;
|
||||
}
|
||||
setFileInspectorPreferredVisible(false);
|
||||
router.setParams({
|
||||
environmentId: String(thread.environmentId),
|
||||
@@ -213,44 +202,36 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode })
|
||||
}
|
||||
router.push(destination);
|
||||
},
|
||||
[layout.usesSplitView, pathname, router],
|
||||
[layout.usesSplitView, pathname, router, selectedThreadKey],
|
||||
);
|
||||
|
||||
return (
|
||||
<AdaptiveWorkspaceContext.Provider value={contextValue}>
|
||||
<View testID="adaptive-workspace-layout" style={{ flex: 1, flexDirection: "row" }}>
|
||||
{layout.usesSplitView && layout.listPaneWidth !== null ? (
|
||||
<Animated.View
|
||||
<View
|
||||
accessibilityElementsHidden={!panes.primarySidebarVisible}
|
||||
collapsable={false}
|
||||
importantForAccessibility={panes.primarySidebarVisible ? "auto" : "no-hide-descendants"}
|
||||
layout={WORKSPACE_PANE_LAYOUT_TRANSITION}
|
||||
pointerEvents={panes.primarySidebarVisible ? "auto" : "none"}
|
||||
style={[
|
||||
{
|
||||
alignSelf: "stretch",
|
||||
overflow: "hidden",
|
||||
width: panes.primarySidebarVisible ? layout.listPaneWidth : 0,
|
||||
},
|
||||
sidebarStyle,
|
||||
]}
|
||||
style={{
|
||||
alignSelf: "stretch",
|
||||
overflow: "hidden",
|
||||
width: panes.primarySidebarVisible ? layout.listPaneWidth : 0,
|
||||
}}
|
||||
>
|
||||
<ThreadNavigationSidebar
|
||||
width={layout.listPaneWidth}
|
||||
selectedThreadKey={selectedThreadKey}
|
||||
onOpenSettings={() => router.push("/settings")}
|
||||
onOpenSettings={handleOpenSettings}
|
||||
onSelectThread={handleSelectThread}
|
||||
onStartNewTask={() => router.push("/new")}
|
||||
onStartNewTask={handleStartNewTask}
|
||||
/>
|
||||
</Animated.View>
|
||||
</View>
|
||||
) : null}
|
||||
<Animated.View
|
||||
collapsable={false}
|
||||
layout={WORKSPACE_PANE_LAYOUT_TRANSITION}
|
||||
style={{ flex: 1 }}
|
||||
>
|
||||
<View collapsable={false} style={{ flex: 1 }}>
|
||||
{props.children}
|
||||
</Animated.View>
|
||||
</View>
|
||||
</View>
|
||||
</AdaptiveWorkspaceContext.Provider>
|
||||
);
|
||||
|
||||
@@ -8,7 +8,6 @@ import Animated, {
|
||||
} from "react-native-reanimated";
|
||||
|
||||
import { useAdaptiveWorkspaceLayout } from "./AdaptiveWorkspaceLayout";
|
||||
import { WORKSPACE_PANE_LAYOUT_TRANSITION } from "./workspace-pane-transition";
|
||||
|
||||
export function AdaptiveInspectorLayout(props: {
|
||||
readonly children: ReactNode;
|
||||
@@ -41,11 +40,7 @@ export function AdaptiveInspectorLayout(props: {
|
||||
|
||||
return (
|
||||
<View className="flex-1 flex-row">
|
||||
<Animated.View
|
||||
collapsable={false}
|
||||
className="min-w-0 flex-1"
|
||||
layout={WORKSPACE_PANE_LAYOUT_TRANSITION}
|
||||
>
|
||||
<Animated.View collapsable={false} className="min-w-0 flex-1">
|
||||
{props.children}
|
||||
</Animated.View>
|
||||
{inspectorSupported ? (
|
||||
@@ -53,7 +48,6 @@ export function AdaptiveInspectorLayout(props: {
|
||||
accessibilityElementsHidden={!inspectorVisible}
|
||||
collapsable={false}
|
||||
importantForAccessibility={inspectorVisible ? "auto" : "no-hide-descendants"}
|
||||
layout={WORKSPACE_PANE_LAYOUT_TRANSITION}
|
||||
pointerEvents={inspectorVisible ? "auto" : "none"}
|
||||
style={[
|
||||
{
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Easing, LinearTransition } from "react-native-reanimated";
|
||||
|
||||
/**
|
||||
* Animates between final Yoga layouts on the UI thread. Keeping pane widths
|
||||
* out of animated styles avoids recalculating the entire workspace on every
|
||||
* display frame while a sidebar or inspector moves.
|
||||
*/
|
||||
export const WORKSPACE_PANE_LAYOUT_TRANSITION = LinearTransition.duration(220).easing(
|
||||
Easing.out(Easing.cubic),
|
||||
);
|
||||
@@ -69,6 +69,7 @@ export interface ThreadDetailScreenProps {
|
||||
readonly selectedThreadQueueCount: number;
|
||||
readonly serverConfig: T3ServerConfig | null;
|
||||
readonly layoutVariant?: LayoutVariant;
|
||||
readonly usesAutomaticContentInsets?: boolean;
|
||||
readonly onOpenDrawer: () => void;
|
||||
readonly onOpenConnectionEditor: () => void;
|
||||
readonly onChangeDraftMessage: (value: string) => void;
|
||||
@@ -387,6 +388,7 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
|
||||
contentBottomInset={estimatedOverlayHeight}
|
||||
contentMaxWidth={contentMaxWidth}
|
||||
layoutVariant={layoutVariant}
|
||||
usesAutomaticContentInsets={props.usesAutomaticContentInsets}
|
||||
skills={selectedProviderSkills}
|
||||
/>
|
||||
</View>
|
||||
|
||||
@@ -38,7 +38,7 @@ import {
|
||||
import { TouchableOpacity } from "react-native-gesture-handler";
|
||||
import ImageViewing from "react-native-image-viewing";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import type { SharedValue } from "react-native-reanimated";
|
||||
import { type SharedValue } from "react-native-reanimated";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
|
||||
import {
|
||||
@@ -108,6 +108,7 @@ export interface ThreadFeedProps {
|
||||
readonly contentBottomInset?: number;
|
||||
readonly contentMaxWidth?: number;
|
||||
readonly layoutVariant?: LayoutVariant;
|
||||
readonly usesAutomaticContentInsets?: boolean;
|
||||
readonly skills?: ReadonlyArray<SelectableMarkdownSkill>;
|
||||
}
|
||||
|
||||
@@ -1156,7 +1157,6 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
|
||||
const insets = useSafeAreaInsets();
|
||||
const topContentInset = props.contentTopInset ?? insets.top + 44;
|
||||
const bottomContentInset = props.contentBottomInset ?? 18;
|
||||
|
||||
const handleViewportLayout = useCallback((event: LayoutChangeEvent) => {
|
||||
const nextWidth = Math.round(event.nativeEvent.layout.width);
|
||||
setViewportWidth((current) => (Math.abs(current - nextWidth) > 1 ? nextWidth : current));
|
||||
@@ -1473,8 +1473,14 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
|
||||
ref={props.listRef}
|
||||
key={props.threadId}
|
||||
style={{ flex: 1 }}
|
||||
contentInsetAdjustmentBehavior="never"
|
||||
automaticallyAdjustsScrollIndicatorInsets={false}
|
||||
scrollIndicatorInsets={{ top: topContentInset, bottom: 0 }}
|
||||
{...(props.usesAutomaticContentInsets
|
||||
? {
|
||||
contentInset: { top: topContentInset, left: 0, right: 0, bottom: 0 },
|
||||
scrollIndicatorInsets: { top: 0, left: 0, right: 0, bottom: 0 },
|
||||
}
|
||||
: { scrollIndicatorInsets: { top: topContentInset, bottom: 0 } })}
|
||||
{...(anchoredEndSpace ? { anchoredEndSpace } : {})}
|
||||
contentInsetEndAdjustment={props.contentInsetEndAdjustment}
|
||||
freeze={props.freeze}
|
||||
@@ -1503,7 +1509,9 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
|
||||
keyboardLiftBehavior="whenAtEnd"
|
||||
estimatedItemSize={180}
|
||||
initialScrollAtEnd
|
||||
ListHeaderComponent={<View style={{ height: topContentInset }} />}
|
||||
ListHeaderComponent={
|
||||
props.usesAutomaticContentInsets ? null : <View style={{ height: topContentInset }} />
|
||||
}
|
||||
contentContainerStyle={{
|
||||
paddingTop: 12,
|
||||
paddingHorizontal: contentHorizontalPadding,
|
||||
|
||||
@@ -71,16 +71,13 @@ const ThreadNavigationRow = memo(function ThreadNavigationRow(props: {
|
||||
primaryAction={primaryAction}
|
||||
threadTitle={thread.title}
|
||||
>
|
||||
{(close) => (
|
||||
{() => (
|
||||
<Pressable
|
||||
accessibilityHint="Swipe left for archive and delete actions"
|
||||
accessibilityLabel={thread.title}
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ selected }}
|
||||
onPress={() => {
|
||||
close();
|
||||
onSelectThread(thread);
|
||||
}}
|
||||
onPress={() => onSelectThread(thread)}
|
||||
style={({ pressed }) => [
|
||||
styles.threadRow,
|
||||
{
|
||||
@@ -144,6 +141,13 @@ export function ThreadNavigationSidebar(props: {
|
||||
openSwipeableRef.current = null;
|
||||
}
|
||||
}, []);
|
||||
const handleSelectThread = useCallback(
|
||||
(thread: EnvironmentThreadShell) => {
|
||||
props.onSelectThread(thread);
|
||||
openSwipeableRef.current?.close();
|
||||
},
|
||||
[props.onSelectThread],
|
||||
);
|
||||
|
||||
return (
|
||||
<View
|
||||
@@ -219,7 +223,7 @@ export function ThreadNavigationSidebar(props: {
|
||||
fullSwipeWidth={props.width - 20}
|
||||
onArchiveThread={archiveThread}
|
||||
onDeleteThread={confirmDeleteThread}
|
||||
onSelectThread={props.onSelectThread}
|
||||
onSelectThread={handleSelectThread}
|
||||
onSwipeableClose={handleSwipeableClose}
|
||||
onSwipeableWillOpen={handleSwipeableWillOpen}
|
||||
pressedBackgroundColor={pressedBackgroundColor}
|
||||
|
||||
@@ -2,9 +2,10 @@ import { Stack, useFocusEffect, useLocalSearchParams, useRouter } from "expo-rou
|
||||
import { useHeaderHeight } from "expo-router/build/react-navigation/elements";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
||||
import * as Option from "effect/Option";
|
||||
import { EnvironmentId, type ProjectScript } from "@t3tools/contracts";
|
||||
import { EnvironmentId, ThreadId, type ProjectScript } from "@t3tools/contracts";
|
||||
import { projectScriptCwd, projectScriptRuntimeEnv } from "@t3tools/shared/projectScripts";
|
||||
import { Pressable, ScrollView, Text as RNText, View } from "react-native";
|
||||
import { Platform, Pressable, ScrollView, Text as RNText, View } from "react-native";
|
||||
import { isLiquidGlassAvailable } from "expo-glass-effect";
|
||||
import { useWorkspaceState } from "../../state/workspace";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
import { useEnvironmentQuery } from "../../state/query";
|
||||
@@ -21,6 +22,7 @@ import {
|
||||
import { scopedThreadKey } from "../../lib/scopedEntities";
|
||||
import { MOBILE_TYPOGRAPHY } from "../../lib/typography";
|
||||
import { connectionTone } from "../connection/connectionTone";
|
||||
import { nativeTopScrollEdgeEffect } from "../../lib/native-scroll-edge-effect";
|
||||
|
||||
import {
|
||||
useRemoteConnections,
|
||||
@@ -70,6 +72,9 @@ interface ThreadInspectorSelection {
|
||||
readonly mode: ThreadInspectorMode;
|
||||
}
|
||||
|
||||
const USES_NATIVE_GLASS_HEADER = Platform.OS === "ios" && isLiquidGlassAvailable();
|
||||
const TOP_SCROLL_EDGE_EFFECT = nativeTopScrollEdgeEffect(Platform.OS, Platform.Version);
|
||||
|
||||
function InspectorPaneRoleActivation() {
|
||||
useAdaptiveWorkspacePaneRole("inspector");
|
||||
return null;
|
||||
@@ -87,6 +92,82 @@ function OpeningThreadLoadingScreen() {
|
||||
return <LoadingScreen message="Opening thread…" messagePlacement="above-spinner" />;
|
||||
}
|
||||
|
||||
interface ThreadRouteScreenProps {
|
||||
readonly onReturnToThread?: () => void;
|
||||
readonly renderInspector?: () => ReactNode;
|
||||
}
|
||||
|
||||
function ThreadUnavailableScreen() {
|
||||
return (
|
||||
<ScrollView
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
contentContainerStyle={{
|
||||
flexGrow: 1,
|
||||
justifyContent: "center",
|
||||
paddingHorizontal: 24,
|
||||
paddingVertical: 32,
|
||||
}}
|
||||
className="bg-screen flex-1"
|
||||
>
|
||||
<EmptyState
|
||||
title="Thread unavailable"
|
||||
detail="This thread is not available in the current mobile snapshot."
|
||||
/>
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
||||
export function ThreadRouteScreen(props: ThreadRouteScreenProps = {}) {
|
||||
const { state: workspaceState } = useWorkspaceState();
|
||||
const { connectionState } = useRemoteConnectionStatus();
|
||||
const { selectedThread } = useThreadSelection();
|
||||
const params = useLocalSearchParams<{
|
||||
environmentId?: string | string[];
|
||||
threadId?: string | string[];
|
||||
}>();
|
||||
const environmentIdRaw = firstRouteParam(params.environmentId);
|
||||
const threadIdRaw = firstRouteParam(params.threadId);
|
||||
const environmentId = environmentIdRaw ? EnvironmentId.make(environmentIdRaw) : null;
|
||||
const routeEnvironmentRuntime = useRemoteEnvironmentRuntime(environmentId);
|
||||
const routeConnectionState =
|
||||
routeEnvironmentRuntime?.connectionState ?? (environmentId ? "available" : connectionState);
|
||||
const routeThreadKey =
|
||||
environmentId !== null && threadIdRaw !== null
|
||||
? scopedThreadKey(environmentId, ThreadId.make(threadIdRaw))
|
||||
: null;
|
||||
const selectedThreadKey =
|
||||
selectedThread === null
|
||||
? null
|
||||
: scopedThreadKey(selectedThread.environmentId, selectedThread.id);
|
||||
const selectedThreadDetailState = useSelectedThreadDetailState();
|
||||
const hasThreadDetail = Option.isSome(selectedThreadDetailState.data);
|
||||
const hasTerminalDetailState =
|
||||
selectedThreadDetailState.status === "deleted" ||
|
||||
Option.isSome(selectedThreadDetailState.error);
|
||||
|
||||
if (environmentId === null || threadIdRaw === null) {
|
||||
return <OpeningThreadLoadingScreen />;
|
||||
}
|
||||
|
||||
if (selectedThread !== null && selectedThreadKey === routeThreadKey) {
|
||||
if (!hasThreadDetail && !hasTerminalDetailState) {
|
||||
return <OpeningThreadLoadingScreen />;
|
||||
}
|
||||
return <ThreadRouteContent {...props} selectedThreadDetailState={selectedThreadDetailState} />;
|
||||
}
|
||||
|
||||
const stillHydrating =
|
||||
workspaceState.isLoadingConnections ||
|
||||
routeConnectionState === "connecting" ||
|
||||
routeConnectionState === "reconnecting";
|
||||
|
||||
if (stillHydrating) {
|
||||
return <OpeningThreadLoadingScreen />;
|
||||
}
|
||||
|
||||
return <ThreadUnavailableScreen />;
|
||||
}
|
||||
|
||||
function ThreadHeaderTitle(props: {
|
||||
readonly foregroundColor: string;
|
||||
readonly secondaryForegroundColor: string;
|
||||
@@ -128,21 +209,19 @@ function ThreadHeaderTitle(props: {
|
||||
);
|
||||
}
|
||||
|
||||
export function ThreadRouteScreen(
|
||||
props: {
|
||||
readonly onReturnToThread?: () => void;
|
||||
readonly renderInspector?: () => ReactNode;
|
||||
} = {},
|
||||
function ThreadRouteContent(
|
||||
props: ThreadRouteScreenProps & {
|
||||
readonly selectedThreadDetailState: ReturnType<typeof useSelectedThreadDetailState>;
|
||||
},
|
||||
) {
|
||||
const { fileInspector, layout, showAuxiliaryPane, toggleAuxiliaryPane } =
|
||||
useAdaptiveWorkspaceLayout();
|
||||
const headerHeight = useHeaderHeight();
|
||||
const { state: workspaceState } = useWorkspaceState();
|
||||
const { connectionState } = useRemoteConnectionStatus();
|
||||
const { onReconnectEnvironment } = useRemoteConnections();
|
||||
const { selectedThread, selectedThreadProject, selectedEnvironmentConnection } =
|
||||
useThreadSelection();
|
||||
const selectedThreadDetailState = useSelectedThreadDetailState();
|
||||
const selectedThreadDetailState = props.selectedThreadDetailState;
|
||||
const selectedThreadDetail = Option.getOrNull(selectedThreadDetailState.data);
|
||||
const { selectedThreadCwd } = useSelectedThreadWorktree();
|
||||
const composer = useThreadComposerState();
|
||||
@@ -208,18 +287,6 @@ export function ThreadRouteScreen(
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" · ");
|
||||
const renderHeaderTitle = useCallback(
|
||||
() => (
|
||||
<ThreadHeaderTitle
|
||||
foregroundColor={foregroundColor}
|
||||
secondaryForegroundColor={secondaryFg}
|
||||
subtitle={headerSubtitle}
|
||||
title={selectedThread?.title ?? ""}
|
||||
/>
|
||||
),
|
||||
[foregroundColor, headerSubtitle, secondaryFg, selectedThread?.title],
|
||||
);
|
||||
|
||||
/* ─── Git status for native header trigger ───────────────────────── */
|
||||
const gitStatus = useEnvironmentQuery(
|
||||
selectedThread !== null && selectedThreadCwd !== null
|
||||
@@ -484,32 +551,7 @@ export function ThreadRouteScreen(
|
||||
}
|
||||
|
||||
if (!selectedThread) {
|
||||
const stillHydrating =
|
||||
workspaceState.isLoadingConnections ||
|
||||
routeConnectionState === "connecting" ||
|
||||
routeConnectionState === "reconnecting";
|
||||
|
||||
if (stillHydrating) {
|
||||
return <OpeningThreadLoadingScreen />;
|
||||
}
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
contentContainerStyle={{
|
||||
flexGrow: 1,
|
||||
justifyContent: "center",
|
||||
paddingHorizontal: 24,
|
||||
paddingVertical: 32,
|
||||
}}
|
||||
className="bg-screen flex-1"
|
||||
>
|
||||
<EmptyState
|
||||
title="Thread unavailable"
|
||||
detail="This thread is not available in the current mobile snapshot."
|
||||
/>
|
||||
</ScrollView>
|
||||
);
|
||||
return <OpeningThreadLoadingScreen />;
|
||||
}
|
||||
|
||||
const selectedThreadKey = scopedThreadKey(selectedThread.environmentId, selectedThread.id);
|
||||
@@ -527,16 +569,37 @@ export function ThreadRouteScreen(
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerShown: true,
|
||||
headerTransparent: true,
|
||||
headerStyle: { backgroundColor: "transparent" },
|
||||
headerShadowVisible: false,
|
||||
headerTransparent: USES_NATIVE_GLASS_HEADER,
|
||||
...(USES_NATIVE_GLASS_HEADER
|
||||
? {}
|
||||
: {
|
||||
headerStyle: { backgroundColor: "transparent" },
|
||||
headerShadowVisible: false,
|
||||
}),
|
||||
headerTintColor: iconColor,
|
||||
headerBackVisible: !layout.usesSplitView,
|
||||
headerBackTitle: "",
|
||||
headerTitle: renderHeaderTitle,
|
||||
scrollEdgeEffects: {
|
||||
// iOS 27 beta currently renders automatic/soft as transparent.
|
||||
// Keep UIKit's subtler automatic style on iOS 26 and use its
|
||||
// native hard edge treatment on iOS 27+.
|
||||
top: TOP_SCROLL_EDGE_EFFECT,
|
||||
bottom: "hidden",
|
||||
left: "hidden",
|
||||
right: "hidden",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
|
||||
<Stack.Screen.Title asChild>
|
||||
<ThreadHeaderTitle
|
||||
foregroundColor={foregroundColor}
|
||||
secondaryForegroundColor={secondaryFg}
|
||||
subtitle={headerSubtitle}
|
||||
title={selectedThread.title}
|
||||
/>
|
||||
</Stack.Screen.Title>
|
||||
|
||||
<WorkspaceSidebarToolbar>
|
||||
{props.onReturnToThread ? (
|
||||
<Stack.Toolbar.Button
|
||||
@@ -603,6 +666,7 @@ export function ThreadRouteScreen(
|
||||
threadCwd={selectedThreadCwd}
|
||||
selectedThreadQueueCount={composer.selectedThreadQueueCount}
|
||||
layoutVariant={layout.variant}
|
||||
usesAutomaticContentInsets={USES_NATIVE_GLASS_HEADER}
|
||||
onOpenDrawer={handleOpenDrawer}
|
||||
onOpenConnectionEditor={handleOpenConnectionEditor}
|
||||
onChangeDraftMessage={composer.onChangeDraftMessage}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { nativeTopScrollEdgeEffect } from "./native-scroll-edge-effect";
|
||||
|
||||
describe("nativeTopScrollEdgeEffect", () => {
|
||||
it("keeps the automatic native treatment on iOS 26", () => {
|
||||
expect(nativeTopScrollEdgeEffect("ios", "26.5")).toBe("automatic");
|
||||
});
|
||||
|
||||
it("uses the native hard treatment on iOS 27 and later", () => {
|
||||
expect(nativeTopScrollEdgeEffect("ios", "27.0")).toBe("hard");
|
||||
expect(nativeTopScrollEdgeEffect("ios", 28)).toBe("hard");
|
||||
});
|
||||
|
||||
it("does not apply the iOS workaround to other platforms", () => {
|
||||
expect(nativeTopScrollEdgeEffect("android", 27)).toBe("automatic");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
export type NativeTopScrollEdgeEffect = "automatic" | "hard";
|
||||
|
||||
function majorVersion(version: number | string): number {
|
||||
if (typeof version === "number") {
|
||||
return Math.trunc(version);
|
||||
}
|
||||
|
||||
const parsed = Number.parseInt(version, 10);
|
||||
return Number.isNaN(parsed) ? 0 : parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* iOS 27 beta currently renders the automatic/soft top scroll-edge effect as
|
||||
* fully transparent. Keep the subtler automatic treatment on iOS 26 and use
|
||||
* UIKit's native hard treatment on iOS 27+ until the platform regression is
|
||||
* resolved.
|
||||
*/
|
||||
export function nativeTopScrollEdgeEffect(
|
||||
os: string,
|
||||
version: number | string,
|
||||
): NativeTopScrollEdgeEffect {
|
||||
return os === "ios" && majorVersion(version) >= 27 ? "hard" : "automatic";
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import { useMemo } from "react";
|
||||
import { EnvironmentId, ThreadId, type ScopedProjectRef } from "@t3tools/contracts";
|
||||
import { useGlobalSearchParams } from "expo-router";
|
||||
import { createContext, createElement, use, useMemo, useRef, type ReactNode } from "react";
|
||||
import {
|
||||
EnvironmentId,
|
||||
ThreadId,
|
||||
type ScopedProjectRef,
|
||||
type ScopedThreadRef,
|
||||
} from "@t3tools/contracts";
|
||||
|
||||
import { useProject, useThreadShell } from "../state/entities";
|
||||
import {
|
||||
@@ -16,12 +21,12 @@ function firstRouteParam(value: string | string[] | undefined): string | null {
|
||||
return value ?? null;
|
||||
}
|
||||
|
||||
export function useThreadSelection() {
|
||||
const params = useLocalSearchParams<{
|
||||
function useResolvedThreadSelection() {
|
||||
const params = useGlobalSearchParams<{
|
||||
environmentId?: string | string[];
|
||||
threadId?: string | string[];
|
||||
}>();
|
||||
const selectedThreadRef = useMemo(() => {
|
||||
const routeThreadRef = useMemo<ScopedThreadRef | null>(() => {
|
||||
const environmentId = firstRouteParam(params.environmentId);
|
||||
const threadId = firstRouteParam(params.threadId);
|
||||
if (!environmentId || !threadId) {
|
||||
@@ -33,6 +38,11 @@ export function useThreadSelection() {
|
||||
threadId: ThreadId.make(threadId),
|
||||
};
|
||||
}, [params.environmentId, params.threadId]);
|
||||
const lastRouteThreadRef = useRef<ScopedThreadRef | null>(null);
|
||||
if (routeThreadRef !== null) {
|
||||
lastRouteThreadRef.current = routeThreadRef;
|
||||
}
|
||||
const selectedThreadRef = routeThreadRef ?? lastRouteThreadRef.current;
|
||||
const selectedThread = useThreadShell(selectedThreadRef);
|
||||
const selectedProjectRef = useMemo<ScopedProjectRef | null>(
|
||||
() =>
|
||||
@@ -49,11 +59,37 @@ export function useThreadSelection() {
|
||||
const selectedEnvironmentConnection = useSavedRemoteConnection(selectedEnvironmentId);
|
||||
const selectedEnvironmentRuntime = useRemoteEnvironmentRuntime(selectedEnvironmentId);
|
||||
|
||||
return {
|
||||
selectedThreadRef,
|
||||
selectedThread,
|
||||
selectedThreadProject,
|
||||
selectedEnvironmentConnection,
|
||||
selectedEnvironmentRuntime,
|
||||
};
|
||||
return useMemo(
|
||||
() => ({
|
||||
selectedThreadRef,
|
||||
selectedThread,
|
||||
selectedThreadProject,
|
||||
selectedEnvironmentConnection,
|
||||
selectedEnvironmentRuntime,
|
||||
}),
|
||||
[
|
||||
selectedEnvironmentConnection,
|
||||
selectedEnvironmentRuntime,
|
||||
selectedThread,
|
||||
selectedThreadProject,
|
||||
selectedThreadRef,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
type ThreadSelectionState = ReturnType<typeof useResolvedThreadSelection>;
|
||||
|
||||
const ThreadSelectionContext = createContext<ThreadSelectionState | null>(null);
|
||||
|
||||
export function ThreadSelectionProvider(props: { readonly children: ReactNode }) {
|
||||
const selection = useResolvedThreadSelection();
|
||||
return createElement(ThreadSelectionContext.Provider, { value: selection }, props.children);
|
||||
}
|
||||
|
||||
export function useThreadSelection(): ThreadSelectionState {
|
||||
const selection = use(ThreadSelectionContext);
|
||||
if (selection === null) {
|
||||
throw new Error("useThreadSelection must be used within ThreadSelectionProvider");
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
Reference in new issue
Block a user