Skip to content
TypeScript

fix(mobile): use native settings and snooze controls (#12512)

Julius Marmingeea15f17afd94
diff --git a/apps/mobile/src/features/settings/appearance/sections/CodeAppearanceSection.tsx b/apps/mobile/src/features/settings/appearance/sections/CodeAppearanceSection.tsx
index bb4bb4d0a8f..6760504bfa2 100644
--- a/apps/mobile/src/features/settings/appearance/sections/CodeAppearanceSection.tsx
+++ b/apps/mobile/src/features/settings/appearance/sections/CodeAppearanceSection.tsx
@@ -26,7 +26,7 @@ export function CodeAppearanceSection() {
);
return (
- <SettingsSection card title="Code & Diffs">
+ <SettingsSection title="Code & Diffs">
<CodeAppearancePreview
fontSize={appearance.codeFontSize}
wordBreak={appearance.codeWordBreak}
diff --git a/apps/mobile/src/features/settings/appearance/sections/TerminalAppearanceSection.tsx b/apps/mobile/src/features/settings/appearance/sections/TerminalAppearanceSection.tsx
index 911e6c307e8..1e8b5a3fbef 100644
--- a/apps/mobile/src/features/settings/appearance/sections/TerminalAppearanceSection.tsx
+++ b/apps/mobile/src/features/settings/appearance/sections/TerminalAppearanceSection.tsx
@@ -26,7 +26,7 @@ export function TerminalAppearanceSection() {
);
return (
- <SettingsSection card title="Terminal">
+ <SettingsSection title="Terminal">
<TerminalAppearancePreview fontSize={appearance.terminalFontSize} />
<AppearancePreviewSeparator />
<SettingsSwitchRow
diff --git a/apps/mobile/src/features/settings/appearance/sections/TextAppearanceSection.tsx b/apps/mobile/src/features/settings/appearance/sections/TextAppearanceSection.tsx
index 6617a75720c..c1424088f8d 100644
--- a/apps/mobile/src/features/settings/appearance/sections/TextAppearanceSection.tsx
+++ b/apps/mobile/src/features/settings/appearance/sections/TextAppearanceSection.tsx
@@ -15,7 +15,7 @@ export function TextAppearanceSection() {
const { isReady, appearance, setBaseFontSize } = useAppearancePreferences();
return (
- <SettingsSection card title="Text">
+ <SettingsSection title="Text">
<TextAppearancePreview fontSize={appearance.baseFontSize} />
<AppearancePreviewSeparator />
<FontSizeSliderRow
diff --git a/apps/mobile/src/features/settings/components/SettingsSection.tsx b/apps/mobile/src/features/settings/components/SettingsSection.tsx
index 954a2b435a3..05276b767fc 100644
--- a/apps/mobile/src/features/settings/components/SettingsSection.tsx
+++ b/apps/mobile/src/features/settings/components/SettingsSection.tsx
@@ -7,8 +7,6 @@ export function SettingsSection(props: {
readonly title?: string;
readonly trailing?: ReactNode;
readonly children: ReactNode;
- /** Force the grouped card background; Android otherwise lists options flat. */
- readonly card?: boolean;
}) {
return (
<View className="gap-2">
@@ -30,9 +28,7 @@ export function SettingsSection(props: {
className={
Platform.OS === "android"
? "overflow-hidden rounded-[28px] bg-card"
- : props.card
- ? "overflow-hidden rounded-[24px] border-continuous bg-card"
- : "overflow-hidden rounded-[24px] border-continuous bg-card android:bg-transparent"
+ : "overflow-hidden rounded-[24px] border-continuous bg-card"
}
>
{props.children}
diff --git a/apps/mobile/src/features/threads/CustomSnoozeSheet.android.tsx b/apps/mobile/src/features/threads/CustomSnoozeSheet.android.tsx
index 85600838881..e066c01b43c 100644
--- a/apps/mobile/src/features/threads/CustomSnoozeSheet.android.tsx
+++ b/apps/mobile/src/features/threads/CustomSnoozeSheet.android.tsx
@@ -1,7 +1,6 @@
import { MaterialSegmentedButtons } from "../../components/MaterialSegmentedButtons.android";
import {
BasicAlertDialog,
- Button,
Column,
DateTimePicker,
Host,
@@ -240,19 +239,16 @@ export function CustomSnoozeSheet(props: Props) {
<Row horizontalArrangement="end" modifiers={[fillMaxWidth()]}>
<TextButton
onClick={props.onClose}
- colors={{ contentColor: colors["--color-primary"] }}
+ colors={{ contentColor: colors["--color-foreground"] }}
>
<Text style={bodyTypography}>Cancel</Text>
</TextButton>
- <Button
+ <TextButton
onClick={submit}
- colors={{
- containerColor: colors["--color-primary"],
- contentColor: colors["--color-primary-foreground"],
- }}
+ colors={{ contentColor: colors["--color-foreground"] }}
>
<Text style={bodyTypography}>Snooze</Text>
- </Button>
+ </TextButton>
</Row>
</Column>
</Column>
diff --git a/apps/mobile/src/features/threads/CustomSnoozeSheet.ios.tsx b/apps/mobile/src/features/threads/CustomSnoozeSheet.ios.tsx
index 20176064be5..c8d9abbc5fa 100644
--- a/apps/mobile/src/features/threads/CustomSnoozeSheet.ios.tsx
+++ b/apps/mobile/src/features/threads/CustomSnoozeSheet.ios.tsx
@@ -1,27 +1,22 @@
import {
- Button,
DatePicker,
Host,
HStack,
Picker,
Popover,
+ RNHostView,
Spacer,
Text,
VStack,
} from "@expo/ui/swift-ui";
import {
- accessibilityAddTraits,
accessibilityHidden,
- buttonBorderShape,
- buttonStyle,
clipped,
- controlSize,
font,
datePickerStyle,
foregroundStyle,
frame,
labelsHidden,
- labelStyle,
padding,
pickerStyle,
tag,
@@ -32,12 +27,17 @@ import {
resolveCustomSnooze,
type CustomSnoozeInput,
} from "@t3tools/client-runtime/state/thread-settled";
-import { useState } from "react";
-import { useWindowDimensions } from "react-native";
+import { useState, type ReactNode } from "react";
+import { NavigationContainer, NavigationIndependentTree } from "@react-navigation/native";
+import { createNativeStackNavigator } from "@react-navigation/native-stack";
+import { ScrollView, useWindowDimensions, View } from "react-native";
+import { useMobileNavigationTheme } from "../../lib/useMobileNavigationTheme";
+import { NativeHeaderToolbar } from "../../native/StackHeader";
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
const durationAmounts = Array.from({ length: 99 }, (_, index) => index + 1);
+const SnoozeStack = createNativeStackNavigator<{ CustomSnooze: undefined }>();
const modes = [
{ value: "date", label: "Date and time" },
{ value: "duration", label: "Duration" },
@@ -52,13 +52,15 @@ export function CustomSnoozeSheet(props: {
readonly onClose: () => void;
readonly onSnooze: (snoozedUntil: string) => void;
}) {
- const { width } = useWindowDimensions();
+ const { width, height } = useWindowDimensions();
const [mode, setMode] = useState<CustomSnoozeInput["mode"]>("date");
const [date, setDate] = useState(() => new Date(Date.now() + 3_600_000));
const [amount, setAmount] = useState(2);
const [unit, setUnit] = useState<"minutes" | "hours" | "days">("hours");
const [error, setError] = useState<string | null>(null);
const { themeVariables: colors, themeAppearance } = useAppearancePreferences();
+ const popoverWidth = Math.min(360, width - 32);
+ const popoverHeight = Math.min(error ? 364 : 324, height - 96);
const updateDate = (value: Date) => {
setDate(value);
setError(null);
@@ -98,133 +100,179 @@ export function CustomSnoozeSheet(props: {
/>
</Popover.Trigger>
<Popover.Content>
- <VStack
- spacing={16}
- modifiers={[padding({ all: 16 }), frame({ width: Math.min(360, width - 32) })]}
+ <SnoozePopoverNavigation
+ width={popoverWidth}
+ height={popoverHeight}
+ onClose={props.onClose}
+ onSubmit={submit}
>
- <HStack spacing={12}>
- <Button
- label="Cancel"
- systemImage="xmark"
- role="cancel"
- onPress={props.onClose}
- modifiers={[
- labelStyle("iconOnly"),
- buttonStyle(NATIVE_LIQUID_GLASS_SUPPORTED ? "glass" : "bordered"),
- buttonBorderShape("circle"),
- controlSize("large"),
- ]}
- />
- <Text
- modifiers={[
- font({ textStyle: "headline" }),
- frame({ maxWidth: Infinity, alignment: "leading" }),
- accessibilityAddTraits(["isHeader"]),
- ]}
- >
- Custom snooze
- </Text>
- <Button
- label="Snooze"
- onPress={submit}
- modifiers={[
- buttonStyle(
- NATIVE_LIQUID_GLASS_SUPPORTED ? "glassProminent" : "borderedProminent",
- ),
- controlSize("large"),
- ]}
- />
- </HStack>
- <Picker
- label="Snooze mode"
- selection={mode}
- onSelectionChange={(value: CustomSnoozeInput["mode"]) => {
- setMode(value);
- setError(null);
- }}
- modifiers={[pickerStyle("segmented")]}
+ <Host
+ matchContents={{ vertical: true }}
+ colorScheme={themeAppearance}
+ style={{ width: popoverWidth }}
>
- {modes.map((option) => (
- <Text key={option.value} modifiers={[tag(option.value)]}>
- {option.label}
- </Text>
- ))}
- </Picker>
- {mode === "date" ? (
- <DatePicker
- title="Snooze until"
- selection={date}
- displayedComponents={["date", "hourAndMinute"]}
- onDateChange={updateDate}
- modifiers={[
- datePickerStyle("wheel"),
- labelsHidden(),
- frame({ maxWidth: Infinity, height: 180 }),
- ]}
- />
- ) : (
- <HStack spacing={0}>
- <Picker
- label="Duration amount"
- selection={amount}
- onSelectionChange={(value: number) => {
- setAmount(value);
- setError(null);
- }}
- modifiers={[
- pickerStyle("wheel"),
- labelsHidden(),
- frame({ minWidth: 0, maxWidth: Infinity, height: 180 }),
- clipped(),
- ]}
- >
- {durationAmounts.map((value) => (
- <Text
- key={value}
- modifiers={[tag(value), foregroundStyle(colors["--color-foreground"])]}
- >
- {String(value)}
- </Text>
- ))}
- </Picker>
+ <VStack
+ spacing={16}
+ modifiers={[padding({ all: 16 }), foregroundStyle(colors["--color-foreground"])]}
+ >
<Picker
- label="Duration unit"
- selection={unit}
- onSelectionChange={(value: typeof unit) => {
- setUnit(value);
+ label="Snooze mode"
+ selection={mode}
+ onSelectionChange={(value: CustomSnoozeInput["mode"]) => {
+ setMode(value);
setError(null);
}}
- modifiers={[
- pickerStyle("wheel"),
- labelsHidden(),
- frame({ minWidth: 0, maxWidth: Infinity, height: 180 }),
- clipped(),
- ]}
+ modifiers={[pickerStyle("segmented")]}
>
- {units.map((option) => (
- <Text
- key={option.value}
- modifiers={[tag(option.value), foregroundStyle(colors["--color-foreground"])]}
- >
+ {modes.map((option) => (
+ <Text key={option.value} modifiers={[tag(option.value)]}>
{option.label}
</Text>
))}
</Picker>
- </HStack>
- )}
- {error ? (
- <Text
- modifiers={[
- font({ textStyle: "footnote" }),
- foregroundStyle(colors["--color-danger-foreground"]),
- ]}
- >
- {error}
- </Text>
- ) : null}
- </VStack>
+ {mode === "date" ? (
+ <DatePicker
+ title="Snooze until"
+ selection={date}
+ displayedComponents={["date", "hourAndMinute"]}
+ onDateChange={updateDate}
+ modifiers={[
+ datePickerStyle("wheel"),
+ labelsHidden(),
+ frame({ maxWidth: Infinity, height: 180 }),
+ ]}
+ />
+ ) : (
+ <HStack spacing={0}>
+ <Picker
+ label="Duration amount"
+ selection={amount}
+ onSelectionChange={(value: number) => {
+ setAmount(value);
+ setError(null);
+ }}
+ modifiers={[
+ pickerStyle("wheel"),
+ labelsHidden(),
+ frame({ minWidth: 0, maxWidth: Infinity, height: 180 }),
+ clipped(),
+ ]}
+ >
+ {durationAmounts.map((value) => (
+ <Text
+ key={value}
+ modifiers={[tag(value), foregroundStyle(colors["--color-foreground"])]}
+ >
+ {String(value)}
+ </Text>
+ ))}
+ </Picker>
+ <Picker
+ label="Duration unit"
+ selection={unit}
+ onSelectionChange={(value: typeof unit) => {
+ setUnit(value);
+ setError(null);
+ }}
+ modifiers={[
+ pickerStyle("wheel"),
+ labelsHidden(),
+ frame({ minWidth: 0, maxWidth: Infinity, height: 180 }),
+ clipped(),
+ ]}
+ >
+ {units.map((option) => (
+ <Text
+ key={option.value}
+ modifiers={[
+ tag(option.value),
+ foregroundStyle(colors["--color-foreground"]),
+ ]}
+ >
+ {option.label}
+ </Text>
+ ))}
+ </Picker>
+ </HStack>
+ )}
+ {error ? (
+ <Text
+ modifiers={[
+ font({ textStyle: "footnote" }),
+ foregroundStyle(colors["--color-danger-foreground"]),
+ ]}
+ >
+ {error}
+ </Text>
+ ) : null}
+ </VStack>
+ </Host>
+ </SnoozePopoverNavigation>
</Popover.Content>
</Popover>
</Host>
);
}
+
+/** The popover owns a native navigation bar, just like the app's sheet screens. */
+function SnoozePopoverNavigation(props: {
+ readonly width: number;
+ readonly height: number;
+ readonly onClose: () => void;
+ readonly onSubmit: () => void;
+ readonly children: ReactNode;
+}) {
+ const navigationTheme = useMobileNavigationTheme();
+ const { themeVariables: colors } = useAppearancePreferences();
+
+ return (
+ <VStack modifiers={[frame({ width: props.width, height: props.height })]}>
+ <RNHostView>
+ <View style={{ width: props.width, height: props.height }}>
+ <NavigationIndependentTree>
+ <NavigationContainer theme={navigationTheme}>
+ <SnoozeStack.Navigator
+ screenOptions={{
+ contentStyle: { backgroundColor: "transparent" },
+ headerShadowVisible: false,
+ headerStyle: {
+ backgroundColor: NATIVE_LIQUID_GLASS_SUPPORTED
+ ? "transparent"
+ : colors["--color-card"],
+ },
+ headerTintColor: colors["--color-foreground"],
+ headerTitleStyle: { fontSize: 17, fontWeight: "700" },
+ headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,
+ title: "Custom snooze",
+ }}
+ >
+ <SnoozeStack.Screen name="CustomSnooze">
+ {() => (
+ <>
+ <NativeHeaderToolbar placement="left">
+ <NativeHeaderToolbar.Button
+ accessibilityLabel="Cancel custom snooze"
+ icon="xmark"
+ onPress={props.onClose}
+ />
+ </NativeHeaderToolbar>
+ <NativeHeaderToolbar placement="right">
+ <NativeHeaderToolbar.Button label="Snooze" onPress={props.onSubmit} />
+ </NativeHeaderToolbar>
+ <ScrollView
+ contentInsetAdjustmentBehavior="automatic"
+ showsVerticalScrollIndicator={false}
+ >
+ {props.children}
+ </ScrollView>
+ </>
+ )}
+ </SnoozeStack.Screen>
+ </SnoozeStack.Navigator>
+ </NavigationContainer>
+ </NavigationIndependentTree>
+ </View>
+ </RNHostView>
+ </VStack>
+ );
+}
diff --git a/apps/mobile/src/features/threads/CustomSnoozeSheet.shared.tsx b/apps/mobile/src/features/threads/CustomSnoozeSheet.shared.tsx
index 9278bb6b941..5fc60bc05df 100644
--- a/apps/mobile/src/features/threads/CustomSnoozeSheet.shared.tsx
+++ b/apps/mobile/src/features/threads/CustomSnoozeSheet.shared.tsx
@@ -152,7 +152,7 @@ export function CustomSnoozeSheet(props: {
</Pressable>
<Pressable
accessibilityRole="button"
- className="min-h-12 justify-center rounded-xl bg-primary px-3"
+ className="min-h-12 justify-center rounded-xl bg-subtle px-3"
onPress={() => {
const input: CustomSnoozeInput =
mode === "date"
@@ -171,7 +171,7 @@ export function CustomSnoozeSheet(props: {
props.onClose();
}}
>
- <AppText className="text-primary-foreground">Snooze</AppText>
+ <AppText className="text-foreground">Snooze</AppText>
</Pressable>
</View>
</ScrollView>
diff --git a/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx b/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
index b8411229a8a..7be5dc4bbdb 100644
--- a/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
+++ b/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
@@ -9,7 +9,6 @@ import type {
import type { LegendListRenderItemProps } from "@legendapp/list/react-native";
import { useAtomSet, useAtomValue } from "@effect/atom-react";
import { AnimatedLegendList } from "@legendapp/list/reanimated";
-import { HeaderHeightContext } from "@react-navigation/elements";
import {
getProviderOptionCurrentLabel,
getProviderOptionCurrentValue,
@@ -31,13 +30,22 @@ import {
useState,
type ReactNode,
} from "react";
-import { Alert, Platform, Pressable, ScrollView, TextInput, View } from "react-native";
+import {
+ Alert,
+ Platform,
+ Pressable,
+ RefreshControl,
+ ScrollView,
+ TextInput,
+ View,
+} from "react-native";
import Animated, { FadeIn, FadeOut, LinearTransition } from "react-native-reanimated";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { SymbolView } from "../../components/AppSymbol";
import { AppText as Text } from "../../components/AppText";
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
+import { AndroidAnchoredMenu } from "../../components/AndroidAnchoredMenu";
import { MaterialButton } from "../../components/MaterialButton";
import { MaterialIconButton } from "../../components/MaterialIconButton";
import { ProviderIcon } from "../../components/ProviderIcon";
@@ -759,12 +767,27 @@ function ThreadSettingsMainContent(props: {
readonly onOpenSubmenu: (submenu: ThreadSettingsSubmenuPage) => void;
}) {
const session = useThreadSettingsSession();
+ const refreshProvidersCommand = useAtomCommand(serverEnvironment.refreshProviders, {
+ reportFailure: false,
+ });
+ const refreshProviderCatalog = useMemo(
+ () => createProviderCatalogRefreshRunner(refreshProvidersCommand),
+ [refreshProvidersCommand],
+ );
+ const [isRefreshingProviders, setIsRefreshingProviders] = useState(false);
+ const refreshProviders = useCallback(() => {
+ if (!session.environmentId || isRefreshingProviders) return;
+ setIsRefreshingProviders(true);
+ void refreshProviderCatalog(session.environmentId).then((result) => {
+ setIsRefreshingProviders(false);
+ const error = providerCatalogRefreshError(result);
+ if (error) Alert.alert("Could not refresh models", error);
+ });
+ }, [isRefreshingProviders, refreshProviderCatalog, session.environmentId]);
const catalogItems = useThreadSettingsCatalogItems(session);
const [animationsReady, setAnimationsReady] = useState(false);
- const nativeHeaderHeight = use(HeaderHeightContext) ?? 0;
const hasActiveCatalogFilter =
session.providerFilter !== null || session.searchQuery.trim().length > 0;
- const usesTransparentNativeHeader = Platform.OS === "ios" && NATIVE_LIQUID_GLASS_SUPPORTED;
const listItems = useMemo<ReadonlyArray<ThreadSettingsCatalogItem>>(
() => [
...(catalogItems.length === 0 ? ([{ kind: "empty", key: "empty" }] as const) : catalogItems),
@@ -830,6 +853,7 @@ function ThreadSettingsMainContent(props: {
return (
<AnimatedLegendList
+ alwaysBounceVertical
automaticallyAdjustsScrollIndicatorInsets
className="flex-1 bg-sheet"
style={
@@ -838,7 +862,7 @@ function ThreadSettingsMainContent(props: {
: undefined
}
contentContainerStyle={{ paddingTop: 4 }}
- contentInsetAdjustmentBehavior={usesTransparentNativeHeader ? "never" : "automatic"}
+ contentInsetAdjustmentBehavior="automatic"
data={listItems}
estimatedItemSize={Platform.OS === "android" ? 56 : 48}
extraData={animationsReady}
@@ -850,7 +874,6 @@ function ThreadSettingsMainContent(props: {
maintainVisibleContentPosition={THREAD_SETTINGS_MAINTAIN_VISIBLE_CONTENT_POSITION}
ListHeaderComponent={
<>
- {usesTransparentNativeHeader ? <View style={{ height: nativeHeaderHeight }} /> : null}
{Platform.OS === "android" ? (
<View className="px-4 pb-2 pt-3">
<View
@@ -886,43 +909,16 @@ function ThreadSettingsMainContent(props: {
/>
) : null}
</View>
- <View className="flex-row gap-2 pt-3">
- <Pressable
- accessibilityRole="button"
- accessibilityState={{
- selected: session.providerFilter !== FAVORITES_PROVIDER_FILTER,
- }}
- className={cn(
- "rounded-full px-4 py-2",
- session.providerFilter !== FAVORITES_PROVIDER_FILTER
- ? "bg-subtle-strong"
- : "bg-subtle",
- )}
- onPress={() => session.setProviderFilter(null)}
- >
- <Text className="text-sm font-t3-medium text-foreground">All</Text>
- </Pressable>
- <Pressable
- accessibilityRole="button"
- accessibilityState={{
- selected: session.providerFilter === FAVORITES_PROVIDER_FILTER,
- }}
- className={cn(
- "rounded-full px-4 py-2",
- session.providerFilter === FAVORITES_PROVIDER_FILTER
- ? "bg-subtle-strong"
- : "bg-subtle",
- )}
- onPress={() => session.setProviderFilter(FAVORITES_PROVIDER_FILTER)}
- >
- <Text className="text-sm font-t3-medium text-foreground">Favorites</Text>
- </Pressable>
- </View>
</View>
) : null}
</>
}
recycleItems
+ refreshControl={
+ session.environmentId ? (
+ <RefreshControl refreshing={isRefreshingProviders} onRefresh={refreshProviders} />
+ ) : undefined
+ }
onLoad={() => setAnimationsReady(true)}
renderItem={renderCatalogItem}
showsVerticalScrollIndicator={false}
@@ -1042,27 +1038,22 @@ function ThreadSettingsModelsScreen() {
const navigation = useNavigation<NativeStackNavigationProp<ThreadSettingsPickerStackParams>>();
const usesNativeMailSearchToolbar = Platform.OS === "ios" && NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED;
const hasCustomCatalogFilter = session.providerFilter !== null || session.showLegacy;
- const refreshProvidersCommand = useAtomCommand(serverEnvironment.refreshProviders, {
- reportFailure: false,
- });
- const refreshProviderCatalog = useMemo(
- () => createProviderCatalogRefreshRunner(refreshProvidersCommand),
- [refreshProvidersCommand],
- );
- const [isRefreshingProviders, setIsRefreshingProviders] = useState(false);
- const refreshProviders = useCallback(() => {
- if (!session.environmentId || isRefreshingProviders) return;
- setIsRefreshingProviders(true);
- void refreshProviderCatalog(session.environmentId).then((result) => {
- setIsRefreshingProviders(false);
- const error = providerCatalogRefreshError(result);
- if (error) Alert.alert("Could not refresh models", error);
- });
- }, [isRefreshingProviders, refreshProviderCatalog, session.environmentId]);
const commitAndClose = useCallback(() => {
if (!session.commitPendingModel()) return;
presentation.onClose();
}, [presentation, session]);
+ const providerFilters = useMemo(
+ () => [
+ { id: "all-providers", title: "All providers", value: null },
+ { id: "favorites", title: "Favorites", value: FAVORITES_PROVIDER_FILTER },
+ ...session.providerGroups.map((group) => ({
+ id: `provider:${group.providerKey}`,
+ title: group.providerLabel,
+ value: group.providerKey,
+ })),
+ ],
+ [session.providerGroups],
+ );
const filterMenu = useMemo(
() => ({
title: "Model filters",
@@ -1070,30 +1061,12 @@ function ThreadSettingsModelsScreen() {
{
type: "submenu" as const,
title: "Provider",
- items: [
- {
- type: "action" as const,
- title: "All providers",
- state: session.providerFilter === null ? ("on" as const) : ("off" as const),
- onPress: () => session.setProviderFilter(null),
- },
- {
- type: "action" as const,
- title: "Favorites",
- state:
- session.providerFilter === FAVORITES_PROVIDER_FILTER
- ? ("on" as const)
- : ("off" as const),
- onPress: () => session.setProviderFilter(FAVORITES_PROVIDER_FILTER),
- },
- ...session.providerGroups.map((group) => ({
- type: "action" as const,
- title: group.providerLabel,
- state:
- session.providerFilter === group.providerKey ? ("on" as const) : ("off" as const),
- onPress: () => session.setProviderFilter(group.providerKey),
- })),
- ],
+ items: providerFilters.map((filter) => ({
+ type: "action" as const,
+ title: filter.title,
+ state: session.providerFilter === filter.value ? ("on" as const) : ("off" as const),
+ onPress: () => session.setProviderFilter(filter.value),
+ })),
},
...(session.hasLegacyModels
? [
@@ -1107,25 +1080,59 @@ function ThreadSettingsModelsScreen() {
: []),
],
}),
- [session],
+ [providerFilters, session],
);
return (
<>
{Platform.OS === "android" ? (
<AndroidScreenHeader
- actions={[
- {
- accessibilityLabel: "Refresh models",
- disabled: isRefreshingProviders || session.environmentId === null,
- icon: "arrow.clockwise",
- onPress: refreshProviders,
- },
- ]}
trailing={
- session.pendingModel ? (
- <MaterialButton label="Save" tone="text" onPress={commitAndClose} />
- ) : undefined
+ <View className="flex-row items-center">
+ <AndroidAnchoredMenu
+ title="Model filters"
+ actions={[
+ {
+ title: "Provider",
+ subactions: providerFilters.map((filter) => ({
+ id: filter.id,
+ title: filter.title,
+ state: session.providerFilter === filter.value ? "on" : "off",
+ })),
+ },
+ ...(session.hasLegacyModels
+ ? [
+ {
+ id: "show-legacy",
+ title: "Show legacy models",
+ state: session.showLegacy ? ("on" as const) : ("off" as const),
+ },
+ ]
+ : []),
+ ]}
+ onPressAction={({ nativeEvent }) => {
+ if (nativeEvent.event === "show-legacy") {
+ session.setShowLegacy(!session.showLegacy);
+ } else {
+ const filter = providerFilters.find((item) => item.id === nativeEvent.event);
+ if (filter) session.setProviderFilter(filter.value);
+ }
+ }}
+ >
+ {(open) => (
+ <MaterialIconButton
+ accessibilityLabel="Filter models"
+ icon="line.3.horizontal.decrease"
+ selected={hasCustomCatalogFilter}
+ variant={hasCustomCatalogFilter ? "tonal" : "standard"}
+ onPress={open}
+ />
+ )}
+ </AndroidAnchoredMenu>
+ {session.pendingModel ? (
+ <MaterialButton label="Save" tone="text" onPress={commitAndClose} />
+ ) : null}
+ </View>
}
onBack={presentation.onClose}
title="Thread settings"
@@ -1189,13 +1196,6 @@ function ThreadSettingsModelsScreen() {
/>
</NativeHeaderToolbar>
<NativeHeaderToolbar placement="right">
- <NativeHeaderToolbar.Button
- accessibilityLabel="Refresh models"
- disabled={isRefreshingProviders || session.environmentId === null}
- icon="arrow.clockwise"
- onPress={refreshProviders}
- separateBackground
- />
<NativeHeaderToolbar.Button
accessibilityLabel={session.pendingModel ? "Save thread settings" : "Done"}
label={session.pendingModel ? "Save" : "Done"}
diff --git a/apps/mobile/src/features/threads/provider-catalog-refresh.ts b/apps/mobile/src/features/threads/provider-catalog-refresh.ts
index 9c0078b0328..de2b1205477 100644
--- a/apps/mobile/src/features/threads/provider-catalog-refresh.ts
+++ b/apps/mobile/src/features/threads/provider-catalog-refresh.ts
@@ -10,7 +10,7 @@ type RefreshProvidersTarget = {
readonly input: { readonly refreshModels: true };
};
-/** Explicit model-picker refresh. Repeated taps share the pending discovery. */
+/** Pull-to-refresh in the model picker shares any pending discovery. */
export function createProviderCatalogRefreshRunner<Result>(
refreshProviders: (target: RefreshProvidersTarget) => Promise<Result>,
) {
diff --git a/apps/mobile/src/features/usage/UsageRouteScreen.tsx b/apps/mobile/src/features/usage/UsageRouteScreen.tsx
index af45e9eefb2..d1bec8cbc14 100644
--- a/apps/mobile/src/features/usage/UsageRouteScreen.tsx
+++ b/apps/mobile/src/features/usage/UsageRouteScreen.tsx
@@ -412,7 +412,7 @@ function ProviderSection(props: {
);
return (
- <SettingsSection title="Providers" card>
+ <SettingsSection title="Providers">
{ordered.map((provider, index) => {
const share = metric === "cost" ? provider.costShare : provider.tokenShare;
return (
@@ -463,7 +463,7 @@ function TotalsSection(props: { readonly merged: MergedUsage; readonly isPast24H
const cachedShare = observedInput === 0 ? 0 : merged.cachedInputTokens / observedInput;
return (
- <SettingsSection title="Totals" card>
+ <SettingsSection title="Totals">
<View className="flex-row flex-wrap">
<MetricCell
label="Processed tokens"
@@ -524,7 +524,7 @@ function ModelsSection(props: { readonly merged: MergedUsage }) {
if (merged.models.length === 0) return null;
return (
- <SettingsSection title="By model" card>
+ <SettingsSection title="By model">
{merged.models.map((model, index) => (
<View
key={`${model.provider}:${model.model}`}