Stop forcing native glass debug route

This commit is contained in:
Julius Marminge committed 2026-06-30 00:18:38 -07:00
1 parent a0e0b6ef71
commit f5d4d7b63c
2 files changed
+140 -98

No files matched your search

+9 -43
View File
@@ -4,17 +4,10 @@ import {
DMSans_700Bold,
useFonts,
} from "@expo-google-fonts/dm-sans";
import { usePathname, useRouter } from "expo-router";
import { usePathname } from "expo-router";
import Stack from "expo-router/stack";
import { useCallback, useEffect } from "react";
import {
LogBox,
Platform,
Settings,
StatusBar,
useColorScheme,
useWindowDimensions,
} from "react-native";
import { useCallback } from "react";
import { StatusBar, useColorScheme, useWindowDimensions } from "react-native";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { KeyboardProvider } from "react-native-keyboard-controller";
import { SafeAreaProvider } from "react-native-safe-area-context";
@@ -39,16 +32,7 @@ import { deriveStableFormSheetDetent } from "../lib/layout";
import { useThemeColor } from "../lib/useThemeColor";
import { HardwareKeyboardCommandProvider } from "../features/keyboard/HardwareKeyboardCommandProvider";
const debugLaunchRoute =
__DEV__ && Platform.OS === "ios" ? Settings.get("T3DebugRoute") : undefined;
if (debugLaunchRoute !== "/debug/rns-glass") {
require("../../global.css");
}
if (debugLaunchRoute === "/debug/rns-glass") {
LogBox.ignoreAllLogs(true);
}
require("../../global.css");
function AppNavigator() {
const pathname = usePathname();
@@ -64,24 +48,16 @@ function AppNavigator() {
function AppNavigatorContent() {
const pathname = usePathname();
const isDebugRoute = pathname.startsWith("/debug/") || debugLaunchRoute === "/debug/rns-glass";
const isDebugRoute = pathname.startsWith("/debug/");
if (isDebugRoute) {
return <DebugNavigatorHost pathname={pathname} />;
return <DebugNavigatorHost />;
}
return <WorkspaceNavigatorHost pathname={pathname} />;
return <WorkspaceNavigatorHost />;
}
function DebugNavigatorHost(props: { readonly pathname: string }) {
const router = useRouter();
useEffect(() => {
if (debugLaunchRoute === "/debug/rns-glass" && props.pathname !== "/debug/rns-glass") {
router.replace("/debug/rns-glass" as never);
}
}, [props.pathname, router]);
function DebugNavigatorHost() {
return (
<>
<StatusBar barStyle="light-content" backgroundColor="transparent" translucent />
@@ -99,22 +75,12 @@ function DebugNavigatorHost(props: { readonly pathname: string }) {
);
}
function WorkspaceNavigatorHost(props: { readonly pathname: string }) {
function WorkspaceNavigatorHost() {
const colorScheme = useColorScheme();
const pathname = props.pathname;
const router = useRouter();
const statusBarBg = useThemeColor("--color-status-bar");
useAgentNotificationNavigation();
useThreadOutboxDrain();
useEffect(() => {
if (!__DEV__ || Platform.OS !== "ios") return;
const debugRoute = Settings.get("T3DebugRoute");
if (typeof debugRoute !== "string" || debugRoute.length === 0 || pathname === debugRoute)
return;
router.replace(debugRoute as never);
}, [pathname, router]);
return (
<>
<StatusBar
@@ -10,6 +10,7 @@ import { SymbolView } from "expo-symbols";
import { useCallback, useRef } from "react";
import {
ActivityIndicator,
Platform,
Pressable,
RefreshControl,
ScrollView,
@@ -57,79 +58,153 @@ function ArchivedThreadsHeader(props: {
readonly selectedEnvironmentId: EnvironmentId | null;
readonly sortOrder: ArchivedThreadSortOrder;
readonly onEnvironmentChange: (environmentId: EnvironmentId | null) => void;
readonly onRefresh: () => void;
readonly onSearchQueryChange: (query: string) => void;
readonly onSortOrderChange: (sortOrder: ArchivedThreadSortOrder) => void;
}) {
const { width } = useWindowDimensions();
const hasCustomFilter = props.selectedEnvironmentId !== null || props.sortOrder !== "newest";
const usesNativeMailToolbar = Platform.OS === "ios" && width < 700;
const archiveFilterMenu = {
title: "Archived thread options",
items: [
{
type: "submenu" as const,
title: "Environment",
items: [
{
type: "action" as const,
title: "All environments",
state: props.selectedEnvironmentId === null ? ("on" as const) : ("off" as const),
onPress: () => props.onEnvironmentChange(null),
},
...props.environments.map((environment) => ({
type: "action" as const,
title: environment.label,
state:
props.selectedEnvironmentId === environment.environmentId
? ("on" as const)
: ("off" as const),
onPress: () => props.onEnvironmentChange(environment.environmentId),
})),
],
},
{
type: "submenu" as const,
title: "Sort by archived date",
items: [
{
type: "action" as const,
title: "Newest first",
state: props.sortOrder === "newest" ? ("on" as const) : ("off" as const),
onPress: () => props.onSortOrderChange("newest"),
},
{
type: "action" as const,
title: "Oldest first",
state: props.sortOrder === "oldest" ? ("on" as const) : ("off" as const),
onPress: () => props.onSortOrderChange("oldest"),
},
],
},
],
};
return (
<>
<Stack.Screen
options={{
title: "Archived Threads",
headerSearchBarOptions: {
autoCapitalize: "none",
hideNavigationBar: false,
obscureBackground: false,
placeholder: "Search archived threads",
placement: "stacked",
onChangeText: (event) => {
props.onSearchQueryChange(event.nativeEvent.text);
},
onCancelButtonPress: () => {
props.onSearchQueryChange("");
},
},
headerTransparent: usesNativeMailToolbar,
headerStyle: usesNativeMailToolbar ? { backgroundColor: "transparent" } : undefined,
headerShadowVisible: usesNativeMailToolbar ? false : undefined,
unstable_navigationItemStyle: usesNativeMailToolbar ? "editor" : undefined,
unstable_headerToolbarItems: usesNativeMailToolbar
? () => [
{
composeButtonId: "archived-refresh",
composeSystemImageName: "arrow.clockwise",
filterMenu: archiveFilterMenu,
filterButtonId: "archived-filter",
filterSystemImageName: hasCustomFilter
? "line.3.horizontal.decrease.circle.fill"
: "line.3.horizontal.decrease",
onComposePress: props.onRefresh,
onSearchTextChange: props.onSearchQueryChange,
placeholder: "Search",
searchTextChangeId: "archived-search-text",
type: "mailSearchToolbar",
useFallbackSearchField: true,
},
]
: undefined,
headerSearchBarOptions: usesNativeMailToolbar
? undefined
: {
autoCapitalize: "none",
hideNavigationBar: false,
obscureBackground: false,
placeholder: "Search archived threads",
placement: "stacked",
onChangeText: (event) => {
props.onSearchQueryChange(event.nativeEvent.text);
},
onCancelButtonPress: () => {
props.onSearchQueryChange("");
},
},
}}
/>
<Stack.Toolbar placement="right">
<Stack.Toolbar.Menu
accessibilityLabel="Filter and sort archived threads"
icon={
hasCustomFilter
? "line.3.horizontal.decrease.circle.fill"
: "line.3.horizontal.decrease.circle"
}
separateBackground
title="Archived thread options"
>
<Stack.Toolbar.Menu title="Environment">
<Stack.Toolbar.Label>Environment</Stack.Toolbar.Label>
<Stack.Toolbar.MenuAction
isOn={props.selectedEnvironmentId === null}
onPress={() => props.onEnvironmentChange(null)}
>
<Stack.Toolbar.Label>All environments</Stack.Toolbar.Label>
</Stack.Toolbar.MenuAction>
{props.environments.map((environment) => (
{usesNativeMailToolbar ? null : (
<Stack.Toolbar placement="right">
<Stack.Toolbar.Menu
accessibilityLabel="Filter and sort archived threads"
icon={
hasCustomFilter
? "line.3.horizontal.decrease.circle.fill"
: "line.3.horizontal.decrease.circle"
}
separateBackground
title="Archived thread options"
>
<Stack.Toolbar.Menu title="Environment">
<Stack.Toolbar.Label>Environment</Stack.Toolbar.Label>
<Stack.Toolbar.MenuAction
key={environment.environmentId}
isOn={props.selectedEnvironmentId === environment.environmentId}
onPress={() => props.onEnvironmentChange(environment.environmentId)}
isOn={props.selectedEnvironmentId === null}
onPress={() => props.onEnvironmentChange(null)}
>
<Stack.Toolbar.Label>{environment.label}</Stack.Toolbar.Label>
<Stack.Toolbar.Label>All environments</Stack.Toolbar.Label>
</Stack.Toolbar.MenuAction>
))}
</Stack.Toolbar.Menu>
{props.environments.map((environment) => (
<Stack.Toolbar.MenuAction
key={environment.environmentId}
isOn={props.selectedEnvironmentId === environment.environmentId}
onPress={() => props.onEnvironmentChange(environment.environmentId)}
>
<Stack.Toolbar.Label>{environment.label}</Stack.Toolbar.Label>
</Stack.Toolbar.MenuAction>
))}
</Stack.Toolbar.Menu>
<Stack.Toolbar.Menu title="Sort by archived date">
<Stack.Toolbar.Label>Sort by archived date</Stack.Toolbar.Label>
<Stack.Toolbar.MenuAction
isOn={props.sortOrder === "newest"}
onPress={() => props.onSortOrderChange("newest")}
>
<Stack.Toolbar.Label>Newest first</Stack.Toolbar.Label>
</Stack.Toolbar.MenuAction>
<Stack.Toolbar.MenuAction
isOn={props.sortOrder === "oldest"}
onPress={() => props.onSortOrderChange("oldest")}
>
<Stack.Toolbar.Label>Oldest first</Stack.Toolbar.Label>
</Stack.Toolbar.MenuAction>
<Stack.Toolbar.Menu title="Sort by archived date">
<Stack.Toolbar.Label>Sort by archived date</Stack.Toolbar.Label>
<Stack.Toolbar.MenuAction
isOn={props.sortOrder === "newest"}
onPress={() => props.onSortOrderChange("newest")}
>
<Stack.Toolbar.Label>Newest first</Stack.Toolbar.Label>
</Stack.Toolbar.MenuAction>
<Stack.Toolbar.MenuAction
isOn={props.sortOrder === "oldest"}
onPress={() => props.onSortOrderChange("oldest")}
>
<Stack.Toolbar.Label>Oldest first</Stack.Toolbar.Label>
</Stack.Toolbar.MenuAction>
</Stack.Toolbar.Menu>
</Stack.Toolbar.Menu>
</Stack.Toolbar.Menu>
</Stack.Toolbar>
</Stack.Toolbar>
)}
</>
);
}
@@ -361,6 +436,7 @@ export function ArchivedThreadsScreen(props: {
<ArchivedThreadsHeader
environments={props.environments}
onEnvironmentChange={props.onEnvironmentChange}
onRefresh={props.onRefresh}
onSearchQueryChange={props.onSearchQueryChange}
onSortOrderChange={props.onSortOrderChange}
selectedEnvironmentId={props.selectedEnvironmentId}