Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02ed33118c | ||
|
|
e9921b0231 | ||
|
|
73cc66ff74 | ||
|
|
021853bc73 |
No files matched your search
+11
-11
@@ -100,13 +100,13 @@
|
||||
|
||||
@variant dark {
|
||||
/* Page backgrounds */
|
||||
--color-screen: #0a0a0a;
|
||||
--color-sheet: rgba(14, 14, 14, 0.98);
|
||||
--color-screen: #000000;
|
||||
--color-sheet: rgba(6, 6, 7, 0.98);
|
||||
|
||||
/* Card / surface */
|
||||
--color-card: #171717;
|
||||
--color-card-alt: #1c1c1c;
|
||||
--color-card-translucent: rgba(17, 17, 17, 0.8);
|
||||
--color-card: #111113;
|
||||
--color-card-alt: #171719;
|
||||
--color-card-translucent: rgba(13, 13, 15, 0.92);
|
||||
|
||||
/* Text */
|
||||
--color-foreground: #f5f5f5;
|
||||
@@ -143,7 +143,7 @@
|
||||
--color-danger-foreground: #fca5a5;
|
||||
|
||||
/* Inputs */
|
||||
--color-input: #141414;
|
||||
--color-input: #0d0d0f;
|
||||
--color-input-border: rgba(255, 255, 255, 0.08);
|
||||
--color-sidebar-search: rgba(118, 118, 128, 0.24);
|
||||
--color-placeholder: #8e8e93;
|
||||
@@ -154,13 +154,13 @@
|
||||
--color-icon-subtle: #8e8e93;
|
||||
|
||||
/* Header / glass chrome */
|
||||
--color-header: rgba(10, 10, 10, 0.97);
|
||||
--color-header: rgba(0, 0, 0, 0.97);
|
||||
--color-header-border: rgba(255, 255, 255, 0.06);
|
||||
--color-glass-surface: rgba(23, 23, 23, 0.78);
|
||||
--color-glass-tint: rgba(23, 23, 23, 0.24);
|
||||
--color-glass-surface: rgba(13, 13, 15, 0.92);
|
||||
--color-glass-tint: rgba(13, 13, 15, 0.24);
|
||||
|
||||
/* StatusBar */
|
||||
--color-status-bar: #0a0a0a;
|
||||
--color-status-bar: #000000;
|
||||
|
||||
/* Markdown */
|
||||
--color-md-body: #e5e5e5;
|
||||
@@ -183,7 +183,7 @@
|
||||
|
||||
/* Drawer / modal backdrop */
|
||||
--color-backdrop: rgba(0, 0, 0, 0.48);
|
||||
--color-drawer: rgba(14, 14, 14, 0.99);
|
||||
--color-drawer: rgba(6, 6, 7, 0.99);
|
||||
--color-drawer-shadow: rgba(0, 0, 0, 0.32);
|
||||
|
||||
/* Misc */
|
||||
|
||||
@@ -50,6 +50,7 @@ import {
|
||||
IconMinus,
|
||||
IconNetwork,
|
||||
IconPalette,
|
||||
IconPaperclip,
|
||||
IconPin,
|
||||
IconPinnedOff,
|
||||
IconPlayerPlay,
|
||||
@@ -61,6 +62,8 @@ import {
|
||||
IconServer,
|
||||
IconSettings,
|
||||
IconSparkles,
|
||||
IconStar,
|
||||
IconStarFilled,
|
||||
IconLayoutSidebarRight,
|
||||
IconTerminal2,
|
||||
IconTextDecrease,
|
||||
@@ -122,6 +125,7 @@ const ANDROID_ICON_BY_SF_SYMBOL: Partial<Record<SFSymbol, Icon>> = {
|
||||
"line.3.horizontal.decrease.circle.fill": IconFilter,
|
||||
magnifyingglass: IconSearch,
|
||||
paintbrush: IconPalette,
|
||||
paperclip: IconPaperclip,
|
||||
"person.crop.circle": IconUserCircle,
|
||||
pin: IconPin,
|
||||
"pin.slash": IconPinnedOff,
|
||||
@@ -137,6 +141,8 @@ const ANDROID_ICON_BY_SF_SYMBOL: Partial<Record<SFSymbol, Icon>> = {
|
||||
"slider.horizontal.3": IconAdjustmentsHorizontal,
|
||||
"square.and.pencil": IconEdit,
|
||||
"square.split.2x1": IconLayoutColumns,
|
||||
star: IconStar,
|
||||
"star.fill": IconStarFilled,
|
||||
"stop.fill": IconPlayerStopFilled,
|
||||
terminal: IconTerminal2,
|
||||
"text.bubble": IconMessage,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import Constants from "expo-constants";
|
||||
import type {
|
||||
NativeStackHeaderItem,
|
||||
NativeStackNavigationOptions,
|
||||
@@ -8,7 +7,6 @@ import { Platform, View } from "react-native";
|
||||
import { AppText as Text } from "./AppText";
|
||||
import { T3Wordmark } from "./T3Wordmark";
|
||||
import { IPAD_HOME_TITLE_OFFSET } from "../lib/layoutMetrics";
|
||||
import { resolveMobileStageLabel } from "../lib/mobileBranding";
|
||||
import { useThemeColor } from "../lib/useThemeColor";
|
||||
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../native/native-glass";
|
||||
|
||||
@@ -26,8 +24,6 @@ export function CompactBrandTitle(
|
||||
) {
|
||||
const iconColor = useThemeColor("--color-icon");
|
||||
const mutedColor = useThemeColor("--color-foreground-muted");
|
||||
const subtleColor = useThemeColor("--color-subtle");
|
||||
const stageLabel = resolveMobileStageLabel(Constants.expoConfig?.extra?.appVariant);
|
||||
const titleOffset =
|
||||
Platform.OS !== "ios"
|
||||
? 0
|
||||
@@ -48,7 +44,7 @@ export function CompactBrandTitle(
|
||||
style={{
|
||||
alignItems: "center",
|
||||
flexDirection: "row",
|
||||
gap: 6,
|
||||
gap: 4,
|
||||
marginLeft: titleOffset,
|
||||
}}
|
||||
>
|
||||
@@ -63,26 +59,6 @@ export function CompactBrandTitle(
|
||||
>
|
||||
Code
|
||||
</Text>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: subtleColor,
|
||||
borderRadius: 999,
|
||||
paddingHorizontal: 6,
|
||||
paddingVertical: 2,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
color: mutedColor,
|
||||
fontFamily: "DMSans-Bold",
|
||||
fontSize: 9,
|
||||
letterSpacing: 0.9,
|
||||
textTransform: "uppercase",
|
||||
}}
|
||||
>
|
||||
{stageLabel}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
type StyleProp,
|
||||
type ViewStyle,
|
||||
} from "react-native";
|
||||
import Svg, { Circle } from "react-native-svg";
|
||||
|
||||
import { useThemeColor } from "../lib/useThemeColor";
|
||||
import { cn } from "../lib/cn";
|
||||
@@ -146,8 +147,9 @@ export function ComposerToolbarButton(props: {
|
||||
readonly minWidth?: number;
|
||||
readonly onPress?: () => void;
|
||||
readonly showChevron?: boolean;
|
||||
readonly size?: "default" | "compact";
|
||||
readonly textTransform?: "none" | "uppercase";
|
||||
readonly variant?: "default" | "primary" | "danger";
|
||||
readonly variant?: "default" | "ghost" | "primary" | "danger";
|
||||
readonly className?: string;
|
||||
readonly style?: StyleProp<ViewStyle>;
|
||||
}) {
|
||||
@@ -157,6 +159,7 @@ export function ComposerToolbarButton(props: {
|
||||
const primaryFg = useThemeColor("--color-primary-foreground");
|
||||
const dangerFg = useThemeColor("--color-danger-foreground");
|
||||
const variant = props.variant ?? "default";
|
||||
const isCompact = props.size === "compact";
|
||||
const isCircle = !props.label && props.showChevron === false;
|
||||
const defaultBorderColor = isDarkMode ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.06)";
|
||||
const activeBorderColor = isDarkMode ? "rgba(255,255,255,0.13)" : "rgba(0,0,0,0.1)";
|
||||
@@ -173,66 +176,86 @@ export function ComposerToolbarButton(props: {
|
||||
: primaryFg
|
||||
: variant === "danger"
|
||||
? dangerFg
|
||||
: iconColor;
|
||||
: variant === "ghost"
|
||||
? iconSubtle
|
||||
: iconColor;
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
accessibilityLabel={props.accessibilityLabel ?? props.label}
|
||||
accessibilityRole="button"
|
||||
disabled={props.disabled}
|
||||
hitSlop={isCompact ? 4 : undefined}
|
||||
onPress={props.onPress}
|
||||
className={cn(
|
||||
// Default width cap lives in the class chain (not the inline style)
|
||||
// so callers can lift it with max-w-full — flex-filling pills in the
|
||||
// thread composer stretch to the row's edge. The numeric maxWidth
|
||||
// prop still wins via the inline style below.
|
||||
"h-11 max-w-[172px] flex-row items-center justify-center rounded-full active:opacity-70",
|
||||
isCircle ? "w-11" : "gap-2 px-3.5",
|
||||
"max-w-[172px] flex-row items-center justify-center rounded-full active:opacity-70",
|
||||
isCompact ? "h-9" : "h-11",
|
||||
isCircle ? (isCompact ? "w-9" : "w-11") : isCompact ? "gap-1.5 px-1.5" : "gap-2 px-3.5",
|
||||
variant === "primary"
|
||||
? props.disabled
|
||||
? "bg-subtle-strong"
|
||||
: "bg-primary"
|
||||
: variant === "danger"
|
||||
? "bg-danger"
|
||||
: props.active
|
||||
? "bg-subtle-strong"
|
||||
: "bg-subtle",
|
||||
: variant === "ghost"
|
||||
? "bg-transparent"
|
||||
: props.active
|
||||
? "bg-subtle-strong"
|
||||
: "bg-subtle",
|
||||
props.className,
|
||||
)}
|
||||
style={({ pressed }) => [
|
||||
{
|
||||
borderColor:
|
||||
variant === "default"
|
||||
? props.active
|
||||
? activeBorderColor
|
||||
: defaultBorderColor
|
||||
: filledBorderColor,
|
||||
borderWidth: 1,
|
||||
variant === "ghost"
|
||||
? "transparent"
|
||||
: variant === "default"
|
||||
? props.active
|
||||
? activeBorderColor
|
||||
: defaultBorderColor
|
||||
: filledBorderColor,
|
||||
borderWidth: variant === "ghost" ? 0 : 1,
|
||||
maxWidth: props.maxWidth,
|
||||
minWidth: props.minWidth,
|
||||
opacity: props.disabled ? 0.55 : pressed ? 0.72 : 1,
|
||||
shadowColor: "#000",
|
||||
shadowOffset: { width: 0, height: isDarkMode ? 3 : 2 },
|
||||
shadowOpacity: props.disabled ? 0 : isDarkMode ? 0.24 : 0.08,
|
||||
shadowOpacity: props.disabled || variant === "ghost" ? 0 : isDarkMode ? 0.24 : 0.08,
|
||||
shadowRadius: isDarkMode ? 10 : 8,
|
||||
},
|
||||
props.style,
|
||||
]}
|
||||
>
|
||||
{props.iconNode ? (
|
||||
<View className="h-4 w-4 items-center justify-center">{props.iconNode}</View>
|
||||
<View
|
||||
className={cn("items-center justify-center", isCompact ? "h-4 w-4" : "h-[18px] w-[18px]")}
|
||||
>
|
||||
{props.iconNode}
|
||||
</View>
|
||||
) : props.icon ? (
|
||||
<SymbolView name={props.icon} size={16} tintColor={iconTintColor} type="monochrome" />
|
||||
<SymbolView
|
||||
name={props.icon}
|
||||
size={isCompact ? 16 : 18}
|
||||
tintColor={iconTintColor}
|
||||
type="monochrome"
|
||||
/>
|
||||
) : null}
|
||||
{props.label ? (
|
||||
<Text
|
||||
className={cn(
|
||||
"shrink text-center text-sm font-t3-bold",
|
||||
"shrink text-center font-t3-bold",
|
||||
isCompact ? "text-sm" : "text-base",
|
||||
variant === "primary"
|
||||
? props.disabled
|
||||
? "text-foreground-muted"
|
||||
: "text-primary-foreground"
|
||||
: "text-foreground",
|
||||
: variant === "ghost"
|
||||
? "text-foreground-muted"
|
||||
: "text-foreground",
|
||||
)}
|
||||
ellipsizeMode="tail"
|
||||
numberOfLines={1}
|
||||
@@ -248,4 +271,49 @@ export function ComposerToolbarButton(props: {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The mobile composer keeps the web context-window affordance in the footer.
|
||||
* Usage is optional because the mobile thread shell does not always include a
|
||||
* context snapshot; in that case the quiet track still reserves the control.
|
||||
*/
|
||||
export function ComposerContextRing(props: { readonly usedPercentage?: number | null }) {
|
||||
const trackColor = useThemeColor("--color-border");
|
||||
const progressColor = useThemeColor("--color-icon-subtle");
|
||||
const normalizedPercentage = Math.max(0, Math.min(100, props.usedPercentage ?? 0));
|
||||
const radius = 7;
|
||||
const circumference = 2 * Math.PI * radius;
|
||||
const dashOffset = circumference - (normalizedPercentage / 100) * circumference;
|
||||
|
||||
return (
|
||||
<View
|
||||
accessible
|
||||
accessibilityLabel={
|
||||
props.usedPercentage == null
|
||||
? "Context window"
|
||||
: `Context window ${Math.round(normalizedPercentage)} percent used`
|
||||
}
|
||||
className="h-11 w-9 items-center justify-center"
|
||||
>
|
||||
<Svg width={20} height={20} viewBox="0 0 18 18">
|
||||
<Circle cx={9} cy={9} r={radius} fill="none" stroke={trackColor} strokeWidth={2.5} />
|
||||
{normalizedPercentage > 0 ? (
|
||||
<Circle
|
||||
cx={9}
|
||||
cy={9}
|
||||
r={radius}
|
||||
fill="none"
|
||||
rotation={-90}
|
||||
origin="9, 9"
|
||||
stroke={progressColor}
|
||||
strokeDasharray={`${circumference} ${circumference}`}
|
||||
strokeDashoffset={dashOffset}
|
||||
strokeLinecap="round"
|
||||
strokeWidth={2.5}
|
||||
/>
|
||||
) : null}
|
||||
</Svg>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export const ComposerToolbarTrigger = ComposerToolbarButton;
|
||||
@@ -0,0 +1,277 @@
|
||||
import type { ModelSelection, ProviderInstanceId } from "@t3tools/contracts";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { FlatList, Keyboard, Modal, Platform, Pressable, TextInput, View } from "react-native";
|
||||
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
import {
|
||||
buildModelPickerProviderGroups,
|
||||
type ModelOption,
|
||||
type ProviderGroup,
|
||||
} from "../lib/modelOptions";
|
||||
import { AppText as Text } from "./AppText";
|
||||
import { SymbolView } from "./AppSymbol";
|
||||
import { ProviderIcon } from "./ProviderIcon";
|
||||
|
||||
type ModelPickerListItem =
|
||||
| {
|
||||
readonly key: string;
|
||||
readonly type: "provider";
|
||||
readonly providerLabel: string;
|
||||
}
|
||||
| {
|
||||
readonly key: string;
|
||||
readonly type: "legacy";
|
||||
readonly providerKey: ProviderInstanceId;
|
||||
readonly count: number;
|
||||
readonly expanded: boolean;
|
||||
readonly searching: boolean;
|
||||
}
|
||||
| {
|
||||
readonly key: string;
|
||||
readonly type: "model";
|
||||
readonly option: ModelOption;
|
||||
};
|
||||
|
||||
function selectedModelKey(selection: ModelSelection | null): string | null {
|
||||
return selection ? `${selection.instanceId}:${selection.model}` : null;
|
||||
}
|
||||
|
||||
function favoriteModelsFirst(
|
||||
models: ReadonlyArray<ModelOption>,
|
||||
favoriteModelKeys: ReadonlySet<string>,
|
||||
): ReadonlyArray<ModelOption> {
|
||||
return models
|
||||
.map((model, index) => ({ model, index }))
|
||||
.sort((a, b) => {
|
||||
const favoriteDelta =
|
||||
Number(favoriteModelKeys.has(b.model.key)) - Number(favoriteModelKeys.has(a.model.key));
|
||||
return favoriteDelta === 0 ? a.index - b.index : favoriteDelta;
|
||||
})
|
||||
.map(({ model }) => model);
|
||||
}
|
||||
|
||||
export function ModelPickerSheet(props: {
|
||||
readonly visible: boolean;
|
||||
readonly groups: ReadonlyArray<ProviderGroup>;
|
||||
readonly selectedModel: ModelSelection | null;
|
||||
readonly favoriteModelKeys: ReadonlySet<string>;
|
||||
readonly favoritesEnabled: boolean;
|
||||
readonly onClose: () => void;
|
||||
readonly onSelectModel: (option: ModelOption) => void;
|
||||
readonly onToggleFavorite: (option: ModelOption) => void;
|
||||
}) {
|
||||
const insets = useSafeAreaInsets();
|
||||
const [query, setQuery] = useState("");
|
||||
const [expandedLegacyProviders, setExpandedLegacyProviders] = useState(
|
||||
() => new Set<ProviderInstanceId>(),
|
||||
);
|
||||
const selectedKey = selectedModelKey(props.selectedModel);
|
||||
|
||||
useEffect(() => {
|
||||
if (!props.visible) return;
|
||||
setQuery("");
|
||||
const selectedLegacy = props.groups
|
||||
.flatMap((group) => group.models)
|
||||
.find((model) => model.key === selectedKey && model.isLegacy);
|
||||
setExpandedLegacyProviders(selectedLegacy ? new Set([selectedLegacy.providerKey]) : new Set());
|
||||
}, [props.groups, props.visible, selectedKey]);
|
||||
|
||||
const filteredGroups = useMemo(
|
||||
() => buildModelPickerProviderGroups(props.groups, query),
|
||||
[props.groups, query],
|
||||
);
|
||||
const searching = query.trim().length > 0;
|
||||
const listItems = useMemo(() => {
|
||||
const items: ModelPickerListItem[] = [];
|
||||
for (const group of filteredGroups) {
|
||||
items.push({
|
||||
key: `provider:${group.providerKey}`,
|
||||
type: "provider",
|
||||
providerLabel: group.providerLabel,
|
||||
});
|
||||
for (const option of favoriteModelsFirst(group.currentModels, props.favoriteModelKeys)) {
|
||||
items.push({ key: `model:${option.key}`, type: "model", option });
|
||||
}
|
||||
if (group.legacyModels.length > 0) {
|
||||
const expanded = searching || expandedLegacyProviders.has(group.providerKey);
|
||||
items.push({
|
||||
key: `legacy:${group.providerKey}`,
|
||||
type: "legacy",
|
||||
providerKey: group.providerKey,
|
||||
count: group.legacyModels.length,
|
||||
expanded,
|
||||
searching,
|
||||
});
|
||||
if (expanded) {
|
||||
for (const option of favoriteModelsFirst(group.legacyModels, props.favoriteModelKeys)) {
|
||||
items.push({ key: `model:${option.key}`, type: "model", option });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}, [expandedLegacyProviders, filteredGroups, props.favoriteModelKeys, searching]);
|
||||
|
||||
const toggleLegacyProvider = (providerKey: ProviderInstanceId) => {
|
||||
setExpandedLegacyProviders((current) => {
|
||||
const next = new Set(current);
|
||||
if (next.has(providerKey)) next.delete(providerKey);
|
||||
else next.add(providerKey);
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
allowSwipeDismissal
|
||||
animationType="slide"
|
||||
onRequestClose={props.onClose}
|
||||
presentationStyle={Platform.OS === "ios" ? "pageSheet" : "fullScreen"}
|
||||
statusBarTranslucent={Platform.OS === "android"}
|
||||
visible={props.visible}
|
||||
>
|
||||
<SafeAreaView
|
||||
className="flex-1 bg-black"
|
||||
edges={["bottom"]}
|
||||
style={{ paddingTop: Platform.OS === "android" ? insets.top : 0 }}
|
||||
>
|
||||
<View className="items-center pb-1 pt-2">
|
||||
<View className="h-1.5 w-16 rounded-full bg-[#515157]" />
|
||||
</View>
|
||||
|
||||
<View className="h-[68px] flex-row items-center px-5">
|
||||
<Pressable
|
||||
accessibilityLabel="Close model picker"
|
||||
accessibilityRole="button"
|
||||
className="h-12 w-[92px] items-center justify-center rounded-full border border-white/10 bg-[#242426] active:opacity-70"
|
||||
onPress={props.onClose}
|
||||
>
|
||||
<Text className="text-lg font-t3-medium text-[#f4f4f5]">Cancel</Text>
|
||||
</Pressable>
|
||||
<Text className="flex-1 text-center text-xl font-t3-bold text-white">Choose model</Text>
|
||||
<View className="w-[92px]" />
|
||||
</View>
|
||||
|
||||
<View className="px-5 pb-3">
|
||||
<View className="h-[52px] flex-row items-center gap-3 rounded-full border border-white/10 bg-[#202022] px-4">
|
||||
<SymbolView name="magnifyingglass" size={22} tintColor="#f4f4f5" type="monochrome" />
|
||||
<TextInput
|
||||
accessibilityLabel="Search models"
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
className="min-w-0 flex-1 text-lg text-white"
|
||||
clearButtonMode="while-editing"
|
||||
onChangeText={setQuery}
|
||||
placeholder="Search models"
|
||||
placeholderTextColor="#85858b"
|
||||
selectionColor="#60a5fa"
|
||||
value={query}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<FlatList
|
||||
data={listItems}
|
||||
keyExtractor={(item) => item.key}
|
||||
keyboardDismissMode="on-drag"
|
||||
keyboardShouldPersistTaps="handled"
|
||||
contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 24) }}
|
||||
ListEmptyComponent={
|
||||
<View className="items-center px-8 py-16">
|
||||
<Text className="text-center text-base text-[#85858b]">
|
||||
{query.trim().length > 0
|
||||
? `No models match “${query.trim()}”.`
|
||||
: "No models found."}
|
||||
</Text>
|
||||
</View>
|
||||
}
|
||||
renderItem={({ item }) => {
|
||||
if (item.type === "provider") {
|
||||
return (
|
||||
<Text className="px-5 pb-3 pt-8 text-lg font-t3-bold text-[#85858b]">
|
||||
{item.providerLabel}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
if (item.type === "legacy") {
|
||||
return (
|
||||
<Pressable
|
||||
accessibilityLabel={`${item.expanded ? "Hide" : "Show"} ${item.count} legacy models`}
|
||||
accessibilityRole="button"
|
||||
className="mx-5 min-h-[58px] flex-row items-center border-b border-white/10 active:opacity-70"
|
||||
disabled={item.searching}
|
||||
onPress={() => toggleLegacyProvider(item.providerKey)}
|
||||
>
|
||||
<SymbolView name="archivebox" size={20} tintColor="#77777d" type="monochrome" />
|
||||
<Text className="ml-3 flex-1 text-base font-t3-medium text-[#a2a2a8]">
|
||||
Legacy models
|
||||
</Text>
|
||||
<Text className="mr-2 text-sm text-[#6f6f75]">{item.count}</Text>
|
||||
{!item.searching ? (
|
||||
<SymbolView
|
||||
name={item.expanded ? "chevron.up" : "chevron.down"}
|
||||
size={14}
|
||||
tintColor="#77777d"
|
||||
type="monochrome"
|
||||
/>
|
||||
) : null}
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
||||
const selected = item.option.key === selectedKey;
|
||||
const favorite = props.favoriteModelKeys.has(item.option.key);
|
||||
return (
|
||||
<View className="mx-5 min-h-[82px] flex-row items-center border-b border-white/10">
|
||||
<Pressable
|
||||
accessibilityLabel={`${item.option.label}, ${item.option.selection.model}`}
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ selected }}
|
||||
className="min-w-0 flex-1 flex-row items-center self-stretch active:opacity-70"
|
||||
onPress={() => {
|
||||
Keyboard.dismiss();
|
||||
props.onSelectModel(item.option);
|
||||
props.onClose();
|
||||
}}
|
||||
>
|
||||
<View className="w-12 items-start">
|
||||
<ProviderIcon provider={item.option.providerDriver} size={28} />
|
||||
</View>
|
||||
<View className="min-w-0 flex-1 py-3">
|
||||
<Text className="text-lg font-t3-bold text-[#f5f5f6]" numberOfLines={1}>
|
||||
{item.option.label}
|
||||
</Text>
|
||||
<Text className="mt-0.5 text-sm text-[#909096]" numberOfLines={1}>
|
||||
{item.option.selection.model}
|
||||
</Text>
|
||||
</View>
|
||||
{selected ? (
|
||||
<SymbolView name="checkmark" size={22} tintColor="#f5f5f6" type="monochrome" />
|
||||
) : null}
|
||||
</Pressable>
|
||||
<Pressable
|
||||
accessibilityLabel={favorite ? "Remove from favorites" : "Add to favorites"}
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ disabled: !props.favoritesEnabled }}
|
||||
className="ml-3 h-11 w-11 items-center justify-center active:opacity-60"
|
||||
disabled={!props.favoritesEnabled}
|
||||
hitSlop={4}
|
||||
onPress={() => props.onToggleFavorite(item.option)}
|
||||
style={{ opacity: props.favoritesEnabled ? 1 : 0.45 }}
|
||||
>
|
||||
<SymbolView
|
||||
name={favorite ? "star.fill" : "star"}
|
||||
size={23}
|
||||
tintColor={favorite ? "#facc15" : "#77777d"}
|
||||
type="monochrome"
|
||||
/>
|
||||
</Pressable>
|
||||
</View>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</SafeAreaView>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -1,40 +1,36 @@
|
||||
import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
|
||||
import type { EnvironmentId, SidebarThreadSortOrder } from "@t3tools/contracts";
|
||||
import type { MenuAction } from "@react-native-menu/menu";
|
||||
import Constants from "expo-constants";
|
||||
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
|
||||
import { useCallback, useMemo, useRef } from "react";
|
||||
import { Platform, Pressable, Text as RNText, TextInput, View } from "react-native";
|
||||
import type { SearchBarCommands } from "react-native-screens";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { Pressable, TextInput, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
import { ControlPillMenu } from "../../components/ControlPill";
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { ControlPillMenu } from "../../components/ControlPill";
|
||||
import { T3Wordmark } from "../../components/T3Wordmark";
|
||||
import { HOME_HORIZONTAL_INSET } from "../../lib/layoutMetrics";
|
||||
import { resolveMobileStageLabel } from "../../lib/mobileBranding";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
|
||||
import { NativeStackScreenOptions } from "../../native/StackHeader";
|
||||
import type { WorkspaceState } from "../../state/workspaceModel";
|
||||
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
|
||||
import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
|
||||
import {
|
||||
createNativeMailSearchToolbarItem,
|
||||
NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED,
|
||||
} from "../layout/native-mail-search-toolbar";
|
||||
import type { HomeProjectSortOrder } from "./homeThreadList";
|
||||
import {
|
||||
buildHomeListFilterMenu,
|
||||
type HomeListFilterMenuEnvironment,
|
||||
type HomeListFilterMenuProject,
|
||||
import type {
|
||||
HomeListFilterMenuEnvironment,
|
||||
HomeListFilterMenuProject,
|
||||
} from "./home-list-filter-menu";
|
||||
import {
|
||||
hasCustomHomeListOptions,
|
||||
PROJECT_SORT_OPTIONS,
|
||||
THREAD_SORT_OPTIONS,
|
||||
} from "./home-list-options";
|
||||
import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
|
||||
import { WorkspaceConnectionStatus } from "./WorkspaceConnectionStatus";
|
||||
|
||||
export type HomeHeaderEnvironment = HomeListFilterMenuEnvironment;
|
||||
export type HomeHeaderEnvironment = HomeListFilterMenuEnvironment & {
|
||||
readonly connectionState: EnvironmentConnectionPhase;
|
||||
};
|
||||
|
||||
export function HomeHeader(props: {
|
||||
readonly catalogState: WorkspaceState;
|
||||
readonly environments: ReadonlyArray<HomeHeaderEnvironment>;
|
||||
readonly projects: ReadonlyArray<HomeListFilterMenuProject>;
|
||||
readonly searchQuery: string;
|
||||
@@ -48,33 +44,26 @@ export function HomeHeader(props: {
|
||||
readonly onProjectSortOrderChange: (sortOrder: HomeProjectSortOrder) => void;
|
||||
readonly onThreadSortOrderChange: (sortOrder: SidebarThreadSortOrder) => void;
|
||||
readonly onOpenSettings: () => void;
|
||||
readonly onStartNewTask: () => void;
|
||||
readonly onReconnectEnvironment: (environmentId: EnvironmentId) => void;
|
||||
}) {
|
||||
if (Platform.OS === "android") {
|
||||
return <AndroidHomeHeader {...props} />;
|
||||
}
|
||||
|
||||
return <IosHomeHeader {...props} />;
|
||||
}
|
||||
|
||||
type HomeHeaderProps = Parameters<typeof HomeHeader>[0];
|
||||
|
||||
function checkedMenuState(checked: boolean) {
|
||||
return checked ? ("on" as const) : undefined;
|
||||
}
|
||||
|
||||
function AndroidHomeHeader(props: HomeHeaderProps) {
|
||||
const insets = useSafeAreaInsets();
|
||||
const iconColor = useThemeColor("--color-icon");
|
||||
const mutedColor = useThemeColor("--color-foreground-muted");
|
||||
const stageLabel = resolveMobileStageLabel(Constants.expoConfig?.extra?.appVariant);
|
||||
// Thread List v2 lays the list out in fixed creation order, so the
|
||||
// sort/group filter controls would be silently ignored — hide them and
|
||||
// key the "customized" icon state off the environment filter alone.
|
||||
const searchInputRef = useRef<TextInput>(null);
|
||||
const [searchVisible, setSearchVisible] = useState(props.searchQuery.length > 0);
|
||||
const threadListV2Enabled = useThreadListV2Enabled();
|
||||
const hasCustomListOptions = threadListV2Enabled
|
||||
? props.selectedEnvironmentId !== null || props.selectedProjectKey !== null
|
||||
: hasCustomHomeListOptions(props);
|
||||
|
||||
const focusSearch = useCallback(() => {
|
||||
setSearchVisible(true);
|
||||
searchInputRef.current?.focus();
|
||||
return true;
|
||||
}, []);
|
||||
useHardwareKeyboardCommand("focusSearch", focusSearch);
|
||||
useEffect(() => {
|
||||
if (searchVisible) searchInputRef.current?.focus();
|
||||
}, [searchVisible]);
|
||||
|
||||
const menuActions = useMemo<MenuAction[]>(
|
||||
() => [
|
||||
{
|
||||
@@ -84,12 +73,15 @@ function AndroidHomeHeader(props: HomeHeaderProps) {
|
||||
{
|
||||
id: "environment:all",
|
||||
title: "All environments",
|
||||
state: checkedMenuState(props.selectedEnvironmentId === null),
|
||||
state: props.selectedEnvironmentId === null ? "on" : undefined,
|
||||
},
|
||||
...props.environments.map((environment) => ({
|
||||
id: `environment:${environment.environmentId}`,
|
||||
title: environment.label,
|
||||
state: checkedMenuState(props.selectedEnvironmentId === environment.environmentId),
|
||||
state:
|
||||
props.selectedEnvironmentId === environment.environmentId
|
||||
? ("on" as const)
|
||||
: undefined,
|
||||
})),
|
||||
],
|
||||
},
|
||||
@@ -103,12 +95,12 @@ function AndroidHomeHeader(props: HomeHeaderProps) {
|
||||
{
|
||||
id: "project:all",
|
||||
title: "All projects",
|
||||
state: checkedMenuState(props.selectedProjectKey === null),
|
||||
state: props.selectedProjectKey === null ? ("on" as const) : undefined,
|
||||
},
|
||||
...props.projects.map((project) => ({
|
||||
id: `project:${project.key}`,
|
||||
title: project.label,
|
||||
state: checkedMenuState(props.selectedProjectKey === project.key),
|
||||
state: props.selectedProjectKey === project.key ? ("on" as const) : undefined,
|
||||
})),
|
||||
],
|
||||
},
|
||||
@@ -122,7 +114,7 @@ function AndroidHomeHeader(props: HomeHeaderProps) {
|
||||
subactions: PROJECT_SORT_OPTIONS.map((option) => ({
|
||||
id: `project-sort:${option.value}`,
|
||||
title: option.label,
|
||||
state: checkedMenuState(props.projectSortOrder === option.value),
|
||||
state: props.projectSortOrder === option.value ? ("on" as const) : undefined,
|
||||
})),
|
||||
},
|
||||
{
|
||||
@@ -131,10 +123,11 @@ function AndroidHomeHeader(props: HomeHeaderProps) {
|
||||
subactions: THREAD_SORT_OPTIONS.map((option) => ({
|
||||
id: `thread-sort:${option.value}`,
|
||||
title: option.label,
|
||||
state: checkedMenuState(props.threadSortOrder === option.value),
|
||||
state: props.threadSortOrder === option.value ? ("on" as const) : undefined,
|
||||
})),
|
||||
},
|
||||
] satisfies MenuAction[])),
|
||||
{ id: "settings", title: "Settings", image: "gearshape" },
|
||||
],
|
||||
[
|
||||
props.environments,
|
||||
@@ -146,30 +139,30 @@ function AndroidHomeHeader(props: HomeHeaderProps) {
|
||||
threadListV2Enabled,
|
||||
],
|
||||
);
|
||||
|
||||
const handleMenuAction = useCallback(
|
||||
(event: { nativeEvent: { event: string } }) => {
|
||||
const id = event.nativeEvent.event;
|
||||
({ nativeEvent }: { readonly nativeEvent: { readonly event: string } }) => {
|
||||
const id = nativeEvent.event;
|
||||
if (id === "settings") {
|
||||
props.onOpenSettings();
|
||||
return;
|
||||
}
|
||||
if (id === "environment:all") {
|
||||
props.onEnvironmentChange(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (id.startsWith("environment:")) {
|
||||
const environmentId = id.slice("environment:".length);
|
||||
const environment = props.environments.find(
|
||||
(candidate) => candidate.environmentId === environmentId,
|
||||
);
|
||||
if (environment) {
|
||||
props.onEnvironmentChange(environment.environmentId);
|
||||
}
|
||||
if (environment) props.onEnvironmentChange(environment.environmentId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (id === "project:all") {
|
||||
props.onProjectChange(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (id.startsWith("project:")) {
|
||||
const projectKey = id.slice("project:".length);
|
||||
if (props.projects.some((project) => project.key === projectKey)) {
|
||||
@@ -177,7 +170,6 @@ function AndroidHomeHeader(props: HomeHeaderProps) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const projectSort = PROJECT_SORT_OPTIONS.find(
|
||||
(option) => id === `project-sort:${option.value}`,
|
||||
);
|
||||
@@ -185,281 +177,161 @@ function AndroidHomeHeader(props: HomeHeaderProps) {
|
||||
props.onProjectSortOrderChange(projectSort.value);
|
||||
return;
|
||||
}
|
||||
|
||||
const threadSort = THREAD_SORT_OPTIONS.find((option) => id === `thread-sort:${option.value}`);
|
||||
if (threadSort) {
|
||||
props.onThreadSortOrderChange(threadSort.value);
|
||||
return;
|
||||
}
|
||||
if (threadSort) props.onThreadSortOrderChange(threadSort.value);
|
||||
},
|
||||
[props],
|
||||
);
|
||||
|
||||
const troubledEnvironment =
|
||||
(props.selectedEnvironmentId === null
|
||||
? undefined
|
||||
: props.environments.find(
|
||||
(environment) =>
|
||||
environment.environmentId === props.selectedEnvironmentId &&
|
||||
environment.connectionState !== "connected",
|
||||
)) ??
|
||||
props.environments.find(
|
||||
(environment) =>
|
||||
environment.connectionState === "connecting" ||
|
||||
environment.connectionState === "reconnecting",
|
||||
) ??
|
||||
props.environments.find((environment) => environment.connectionState !== "connected") ??
|
||||
props.environments[0];
|
||||
const selectedEnvironment =
|
||||
props.selectedEnvironmentId === null
|
||||
? null
|
||||
: (props.environments.find(
|
||||
(environment) => environment.environmentId === props.selectedEnvironmentId,
|
||||
) ?? null);
|
||||
const selectedProjectLabel =
|
||||
props.projects.find((project) => project.key === props.selectedProjectKey)?.label ??
|
||||
"All projects";
|
||||
|
||||
return (
|
||||
<>
|
||||
<NativeStackScreenOptions options={{ headerShown: false }} />
|
||||
<View
|
||||
className="border-b border-header-border bg-header pb-3"
|
||||
style={{
|
||||
paddingHorizontal: HOME_HORIZONTAL_INSET,
|
||||
paddingTop: Math.max(insets.top, 12),
|
||||
backgroundColor: "#000",
|
||||
borderBottomColor: "rgba(255,255,255,0.06)",
|
||||
borderBottomWidth: 1,
|
||||
paddingTop: insets.top,
|
||||
}}
|
||||
>
|
||||
<View className="w-full max-w-[720px] self-center gap-3">
|
||||
<View className="flex-row items-center gap-2.5">
|
||||
<View className="flex-1 flex-row items-center gap-2">
|
||||
{/* Mirrors the desktop SidebarBrand: T3 mark + muted "Code". */}
|
||||
<T3Wordmark color={iconColor} height={15} />
|
||||
<RNText className="-ml-0.5 text-[21px] font-t3-medium tracking-[-0.5px] text-foreground-muted">
|
||||
Code
|
||||
</RNText>
|
||||
<View className="rounded-full bg-subtle px-2 py-0.75">
|
||||
<RNText className="text-[11px] font-t3-bold tracking-[1.1px] text-foreground-muted uppercase">
|
||||
{stageLabel}
|
||||
</RNText>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<ControlPillMenu
|
||||
actions={menuActions}
|
||||
isAnchoredToRight
|
||||
onPressAction={handleMenuAction}
|
||||
>
|
||||
<Pressable
|
||||
accessibilityLabel="Filter and sort threads"
|
||||
accessibilityRole="button"
|
||||
className="size-11 items-center justify-center rounded-full bg-subtle"
|
||||
>
|
||||
<SymbolView
|
||||
name={
|
||||
hasCustomListOptions
|
||||
? "line.3.horizontal.decrease.circle.fill"
|
||||
: "line.3.horizontal.decrease.circle"
|
||||
}
|
||||
size={16}
|
||||
tintColor={iconColor}
|
||||
type="monochrome"
|
||||
/>
|
||||
</Pressable>
|
||||
</ControlPillMenu>
|
||||
{/* Built identically to the filter button so the two circles
|
||||
match exactly (ControlPill sizes via Tailwind classes and
|
||||
resolves to a different box). */}
|
||||
<Pressable
|
||||
accessibilityLabel="Open settings"
|
||||
accessibilityRole="button"
|
||||
<View className="h-14 flex-row items-center px-4">
|
||||
<View className="min-w-0 flex-1">
|
||||
<WorkspaceConnectionStatus
|
||||
state={props.catalogState}
|
||||
environmentLabel={troubledEnvironment?.label}
|
||||
environmentConnectionState={troubledEnvironment?.connectionState}
|
||||
onPress={props.onOpenSettings}
|
||||
className="size-11 items-center justify-center rounded-full bg-subtle"
|
||||
>
|
||||
<SymbolView name="gearshape" size={18} tintColor={iconColor} type="monochrome" />
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
<View className="min-h-12 flex-row items-center gap-2.5 rounded-2xl border border-input-border bg-input px-3.5">
|
||||
<SymbolView name="magnifyingglass" size={17} tintColor={mutedColor} type="monochrome" />
|
||||
<TextInput
|
||||
accessibilityLabel="Search threads"
|
||||
autoCapitalize="none"
|
||||
onChangeText={props.onSearchQueryChange}
|
||||
placeholder="Search threads"
|
||||
placeholderTextColorClassName="accent-placeholder"
|
||||
className="flex-1 py-2.5 text-base font-sans text-foreground"
|
||||
value={props.searchQuery}
|
||||
onReconnect={
|
||||
troubledEnvironment
|
||||
? () => props.onReconnectEnvironment(troubledEnvironment.environmentId)
|
||||
: undefined
|
||||
}
|
||||
variant="header"
|
||||
fallback={
|
||||
<View
|
||||
accessibilityLabel="T3 Code, Threads"
|
||||
accessibilityRole="header"
|
||||
className="flex-row items-center gap-2"
|
||||
>
|
||||
<T3Wordmark color="#f5f5f5" height={16} />
|
||||
<Text className="text-[21px] font-t3-medium tracking-[-0.5px] text-[#8e8e93]">
|
||||
Code
|
||||
</Text>
|
||||
</View>
|
||||
}
|
||||
/>
|
||||
{props.searchQuery.length > 0 ? (
|
||||
<Pressable
|
||||
accessibilityLabel="Clear search"
|
||||
hitSlop={10}
|
||||
onPress={() => props.onSearchQueryChange("")}
|
||||
>
|
||||
<SymbolView
|
||||
name="xmark.circle.fill"
|
||||
size={17}
|
||||
tintColor={mutedColor}
|
||||
type="monochrome"
|
||||
/>
|
||||
</Pressable>
|
||||
) : null}
|
||||
</View>
|
||||
<Pressable
|
||||
accessibilityLabel={searchVisible ? "Close thread search" : "Search threads"}
|
||||
accessibilityRole="button"
|
||||
className="size-12 items-center justify-center"
|
||||
hitSlop={4}
|
||||
onPress={() => {
|
||||
if (searchVisible) {
|
||||
props.onSearchQueryChange("");
|
||||
setSearchVisible(false);
|
||||
} else {
|
||||
setSearchVisible(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SymbolView
|
||||
name={searchVisible ? "xmark" : "magnifyingglass"}
|
||||
size={20}
|
||||
tintColor="#b9bbc2"
|
||||
type="monochrome"
|
||||
/>
|
||||
</Pressable>
|
||||
<ControlPillMenu actions={menuActions} isAnchoredToRight onPressAction={handleMenuAction}>
|
||||
<Pressable
|
||||
accessibilityLabel="Filter threads and open settings"
|
||||
accessibilityRole="button"
|
||||
className="size-12 items-center justify-center"
|
||||
hitSlop={4}
|
||||
>
|
||||
<SymbolView
|
||||
name={
|
||||
hasCustomListOptions
|
||||
? "line.3.horizontal.decrease.circle.fill"
|
||||
: "line.3.horizontal.decrease.circle"
|
||||
}
|
||||
size={20}
|
||||
tintColor="#b9bbc2"
|
||||
type="monochrome"
|
||||
/>
|
||||
</Pressable>
|
||||
</ControlPillMenu>
|
||||
</View>
|
||||
|
||||
<View className="h-11 flex-row items-center px-4">
|
||||
{searchVisible ? (
|
||||
<>
|
||||
<SymbolView name="magnifyingglass" size={16} tintColor="#71717a" type="monochrome" />
|
||||
<TextInput
|
||||
ref={searchInputRef}
|
||||
accessibilityLabel="Search threads"
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
className="ml-2 flex-1 py-0 text-base font-sans text-white"
|
||||
onChangeText={props.onSearchQueryChange}
|
||||
placeholder="Search threads"
|
||||
placeholderTextColor="#52525b"
|
||||
returnKeyType="search"
|
||||
value={props.searchQuery}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<View className="flex-1">
|
||||
<ControlPillMenu actions={menuActions} onPressAction={handleMenuAction}>
|
||||
<Pressable
|
||||
accessibilityLabel={`Project filter, ${selectedProjectLabel}`}
|
||||
accessibilityRole="button"
|
||||
className="h-11 w-full flex-row items-center"
|
||||
>
|
||||
<SymbolView name="folder" size={16} tintColor="#71717a" type="monochrome" />
|
||||
<Text
|
||||
className="ml-2 max-w-[70%] text-sm font-t3-medium text-[#8e8e93]"
|
||||
numberOfLines={1}
|
||||
>
|
||||
{selectedProjectLabel}
|
||||
</Text>
|
||||
<SymbolView name="chevron.down" size={10} tintColor="#636366" type="monochrome" />
|
||||
{selectedEnvironment ? (
|
||||
<Text className="ml-2 text-xs text-[#71717a]" numberOfLines={1}>
|
||||
{selectedEnvironment.label}
|
||||
</Text>
|
||||
) : null}
|
||||
</Pressable>
|
||||
</ControlPillMenu>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function IosHomeHeader(props: HomeHeaderProps) {
|
||||
const searchBarRef = useRef<SearchBarCommands>(null);
|
||||
const iconColor = useThemeColor("--color-icon");
|
||||
// Thread List v2 lays the list out in fixed creation order, so the
|
||||
// sort/group filter controls would be silently ignored — hide them and
|
||||
// key the "customized" icon state off the environment filter alone.
|
||||
const threadListV2Enabled = useThreadListV2Enabled();
|
||||
const hasCustomListOptions = threadListV2Enabled
|
||||
? props.selectedEnvironmentId !== null || props.selectedProjectKey !== null
|
||||
: hasCustomHomeListOptions(props);
|
||||
const focusSearch = useCallback(() => {
|
||||
searchBarRef.current?.focus();
|
||||
return searchBarRef.current !== null;
|
||||
}, []);
|
||||
useHardwareKeyboardCommand("focusSearch", focusSearch);
|
||||
const filterMenu = buildHomeListFilterMenu({
|
||||
...props,
|
||||
listOrganization: !threadListV2Enabled,
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<NativeStackScreenOptions
|
||||
optionsVersion={filterMenu.items}
|
||||
options={{
|
||||
// Static header config (glass, title, fonts) lives in Stack.tsx
|
||||
// (GLASS_HEADER_OPTIONS). Only dynamic values are set here.
|
||||
headerTintColor: iconColor,
|
||||
unstable_headerRightItems:
|
||||
Platform.OS === "ios"
|
||||
? () => [
|
||||
withNativeGlassHeaderItem({
|
||||
accessibilityLabel: "Open settings",
|
||||
icon: { name: "ellipsis", type: "sfSymbol" } as const,
|
||||
identifier: "home-settings",
|
||||
label: "",
|
||||
onPress: props.onOpenSettings,
|
||||
type: "button",
|
||||
}),
|
||||
]
|
||||
: undefined,
|
||||
// The keys below are set per-branch (not `undefined`) so a later
|
||||
// reapply cannot clobber options owned by NativeHeaderToolbar.
|
||||
...(NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED
|
||||
? {
|
||||
unstable_headerToolbarItems: () => [
|
||||
createNativeMailSearchToolbarItem({
|
||||
composeButtonId: "home-new-task",
|
||||
composeSystemImageName: "square.and.pencil",
|
||||
filterMenu,
|
||||
filterButtonId: "home-filter",
|
||||
filterSystemImageName: hasCustomListOptions
|
||||
? "line.3.horizontal.decrease.circle.fill"
|
||||
: "line.3.horizontal.decrease",
|
||||
onComposePress: props.onStartNewTask,
|
||||
onSearchTextChange: props.onSearchQueryChange,
|
||||
placeholder: "Search",
|
||||
searchTextChangeId: "home-search-text",
|
||||
}),
|
||||
],
|
||||
}
|
||||
: {
|
||||
// Pre-Liquid-Glass iOS: standard pull-down search in the nav
|
||||
// bar; create + sort live in the plain bottom toolbar below.
|
||||
headerSearchBarOptions: {
|
||||
ref: searchBarRef,
|
||||
autoCapitalize: "none" as const,
|
||||
hideNavigationBar: false,
|
||||
placeholder: "Search",
|
||||
onCancelButtonPress: () => {
|
||||
props.onSearchQueryChange("");
|
||||
},
|
||||
onChangeText: (event) => {
|
||||
props.onSearchQueryChange(event.nativeEvent.text);
|
||||
},
|
||||
},
|
||||
}),
|
||||
}}
|
||||
/>
|
||||
|
||||
{NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED ? null : (
|
||||
<NativeHeaderToolbar placement="bottom">
|
||||
<NativeHeaderToolbar.Menu
|
||||
accessibilityLabel="Filter and sort threads"
|
||||
icon={
|
||||
hasCustomListOptions
|
||||
? "line.3.horizontal.decrease.circle.fill"
|
||||
: "line.3.horizontal.decrease.circle"
|
||||
}
|
||||
title="Thread list options"
|
||||
separateBackground
|
||||
>
|
||||
<NativeHeaderToolbar.Menu title="Environment">
|
||||
<NativeHeaderToolbar.Label>Environment</NativeHeaderToolbar.Label>
|
||||
<NativeHeaderToolbar.MenuAction
|
||||
isOn={props.selectedEnvironmentId === null}
|
||||
onPress={() => props.onEnvironmentChange(null)}
|
||||
subtitle="Show threads from every environment"
|
||||
>
|
||||
<NativeHeaderToolbar.Label>All environments</NativeHeaderToolbar.Label>
|
||||
</NativeHeaderToolbar.MenuAction>
|
||||
{props.environments.map((environment) => (
|
||||
<NativeHeaderToolbar.MenuAction
|
||||
key={environment.environmentId}
|
||||
isOn={props.selectedEnvironmentId === environment.environmentId}
|
||||
onPress={() => props.onEnvironmentChange(environment.environmentId)}
|
||||
>
|
||||
<NativeHeaderToolbar.Label>{environment.label}</NativeHeaderToolbar.Label>
|
||||
</NativeHeaderToolbar.MenuAction>
|
||||
))}
|
||||
</NativeHeaderToolbar.Menu>
|
||||
|
||||
{props.projects.length > 0 ? (
|
||||
<NativeHeaderToolbar.Menu title="Project">
|
||||
<NativeHeaderToolbar.Label>Project</NativeHeaderToolbar.Label>
|
||||
<NativeHeaderToolbar.MenuAction
|
||||
isOn={props.selectedProjectKey === null}
|
||||
onPress={() => props.onProjectChange(null)}
|
||||
subtitle="Show threads from every project"
|
||||
>
|
||||
<NativeHeaderToolbar.Label>All projects</NativeHeaderToolbar.Label>
|
||||
</NativeHeaderToolbar.MenuAction>
|
||||
{props.projects.map((project) => (
|
||||
<NativeHeaderToolbar.MenuAction
|
||||
key={project.key}
|
||||
isOn={props.selectedProjectKey === project.key}
|
||||
onPress={() => props.onProjectChange(project.key)}
|
||||
>
|
||||
<NativeHeaderToolbar.Label>{project.label}</NativeHeaderToolbar.Label>
|
||||
</NativeHeaderToolbar.MenuAction>
|
||||
))}
|
||||
</NativeHeaderToolbar.Menu>
|
||||
) : null}
|
||||
|
||||
{threadListV2Enabled ? null : (
|
||||
<NativeHeaderToolbar.Menu title="Sort projects">
|
||||
<NativeHeaderToolbar.Label>Sort projects</NativeHeaderToolbar.Label>
|
||||
{PROJECT_SORT_OPTIONS.map((option) => (
|
||||
<NativeHeaderToolbar.MenuAction
|
||||
key={option.value}
|
||||
isOn={props.projectSortOrder === option.value}
|
||||
onPress={() => props.onProjectSortOrderChange(option.value)}
|
||||
>
|
||||
<NativeHeaderToolbar.Label>{option.label}</NativeHeaderToolbar.Label>
|
||||
</NativeHeaderToolbar.MenuAction>
|
||||
))}
|
||||
</NativeHeaderToolbar.Menu>
|
||||
)}
|
||||
|
||||
{threadListV2Enabled ? null : (
|
||||
<NativeHeaderToolbar.Menu title="Sort threads">
|
||||
<NativeHeaderToolbar.Label>Sort threads</NativeHeaderToolbar.Label>
|
||||
{THREAD_SORT_OPTIONS.map((option) => (
|
||||
<NativeHeaderToolbar.MenuAction
|
||||
key={option.value}
|
||||
isOn={props.threadSortOrder === option.value}
|
||||
onPress={() => props.onThreadSortOrderChange(option.value)}
|
||||
>
|
||||
<NativeHeaderToolbar.Label>{option.label}</NativeHeaderToolbar.Label>
|
||||
</NativeHeaderToolbar.MenuAction>
|
||||
))}
|
||||
</NativeHeaderToolbar.Menu>
|
||||
)}
|
||||
</NativeHeaderToolbar.Menu>
|
||||
<NativeHeaderToolbar.Spacer flexible />
|
||||
<NativeHeaderToolbar.Button
|
||||
accessibilityLabel="New task"
|
||||
icon="square.and.pencil"
|
||||
onPress={props.onStartNewTask}
|
||||
separateBackground
|
||||
/>
|
||||
</NativeHeaderToolbar>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -2,22 +2,25 @@ 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 { View } from "react-native";
|
||||
|
||||
import { getCompactBrandHeaderOptions } from "../../components/CompactBrandTitle";
|
||||
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
|
||||
import { useProjects, useThreadShells } from "../../state/entities";
|
||||
import { usePendingNewTasks } from "../../state/use-pending-new-tasks";
|
||||
import { useWorkspaceState } from "../../state/workspace";
|
||||
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
|
||||
import {
|
||||
useRemoteConnections,
|
||||
useSavedRemoteConnections,
|
||||
} from "../../state/use-remote-environment-registry";
|
||||
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
|
||||
import { WorkspaceEmptyDetail } from "../layout/WorkspaceEmptyDetail";
|
||||
import { WorkspaceSidebarToolbar } from "../layout/workspace-sidebar-toolbar";
|
||||
import { checkForAppUpdateOnLaunch } from "../updates/app-updates";
|
||||
import { AndroidHomeFabLayout } from "./AndroidHomeFab";
|
||||
import { HomeScreen } from "./HomeScreen";
|
||||
import { HomeHeader } from "./HomeHeader";
|
||||
import { useHomeListOptions } from "./home-list-options";
|
||||
import { buildHomeProjectScopes } from "./homeThreadList";
|
||||
import { resolveHomeEnvironmentConnectionPhase } from "./workspace-connection-status";
|
||||
import { usePendingTaskListActions } from "./usePendingTaskListActions";
|
||||
import { useThreadListActions } from "./useThreadListActions";
|
||||
|
||||
@@ -29,6 +32,7 @@ export function HomeRouteScreen() {
|
||||
const threads = useThreadShells();
|
||||
const { environments: workspaceEnvironments, state: catalogState } = useWorkspaceState();
|
||||
const { savedConnectionsById } = useSavedRemoteConnections();
|
||||
const { onReconnectEnvironment } = useRemoteConnections();
|
||||
const navigation = useNavigation();
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
|
||||
@@ -58,12 +62,14 @@ export function HomeRouteScreen() {
|
||||
Object.values(savedConnectionsById).map((connection) => ({
|
||||
environmentId: connection.environmentId,
|
||||
label: connection.environmentLabel,
|
||||
connectionState:
|
||||
connectionStateByEnvironmentId.get(connection.environmentId) ?? "available",
|
||||
connectionState: resolveHomeEnvironmentConnectionPhase(
|
||||
connectionStateByEnvironmentId.get(connection.environmentId),
|
||||
catalogState.isLoadingConnections,
|
||||
),
|
||||
})),
|
||||
Order.mapInput(Order.String, (environment: { readonly label: string }) => environment.label),
|
||||
);
|
||||
}, [savedConnectionsById, workspaceEnvironments]);
|
||||
}, [catalogState.isLoadingConnections, savedConnectionsById, workspaceEnvironments]);
|
||||
const availableEnvironmentIds = useMemo(
|
||||
() => new Set(environments.map((environment) => environment.environmentId)),
|
||||
[environments],
|
||||
@@ -103,7 +109,12 @@ export function HomeRouteScreen() {
|
||||
return (
|
||||
<>
|
||||
<NativeStackScreenOptions
|
||||
options={{ title: "", headerTitle: "", unstable_headerLeftItems: () => [] }}
|
||||
options={{
|
||||
headerShown: true,
|
||||
title: "",
|
||||
headerTitle: "",
|
||||
unstable_headerLeftItems: () => [],
|
||||
}}
|
||||
/>
|
||||
<WorkspaceSidebarToolbar
|
||||
afterSidebarButton={
|
||||
@@ -122,85 +133,80 @@ export function HomeRouteScreen() {
|
||||
}
|
||||
|
||||
return (
|
||||
<AndroidHomeFabLayout
|
||||
onStartNewTask={() => navigation.navigate("NewTaskSheet", { screen: "NewTask" })}
|
||||
>
|
||||
<>
|
||||
{/* Restore the compact title after the split branch blanks the detail header. */}
|
||||
<NativeStackScreenOptions options={getCompactBrandHeaderOptions()} />
|
||||
<HomeHeader
|
||||
environments={environments}
|
||||
projects={projectFilterOptions}
|
||||
searchQuery={searchQuery}
|
||||
selectedEnvironmentId={selectedEnvironmentId}
|
||||
selectedProjectKey={selectedProjectKey}
|
||||
projectSortOrder={listOptions.projectSortOrder}
|
||||
threadSortOrder={listOptions.threadSortOrder}
|
||||
onEnvironmentChange={setSelectedEnvironmentId}
|
||||
onProjectChange={setSelectedProjectKey}
|
||||
onOpenSettings={() => navigation.navigate("SettingsSheet", { screen: "Settings" })}
|
||||
onProjectSortOrderChange={setProjectSortOrder}
|
||||
onSearchQueryChange={setSearchQuery}
|
||||
onStartNewTask={() => navigation.navigate("NewTaskSheet", { screen: "NewTask" })}
|
||||
onThreadSortOrderChange={setThreadSortOrder}
|
||||
/>
|
||||
<View className="flex-1 bg-black">
|
||||
<HomeHeader
|
||||
catalogState={catalogState}
|
||||
environments={environments}
|
||||
projects={projectFilterOptions}
|
||||
searchQuery={searchQuery}
|
||||
selectedEnvironmentId={selectedEnvironmentId}
|
||||
selectedProjectKey={selectedProjectKey}
|
||||
projectSortOrder={listOptions.projectSortOrder}
|
||||
threadSortOrder={listOptions.threadSortOrder}
|
||||
onEnvironmentChange={setSelectedEnvironmentId}
|
||||
onProjectChange={setSelectedProjectKey}
|
||||
onOpenSettings={() => navigation.navigate("SettingsSheet", { screen: "Settings" })}
|
||||
onProjectSortOrderChange={setProjectSortOrder}
|
||||
onReconnectEnvironment={onReconnectEnvironment}
|
||||
onSearchQueryChange={setSearchQuery}
|
||||
onThreadSortOrderChange={setThreadSortOrder}
|
||||
/>
|
||||
|
||||
<HomeScreen
|
||||
catalogState={catalogState}
|
||||
environments={environments}
|
||||
onAddConnection={() =>
|
||||
navigation.navigate("SettingsSheet", { screen: "SettingsEnvironmentNew" })
|
||||
}
|
||||
onArchiveThread={archiveThread}
|
||||
onDeleteThread={confirmDeleteThread}
|
||||
onSettleThread={settleThread}
|
||||
onSnoozeThread={snoozeThread}
|
||||
onUnsnoozeThread={unsnoozeThread}
|
||||
onUnsettleThread={unsettleThread}
|
||||
onPinThread={pinThread}
|
||||
onUnpinThread={unpinThread}
|
||||
onEnvironmentChange={setSelectedEnvironmentId}
|
||||
onProjectChange={setSelectedProjectKey}
|
||||
onOpenEnvironments={() =>
|
||||
navigation.navigate("SettingsSheet", { screen: "SettingsEnvironments" })
|
||||
}
|
||||
onOpenSettings={() => navigation.navigate("SettingsSheet", { screen: "Settings" })}
|
||||
onProjectSortOrderChange={setProjectSortOrder}
|
||||
onSearchQueryChange={setSearchQuery}
|
||||
onSelectThread={(thread) => {
|
||||
// Settled threads are live shells: opening one is plain
|
||||
// navigation, and sending a message un-settles server-side.
|
||||
navigation.navigate("Thread", {
|
||||
environmentId: thread.environmentId,
|
||||
threadId: thread.id,
|
||||
});
|
||||
}}
|
||||
onSelectPendingTask={openPendingTask}
|
||||
onDeletePendingTask={confirmDeletePendingTask}
|
||||
onNewThreadInProject={(project) => {
|
||||
navigation.navigate("NewTaskSheet", {
|
||||
screen: "NewTaskDraft",
|
||||
params: {
|
||||
environmentId: String(project.environmentId),
|
||||
projectId: String(project.id),
|
||||
title: project.title,
|
||||
},
|
||||
});
|
||||
}}
|
||||
onStartNewTask={() => navigation.navigate("NewTaskSheet", { screen: "NewTask" })}
|
||||
onThreadSortOrderChange={setThreadSortOrder}
|
||||
pendingTasks={pendingTasks}
|
||||
projectGroupingMode={listOptions.projectGroupingMode}
|
||||
projects={projects}
|
||||
projectSortOrder={listOptions.projectSortOrder}
|
||||
savedConnectionsById={savedConnectionsById}
|
||||
searchQuery={searchQuery}
|
||||
selectedEnvironmentId={selectedEnvironmentId}
|
||||
selectedProjectKey={selectedProjectKey}
|
||||
threads={threads}
|
||||
threadSortOrder={listOptions.threadSortOrder}
|
||||
/>
|
||||
</>
|
||||
</AndroidHomeFabLayout>
|
||||
<HomeScreen
|
||||
catalogState={catalogState}
|
||||
environments={environments}
|
||||
onAddConnection={() =>
|
||||
navigation.navigate("SettingsSheet", { screen: "SettingsEnvironmentNew" })
|
||||
}
|
||||
onArchiveThread={archiveThread}
|
||||
onDeleteThread={confirmDeleteThread}
|
||||
onSettleThread={settleThread}
|
||||
onSnoozeThread={snoozeThread}
|
||||
onUnsnoozeThread={unsnoozeThread}
|
||||
onUnsettleThread={unsettleThread}
|
||||
onPinThread={pinThread}
|
||||
onUnpinThread={unpinThread}
|
||||
onEnvironmentChange={setSelectedEnvironmentId}
|
||||
onProjectChange={setSelectedProjectKey}
|
||||
onOpenEnvironments={() =>
|
||||
navigation.navigate("SettingsSheet", { screen: "SettingsEnvironments" })
|
||||
}
|
||||
onOpenSettings={() => navigation.navigate("SettingsSheet", { screen: "Settings" })}
|
||||
onProjectSortOrderChange={setProjectSortOrder}
|
||||
onSearchQueryChange={setSearchQuery}
|
||||
onSelectThread={(thread) => {
|
||||
// Settled threads are live shells: opening one is plain
|
||||
// navigation, and sending a message un-settles server-side.
|
||||
navigation.navigate("Thread", {
|
||||
environmentId: thread.environmentId,
|
||||
threadId: thread.id,
|
||||
});
|
||||
}}
|
||||
onSelectPendingTask={openPendingTask}
|
||||
onDeletePendingTask={confirmDeletePendingTask}
|
||||
onNewThreadInProject={(project) => {
|
||||
navigation.navigate("NewTaskSheet", {
|
||||
screen: "NewTaskDraft",
|
||||
params: {
|
||||
environmentId: String(project.environmentId),
|
||||
projectId: String(project.id),
|
||||
title: project.title,
|
||||
},
|
||||
});
|
||||
}}
|
||||
onStartNewTask={() => navigation.navigate("NewTaskSheet", { screen: "NewTask" })}
|
||||
onThreadSortOrderChange={setThreadSortOrder}
|
||||
pendingTasks={pendingTasks}
|
||||
projectGroupingMode={listOptions.projectGroupingMode}
|
||||
projects={projects}
|
||||
projectSortOrder={listOptions.projectSortOrder}
|
||||
savedConnectionsById={savedConnectionsById}
|
||||
searchQuery={searchQuery}
|
||||
selectedEnvironmentId={selectedEnvironmentId}
|
||||
selectedProjectKey={selectedProjectKey}
|
||||
threads={threads}
|
||||
threadSortOrder={listOptions.threadSortOrder}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -19,17 +19,16 @@ import type {
|
||||
import { useAtomSet, useAtomValue } from "@effect/atom-react";
|
||||
import { AsyncResult } from "effect/unstable/reactivity";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { ActivityIndicator, FlatList, Platform, Pressable, View } from "react-native";
|
||||
import { FlatList, Platform, Pressable, View } from "react-native";
|
||||
import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import { EmptyState } from "../../components/EmptyState";
|
||||
import type { WorkspaceEnvironment, WorkspaceState } from "../../state/workspaceModel";
|
||||
import type { SavedRemoteConnection } from "../../lib/connection";
|
||||
import { scopedProjectKey } from "../../lib/scopedEntities";
|
||||
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
|
||||
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
|
||||
import { useThreadSearch } from "../../state/queries";
|
||||
import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
|
||||
@@ -71,8 +70,6 @@ import {
|
||||
type HomeProjectSortOrder,
|
||||
} from "./homeThreadList";
|
||||
import { SwipeableScrollGateProvider, useSwipeableScrollGate } from "./thread-swipe-actions";
|
||||
import { WorkspaceConnectionStatus } from "./WorkspaceConnectionStatus";
|
||||
import { shouldShowWorkspaceConnectionStatus } from "./workspace-connection-status";
|
||||
|
||||
/* ─── Types ──────────────────────────────────────────────────────────── */
|
||||
|
||||
@@ -120,14 +117,7 @@ interface HomeScreenProps {
|
||||
|
||||
/* ─── Layout constants ───────────────────────────────────────────────── */
|
||||
|
||||
const ESTIMATED_THREAD_ROW_HEIGHT = 72;
|
||||
const PRE_LIQUID_GLASS_BOTTOM_TOOLBAR_HEIGHT = 44;
|
||||
/**
|
||||
* Top spacing between the list and the Android custom header. The Android
|
||||
* header (AndroidHomeHeader) is rendered in-flow above this screen and
|
||||
* already consumes the top safe-area inset, so the list only needs breathing
|
||||
* room here.
|
||||
*/
|
||||
const ESTIMATED_THREAD_ROW_HEIGHT = 92;
|
||||
|
||||
function deriveEmptyState(props: {
|
||||
readonly catalogState: WorkspaceState;
|
||||
@@ -192,10 +182,6 @@ function deriveEmptyState(props: {
|
||||
};
|
||||
}
|
||||
|
||||
function HomeTopContentSpacer() {
|
||||
return <View className="h-4" />;
|
||||
}
|
||||
|
||||
/* ─── Main screen ────────────────────────────────────────────────────── */
|
||||
|
||||
export function HomeScreen(props: HomeScreenProps) {
|
||||
@@ -208,11 +194,6 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
const openSwipeableRef = useRef<SwipeableMethods | null>(null);
|
||||
const listRef = useRef<LegendListRef | null>(null);
|
||||
const insets = useSafeAreaInsets();
|
||||
const accentColor = useThemeColor("--color-icon-muted");
|
||||
const iosBottomToolbarClearance =
|
||||
Platform.OS === "ios" && !NATIVE_LIQUID_GLASS_SUPPORTED
|
||||
? PRE_LIQUID_GLASS_BOTTOM_TOOLBAR_HEIGHT
|
||||
: 0;
|
||||
const searchEnvironmentIds = useMemo(
|
||||
() =>
|
||||
props.selectedEnvironmentId === null
|
||||
@@ -416,6 +397,16 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
return map;
|
||||
}, [props.projects]);
|
||||
|
||||
const connectionStateByEnvironmentId = useMemo(
|
||||
() =>
|
||||
new Map(
|
||||
props.environments.map(
|
||||
(environment) => [environment.environmentId, environment.connectionState] as const,
|
||||
),
|
||||
),
|
||||
[props.environments],
|
||||
);
|
||||
|
||||
const v2ProjectScopeKey = props.selectedProjectKey;
|
||||
const v2ScopeProjects = useMemo(
|
||||
() =>
|
||||
@@ -706,11 +697,12 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
project={projectByKey.get(pendingScopeKey) ?? null}
|
||||
projectTitle={v2ProjectTitleByProjectKey.get(pendingScopeKey)}
|
||||
environmentLabel={
|
||||
Object.keys(props.savedConnectionsById).length > 1
|
||||
? (props.savedConnectionsById[item.pendingTask.message.environmentId]
|
||||
?.environmentLabel ?? null)
|
||||
: null
|
||||
props.savedConnectionsById[item.pendingTask.message.environmentId]
|
||||
?.environmentLabel ?? null
|
||||
}
|
||||
environmentConnectionState={connectionStateByEnvironmentId.get(
|
||||
item.pendingTask.message.environmentId,
|
||||
)}
|
||||
showPendingDivider={item.showPendingDivider}
|
||||
onSelectPendingTask={props.onSelectPendingTask}
|
||||
onDeletePendingTask={props.onDeletePendingTask}
|
||||
@@ -760,10 +752,9 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
)?.driver ?? null
|
||||
}
|
||||
environmentLabel={
|
||||
Object.keys(props.savedConnectionsById).length > 1
|
||||
? (props.savedConnectionsById[thread.environmentId]?.environmentLabel ?? null)
|
||||
: null
|
||||
props.savedConnectionsById[thread.environmentId]?.environmentLabel ?? null
|
||||
}
|
||||
environmentConnectionState={connectionStateByEnvironmentId.get(thread.environmentId)}
|
||||
searchMatch={threadSearchMatchByKey.get(
|
||||
threadSearchMatchKey({
|
||||
environmentId: thread.environmentId,
|
||||
@@ -804,6 +795,7 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
handleSwipeableWillOpen,
|
||||
handleUnsettleThread,
|
||||
pinningEnvironmentIds,
|
||||
connectionStateByEnvironmentId,
|
||||
projectByKey,
|
||||
projectCwdByKey,
|
||||
props.onArchiveThread,
|
||||
@@ -829,6 +821,7 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
// HomeScreen render.
|
||||
const v2ExtraData = useMemo(
|
||||
() => ({
|
||||
connectionStateByEnvironmentId,
|
||||
projectByKey,
|
||||
projectCwdByKey,
|
||||
projectTitleByProjectKey: v2ProjectTitleByProjectKey,
|
||||
@@ -839,6 +832,7 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
threadSearchMatchByKey,
|
||||
}),
|
||||
[
|
||||
connectionStateByEnvironmentId,
|
||||
projectByKey,
|
||||
projectCwdByKey,
|
||||
props.searchQuery,
|
||||
@@ -969,29 +963,34 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
? null
|
||||
: (props.savedConnectionsById[props.selectedEnvironmentId]?.environmentLabel ??
|
||||
"this environment");
|
||||
const shouldShowConnectionStatus = shouldShowWorkspaceConnectionStatus(props.catalogState);
|
||||
const emptyState = deriveEmptyState({
|
||||
catalogState: props.catalogState,
|
||||
projectCount: props.projects.length,
|
||||
});
|
||||
const connectionStatus =
|
||||
shouldShowConnectionStatus && Platform.OS !== "ios" ? (
|
||||
<View
|
||||
className="absolute left-0 right-0 items-center"
|
||||
style={{ bottom: Math.max(insets.bottom, 18) + 76 }}
|
||||
>
|
||||
<WorkspaceConnectionStatus state={props.catalogState} onPress={props.onOpenEnvironments} />
|
||||
</View>
|
||||
) : null;
|
||||
const composeAction = (
|
||||
<Pressable
|
||||
accessibilityLabel="New task"
|
||||
accessibilityRole="button"
|
||||
className="absolute right-4 size-14 items-center justify-center rounded-full bg-white"
|
||||
onPress={props.onStartNewTask}
|
||||
style={({ pressed }) => ({
|
||||
bottom: Math.max(insets.bottom, 16) + 9,
|
||||
opacity: pressed ? 0.72 : 1,
|
||||
shadowColor: "#000",
|
||||
shadowOffset: { width: 0, height: 10 },
|
||||
shadowOpacity: 0.7,
|
||||
shadowRadius: 26,
|
||||
})}
|
||||
>
|
||||
<SymbolView name="square.and.pencil" size={22} tintColor="#000" type="monochrome" />
|
||||
</Pressable>
|
||||
);
|
||||
|
||||
if (!hasAnyThreads) {
|
||||
return (
|
||||
<View
|
||||
className="flex-1 items-center justify-center bg-screen px-8"
|
||||
style={{
|
||||
paddingBottom: Math.max(insets.bottom, 24) + iosBottomToolbarClearance,
|
||||
paddingTop: NATIVE_LIQUID_GLASS_SUPPORTED ? insets.top + 72 : 0,
|
||||
}}
|
||||
className="flex-1 items-center justify-center px-8"
|
||||
style={{ backgroundColor: "#000", paddingBottom: Math.max(insets.bottom, 24) }}
|
||||
>
|
||||
<View className="w-full max-w-[430px]">
|
||||
<EmptyState
|
||||
@@ -1001,45 +1000,15 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
onAction={!props.catalogState.hasReadyEnvironment ? props.onAddConnection : undefined}
|
||||
variant="plain"
|
||||
/>
|
||||
{emptyState.loading && !shouldShowConnectionStatus ? (
|
||||
<View className="mt-4 items-center">
|
||||
<ActivityIndicator color={accentColor} />
|
||||
</View>
|
||||
) : null}
|
||||
{shouldShowConnectionStatus && Platform.OS === "ios" ? (
|
||||
<View className="mt-4">
|
||||
<WorkspaceConnectionStatus
|
||||
state={props.catalogState}
|
||||
onPress={props.onOpenEnvironments}
|
||||
variant="sidebar"
|
||||
/>
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
{connectionStatus}
|
||||
{composeAction}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const listHeader = (
|
||||
<>
|
||||
{Platform.OS === "ios" ? null : <HomeTopContentSpacer />}
|
||||
|
||||
{shouldShowConnectionStatus && Platform.OS === "ios" ? (
|
||||
<View className="pb-4">
|
||||
<WorkspaceConnectionStatus
|
||||
state={props.catalogState}
|
||||
onPress={props.onOpenEnvironments}
|
||||
variant="sidebar"
|
||||
/>
|
||||
</View>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
|
||||
// Project scoping lives in the header filter menu (no inline chip row on
|
||||
// mobile — the menu is the one filter surface).
|
||||
const v2ListHeader = listHeader;
|
||||
const listHeader = null;
|
||||
|
||||
const listEmpty = !hasResults ? (
|
||||
hasSearchQuery && threadSearch.isPending ? null : hasSearchQuery ? (
|
||||
@@ -1076,14 +1045,14 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
|
||||
if (threadListV2Enabled) {
|
||||
return (
|
||||
<View className="flex-1 bg-screen">
|
||||
<View className="flex-1" style={{ backgroundColor: "#000" }}>
|
||||
<SwipeableScrollGateProvider enabled={swipeEnabled}>
|
||||
<FlatList
|
||||
data={threadListV2Items}
|
||||
renderItem={renderV2Item}
|
||||
keyExtractor={v2KeyExtractor}
|
||||
extraData={v2ExtraData}
|
||||
ListHeaderComponent={v2ListHeader}
|
||||
ListHeaderComponent={listHeader}
|
||||
ListFooterComponent={
|
||||
settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 ? (
|
||||
<Pressable
|
||||
@@ -1101,28 +1070,25 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
}
|
||||
ListEmptyComponent={v2ListEmpty}
|
||||
style={{ flex: 1 }}
|
||||
automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
|
||||
contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
|
||||
automaticallyAdjustsScrollIndicatorInsets={false}
|
||||
contentInsetAdjustmentBehavior="never"
|
||||
showsVerticalScrollIndicator={false}
|
||||
keyboardDismissMode="on-drag"
|
||||
keyboardShouldPersistTaps="handled"
|
||||
{...scrollGateHandlers}
|
||||
scrollEventThrottle={16}
|
||||
contentContainerStyle={{
|
||||
paddingBottom:
|
||||
Platform.OS === "ios"
|
||||
? Math.max(insets.bottom, 24) + 96 + iosBottomToolbarClearance
|
||||
: Math.max(insets.bottom, 16) + 88,
|
||||
paddingBottom: Math.max(insets.bottom, 16) + 80,
|
||||
}}
|
||||
/>
|
||||
</SwipeableScrollGateProvider>
|
||||
{connectionStatus}
|
||||
{composeAction}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="flex-1 bg-screen">
|
||||
<View className="flex-1" style={{ backgroundColor: "#000" }}>
|
||||
{/* Sticky headers are deliberately not wired up: LegendList's JS sticky
|
||||
implementation mispositions pinned headers at mount under iOS
|
||||
automatic content insets (headers render one nav-inset too low until
|
||||
@@ -1142,8 +1108,8 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
ListHeaderComponent={listHeader}
|
||||
ListEmptyComponent={listEmpty}
|
||||
style={{ flex: 1 }}
|
||||
automaticallyAdjustsScrollIndicatorInsets={NATIVE_LIQUID_GLASS_SUPPORTED}
|
||||
contentInsetAdjustmentBehavior={NATIVE_LIQUID_GLASS_SUPPORTED ? "automatic" : "never"}
|
||||
automaticallyAdjustsScrollIndicatorInsets={false}
|
||||
contentInsetAdjustmentBehavior="never"
|
||||
showsVerticalScrollIndicator={false}
|
||||
keyboardDismissMode="on-drag"
|
||||
keyboardShouldPersistTaps="handled"
|
||||
@@ -1151,27 +1117,19 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
recycleItems
|
||||
scrollEventThrottle={16}
|
||||
contentContainerStyle={{
|
||||
// Android reserves room for the floating new-task FAB
|
||||
// (56 button + 16 gap + bottom inset). Pre-glass iOS shows a
|
||||
// standard 44pt bottom toolbar that overlays the list and is not
|
||||
// reflected in insets while contentInsetAdjustmentBehavior is
|
||||
// "never".
|
||||
paddingBottom:
|
||||
Platform.OS === "ios"
|
||||
? Math.max(insets.bottom, 24) + 24 + iosBottomToolbarClearance
|
||||
: Math.max(insets.bottom, 16) + 88,
|
||||
paddingBottom: Math.max(insets.bottom, 16) + 80,
|
||||
}}
|
||||
scrollIndicatorInsets={
|
||||
Platform.OS === "ios"
|
||||
? {
|
||||
bottom: Math.max(insets.bottom, 16) + 24 + iosBottomToolbarClearance,
|
||||
bottom: Math.max(insets.bottom, 16) + 80,
|
||||
top: 0,
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
</SwipeableScrollGateProvider>
|
||||
{connectionStatus}
|
||||
{composeAction}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -2,7 +2,9 @@ import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import type { WorkspaceState } from "../../state/workspaceModel";
|
||||
import {
|
||||
resolveHomeEnvironmentConnectionPhase,
|
||||
shouldShowWorkspaceConnectionStatus,
|
||||
workspaceConnectionHeaderPresentation,
|
||||
workspaceConnectionStatusLabel,
|
||||
} from "./workspace-connection-status";
|
||||
|
||||
@@ -25,6 +27,12 @@ function workspaceState(overrides: Partial<WorkspaceState> = {}): WorkspaceState
|
||||
}
|
||||
|
||||
describe("workspace connection status", () => {
|
||||
it("treats uncatalogued saved environments as connecting during startup", () => {
|
||||
expect(resolveHomeEnvironmentConnectionPhase(undefined, true)).toBe("connecting");
|
||||
expect(resolveHomeEnvironmentConnectionPhase(undefined, false)).toBe("available");
|
||||
expect(resolveHomeEnvironmentConnectionPhase("connected", true)).toBe("connected");
|
||||
});
|
||||
|
||||
it("stays hidden while a ready environment is connected", () => {
|
||||
expect(shouldShowWorkspaceConnectionStatus(workspaceState())).toBe(false);
|
||||
});
|
||||
@@ -84,4 +92,56 @@ describe("workspace connection status", () => {
|
||||
expect(shouldShowWorkspaceConnectionStatus(state)).toBe(true);
|
||||
expect(workspaceConnectionStatusLabel(state)).toBe("Loading threads...");
|
||||
});
|
||||
|
||||
it("keeps healthy shell synchronization out of the Home wordmark", () => {
|
||||
const state = workspaceState({ hasPendingShellSnapshot: true });
|
||||
|
||||
expect(workspaceConnectionHeaderPresentation(state, "Leftbook")).toBeNull();
|
||||
});
|
||||
|
||||
it("presents reconnecting environments in amber", () => {
|
||||
const state = workspaceState({
|
||||
hasConnectingEnvironment: true,
|
||||
connectingEnvironments: [
|
||||
{
|
||||
environmentId: "environment-1" as never,
|
||||
environmentLabel: "Leftbook",
|
||||
displayUrl: "",
|
||||
isRelayManaged: false,
|
||||
connectionState: "reconnecting",
|
||||
connectionError: null,
|
||||
connectionErrorTraceId: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(workspaceConnectionHeaderPresentation(state, "Other device")).toEqual({
|
||||
detail: "reconnecting",
|
||||
label: "Leftbook",
|
||||
tone: "amber",
|
||||
});
|
||||
});
|
||||
|
||||
it("presents unreachable environments in red", () => {
|
||||
const state = workspaceState({
|
||||
connectionError: "Connection refused",
|
||||
hasReadyEnvironment: false,
|
||||
});
|
||||
|
||||
expect(workspaceConnectionHeaderPresentation(state, "Steambox")).toEqual({
|
||||
detail: "unreachable",
|
||||
label: "Steambox",
|
||||
tone: "red",
|
||||
});
|
||||
});
|
||||
|
||||
it("surfaces one unavailable device while other environments stay connected", () => {
|
||||
const state = workspaceState();
|
||||
|
||||
expect(workspaceConnectionHeaderPresentation(state, "Steambox", "available")).toEqual({
|
||||
detail: "unreachable",
|
||||
label: "Steambox",
|
||||
tone: "red",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,17 +1,81 @@
|
||||
import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
|
||||
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import { ActivityIndicator, Pressable } from "react-native";
|
||||
import type { ReactNode } from "react";
|
||||
import { Pressable, View } from "react-native";
|
||||
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
import type { WorkspaceState } from "../../state/workspaceModel";
|
||||
import { workspaceConnectionStatusLabel } from "./workspace-connection-status";
|
||||
import {
|
||||
workspaceConnectionHeaderPresentation,
|
||||
workspaceConnectionStatusLabel,
|
||||
} from "./workspace-connection-status";
|
||||
|
||||
export function WorkspaceConnectionStatus(props: {
|
||||
readonly state: WorkspaceState;
|
||||
readonly onPress: () => void;
|
||||
readonly variant?: "floating" | "sidebar";
|
||||
readonly onReconnect?: () => void;
|
||||
readonly environmentLabel?: string;
|
||||
readonly environmentConnectionState?: EnvironmentConnectionPhase;
|
||||
readonly fallback?: ReactNode;
|
||||
readonly variant?: "floating" | "header" | "sidebar";
|
||||
}) {
|
||||
const iconColor = useThemeColor("--color-icon-muted");
|
||||
if (props.variant === "header") {
|
||||
const presentation = workspaceConnectionHeaderPresentation(
|
||||
props.state,
|
||||
props.environmentLabel,
|
||||
props.environmentConnectionState,
|
||||
);
|
||||
if (presentation === null) return <>{props.fallback}</>;
|
||||
|
||||
const tintColor = presentation.tone === "amber" ? "#fbbf24" : "#f87171";
|
||||
const label = `${presentation.label} ${presentation.detail}`;
|
||||
return (
|
||||
<View className="h-12 min-w-0 flex-row items-center gap-2.5">
|
||||
<Pressable
|
||||
accessibilityHint="Opens environment settings"
|
||||
accessibilityLabel={label}
|
||||
accessibilityRole="button"
|
||||
className="min-w-0 flex-1 flex-row items-center gap-2.5 self-stretch"
|
||||
onPress={props.onPress}
|
||||
>
|
||||
<SymbolView
|
||||
name={
|
||||
presentation.tone === "amber" ? "point.3.connected.trianglepath.dotted" : "wifi.slash"
|
||||
}
|
||||
size={17}
|
||||
tintColor={tintColor}
|
||||
type="monochrome"
|
||||
/>
|
||||
<Text
|
||||
className="min-w-0 shrink text-base font-t3-bold"
|
||||
numberOfLines={1}
|
||||
style={{ color: tintColor }}
|
||||
>
|
||||
{presentation.label}{" "}
|
||||
<Text className="text-sm font-t3-medium" style={{ color: tintColor, opacity: 0.72 }}>
|
||||
{presentation.detail}
|
||||
</Text>
|
||||
</Text>
|
||||
</Pressable>
|
||||
{presentation.tone === "red" && props.onReconnect ? (
|
||||
<Pressable
|
||||
accessibilityLabel={`Reconnect ${presentation.label}`}
|
||||
accessibilityRole="button"
|
||||
hitSlop={8}
|
||||
onPress={props.onReconnect}
|
||||
>
|
||||
<Text className="text-xs font-t3-bold" style={{ color: tintColor }}>
|
||||
Reconnect
|
||||
</Text>
|
||||
</Pressable>
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const isSynchronizing =
|
||||
props.state.networkStatus !== "offline" &&
|
||||
props.state.connectionError === null &&
|
||||
@@ -41,7 +105,12 @@ export function WorkspaceConnectionStatus(props: {
|
||||
}
|
||||
>
|
||||
{isSynchronizing ? (
|
||||
<ActivityIndicator color={iconColor} size="small" />
|
||||
<SymbolView
|
||||
name="point.3.connected.trianglepath.dotted"
|
||||
size={15}
|
||||
tintColor={iconColor}
|
||||
type="monochrome"
|
||||
/>
|
||||
) : (
|
||||
<SymbolView name="wifi.slash" size={15} tintColor={iconColor} type="monochrome" />
|
||||
)}
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
|
||||
|
||||
import type { WorkspaceState } from "../../state/workspaceModel";
|
||||
|
||||
export function resolveHomeEnvironmentConnectionPhase(
|
||||
connectionState: EnvironmentConnectionPhase | undefined,
|
||||
isLoadingConnections: boolean,
|
||||
): EnvironmentConnectionPhase {
|
||||
return connectionState ?? (isLoadingConnections ? "connecting" : "available");
|
||||
}
|
||||
|
||||
export function shouldShowWorkspaceConnectionStatus(state: WorkspaceState): boolean {
|
||||
return (
|
||||
state.networkStatus === "offline" ||
|
||||
@@ -24,3 +33,71 @@ export function workspaceConnectionStatusLabel(state: WorkspaceState): string {
|
||||
}
|
||||
return "Not connected";
|
||||
}
|
||||
|
||||
export interface WorkspaceConnectionHeaderPresentation {
|
||||
readonly detail: "reconnecting" | "unreachable";
|
||||
readonly label: string;
|
||||
readonly tone: "amber" | "red";
|
||||
}
|
||||
|
||||
/**
|
||||
* Only actual connection trouble displaces the Home wordmark. Shell catch-up
|
||||
* is healthy background work and deliberately leaves the header unchanged.
|
||||
*/
|
||||
export function workspaceConnectionHeaderPresentation(
|
||||
state: WorkspaceState,
|
||||
environmentLabel?: string,
|
||||
environmentConnectionState?: EnvironmentConnectionPhase,
|
||||
): WorkspaceConnectionHeaderPresentation | null {
|
||||
if (state.networkStatus === "offline") {
|
||||
return {
|
||||
detail: "unreachable",
|
||||
label: environmentLabel ?? "Network",
|
||||
tone: "red",
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
environmentConnectionState === "connecting" ||
|
||||
environmentConnectionState === "reconnecting"
|
||||
) {
|
||||
return {
|
||||
detail: "reconnecting",
|
||||
label: environmentLabel ?? "Environment",
|
||||
tone: "amber",
|
||||
};
|
||||
}
|
||||
|
||||
if (environmentConnectionState && environmentConnectionState !== "connected") {
|
||||
return {
|
||||
detail: "unreachable",
|
||||
label: environmentLabel ?? "Environment",
|
||||
tone: "red",
|
||||
};
|
||||
}
|
||||
|
||||
if (state.connectingEnvironments.length > 0) {
|
||||
const connecting = state.connectingEnvironments[0];
|
||||
return {
|
||||
detail: "reconnecting",
|
||||
label:
|
||||
state.connectingEnvironments.length === 1
|
||||
? (connecting?.environmentLabel ?? environmentLabel ?? "Environment")
|
||||
: `${state.connectingEnvironments.length} environments`,
|
||||
tone: "amber",
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
state.connectionError !== null ||
|
||||
(state.hasConnections && state.hasLoadedShellSnapshot && !state.hasReadyEnvironment)
|
||||
) {
|
||||
return {
|
||||
detail: "unreachable",
|
||||
label: environmentLabel ?? "Environment",
|
||||
tone: "red",
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
import { NativeStackScreenOptions } from "../../native/StackHeader";
|
||||
import { StackActions, useNavigation, usePreventRemove } from "@react-navigation/native";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { Alert, InteractionManager, Platform, View, useColorScheme } from "react-native";
|
||||
import { Alert, Keyboard, Pressable, View, useColorScheme } from "react-native";
|
||||
import { KeyboardAvoidingView, useKeyboardState } from "react-native-keyboard-controller";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
import { useFontFamily } from "../../lib/useFontFamily";
|
||||
|
||||
import { EnvironmentId } from "@t3tools/contracts";
|
||||
import {
|
||||
@@ -20,9 +19,11 @@ import {
|
||||
ComposerToolbarScroller,
|
||||
ComposerToolbarTrigger,
|
||||
} from "../../components/ComposerToolbarTrigger";
|
||||
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import { ComposerAttachmentStrip } from "../../components/ComposerAttachmentStrip";
|
||||
import { ControlPill, ControlPillMenu } from "../../components/ControlPill";
|
||||
import { ControlPillMenu } from "../../components/ControlPill";
|
||||
import { ModelPickerSheet } from "../../components/ModelPickerSheet";
|
||||
import { ProviderIcon } from "../../components/ProviderIcon";
|
||||
import { ComposerSurface } from "./ThreadComposer";
|
||||
|
||||
@@ -31,7 +32,6 @@ import { convertPastedImagesToAttachments, pickComposerImages } from "../../lib/
|
||||
import {
|
||||
applyProviderOptionMenuEvent,
|
||||
buildProviderOptionMenuActions,
|
||||
providerOptionsConfigurationLabel,
|
||||
resolveProviderOptionDescriptors,
|
||||
} from "../../lib/providerOptions";
|
||||
import { useScaledTextRole } from "../settings/appearance/useScaledTextRole";
|
||||
@@ -43,7 +43,7 @@ import {
|
||||
type ComposerDraft,
|
||||
} from "../../state/use-composer-drafts";
|
||||
import { useEnvironmentServerConfig, useProjects } from "../../state/entities";
|
||||
import { buildModelMenuActions, resolveSelectableModelSelection } from "../../lib/modelOptions";
|
||||
import { resolveSelectableModelSelection } from "../../lib/modelOptions";
|
||||
import { deriveThreadTitleFromPrompt } from "../../lib/projectThreadStartTurn";
|
||||
import { armAgentAwarenessLiveActivityForLocalWork } from "../agent-awareness/remoteRegistration";
|
||||
import { enqueueThreadOutboxMessage, removeThreadOutboxMessage } from "../../state/thread-outbox";
|
||||
@@ -51,18 +51,7 @@ import { useRemoteConnectionStatus } from "../../state/use-remote-environment-re
|
||||
import { branchBadgeLabel, useNewTaskFlow } from "./new-task-flow-provider";
|
||||
import { useCreateProjectThread } from "./use-project-actions";
|
||||
import { useIncomingShare } from "../sharing/IncomingShareProvider";
|
||||
|
||||
function formatWorkspaceLabel(input: {
|
||||
readonly workspaceMode: string;
|
||||
readonly currentBranchName: string | null;
|
||||
readonly selectedBranchName: string | null;
|
||||
}): string {
|
||||
const branchName = input.selectedBranchName ?? input.currentBranchName;
|
||||
if (input.workspaceMode === "worktree") {
|
||||
return branchName ? `New worktree · ${branchName}` : "New worktree";
|
||||
}
|
||||
return branchName ? `Current · ${branchName}` : "Current checkout";
|
||||
}
|
||||
import { useModelFavorites } from "./useModelFavorites";
|
||||
|
||||
export function NewTaskDraftScreen(props: {
|
||||
readonly initialProjectRef?: {
|
||||
@@ -94,6 +83,9 @@ export function NewTaskDraftScreen(props: {
|
||||
const selectedEnvironmentServerConfig = useEnvironmentServerConfig(
|
||||
selectedProject?.environmentId ?? null,
|
||||
);
|
||||
const { favoriteModelKeys, favoritesReady, toggleFavorite } = useModelFavorites(
|
||||
selectedProject?.environmentId ?? null,
|
||||
);
|
||||
const environmentConnected =
|
||||
selectedProject !== null &&
|
||||
connectedEnvironments.find(
|
||||
@@ -101,12 +93,12 @@ export function NewTaskDraftScreen(props: {
|
||||
)?.connectionState === "connected";
|
||||
const promptInputRef = useRef<ComposerEditorHandle>(null);
|
||||
const loadedBranchesProjectKeyRef = useRef<string | null>(null);
|
||||
const [isComposerFocused, setIsComposerFocused] = useState(false);
|
||||
const [importingShareKey, setImportingShareKey] = useState<string | null>(null);
|
||||
const [isCancellingShareImport, setIsCancellingShareImport] = useState(false);
|
||||
const [cancelledIncomingShareId, setCancelledIncomingShareId] = useState<string | null>(null);
|
||||
const [isReturningToProjectPicker, setIsReturningToProjectPicker] = useState(false);
|
||||
const [shareImportAttempt, setShareImportAttempt] = useState(0);
|
||||
const [modelPickerVisible, setModelPickerVisible] = useState(false);
|
||||
const startedShareImportKeyRef = useRef<string | null>(null);
|
||||
const cancellingShareImportKeyRef = useRef<string | null>(null);
|
||||
const shareImportDraftBackupRef = useRef(new Map<string, ComposerDraft>());
|
||||
@@ -221,11 +213,8 @@ export function NewTaskDraftScreen(props: {
|
||||
}, [props.pendingTaskId, cancelEditingPendingTask]);
|
||||
|
||||
const foregroundColor = useThemeColor("--color-foreground");
|
||||
const regularFontFamily = useFontFamily("regular");
|
||||
const bodyText = useScaledTextRole("body");
|
||||
const headlineText = useScaledTextRole("headline");
|
||||
const sheetFadeOpaque = colorScheme === "dark" ? "rgba(14,14,14,0.98)" : "rgba(242,242,247,0.98)";
|
||||
const sheetFadeTransparent = colorScheme === "dark" ? "rgba(14,14,14,0)" : "rgba(242,242,247,0)";
|
||||
|
||||
// A new navigation to this mounted screen delivers a fresh initialProjectRef
|
||||
// reference — treat it as a new request and let it apply again.
|
||||
@@ -510,26 +499,6 @@ export function NewTaskDraftScreen(props: {
|
||||
shareImportAttempt,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
// Android starts with the collapsed composer pill (like an open thread)
|
||||
// and only expands/focuses when tapped.
|
||||
if (!selectedProject || Platform.OS === "android") {
|
||||
return;
|
||||
}
|
||||
|
||||
let focusFrame: ReturnType<typeof requestAnimationFrame> | null = null;
|
||||
const interaction = InteractionManager.runAfterInteractions(() => {
|
||||
focusFrame = requestAnimationFrame(() => promptInputRef.current?.focus());
|
||||
});
|
||||
|
||||
return () => {
|
||||
interaction.cancel();
|
||||
if (focusFrame !== null) {
|
||||
cancelAnimationFrame(focusFrame);
|
||||
}
|
||||
};
|
||||
}, [selectedProject]);
|
||||
|
||||
const environmentMenuActions = useMemo(
|
||||
() =>
|
||||
flow.environments.map((environment) => ({
|
||||
@@ -542,10 +511,6 @@ export function NewTaskDraftScreen(props: {
|
||||
[flow.environments, flow.selectedEnvironmentId, isIncomingShareTransferPending],
|
||||
);
|
||||
|
||||
const modelMenuActions = useMemo(
|
||||
() => buildModelMenuActions(flow.providerGroups, flow.selectedModel),
|
||||
[flow.providerGroups, flow.selectedModel],
|
||||
);
|
||||
const providerOptionDescriptors = useMemo(
|
||||
() =>
|
||||
resolveProviderOptionDescriptors({
|
||||
@@ -669,30 +634,19 @@ export function NewTaskDraftScreen(props: {
|
||||
flow.environments.find(
|
||||
(environment) => environment.environmentId === flow.selectedEnvironmentId,
|
||||
)?.environmentLabel ?? "Environment";
|
||||
const currentBranchName =
|
||||
flow.availableBranches.find((branch) => branch.current)?.name ??
|
||||
flow.availableBranches.find((branch) => branch.isDefault)?.name ??
|
||||
null;
|
||||
const configurationLabel = useMemo(
|
||||
() => providerOptionsConfigurationLabel(providerOptionDescriptors),
|
||||
[providerOptionDescriptors],
|
||||
const configurationMenuActions = useMemo(
|
||||
() => [
|
||||
...optionsMenuActions,
|
||||
{
|
||||
id: "options-environment",
|
||||
title: "Environment",
|
||||
subtitle: selectedEnvironmentLabel,
|
||||
subactions: environmentMenuActions,
|
||||
},
|
||||
...workspaceMenuActions,
|
||||
],
|
||||
[environmentMenuActions, optionsMenuActions, selectedEnvironmentLabel, workspaceMenuActions],
|
||||
);
|
||||
const workspaceLabel = useMemo(
|
||||
() =>
|
||||
formatWorkspaceLabel({
|
||||
currentBranchName,
|
||||
selectedBranchName: flow.selectedBranchName,
|
||||
workspaceMode: flow.workspaceMode,
|
||||
}),
|
||||
[currentBranchName, flow.selectedBranchName, flow.workspaceMode],
|
||||
);
|
||||
function handleModelMenuAction(event: string) {
|
||||
if (isIncomingShareTransferPending || !event.startsWith("model:")) {
|
||||
return;
|
||||
}
|
||||
flow.setSelectedModelKey(event.slice("model:".length));
|
||||
}
|
||||
|
||||
function handleEnvironmentMenuAction(event: string) {
|
||||
if (isIncomingShareTransferPending || !event.startsWith("environment:")) {
|
||||
return;
|
||||
@@ -745,6 +699,12 @@ export function NewTaskDraftScreen(props: {
|
||||
}
|
||||
}
|
||||
|
||||
function handleConfigurationMenuAction(event: string) {
|
||||
handleOptionsMenuAction(event);
|
||||
handleEnvironmentMenuAction(event);
|
||||
handleWorkspaceMenuAction(event);
|
||||
}
|
||||
|
||||
async function handlePickImages(): Promise<void> {
|
||||
if (isIncomingShareTransferPending) {
|
||||
return;
|
||||
@@ -911,24 +871,13 @@ export function NewTaskDraftScreen(props: {
|
||||
|
||||
if (!selectedProject) {
|
||||
return (
|
||||
<View className="flex-1 bg-sheet">
|
||||
{Platform.OS === "android" ? (
|
||||
<>
|
||||
<NativeStackScreenOptions options={{ headerShown: false }} />
|
||||
<AndroidScreenHeader title="New Thread" onBack={() => navigation.goBack()} />
|
||||
</>
|
||||
) : (
|
||||
<NativeStackScreenOptions options={{ title: "Loading task" }} />
|
||||
)}
|
||||
<View className="flex-1 bg-screen">
|
||||
<NativeStackScreenOptions options={{ headerShown: false }} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const isAndroid = Platform.OS === "android";
|
||||
const isDarkMode = colorScheme === "dark";
|
||||
// Android expansion follows native editor focus so relayout cannot race
|
||||
// the touch gesture that opens the keyboard.
|
||||
const isExpanded = !isAndroid || isComposerFocused;
|
||||
const canStart =
|
||||
Boolean(flow.selectedProject) &&
|
||||
Boolean(flow.selectedModel) &&
|
||||
@@ -940,90 +889,57 @@ export function NewTaskDraftScreen(props: {
|
||||
const promptEditor = (
|
||||
<ComposerEditor
|
||||
ref={promptInputRef}
|
||||
// Native autoFocus fires becomeFirstResponder in didMoveToWindow, which
|
||||
// forces the iOS keyboard bring-up during the formSheet present
|
||||
// animation and stalls it. The runAfterInteractions effect above focuses
|
||||
// the editor once the transition settles instead.
|
||||
autoFocus={false}
|
||||
editable={!isIncomingShareTransferPending}
|
||||
multiline
|
||||
scrollEnabled={isExpanded}
|
||||
scrollEnabled
|
||||
value={flow.prompt}
|
||||
skills={flow.selectedProviderSkills}
|
||||
onChangeText={flow.setPrompt}
|
||||
onFocus={() => setIsComposerFocused(true)}
|
||||
onBlur={() => setIsComposerFocused(false)}
|
||||
onPasteImages={(uris) => void handleNativePasteImages(uris)}
|
||||
placeholder={`Describe a coding task in ${selectedProject.title}`}
|
||||
// Same collapsed centering as ThreadComposer: native vertical gravity
|
||||
// in a pill-height box.
|
||||
singleLineCentered={!isExpanded}
|
||||
contentInsetVertical={isAndroid ? 0 : undefined}
|
||||
style={
|
||||
isAndroid
|
||||
? isExpanded
|
||||
? { minHeight: 80, maxHeight: 160, paddingHorizontal: 4, paddingVertical: 4 }
|
||||
: { height: 36 }
|
||||
: { flex: 1, minHeight: 0 }
|
||||
}
|
||||
textStyle={
|
||||
isAndroid
|
||||
? { ...bodyText, color: foregroundColor, fontFamily: regularFontFamily }
|
||||
: headlineText
|
||||
}
|
||||
placeholder="Ask anything..."
|
||||
contentInsetVertical={0}
|
||||
style={{
|
||||
minHeight: 76,
|
||||
maxHeight: 160,
|
||||
paddingHorizontal: 4,
|
||||
paddingVertical: 4,
|
||||
}}
|
||||
textStyle={{ ...bodyText, color: foregroundColor }}
|
||||
/>
|
||||
);
|
||||
|
||||
const toolbarPills = (
|
||||
<>
|
||||
<ComposerToolbarButton
|
||||
icon="plus"
|
||||
accessibilityLabel="Add attachment"
|
||||
disabled={isIncomingShareTransferPending}
|
||||
icon="paperclip"
|
||||
onPress={() => void handlePickImages()}
|
||||
showChevron={false}
|
||||
variant="ghost"
|
||||
/>
|
||||
<ComposerToolbarTrigger
|
||||
accessibilityLabel="Choose model"
|
||||
disabled={isIncomingShareTransferPending}
|
||||
iconNode={<ProviderIcon provider={flow.selectedModelOption?.providerDriver} size={18} />}
|
||||
label={flow.selectedModelOption?.label ?? "Model"}
|
||||
onPress={() => {
|
||||
Keyboard.dismiss();
|
||||
setModelPickerVisible(true);
|
||||
}}
|
||||
variant="ghost"
|
||||
/>
|
||||
<ControlPillMenu
|
||||
actions={modelMenuActions}
|
||||
onPressAction={({ nativeEvent }) => handleModelMenuAction(nativeEvent.event)}
|
||||
>
|
||||
<ComposerToolbarTrigger
|
||||
accessibilityLabel="Model"
|
||||
disabled={isIncomingShareTransferPending}
|
||||
iconNode={<ProviderIcon provider={flow.selectedModelOption?.providerDriver} size={16} />}
|
||||
label={flow.selectedModelOption?.label ?? "Model"}
|
||||
/>
|
||||
</ControlPillMenu>
|
||||
<ControlPillMenu
|
||||
actions={optionsMenuActions}
|
||||
onPressAction={({ nativeEvent }) => handleOptionsMenuAction(nativeEvent.event)}
|
||||
actions={configurationMenuActions}
|
||||
onPressAction={({ nativeEvent }) => handleConfigurationMenuAction(nativeEvent.event)}
|
||||
>
|
||||
<ComposerToolbarTrigger
|
||||
accessibilityLabel="Configuration"
|
||||
disabled={isIncomingShareTransferPending}
|
||||
icon="slider.horizontal.3"
|
||||
label={configurationLabel}
|
||||
/>
|
||||
</ControlPillMenu>
|
||||
<ControlPillMenu
|
||||
actions={environmentMenuActions}
|
||||
onPressAction={({ nativeEvent }) => handleEnvironmentMenuAction(nativeEvent.event)}
|
||||
>
|
||||
<ComposerToolbarTrigger
|
||||
accessibilityLabel="Environment"
|
||||
disabled={isIncomingShareTransferPending}
|
||||
icon="desktopcomputer"
|
||||
label={selectedEnvironmentLabel}
|
||||
/>
|
||||
</ControlPillMenu>
|
||||
<ControlPillMenu
|
||||
actions={workspaceMenuActions}
|
||||
onPressAction={({ nativeEvent }) => handleWorkspaceMenuAction(nativeEvent.event)}
|
||||
>
|
||||
<ComposerToolbarTrigger
|
||||
accessibilityLabel="Workspace"
|
||||
disabled={isIncomingShareTransferPending}
|
||||
icon="point.topleft.down.curvedto.point.bottomright.up"
|
||||
label={workspaceLabel}
|
||||
showChevron={false}
|
||||
variant="ghost"
|
||||
/>
|
||||
</ControlPillMenu>
|
||||
</>
|
||||
@@ -1034,7 +950,7 @@ export function NewTaskDraftScreen(props: {
|
||||
accessibilityLabel={
|
||||
flow.submitting ? "Starting task" : environmentConnected ? "Start task" : "Queue task"
|
||||
}
|
||||
icon={environmentConnected ? "arrow.up" : "tray.and.arrow.up"}
|
||||
icon="arrow.up"
|
||||
onPress={() => void handleStart()}
|
||||
variant="primary"
|
||||
showChevron={false}
|
||||
@@ -1042,115 +958,126 @@ export function NewTaskDraftScreen(props: {
|
||||
/>
|
||||
);
|
||||
|
||||
if (isAndroid) {
|
||||
// The draft is a thread that doesn't exist yet, so it mirrors the thread
|
||||
// page: in-screen header, empty feed canvas above, and the same floating
|
||||
// composer chrome as ThreadComposer (collapsed pill → expanded card).
|
||||
return (
|
||||
<View className="flex-1 bg-screen">
|
||||
<NativeStackScreenOptions options={{ headerShown: false }} />
|
||||
<AndroidScreenHeader title="New Thread" onBack={() => navigation.goBack()} />
|
||||
|
||||
<KeyboardAvoidingView automaticOffset behavior="padding" className="flex-1">
|
||||
<View className="flex-1" />
|
||||
|
||||
<View
|
||||
className="px-4 pt-2"
|
||||
return (
|
||||
<View
|
||||
className="flex-1 overflow-hidden"
|
||||
style={{
|
||||
backgroundColor: isDarkMode ? "#000000" : "#f2f2f7",
|
||||
borderColor: isDarkMode ? "rgba(255,255,255,0.14)" : "rgba(0,0,0,0.1)",
|
||||
borderTopLeftRadius: 20,
|
||||
borderTopRightRadius: 20,
|
||||
borderTopWidth: 1,
|
||||
}}
|
||||
>
|
||||
<NativeStackScreenOptions options={{ headerShown: false }} />
|
||||
<KeyboardAvoidingView automaticOffset behavior="padding" className="flex-1">
|
||||
<View style={{ paddingTop: Math.max(insets.top, 8) }}>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
disabled={isIncomingShareTransferPending || isCancellingShareImport}
|
||||
hitSlop={8}
|
||||
onPress={() => navigation.goBack()}
|
||||
className="self-start px-4 py-3 active:opacity-60"
|
||||
style={{
|
||||
paddingBottom: controlsBottomPadding,
|
||||
experimental_backgroundImage: isDarkMode
|
||||
? "linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.85) 40%, rgba(0,0,0,0.95) 100%)"
|
||||
: "linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,0.85) 40%, rgba(255,255,255,0.95) 100%)",
|
||||
opacity: isIncomingShareTransferPending || isCancellingShareImport ? 0.45 : 1,
|
||||
}}
|
||||
>
|
||||
<ComposerSurface
|
||||
isDarkMode={isDarkMode}
|
||||
style={
|
||||
isExpanded
|
||||
? {
|
||||
borderRadius: 20,
|
||||
overflow: "hidden",
|
||||
paddingHorizontal: 14,
|
||||
paddingVertical: 12,
|
||||
}
|
||||
: {
|
||||
borderRadius: 999,
|
||||
overflow: "hidden",
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
paddingLeft: 18,
|
||||
paddingRight: 5,
|
||||
paddingVertical: 5,
|
||||
}
|
||||
}
|
||||
<Text className="text-sm text-foreground-muted">Cancel</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
<View className="min-h-0 flex-1 items-center justify-center px-6 pb-12">
|
||||
<Text
|
||||
className="text-center font-t3-medium text-foreground"
|
||||
style={[headlineText, { fontSize: 28, lineHeight: 34, letterSpacing: -0.6 }]}
|
||||
>
|
||||
What should we build
|
||||
</Text>
|
||||
<View className="max-w-full flex-row items-center justify-center">
|
||||
<Text
|
||||
className="font-t3-medium text-foreground"
|
||||
style={[headlineText, { fontSize: 28, lineHeight: 34, letterSpacing: -0.6 }]}
|
||||
>
|
||||
{isExpanded && flow.attachments.length > 0 ? (
|
||||
<View className="pb-2.5">
|
||||
<ComposerAttachmentStrip
|
||||
attachments={flow.attachments}
|
||||
onRemove={
|
||||
isIncomingShareTransferPending ? () => undefined : flow.removeAttachment
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
) : null}
|
||||
<View className={isExpanded ? undefined : "min-w-0 flex-1"}>{promptEditor}</View>
|
||||
{!isExpanded ? (
|
||||
<ControlPill
|
||||
icon="arrow.up"
|
||||
variant="primary"
|
||||
disabled={!canStart}
|
||||
onPress={() => void handleStart()}
|
||||
/>
|
||||
) : null}
|
||||
</ComposerSurface>
|
||||
|
||||
{isExpanded ? (
|
||||
<ComposerToolbarRow paddingBottom={8} paddingHorizontal={0} paddingTop={8}>
|
||||
<ComposerToolbarScroller
|
||||
fadeOpaque={isDarkMode ? "rgba(0,0,0,0.95)" : "rgba(255,255,255,0.95)"}
|
||||
fadeTransparent={isDarkMode ? "rgba(0,0,0,0)" : "rgba(255,255,255,0)"}
|
||||
>
|
||||
{toolbarPills}
|
||||
</ComposerToolbarScroller>
|
||||
{startButton}
|
||||
</ComposerToolbarRow>
|
||||
) : null}
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="flex-1 bg-sheet">
|
||||
<NativeStackScreenOptions options={{ title: selectedProject.title }} />
|
||||
|
||||
<KeyboardAvoidingView automaticOffset behavior="padding" className="flex-1">
|
||||
<View className="min-h-0 flex-1 px-5 pt-2">{promptEditor}</View>
|
||||
|
||||
<View className="border-t border-border" style={{ paddingBottom: controlsBottomPadding }}>
|
||||
{flow.attachments.length > 0 ? (
|
||||
<View className="px-4 pt-3">
|
||||
<ComposerAttachmentStrip
|
||||
attachments={flow.attachments}
|
||||
onRemove={isIncomingShareTransferPending ? () => undefined : flow.removeAttachment}
|
||||
imageSize={88}
|
||||
imageBorderRadius={20}
|
||||
/>
|
||||
in{" "}
|
||||
</Text>
|
||||
<View
|
||||
className="max-w-[240px] border-b border-foreground-muted"
|
||||
style={{ borderStyle: "dotted" }}
|
||||
>
|
||||
<Text
|
||||
className="font-t3-medium text-foreground"
|
||||
ellipsizeMode="tail"
|
||||
numberOfLines={1}
|
||||
style={[headlineText, { fontSize: 28, lineHeight: 34, letterSpacing: -0.6 }]}
|
||||
>
|
||||
{selectedProject.title}
|
||||
</Text>
|
||||
</View>
|
||||
) : null}
|
||||
<ComposerToolbarRow paddingBottom={controlsBottomPadding} paddingHorizontal={6}>
|
||||
<ComposerToolbarScroller
|
||||
fadeOpaque={sheetFadeOpaque}
|
||||
fadeTransparent={sheetFadeTransparent}
|
||||
<Text
|
||||
className="font-t3-medium text-foreground"
|
||||
style={[headlineText, { fontSize: 28, lineHeight: 34, letterSpacing: -0.6 }]}
|
||||
>
|
||||
{toolbarPills}
|
||||
</ComposerToolbarScroller>
|
||||
{startButton}
|
||||
</ComposerToolbarRow>
|
||||
?
|
||||
</Text>
|
||||
</View>
|
||||
<View className="mt-2 flex-row items-center gap-1.5">
|
||||
<SymbolView
|
||||
name="desktopcomputer"
|
||||
size={12}
|
||||
tintColor={isDarkMode ? "#66676d" : "#8e8e93"}
|
||||
type="monochrome"
|
||||
/>
|
||||
<Text className="text-xs text-foreground-tertiary">on {selectedEnvironmentLabel}</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View
|
||||
style={{ paddingBottom: controlsBottomPadding, paddingHorizontal: 10, paddingTop: 8 }}
|
||||
>
|
||||
<ComposerSurface
|
||||
isDarkMode={isDarkMode}
|
||||
style={{
|
||||
backgroundColor: isDarkMode ? "rgba(17,17,19,0.95)" : "rgba(255,255,255,0.95)",
|
||||
borderRadius: 22,
|
||||
overflow: "hidden",
|
||||
paddingBottom: 6,
|
||||
paddingHorizontal: 12,
|
||||
paddingTop: 10,
|
||||
}}
|
||||
>
|
||||
{flow.attachments.length > 0 ? (
|
||||
<View className="pb-2.5">
|
||||
<ComposerAttachmentStrip
|
||||
attachments={flow.attachments}
|
||||
onRemove={
|
||||
isIncomingShareTransferPending ? () => undefined : flow.removeAttachment
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
) : null}
|
||||
{promptEditor}
|
||||
<ComposerToolbarRow paddingBottom={0} paddingHorizontal={0} paddingTop={4}>
|
||||
<ComposerToolbarScroller
|
||||
fadeOpaque={isDarkMode ? "rgba(17,17,19,0.95)" : "rgba(255,255,255,0.95)"}
|
||||
fadeTransparent={isDarkMode ? "rgba(17,17,19,0)" : "rgba(255,255,255,0)"}
|
||||
>
|
||||
{toolbarPills}
|
||||
</ComposerToolbarScroller>
|
||||
{startButton}
|
||||
</ComposerToolbarRow>
|
||||
</ComposerSurface>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
<ModelPickerSheet
|
||||
favoriteModelKeys={favoriteModelKeys}
|
||||
favoritesEnabled={favoritesReady}
|
||||
groups={flow.providerGroups}
|
||||
onClose={() => setModelPickerVisible(false)}
|
||||
onSelectModel={(option) => flow.setSelectedModelKey(option.key)}
|
||||
onToggleFavorite={toggleFavorite}
|
||||
selectedModel={flow.selectedModel}
|
||||
visible={modelPickerVisible}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -2,10 +2,12 @@ import type { ApprovalRequestId, ProviderApprovalDecision } from "@t3tools/contr
|
||||
import { Pressable, View } from "react-native";
|
||||
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { cn } from "../../lib/cn";
|
||||
import type { PendingApproval } from "../../lib/threadActivity";
|
||||
|
||||
export interface PendingApprovalCardProps {
|
||||
readonly approval: PendingApproval;
|
||||
readonly approvalCount: number;
|
||||
readonly respondingApprovalId: ApprovalRequestId | null;
|
||||
readonly onRespond: (
|
||||
requestId: ApprovalRequestId,
|
||||
@@ -13,44 +15,106 @@ export interface PendingApprovalCardProps {
|
||||
) => Promise<unknown>;
|
||||
}
|
||||
|
||||
const APPROVAL_COPY = {
|
||||
command: {
|
||||
eyebrow: "Command",
|
||||
title: "Command approval requested",
|
||||
},
|
||||
"file-read": {
|
||||
eyebrow: "File read",
|
||||
title: "File read approval requested",
|
||||
},
|
||||
"file-change": {
|
||||
eyebrow: "File change",
|
||||
title: "File change approval requested",
|
||||
},
|
||||
} as const satisfies Record<PendingApproval["requestKind"], { eyebrow: string; title: string }>;
|
||||
|
||||
export function PendingApprovalCard(props: PendingApprovalCardProps) {
|
||||
const copy = APPROVAL_COPY[props.approval.requestKind];
|
||||
const isResponding = props.respondingApprovalId === props.approval.requestId;
|
||||
const respond = (decision: ProviderApprovalDecision) => {
|
||||
void props.onRespond(props.approval.requestId, decision);
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="gap-2.5 rounded-[20px] border border-neutral-200 bg-neutral-100/80 p-4 dark:border-white/6 dark:bg-neutral-900/80">
|
||||
<Text className="font-t3-bold text-2xs uppercase tracking-[1.1px] text-sky-700 dark:text-sky-300">
|
||||
Approval needed
|
||||
</Text>
|
||||
<Text className="font-t3-bold text-lg text-neutral-950 dark:text-neutral-50">
|
||||
{props.approval.requestKind}
|
||||
</Text>
|
||||
{props.approval.detail ? (
|
||||
<Text className="font-sans text-sm leading-normal text-neutral-600 dark:text-neutral-400">
|
||||
{props.approval.detail}
|
||||
</Text>
|
||||
) : null}
|
||||
<View className="flex-row flex-wrap gap-2.5">
|
||||
<Pressable
|
||||
className="items-center justify-center rounded-[14px] bg-blue-500 px-3.5 py-3"
|
||||
disabled={props.respondingApprovalId === props.approval.requestId}
|
||||
onPress={() => void props.onRespond(props.approval.requestId, "accept")}
|
||||
>
|
||||
<Text className="font-t3-extrabold text-sm text-white">Allow once</Text>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
className="items-center justify-center rounded-[14px] bg-neutral-200 px-3.5 py-3 dark:bg-neutral-800"
|
||||
disabled={props.respondingApprovalId === props.approval.requestId}
|
||||
onPress={() => void props.onRespond(props.approval.requestId, "acceptForSession")}
|
||||
>
|
||||
<Text className="font-t3-bold text-sm text-neutral-950 dark:text-neutral-50">
|
||||
Allow session
|
||||
<View
|
||||
accessibilityLabel={copy.title}
|
||||
className="overflow-hidden rounded-[22px] border border-border bg-card"
|
||||
>
|
||||
<View className="gap-2.5 px-4 pb-3.5 pt-3.5">
|
||||
<View className="flex-row items-center justify-between gap-3">
|
||||
<Text className="font-t3-bold text-2xs uppercase tracking-[1.2px] text-amber-600 dark:text-amber-300">
|
||||
Pending approval
|
||||
</Text>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
className="items-center justify-center rounded-[14px] bg-rose-100 px-3.5 py-3 dark:bg-rose-500/18"
|
||||
disabled={props.respondingApprovalId === props.approval.requestId}
|
||||
onPress={() => void props.onRespond(props.approval.requestId, "decline")}
|
||||
>
|
||||
<Text className="font-t3-bold text-sm text-rose-700 dark:text-rose-300">Decline</Text>
|
||||
</Pressable>
|
||||
<Text className="font-t3-medium text-sm tabular-nums text-foreground-tertiary">
|
||||
1/{Math.max(1, props.approvalCount)}
|
||||
</Text>
|
||||
</View>
|
||||
<Text className="font-t3-bold text-lg text-foreground">{copy.title}</Text>
|
||||
<View className="gap-1.5 rounded-xl border border-border-subtle bg-screen px-3 py-2.5">
|
||||
<Text className="font-t3-bold text-2xs uppercase tracking-[1.1px] text-foreground-tertiary">
|
||||
{copy.eyebrow}
|
||||
</Text>
|
||||
<Text selectable className="font-mono text-sm leading-[21px] text-foreground-secondary">
|
||||
{props.approval.detail ?? "Review the requested operation before continuing."}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="gap-2.5 border-t border-border px-3 pb-3 pt-2.5">
|
||||
<View className="flex-row gap-2">
|
||||
<Pressable
|
||||
accessibilityLabel="Approve once"
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ disabled: isResponding }}
|
||||
className={cn(
|
||||
"min-h-12 flex-1 items-center justify-center rounded-xl bg-blue-600 px-3",
|
||||
isResponding && "opacity-50",
|
||||
)}
|
||||
disabled={isResponding}
|
||||
onPress={() => respond("accept")}
|
||||
>
|
||||
<Text className="font-t3-bold text-base text-white">Approve once</Text>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
accessibilityLabel="Always allow for this session"
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ disabled: isResponding }}
|
||||
className={cn(
|
||||
"min-h-12 flex-1 items-center justify-center rounded-xl border border-secondary-border bg-secondary px-3",
|
||||
isResponding && "opacity-50",
|
||||
)}
|
||||
disabled={isResponding}
|
||||
onPress={() => respond("acceptForSession")}
|
||||
>
|
||||
<Text className="font-t3-bold text-base text-secondary-foreground">Always allow</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
<View className="flex-row items-center justify-center gap-8">
|
||||
<Pressable
|
||||
accessibilityLabel="Decline approval"
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ disabled: isResponding }}
|
||||
className={cn("min-h-7 justify-center px-2", isResponding && "opacity-50")}
|
||||
disabled={isResponding}
|
||||
hitSlop={8}
|
||||
onPress={() => respond("decline")}
|
||||
>
|
||||
<Text className="font-t3-bold text-base text-red-600 dark:text-red-400">Decline</Text>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
accessibilityLabel="Cancel turn"
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ disabled: isResponding }}
|
||||
className={cn("min-h-7 justify-center px-2", isResponding && "opacity-50")}
|
||||
disabled={isResponding}
|
||||
hitSlop={8}
|
||||
onPress={() => respond("cancel")}
|
||||
>
|
||||
<Text className="font-t3-medium text-base text-foreground-muted">Cancel turn</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import type { ApprovalRequestId } from "@t3tools/contracts";
|
||||
import { useState } from "react";
|
||||
import { Pressable, View } from "react-native";
|
||||
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
|
||||
import { cn } from "../../lib/cn";
|
||||
import type { PendingUserInput, PendingUserInputDraftAnswer } from "../../lib/threadActivity";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
export interface PendingUserInputCardProps {
|
||||
readonly pendingUserInput: PendingUserInput;
|
||||
@@ -23,83 +26,176 @@ export interface PendingUserInputCardProps {
|
||||
readonly onSubmit: () => Promise<unknown>;
|
||||
}
|
||||
|
||||
function hasDraftAnswer(draft: PendingUserInputDraftAnswer | undefined): boolean {
|
||||
return Boolean(draft?.customAnswer?.trim() || draft?.selectedOptionLabel?.trim());
|
||||
}
|
||||
|
||||
function firstUnansweredQuestionIndex(
|
||||
questions: PendingUserInput["questions"],
|
||||
drafts: Record<string, PendingUserInputDraftAnswer>,
|
||||
): number {
|
||||
const index = questions.findIndex((question) => !hasDraftAnswer(drafts[question.id]));
|
||||
return index === -1 ? Math.max(questions.length - 1, 0) : index;
|
||||
}
|
||||
|
||||
export function PendingUserInputCard(props: PendingUserInputCardProps) {
|
||||
const [questionIndex, setQuestionIndex] = useState(() =>
|
||||
firstUnansweredQuestionIndex(props.pendingUserInput.questions, props.drafts),
|
||||
);
|
||||
const selectedColor = useThemeColor("--color-md-link");
|
||||
const activeQuestion = props.pendingUserInput.questions[questionIndex] ?? null;
|
||||
const draft = activeQuestion ? props.drafts[activeQuestion.id] : undefined;
|
||||
const isResponding = props.respondingUserInputId === props.pendingUserInput.requestId;
|
||||
const isLastQuestion = questionIndex >= props.pendingUserInput.questions.length - 1;
|
||||
const canGoBack = questionIndex > 0 && !isResponding;
|
||||
const canAdvance = hasDraftAnswer(draft);
|
||||
const canContinue = isLastQuestion ? props.answers !== null : canAdvance;
|
||||
|
||||
if (!activeQuestion) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const handleAdvance = () => {
|
||||
if (!canContinue || isResponding) {
|
||||
return;
|
||||
}
|
||||
if (!isLastQuestion) {
|
||||
setQuestionIndex((current) =>
|
||||
Math.min(current + 1, props.pendingUserInput.questions.length - 1),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (props.answers) {
|
||||
void props.onSubmit();
|
||||
}
|
||||
};
|
||||
|
||||
const handleBack = () => {
|
||||
if (!canGoBack) return;
|
||||
setQuestionIndex((current) => Math.max(0, current - 1));
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="gap-2.5 rounded-[20px] border border-neutral-200 bg-neutral-100/80 p-4 dark:border-white/6 dark:bg-neutral-900/80">
|
||||
<Text className="font-t3-bold text-2xs uppercase tracking-[1.1px] text-sky-700 dark:text-sky-300">
|
||||
User input needed
|
||||
</Text>
|
||||
<Text className="font-t3-bold text-lg text-neutral-950 dark:text-neutral-50">
|
||||
Fill in the pending answers
|
||||
</Text>
|
||||
{props.pendingUserInput.questions.map((question) => {
|
||||
const draft = props.drafts[question.id];
|
||||
return (
|
||||
<View key={question.id} className="gap-2 pt-1">
|
||||
<Text className="font-t3-bold text-xs uppercase tracking-[1px] text-neutral-500 dark:text-neutral-500">
|
||||
{question.header}
|
||||
</Text>
|
||||
<Text className="font-sans text-base leading-snug text-neutral-950 dark:text-neutral-50">
|
||||
{question.question}
|
||||
</Text>
|
||||
<View className="flex-row flex-wrap gap-2.5">
|
||||
{question.options.map((option) => {
|
||||
const selected =
|
||||
draft?.selectedOptionLabel === option.label && !draft.customAnswer?.trim().length;
|
||||
return (
|
||||
<Pressable
|
||||
key={option.label}
|
||||
className={cn(
|
||||
"rounded-full border px-3 py-2.5 ",
|
||||
selected
|
||||
? "border-blue-300/50 bg-blue-50 dark:border-blue-400/28 dark:bg-blue-400/14"
|
||||
: "border-neutral-200 bg-white dark:border-white/6 dark:bg-neutral-950/70",
|
||||
)}
|
||||
onPress={() =>
|
||||
props.onSelectOption(
|
||||
props.pendingUserInput.requestId,
|
||||
question.id,
|
||||
option.label,
|
||||
)
|
||||
}
|
||||
>
|
||||
<Text
|
||||
className={cn(
|
||||
"font-t3-bold text-sm",
|
||||
selected
|
||||
? "text-sky-700 dark:text-sky-300"
|
||||
: "text-neutral-600 dark:text-neutral-300",
|
||||
)}
|
||||
>
|
||||
{option.label}
|
||||
</Text>
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
<TextInput
|
||||
value={draft?.customAnswer ?? ""}
|
||||
onChangeText={(value) =>
|
||||
props.onChangeCustomAnswer(props.pendingUserInput.requestId, question.id, value)
|
||||
<View
|
||||
accessibilityLabel={`Input needed: ${activeQuestion.question}`}
|
||||
className="overflow-hidden rounded-[22px] border border-border bg-card"
|
||||
>
|
||||
<View className="gap-2 px-4 pb-3 pt-3.5">
|
||||
<View className="flex-row items-center justify-between gap-3">
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
className="min-w-0 flex-1 font-t3-bold text-2xs uppercase tracking-[1.2px] text-indigo-600 dark:text-indigo-300"
|
||||
>
|
||||
{activeQuestion.header}
|
||||
</Text>
|
||||
<Text className="font-t3-medium text-sm tabular-nums text-foreground-tertiary">
|
||||
{questionIndex + 1}/{props.pendingUserInput.questions.length}
|
||||
</Text>
|
||||
</View>
|
||||
<Text className="font-t3-bold text-lg leading-[24px] text-foreground">
|
||||
{activeQuestion.question}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View className="gap-1.5 border-t border-border px-3 py-2.5">
|
||||
{activeQuestion.options.map((option, index) => {
|
||||
const selected =
|
||||
draft?.selectedOptionLabel === option.label && !draft.customAnswer?.trim().length;
|
||||
return (
|
||||
<Pressable
|
||||
key={option.label}
|
||||
accessibilityLabel={`${option.label}. ${option.description}`}
|
||||
accessibilityRole="radio"
|
||||
accessibilityState={{ checked: selected, disabled: isResponding }}
|
||||
className={cn(
|
||||
"min-h-[68px] flex-row items-center gap-3 rounded-xl border px-3 py-3",
|
||||
selected ? "border-blue-500/45 bg-blue-500/10" : "border-transparent bg-subtle",
|
||||
isResponding && "opacity-50",
|
||||
)}
|
||||
disabled={isResponding}
|
||||
onPress={() =>
|
||||
props.onSelectOption(
|
||||
props.pendingUserInput.requestId,
|
||||
activeQuestion.id,
|
||||
option.label,
|
||||
)
|
||||
}
|
||||
placeholder="Or type a custom answer"
|
||||
className="min-h-[54px] rounded-2xl border border-neutral-200 bg-white px-3.5 py-3 font-sans text-base text-neutral-950 dark:border-white/8 dark:bg-neutral-950/70 dark:text-neutral-50"
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
<Pressable
|
||||
className={cn(
|
||||
"items-center justify-center rounded-2xl px-4 py-3.5",
|
||||
props.answers ? "bg-blue-500" : "bg-neutral-200 dark:bg-neutral-700/60",
|
||||
>
|
||||
<View className="min-w-0 flex-1 gap-0.5">
|
||||
<Text className="font-t3-bold text-base text-foreground">{option.label}</Text>
|
||||
{option.description !== option.label ? (
|
||||
<Text className="font-sans text-sm leading-[19px] text-foreground-muted">
|
||||
{option.description}
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
{selected ? (
|
||||
<SymbolView
|
||||
name="checkmark"
|
||||
size={16}
|
||||
tintColor={selectedColor}
|
||||
type="monochrome"
|
||||
/>
|
||||
) : index < 9 ? (
|
||||
<View className="size-6 items-center justify-center rounded-md border border-border bg-screen/40">
|
||||
<Text className="font-t3-medium text-xs tabular-nums text-foreground-muted">
|
||||
{index + 1}
|
||||
</Text>
|
||||
</View>
|
||||
) : null}
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
|
||||
<TextInput
|
||||
accessibilityLabel="Write a custom answer"
|
||||
editable={!isResponding}
|
||||
value={draft?.customAnswer ?? ""}
|
||||
onChangeText={(value) =>
|
||||
props.onChangeCustomAnswer(props.pendingUserInput.requestId, activeQuestion.id, value)
|
||||
}
|
||||
placeholder="Write a different answer"
|
||||
selectionColor={selectedColor}
|
||||
className="mt-1 min-h-12 rounded-xl bg-screen px-3 py-3 text-base"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View className="flex-row items-center justify-between border-t border-border px-3 py-2.5">
|
||||
{questionIndex > 0 ? (
|
||||
<Pressable
|
||||
accessibilityLabel="Previous question"
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ disabled: !canGoBack }}
|
||||
className={cn("min-h-11 items-center justify-center px-3", !canGoBack && "opacity-50")}
|
||||
disabled={!canGoBack}
|
||||
onPress={handleBack}
|
||||
>
|
||||
<Text className="font-t3-bold text-base text-foreground-muted">Back</Text>
|
||||
</Pressable>
|
||||
) : (
|
||||
<View />
|
||||
)}
|
||||
disabled={
|
||||
props.answers === null || props.respondingUserInputId === props.pendingUserInput.requestId
|
||||
}
|
||||
onPress={() => void props.onSubmit()}
|
||||
>
|
||||
<Text className="font-t3-extrabold text-sm text-white">Submit answers</Text>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
accessibilityLabel={isLastQuestion ? "Submit answers" : "Next question"}
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ disabled: !canContinue || isResponding }}
|
||||
className={cn(
|
||||
"min-h-11 items-center justify-center rounded-full px-5",
|
||||
canContinue && !isResponding ? "bg-blue-600" : "bg-subtle-strong",
|
||||
)}
|
||||
disabled={!canContinue || isResponding}
|
||||
onPress={handleAdvance}
|
||||
>
|
||||
<Text
|
||||
className={cn(
|
||||
"font-t3-bold text-base",
|
||||
canContinue && !isResponding ? "text-white" : "text-foreground-tertiary",
|
||||
)}
|
||||
>
|
||||
{isLastQuestion ? "Submit answers" : "Next question"}
|
||||
</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -17,8 +17,8 @@ import {
|
||||
import type { ReactNode } from "react";
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState, type RefObject } from "react";
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Image,
|
||||
Keyboard,
|
||||
Platform,
|
||||
Pressable,
|
||||
useColorScheme,
|
||||
@@ -50,10 +50,11 @@ import {
|
||||
ComposerToolbarScroller,
|
||||
ComposerToolbarTrigger,
|
||||
} from "../../components/ComposerToolbarTrigger";
|
||||
import { ControlPill, ControlPillMenu } from "../../components/ControlPill";
|
||||
import { ControlPillMenu } from "../../components/ControlPill";
|
||||
import { ModelPickerSheet } from "../../components/ModelPickerSheet";
|
||||
import { ProviderIcon } from "../../components/ProviderIcon";
|
||||
import type { DraftComposerImageAttachment } from "../../lib/composerImages";
|
||||
import { buildModelMenuActions, buildModelOptions, groupByProvider } from "../../lib/modelOptions";
|
||||
import { buildModelOptions, groupByProvider } from "../../lib/modelOptions";
|
||||
import { useScaledTextRole } from "../settings/appearance/useScaledTextRole";
|
||||
import type { RemoteClientConnectionState } from "../../lib/connection";
|
||||
import {
|
||||
@@ -64,23 +65,23 @@ import {
|
||||
import {
|
||||
applyProviderOptionMenuEvent,
|
||||
buildProviderOptionMenuActions,
|
||||
providerOptionsConfigurationLabel,
|
||||
resolveProviderOptionDescriptors,
|
||||
} from "../../lib/providerOptions";
|
||||
import { useComposerPathSearch } from "../../state/use-composer-path-search";
|
||||
import { ComposerCommandPopover, type ComposerCommandItem } from "./ComposerCommandPopover";
|
||||
import { useModelFavorites } from "./useModelFavorites";
|
||||
|
||||
/**
|
||||
* Height of the collapsed composer (pill + vertical padding, excluding safe-area inset).
|
||||
* Exported so the parent can compute feed overlap / content insets.
|
||||
*/
|
||||
export const COMPOSER_COLLAPSED_CHROME = 60;
|
||||
export const COMPOSER_COLLAPSED_CHROME = 68;
|
||||
|
||||
/**
|
||||
* Height of the expanded composer (card + toolbar + vertical padding, excluding safe-area inset).
|
||||
* Used by the parent to compute the larger feed bottom inset when the composer is focused.
|
||||
*/
|
||||
export const COMPOSER_EXPANDED_CHROME = 174;
|
||||
export const COMPOSER_EXPANDED_CHROME = 184;
|
||||
|
||||
export interface ThreadComposerProps {
|
||||
readonly draftMessage: string;
|
||||
@@ -168,7 +169,7 @@ export function ComposerSurface(props: {
|
||||
style={[
|
||||
props.style,
|
||||
{
|
||||
backgroundColor: props.isDarkMode ? "rgba(44,44,46,0.96)" : "rgba(255,255,255,0.96)",
|
||||
backgroundColor: props.isDarkMode ? "rgba(17,17,19,0.96)" : "rgba(255,255,255,0.96)",
|
||||
borderWidth: 1,
|
||||
borderColor: props.isDarkMode ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.06)",
|
||||
},
|
||||
@@ -249,11 +250,11 @@ const ComposerConnectionStatusPill = memo(function ComposerConnectionStatusPill(
|
||||
onPress={props.onPress}
|
||||
className="max-w-full flex-row items-center gap-2 rounded-full bg-white/90 px-3 py-2 shadow-sm active:opacity-70 dark:bg-neutral-900/90"
|
||||
>
|
||||
{isReconnecting ? (
|
||||
<ActivityIndicator size="small" color="#8e8e93" />
|
||||
) : (
|
||||
<View className="h-2 w-2 rounded-full bg-red-500" />
|
||||
)}
|
||||
<View
|
||||
className={
|
||||
isReconnecting ? "h-2 w-2 rounded-full bg-sky-400" : "h-2 w-2 rounded-full bg-red-500"
|
||||
}
|
||||
/>
|
||||
<Text
|
||||
className="max-w-[260px] text-sm font-t3-bold leading-snug text-foreground"
|
||||
numberOfLines={1}
|
||||
@@ -277,6 +278,7 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
const { onExpandedChange } = props;
|
||||
|
||||
const [previewImageUri, setPreviewImageUri] = useState<string | null>(null);
|
||||
const [modelPickerVisible, setModelPickerVisible] = useState(false);
|
||||
const hasContent = props.draftMessage.trim().length > 0 || props.draftAttachments.length > 0;
|
||||
const isExpanded = isFocused;
|
||||
const canSend = hasContent;
|
||||
@@ -322,7 +324,7 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
environmentLabel: props.environmentLabel,
|
||||
threadSyncPhase: props.threadSyncPhase,
|
||||
});
|
||||
const toolbarFadeOpaque = isDarkMode ? "rgba(0,0,0,0.95)" : "rgba(255,255,255,0.95)";
|
||||
const toolbarFadeOpaque = isDarkMode ? "rgba(17,17,19,0.95)" : "rgba(255,255,255,0.95)";
|
||||
const toolbarFadeTransparent = isDarkMode ? "rgba(0,0,0,0)" : "rgba(255,255,255,0)";
|
||||
const selectedProviderStatus = useMemo(() => {
|
||||
if (!props.serverConfig) return null;
|
||||
@@ -601,13 +603,8 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
}),
|
||||
[currentModelOption?.capabilities, currentModelSelection.options],
|
||||
);
|
||||
const configurationLabel = useMemo(
|
||||
() => providerOptionsConfigurationLabel(providerOptionDescriptors),
|
||||
[providerOptionDescriptors],
|
||||
);
|
||||
const modelMenuActions = useMemo(
|
||||
() => buildModelMenuActions(providerGroups, currentModelSelection),
|
||||
[providerGroups, currentModelSelection],
|
||||
const { favoriteModelKeys, favoritesReady, toggleFavorite } = useModelFavorites(
|
||||
props.environmentId,
|
||||
);
|
||||
|
||||
// ── Options menu ─────────────────────────────────────────
|
||||
@@ -660,17 +657,6 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
);
|
||||
|
||||
// ── Menu handlers ────────────────────────────────────────
|
||||
function handleModelMenuAction(event: string) {
|
||||
if (!event.startsWith("model:")) {
|
||||
return;
|
||||
}
|
||||
const modelKey = event.slice("model:".length);
|
||||
const option = modelOptions.find((o) => o.key === modelKey);
|
||||
if (option) {
|
||||
props.onUpdateModelSelection(option.selection);
|
||||
}
|
||||
}
|
||||
|
||||
function handleOptionsMenuAction(event: string) {
|
||||
const providerOptions = applyProviderOptionMenuEvent(providerOptionDescriptors, event);
|
||||
if (providerOptions) {
|
||||
@@ -693,9 +679,9 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
|
||||
return (
|
||||
<Animated.View
|
||||
className="px-4"
|
||||
layout={COMPOSER_LAYOUT_TRANSITION}
|
||||
style={{
|
||||
paddingHorizontal: 14,
|
||||
paddingTop: isExpanded ? 8 : 6,
|
||||
paddingBottom: (props.bottomInset ?? 0) + (isExpanded ? 8 : 6),
|
||||
experimental_backgroundImage: isDarkMode
|
||||
@@ -731,19 +717,23 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
style={
|
||||
isExpanded
|
||||
? {
|
||||
borderRadius: 20,
|
||||
borderRadius: 22,
|
||||
overflow: "hidden" as const,
|
||||
paddingHorizontal: 14,
|
||||
paddingVertical: 12,
|
||||
paddingHorizontal: 12,
|
||||
paddingBottom: 6,
|
||||
paddingTop: 10,
|
||||
backgroundColor: isDarkMode ? "rgba(17,17,19,0.95)" : "rgba(255,255,255,0.95)",
|
||||
}
|
||||
: {
|
||||
borderRadius: 999,
|
||||
borderRadius: 28,
|
||||
overflow: "hidden" as const,
|
||||
flexDirection: "row" as const,
|
||||
alignItems: "center" as const,
|
||||
minHeight: 54,
|
||||
paddingLeft: 18,
|
||||
paddingRight: 5,
|
||||
paddingVertical: 5,
|
||||
paddingVertical: 6,
|
||||
backgroundColor: isDarkMode ? "rgba(17,17,19,0.95)" : "rgba(255,255,255,0.95)",
|
||||
}
|
||||
}
|
||||
>
|
||||
@@ -772,7 +762,7 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
onChangeText={props.onChangeDraftMessage}
|
||||
onSelectionChange={handleSelectionChange}
|
||||
onPasteImages={(uris) => void props.onNativePasteImages(uris)}
|
||||
placeholder={props.placeholder}
|
||||
placeholder={showStopAction ? "Message to queue..." : props.placeholder}
|
||||
onFocus={handleFocus}
|
||||
onBlur={handleBlur}
|
||||
onSubmit={handleSend}
|
||||
@@ -784,7 +774,7 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
style={
|
||||
isExpanded
|
||||
? {
|
||||
minHeight: 80,
|
||||
minHeight: 76,
|
||||
maxHeight: 160,
|
||||
paddingHorizontal: 4,
|
||||
paddingVertical: 4,
|
||||
@@ -822,81 +812,88 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
{!isExpanded ? (
|
||||
<Animated.View entering={FadeIn.duration(180)} exiting={FadeOut.duration(100)}>
|
||||
{showStopAction ? (
|
||||
<ControlPill icon="stop.fill" variant="danger" onPress={props.onStopThread} />
|
||||
<ComposerToolbarButton
|
||||
accessibilityLabel="Stop"
|
||||
icon="stop.fill"
|
||||
variant="danger"
|
||||
onPress={props.onStopThread}
|
||||
showChevron={false}
|
||||
/>
|
||||
) : (
|
||||
<ControlPill
|
||||
<ComposerToolbarButton
|
||||
accessibilityLabel={sendLabel}
|
||||
icon="arrow.up"
|
||||
variant="primary"
|
||||
disabled={!canSend}
|
||||
onPress={handleSend}
|
||||
showChevron={false}
|
||||
/>
|
||||
)}
|
||||
</Animated.View>
|
||||
) : null}
|
||||
</ComposerSurface>
|
||||
|
||||
{isExpanded ? (
|
||||
// Toolbar row — matches draft page layout (expanded only)
|
||||
<Animated.View entering={FadeIn.duration(160)} exiting={FadeOut.duration(120)}>
|
||||
<ComposerToolbarRow paddingBottom={8} paddingHorizontal={0} paddingTop={8}>
|
||||
<ComposerToolbarScroller
|
||||
fadeOpaque={toolbarFadeOpaque}
|
||||
fadeTransparent={toolbarFadeTransparent}
|
||||
>
|
||||
<ComposerToolbarButton
|
||||
accessibilityLabel="Add attachment"
|
||||
icon="plus"
|
||||
onPress={() => void props.onPickDraftImages()}
|
||||
showChevron={false}
|
||||
/>
|
||||
<ControlPillMenu
|
||||
actions={modelMenuActions}
|
||||
onPressAction={({ nativeEvent }) => handleModelMenuAction(nativeEvent.event)}
|
||||
{isExpanded ? (
|
||||
<Animated.View entering={FadeIn.duration(160)} exiting={FadeOut.duration(120)}>
|
||||
<ComposerToolbarRow paddingBottom={0} paddingHorizontal={0} paddingTop={4}>
|
||||
<ComposerToolbarScroller
|
||||
fadeOpaque={toolbarFadeOpaque}
|
||||
fadeTransparent={toolbarFadeTransparent}
|
||||
>
|
||||
<ComposerToolbarButton
|
||||
accessibilityLabel="Add attachment"
|
||||
icon="paperclip"
|
||||
onPress={() => void props.onPickDraftImages()}
|
||||
showChevron={false}
|
||||
variant="ghost"
|
||||
/>
|
||||
<ComposerToolbarTrigger
|
||||
accessibilityLabel="Model"
|
||||
accessibilityLabel="Choose model"
|
||||
iconNode={
|
||||
<ProviderIcon provider={currentModelOption?.providerDriver} size={16} />
|
||||
<ProviderIcon provider={currentModelOption?.providerDriver} size={18} />
|
||||
}
|
||||
label={currentModelOption?.label ?? currentModelSelection.model}
|
||||
onPress={() => {
|
||||
Keyboard.dismiss();
|
||||
setModelPickerVisible(true);
|
||||
}}
|
||||
variant="ghost"
|
||||
/>
|
||||
</ControlPillMenu>
|
||||
<ControlPillMenu
|
||||
actions={optionsMenuActions}
|
||||
onPressAction={({ nativeEvent }) => handleOptionsMenuAction(nativeEvent.event)}
|
||||
>
|
||||
<ComposerToolbarTrigger
|
||||
accessibilityLabel="Configuration"
|
||||
icon="slider.horizontal.3"
|
||||
label={configurationLabel}
|
||||
/>
|
||||
</ControlPillMenu>
|
||||
{showStopAction ? (
|
||||
<ComposerToolbarButton
|
||||
accessibilityLabel="Stop"
|
||||
icon="stop.fill"
|
||||
variant="danger"
|
||||
onPress={props.onStopThread}
|
||||
showChevron={false}
|
||||
/>
|
||||
) : null}
|
||||
</ComposerToolbarScroller>
|
||||
<ComposerToolbarButton
|
||||
accessibilityLabel={sendLabel}
|
||||
icon="arrow.up"
|
||||
variant="primary"
|
||||
disabled={!canSend}
|
||||
onPress={handleSend}
|
||||
showChevron={false}
|
||||
/>
|
||||
</ComposerToolbarRow>
|
||||
</Animated.View>
|
||||
) : null}
|
||||
<ControlPillMenu
|
||||
actions={optionsMenuActions}
|
||||
onPressAction={({ nativeEvent }) => handleOptionsMenuAction(nativeEvent.event)}
|
||||
>
|
||||
<ComposerToolbarTrigger
|
||||
accessibilityLabel="Configuration"
|
||||
icon="slider.horizontal.3"
|
||||
showChevron={false}
|
||||
variant="ghost"
|
||||
/>
|
||||
</ControlPillMenu>
|
||||
{showStopAction ? (
|
||||
<ComposerToolbarButton
|
||||
accessibilityLabel="Stop"
|
||||
icon="stop.fill"
|
||||
variant="danger"
|
||||
onPress={props.onStopThread}
|
||||
showChevron={false}
|
||||
/>
|
||||
) : null}
|
||||
</ComposerToolbarScroller>
|
||||
<ComposerToolbarButton
|
||||
accessibilityLabel={sendLabel}
|
||||
icon="arrow.up"
|
||||
variant="primary"
|
||||
disabled={!canSend}
|
||||
onPress={handleSend}
|
||||
showChevron={false}
|
||||
/>
|
||||
</ComposerToolbarRow>
|
||||
</Animated.View>
|
||||
) : null}
|
||||
</ComposerSurface>
|
||||
|
||||
{/* Queue count */}
|
||||
{props.queueCount > 0 ? (
|
||||
<Animated.View entering={FadeIn.duration(180)} exiting={FadeOut.duration(120)}>
|
||||
<Text className="pt-2 text-xs text-foreground-muted">
|
||||
<Text className="pt-1 text-sm text-foreground-muted">
|
||||
{props.queueCount} queued message{props.queueCount === 1 ? "" : "s"} will send
|
||||
automatically.
|
||||
</Text>
|
||||
@@ -912,6 +909,16 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
|
||||
swipeToCloseEnabled
|
||||
doubleTapToZoomEnabled
|
||||
/>
|
||||
<ModelPickerSheet
|
||||
favoriteModelKeys={favoriteModelKeys}
|
||||
favoritesEnabled={favoritesReady}
|
||||
groups={providerGroups}
|
||||
onClose={() => setModelPickerVisible(false)}
|
||||
onSelectModel={(option) => props.onUpdateModelSelection(option.selection)}
|
||||
onToggleFavorite={toggleFavorite}
|
||||
selectedModel={currentModelSelection}
|
||||
visible={modelPickerVisible}
|
||||
/>
|
||||
</Animated.View>
|
||||
);
|
||||
});
|
||||
@@ -51,6 +51,7 @@ export interface ThreadDetailScreenProps {
|
||||
readonly selectedThreadFeed: ReadonlyArray<ThreadFeedEntry>;
|
||||
readonly activeWorkStartedAt: string | null;
|
||||
readonly activePendingApproval: PendingApproval | null;
|
||||
readonly activePendingApprovalCount: number;
|
||||
readonly respondingApprovalId: ApprovalRequestId | null;
|
||||
readonly activePendingUserInput: PendingUserInput | null;
|
||||
readonly activePendingUserInputDrafts: Record<string, PendingUserInputDraftAnswer>;
|
||||
@@ -181,6 +182,8 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
|
||||
const lastScrolledAnchorMessageIdRef = useRef<MessageId | null>(null);
|
||||
const [composerExpanded, setComposerExpanded] = useState(false);
|
||||
const [anchorMessageId, setAnchorMessageId] = useState<MessageId | null>(null);
|
||||
const activePendingRequest = props.activePendingApproval ?? props.activePendingUserInput;
|
||||
const activePendingRequestId = activePendingRequest?.requestId ?? null;
|
||||
const composerBottomInset = composerExpanded ? 0 : Math.max(insets.bottom, 12);
|
||||
const contentPresentationKind = props.contentPresentation.kind;
|
||||
// The raw sync status enters "synchronizing" on every full fetch, cached or
|
||||
@@ -201,7 +204,11 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
|
||||
})();
|
||||
const selectedThreadFeed = props.selectedThreadFeed;
|
||||
const composerChrome = composerExpanded ? COMPOSER_EXPANDED_CHROME : COMPOSER_COLLAPSED_CHROME;
|
||||
const composerOverlapHeight = composerChrome + composerBottomInset;
|
||||
const requestChrome =
|
||||
(props.activePendingApproval ? 270 : 0) + (props.activePendingUserInput ? 430 : 0);
|
||||
const composerOverlapHeight = activePendingRequest
|
||||
? requestChrome + Math.max(insets.bottom, 12)
|
||||
: composerChrome + composerBottomInset;
|
||||
const estimatedOverlayHeight = composerOverlapHeight;
|
||||
// The overlay's measured height includes the home-indicator inset (the
|
||||
// composer pads it), but contentInsetAdjustmentBehavior="automatic" makes
|
||||
@@ -242,6 +249,14 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
|
||||
freeze.set(false);
|
||||
}, [freeze, selectedThreadKey]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!activePendingRequestId) {
|
||||
return;
|
||||
}
|
||||
setComposerExpanded(false);
|
||||
composerEditorRef.current?.blur();
|
||||
}, [activePendingRequestId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
anchorMessageId === null ||
|
||||
@@ -388,21 +403,24 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
|
||||
pushes the resting content floor up by the same amount. */}
|
||||
<View ref={composerOverlayRef} onLayout={onComposerLayout} className="w-full">
|
||||
<View className="w-full self-center" style={{ maxWidth: contentMaxWidth }}>
|
||||
{props.activePendingApproval || props.activePendingUserInput ? (
|
||||
{activePendingRequest ? (
|
||||
<Animated.View
|
||||
className="shrink-0 gap-3 px-4 pb-3"
|
||||
className="shrink-0 gap-2 px-2.5 pt-1.5"
|
||||
entering={FadeInDown.duration(220)}
|
||||
exiting={FadeOut.duration(140)}
|
||||
style={{ paddingBottom: Math.max(insets.bottom, 10) }}
|
||||
>
|
||||
{props.activePendingApproval ? (
|
||||
<PendingApprovalCard
|
||||
approval={props.activePendingApproval}
|
||||
approvalCount={props.activePendingApprovalCount}
|
||||
respondingApprovalId={props.respondingApprovalId}
|
||||
onRespond={props.onRespondToApproval}
|
||||
/>
|
||||
) : null}
|
||||
{props.activePendingUserInput ? (
|
||||
<PendingUserInputCard
|
||||
key={props.activePendingUserInput.requestId}
|
||||
pendingUserInput={props.activePendingUserInput}
|
||||
drafts={props.activePendingUserInputDrafts}
|
||||
answers={props.activePendingUserInputAnswers}
|
||||
@@ -416,35 +434,37 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
<ThreadComposer
|
||||
editorRef={composerEditorRef}
|
||||
draftMessage={props.draftMessage}
|
||||
draftAttachments={props.draftAttachments}
|
||||
placeholder="Ask the repo agent, or run a command…"
|
||||
contentMaxWidth={contentMaxWidth}
|
||||
connectionState={props.connectionStateLabel}
|
||||
connectionError={props.connectionError}
|
||||
environmentLabel={props.environmentLabel}
|
||||
threadSyncPhase={threadSyncPhase}
|
||||
selectedThread={props.selectedThread}
|
||||
serverConfig={props.serverConfig}
|
||||
queueCount={props.selectedThreadQueueCount}
|
||||
activeThreadBusy={props.activeThreadBusy}
|
||||
environmentId={props.environmentId}
|
||||
projectCwd={props.projectWorkspaceRoot}
|
||||
bottomInset={composerBottomInset}
|
||||
onChangeDraftMessage={props.onChangeDraftMessage}
|
||||
onPickDraftImages={props.onPickDraftImages}
|
||||
onNativePasteImages={props.onNativePasteImages}
|
||||
onRemoveDraftImage={props.onRemoveDraftImage}
|
||||
onStopThread={props.onStopThread}
|
||||
onSendMessage={handleSendMessage}
|
||||
onReconnectEnvironment={props.onReconnectEnvironment}
|
||||
onUpdateModelSelection={props.onUpdateThreadModelSelection}
|
||||
onUpdateRuntimeMode={props.onUpdateThreadRuntimeMode}
|
||||
onUpdateInteractionMode={props.onUpdateThreadInteractionMode}
|
||||
onExpandedChange={setComposerExpanded}
|
||||
/>
|
||||
{activePendingRequest ? null : (
|
||||
<ThreadComposer
|
||||
editorRef={composerEditorRef}
|
||||
draftMessage={props.draftMessage}
|
||||
draftAttachments={props.draftAttachments}
|
||||
placeholder="Ask anything..."
|
||||
contentMaxWidth={contentMaxWidth}
|
||||
connectionState={props.connectionStateLabel}
|
||||
connectionError={props.connectionError}
|
||||
environmentLabel={props.environmentLabel}
|
||||
threadSyncPhase={threadSyncPhase}
|
||||
selectedThread={props.selectedThread}
|
||||
serverConfig={props.serverConfig}
|
||||
queueCount={props.selectedThreadQueueCount}
|
||||
activeThreadBusy={props.activeThreadBusy}
|
||||
environmentId={props.environmentId}
|
||||
projectCwd={props.projectWorkspaceRoot}
|
||||
bottomInset={composerBottomInset}
|
||||
onChangeDraftMessage={props.onChangeDraftMessage}
|
||||
onPickDraftImages={props.onPickDraftImages}
|
||||
onNativePasteImages={props.onNativePasteImages}
|
||||
onRemoveDraftImage={props.onRemoveDraftImage}
|
||||
onStopThread={props.onStopThread}
|
||||
onSendMessage={handleSendMessage}
|
||||
onReconnectEnvironment={props.onReconnectEnvironment}
|
||||
onUpdateModelSelection={props.onUpdateThreadModelSelection}
|
||||
onUpdateRuntimeMode={props.onUpdateThreadRuntimeMode}
|
||||
onUpdateInteractionMode={props.onUpdateThreadInteractionMode}
|
||||
onExpandedChange={setComposerExpanded}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
</KeyboardStickyView>
|
||||
) : null}
|
||||
|
||||
@@ -9,7 +9,7 @@ import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } fro
|
||||
import * as Option from "effect/Option";
|
||||
import { EnvironmentId, ThreadId, type ProjectScript } from "@t3tools/contracts";
|
||||
import { projectScriptCwd, projectScriptRuntimeEnv } from "@t3tools/shared/projectScripts";
|
||||
import { Platform, ScrollView, View } from "react-native";
|
||||
import { Platform, Pressable, ScrollView, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useWorkspaceState } from "../../state/workspace";
|
||||
import { useEnvironmentQuery } from "../../state/query";
|
||||
@@ -17,6 +17,7 @@ import { dismissGitActionResult, useGitActionProgress } from "../../state/use-vc
|
||||
import { vcsEnvironment } from "../../state/vcs";
|
||||
|
||||
import { EmptyState } from "../../components/EmptyState";
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import {
|
||||
AndroidScreenHeader,
|
||||
type AndroidHeaderAction,
|
||||
@@ -60,6 +61,10 @@ import { useSelectedThreadWorktree } from "../../state/use-selected-thread-workt
|
||||
import { useThreadComposerState } from "../../state/use-thread-composer-state";
|
||||
import { threadEnvironment } from "../../state/threads";
|
||||
import { projectThreadContentPresentation } from "./threadContentPresentation";
|
||||
import {
|
||||
resolveThreadHeaderStatus,
|
||||
type ThreadHeaderStatusPresentation,
|
||||
} from "./threadHeaderPresentation";
|
||||
import {
|
||||
useAdaptiveWorkspaceLayout,
|
||||
useAdaptiveWorkspacePaneRole,
|
||||
@@ -79,6 +84,42 @@ interface ThreadInspectorSelection {
|
||||
|
||||
type NativeHeaderItems = ReadonlyArray<Record<string, unknown>>;
|
||||
|
||||
function isUnknownRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
}
|
||||
|
||||
function ThreadHeaderStatus(props: {
|
||||
readonly status: ThreadHeaderStatusPresentation;
|
||||
readonly onPress: () => void;
|
||||
}) {
|
||||
return (
|
||||
<Pressable
|
||||
accessibilityHint="Opens git controls"
|
||||
accessibilityLabel={`Thread status: ${props.status.label}`}
|
||||
accessibilityRole="button"
|
||||
hitSlop={8}
|
||||
onPress={props.onPress}
|
||||
className="min-h-11 flex-row items-center justify-center px-1"
|
||||
>
|
||||
<Text
|
||||
className={
|
||||
props.status.kind === "approval"
|
||||
? "font-t3-bold text-base text-amber-600 dark:text-amber-300"
|
||||
: props.status.kind === "input"
|
||||
? "font-t3-bold text-base text-indigo-600 dark:text-indigo-300"
|
||||
: props.status.kind === "working"
|
||||
? "font-t3-bold text-base tabular-nums text-sky-600 dark:text-sky-400"
|
||||
: props.status.kind === "failed"
|
||||
? "font-t3-bold text-base text-red-600 dark:text-red-400"
|
||||
: "font-t3-bold text-base text-green-600 dark:text-green-400"
|
||||
}
|
||||
>
|
||||
{props.status.nativeLabel}
|
||||
</Text>
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
||||
function InspectorPaneRoleActivation() {
|
||||
useAdaptiveWorkspacePaneRole("inspector");
|
||||
return null;
|
||||
@@ -281,11 +322,37 @@ function ThreadRouteContent(
|
||||
/* ─── Native header theming ──────────────────────────────────────── */
|
||||
const usesNativeHeaderGlass = NATIVE_LIQUID_GLASS_SUPPORTED;
|
||||
const headerSubtitle = [
|
||||
selectedThreadProject?.title ?? null,
|
||||
selectedThread?.branch ? `⑂ ${selectedThread.branch}` : null,
|
||||
selectedEnvironmentConnection?.environmentLabel ?? null,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" · ");
|
||||
const headerHasPendingApproval = Boolean(
|
||||
requests.activePendingApproval ?? selectedThread?.hasPendingApprovals,
|
||||
);
|
||||
const headerHasPendingUserInput = Boolean(
|
||||
requests.activePendingUserInput ?? selectedThread?.hasPendingUserInput,
|
||||
);
|
||||
const headerTimerEnabled =
|
||||
composer.activeThreadBusy && !headerHasPendingApproval && !headerHasPendingUserInput;
|
||||
const [headerNowMs, setHeaderNowMs] = useState(() => Date.now());
|
||||
useEffect(() => {
|
||||
if (!headerTimerEnabled) {
|
||||
return;
|
||||
}
|
||||
setHeaderNowMs(Date.now());
|
||||
const intervalId = setInterval(() => setHeaderNowMs(Date.now()), 1_000);
|
||||
return () => clearInterval(intervalId);
|
||||
}, [composer.activeWorkStartedAt, headerTimerEnabled]);
|
||||
const threadHeaderStatus = resolveThreadHeaderStatus({
|
||||
hasPendingApproval: headerHasPendingApproval,
|
||||
hasPendingUserInput: headerHasPendingUserInput,
|
||||
active: composer.activeThreadBusy,
|
||||
failed:
|
||||
selectedThread?.session?.status === "error" || selectedThread?.latestTurn?.state === "error",
|
||||
activeWorkStartedAt: composer.activeWorkStartedAt,
|
||||
nowMs: headerNowMs,
|
||||
});
|
||||
/* ─── Git status for native header trigger ───────────────────────── */
|
||||
const gitStatus = useEnvironmentQuery(
|
||||
selectedThread !== null && selectedThreadCwd !== null
|
||||
@@ -685,11 +752,6 @@ function ThreadRouteContent(
|
||||
onPress: () => handleOpenTerminal(null),
|
||||
});
|
||||
}
|
||||
actions.push({
|
||||
accessibilityLabel: "Open git controls",
|
||||
icon: "point.topleft.down.curvedto.point.bottomright.up",
|
||||
onPress: handleOpenGitInspector,
|
||||
});
|
||||
if (fileInspector.supported && selectedThreadCwd !== null) {
|
||||
actions.push({
|
||||
accessibilityLabel: "Toggle inspector",
|
||||
@@ -725,6 +787,92 @@ function ThreadRouteContent(
|
||||
],
|
||||
[navigation],
|
||||
);
|
||||
const compactThreadActionItem = useMemo(() => {
|
||||
const gitItem = compactRightHeaderItems.find((item) => item.identifier === "thread-right-git");
|
||||
if (!gitItem) {
|
||||
return null;
|
||||
}
|
||||
const existingMenu = isUnknownRecord(gitItem.menu) ? gitItem.menu : null;
|
||||
const existingMenuItems =
|
||||
existingMenu && Array.isArray(existingMenu.items) ? existingMenu.items : [];
|
||||
return {
|
||||
...gitItem,
|
||||
accessibilityLabel: "Thread actions",
|
||||
icon: { name: "ellipsis", type: "sfSymbol" as const },
|
||||
identifier: "thread-right-actions",
|
||||
label: undefined,
|
||||
menu: {
|
||||
...existingMenu,
|
||||
items: [
|
||||
...existingMenuItems,
|
||||
{
|
||||
description: "Browse this thread's worktree",
|
||||
disabled: selectedThreadCwd === null,
|
||||
icon: { name: "folder", type: "sfSymbol" as const },
|
||||
label: "Files",
|
||||
onPress: handleOpenFilesInspector,
|
||||
type: "action" as const,
|
||||
},
|
||||
{
|
||||
description: "Open this thread's shell",
|
||||
disabled: !selectedThreadProject?.workspaceRoot,
|
||||
icon: { name: "terminal", type: "sfSymbol" as const },
|
||||
label: "Terminal",
|
||||
onPress: () => handleOpenTerminal(null),
|
||||
type: "action" as const,
|
||||
},
|
||||
],
|
||||
title: "Thread actions",
|
||||
},
|
||||
sharesBackground: false,
|
||||
tintColor: undefined,
|
||||
width: 44,
|
||||
};
|
||||
}, [
|
||||
compactRightHeaderItems,
|
||||
handleOpenFilesInspector,
|
||||
handleOpenTerminal,
|
||||
selectedThreadCwd,
|
||||
selectedThreadProject?.workspaceRoot,
|
||||
]);
|
||||
const compactThreadStatusItem = useMemo(
|
||||
() => ({
|
||||
accessibilityLabel: `Thread status: ${threadHeaderStatus.label}`,
|
||||
icon: {
|
||||
name:
|
||||
threadHeaderStatus.kind === "done"
|
||||
? "checkmark.circle"
|
||||
: threadHeaderStatus.kind === "working"
|
||||
? "timer"
|
||||
: threadHeaderStatus.kind === "approval"
|
||||
? "exclamationmark.circle"
|
||||
: threadHeaderStatus.kind === "input"
|
||||
? "questionmark.circle"
|
||||
: "xmark.circle",
|
||||
type: "sfSymbol" as const,
|
||||
},
|
||||
identifier: "thread-right-status",
|
||||
label: threadHeaderStatus.nativeLabel,
|
||||
onPress: handleOpenGitInspector,
|
||||
sharesBackground: false,
|
||||
tintColor: threadHeaderStatus.tintColor,
|
||||
type: "button" as const,
|
||||
}),
|
||||
[handleOpenGitInspector, threadHeaderStatus],
|
||||
);
|
||||
const nativeThreadRightHeaderItems = useMemo<NativeHeaderItems>(() => {
|
||||
if (layout.usesSplitView) {
|
||||
return threadCenterHeaderItems;
|
||||
}
|
||||
return compactThreadActionItem
|
||||
? [compactThreadStatusItem, compactThreadActionItem]
|
||||
: [compactThreadStatusItem];
|
||||
}, [
|
||||
compactThreadActionItem,
|
||||
compactThreadStatusItem,
|
||||
layout.usesSplitView,
|
||||
threadCenterHeaderItems,
|
||||
]);
|
||||
|
||||
if (!environmentId || !threadId) {
|
||||
return <OpeningThreadLoadingScreen />;
|
||||
@@ -757,6 +905,7 @@ function ThreadRouteContent(
|
||||
selectedThreadFeed={composer.selectedThreadFeed}
|
||||
activeWorkStartedAt={composer.activeWorkStartedAt}
|
||||
activePendingApproval={requests.activePendingApproval}
|
||||
activePendingApprovalCount={requests.activePendingApprovalCount}
|
||||
respondingApprovalId={requests.respondingApprovalId}
|
||||
activePendingUserInput={requests.activePendingUserInput}
|
||||
activePendingUserInputDrafts={requests.activePendingUserInputDrafts}
|
||||
@@ -798,17 +947,16 @@ function ThreadRouteContent(
|
||||
<>
|
||||
{activeInspectorRenderer ? <InspectorPaneRoleActivation /> : null}
|
||||
<NativeStackScreenOptions
|
||||
optionsVersion={nativeThreadRightHeaderItems}
|
||||
options={{
|
||||
// Android draws its own in-flow header (AndroidScreenHeader below);
|
||||
// the native stack header stays iOS-only.
|
||||
headerShown: Platform.OS !== "android",
|
||||
headerTitle: selectedThread.title,
|
||||
headerTitleStyle: usesNativeHeaderGlass
|
||||
? {
|
||||
fontSize: 17,
|
||||
fontWeight: "800",
|
||||
}
|
||||
: undefined,
|
||||
headerTitleStyle: {
|
||||
fontSize: 19,
|
||||
fontWeight: "800",
|
||||
},
|
||||
title: selectedThread.title,
|
||||
headerBackVisible: !layout.usesSplitView,
|
||||
// Compact uses the NATIVE back button when a previous route exists;
|
||||
@@ -826,10 +974,8 @@ function ThreadRouteContent(
|
||||
// the git controls on the RIGHT (no center items — center space is
|
||||
// reserved for future breadcrumbs/status).
|
||||
unstable_headerRightItems:
|
||||
Platform.OS === "ios"
|
||||
? () => (layout.usesSplitView ? threadCenterHeaderItems : compactRightHeaderItems)
|
||||
: undefined,
|
||||
unstable_headerSubtitle: usesNativeHeaderGlass ? headerSubtitle : undefined,
|
||||
Platform.OS === "ios" ? () => nativeThreadRightHeaderItems : undefined,
|
||||
unstable_headerSubtitle: headerSubtitle.length > 0 ? headerSubtitle : undefined,
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -839,6 +985,9 @@ function ThreadRouteContent(
|
||||
subtitle={headerSubtitle}
|
||||
onBack={layout.usesSplitView ? undefined : () => navigation.goBack()}
|
||||
actions={androidHeaderActions}
|
||||
trailing={
|
||||
<ThreadHeaderStatus status={threadHeaderStatus} onPress={handleOpenGitInspector} />
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import type {
|
||||
EnvironmentProject,
|
||||
EnvironmentThreadShell,
|
||||
} from "@t3tools/client-runtime/state/shell";
|
||||
import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
|
||||
import type { EnvironmentThreadSearchMatch } from "@t3tools/client-runtime/state/thread-search";
|
||||
import { canSnooze, resolveSnoozePresets } from "@t3tools/client-runtime/state/thread-settled";
|
||||
import type { MenuAction } from "@react-native-menu/menu";
|
||||
@@ -53,12 +54,28 @@ const MONO_FONT = Platform.select({
|
||||
// Live Activity/widgets (amber approval, indigo input, sky working) so a
|
||||
// thread reads the same color everywhere it surfaces.
|
||||
const STATUS_LABEL_BY_STATUS: Partial<
|
||||
Record<ThreadListV2Status, { label: string; className: string }>
|
||||
Record<ThreadListV2Status, { label: string; className: string; screenColor: string }>
|
||||
> = {
|
||||
approval: { label: "Approval", className: "text-amber-700 dark:text-amber-300" },
|
||||
input: { label: "Input", className: "text-indigo-600 dark:text-indigo-300" },
|
||||
working: { label: "Working", className: "text-sky-600 dark:text-sky-400" },
|
||||
failed: { label: "Failed", className: "text-red-700 dark:text-red-300" },
|
||||
approval: {
|
||||
label: "Approval",
|
||||
className: "text-amber-700 dark:text-amber-300",
|
||||
screenColor: "#fbbf24",
|
||||
},
|
||||
input: {
|
||||
label: "Input",
|
||||
className: "text-indigo-600 dark:text-indigo-300",
|
||||
screenColor: "#a5b4fc",
|
||||
},
|
||||
working: {
|
||||
label: "Working",
|
||||
className: "text-sky-600 dark:text-sky-400",
|
||||
screenColor: "#38bdf8",
|
||||
},
|
||||
failed: {
|
||||
label: "Failed",
|
||||
className: "text-red-700 dark:text-red-300",
|
||||
screenColor: "#f87171",
|
||||
},
|
||||
};
|
||||
|
||||
function threadTimeLabel(thread: EnvironmentThreadShell): string {
|
||||
@@ -104,7 +121,14 @@ export const ThreadListV2SectionDivider = memo(function ThreadListV2SectionDivid
|
||||
props.pane === "sidebar" ? "px-3" : "px-5",
|
||||
)}
|
||||
>
|
||||
<Text className="text-xs font-t3-medium text-foreground-tertiary">{props.label}</Text>
|
||||
<Text
|
||||
className={cn(
|
||||
"font-t3-medium text-foreground-tertiary",
|
||||
props.pane === "sidebar" ? "text-xs" : "text-sm",
|
||||
)}
|
||||
>
|
||||
{props.label}
|
||||
</Text>
|
||||
<View className="h-px flex-1" style={{ backgroundColor: borderColor }} />
|
||||
</View>
|
||||
);
|
||||
@@ -129,14 +153,21 @@ export const ThreadListV2SnoozedShelfHeader = memo(function ThreadListV2SnoozedS
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ expanded: props.expanded }}
|
||||
className={cn(
|
||||
"mb-1.5 mt-4 flex-row items-center gap-2.5",
|
||||
props.pane === "sidebar" ? "px-3" : "px-5",
|
||||
"flex-row items-center gap-2.5",
|
||||
props.pane === "sidebar" ? "mb-1.5 mt-4 px-3" : "h-[42px] px-4",
|
||||
)}
|
||||
onPress={props.onToggle}
|
||||
style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}
|
||||
>
|
||||
<Text className="text-xs font-t3-medium text-blue-600 dark:text-blue-400">
|
||||
{props.expanded ? "Snoozed" : `Snoozed (${props.count})`}
|
||||
<Text
|
||||
className={cn(
|
||||
"text-xs font-t3-medium",
|
||||
props.pane === "sidebar"
|
||||
? "text-xs text-blue-600 dark:text-blue-400"
|
||||
: "text-sm text-[#60a5fa]",
|
||||
)}
|
||||
>
|
||||
{props.pane === "sidebar" && props.expanded ? "Snoozed" : `Snoozed (${props.count})`}
|
||||
</Text>
|
||||
<View className="h-px flex-1 bg-blue-500/20 dark:bg-blue-400/15" />
|
||||
<SymbolView
|
||||
@@ -165,13 +196,18 @@ export const ThreadListV2SettledShelfHeader = memo(function ThreadListV2SettledS
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ expanded: props.expanded }}
|
||||
className={cn(
|
||||
"mb-1.5 mt-4 flex-row items-center gap-2.5",
|
||||
props.pane === "sidebar" ? "px-3" : "px-5",
|
||||
"flex-row items-center gap-2.5",
|
||||
props.pane === "sidebar" ? "mb-1.5 mt-4 px-3" : "h-[42px] px-4",
|
||||
)}
|
||||
onPress={props.onToggle}
|
||||
style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}
|
||||
>
|
||||
<Text className="text-xs font-t3-medium text-foreground-tertiary">
|
||||
<Text
|
||||
className={cn(
|
||||
"font-t3-medium",
|
||||
props.pane === "sidebar" ? "text-xs text-foreground-tertiary" : "text-sm text-[#74757b]",
|
||||
)}
|
||||
>
|
||||
{props.expanded ? "Settled" : `Settled (${props.count})`}
|
||||
</Text>
|
||||
<View className="h-px flex-1 bg-border" />
|
||||
@@ -201,6 +237,7 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
|
||||
readonly project: EnvironmentProject | null;
|
||||
readonly projectTitle?: string;
|
||||
readonly environmentLabel: string | null;
|
||||
readonly environmentConnectionState?: EnvironmentConnectionPhase;
|
||||
readonly pane?: "screen" | "sidebar";
|
||||
/** Draws the "Pending" divider above the first queued row. */
|
||||
readonly showPendingDivider: boolean;
|
||||
@@ -214,6 +251,9 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
|
||||
const projectTitle =
|
||||
props.projectTitle ?? props.project?.title ?? pendingTask.creation.projectTitle ?? "";
|
||||
const branch = pendingTask.creation.branch;
|
||||
const staleEnvironment =
|
||||
props.environmentConnectionState !== undefined &&
|
||||
props.environmentConnectionState !== "connected";
|
||||
|
||||
const handleMenuAction = useCallback(
|
||||
({ nativeEvent }: { readonly nativeEvent: { readonly event: string } }) => {
|
||||
@@ -228,34 +268,90 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
|
||||
{props.project ? (
|
||||
<ProjectFavicon
|
||||
environmentId={pendingTask.message.environmentId}
|
||||
size={15}
|
||||
size={sidebarPane ? 15 : 18}
|
||||
projectTitle={projectTitle}
|
||||
workspaceRoot={props.project.workspaceRoot}
|
||||
/>
|
||||
) : null}
|
||||
<Text className="flex-1 text-sm font-t3-medium text-foreground-muted" numberOfLines={1}>
|
||||
<Text
|
||||
className={cn(
|
||||
"flex-1 font-t3-medium",
|
||||
sidebarPane ? "text-sm text-foreground-muted" : "text-sm text-[#9a9ba1]",
|
||||
)}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{projectTitle}
|
||||
</Text>
|
||||
<Text className="text-xs text-foreground-tertiary">Queued</Text>
|
||||
<Text
|
||||
className={cn(
|
||||
sidebarPane ? "text-xs text-foreground-tertiary" : "text-xs text-[#818289]",
|
||||
)}
|
||||
>
|
||||
Queued
|
||||
</Text>
|
||||
</View>
|
||||
{/* One line, unlike the two an active row allows: a queued title is
|
||||
derived from the whole prompt rather than written as a title, so the
|
||||
second line is usually a stray word or emoji rather than meaning. */}
|
||||
<Text className="mt-1 text-base font-t3-medium text-foreground" numberOfLines={1}>
|
||||
<Text
|
||||
className={cn(
|
||||
"mt-1 font-t3-medium",
|
||||
sidebarPane ? "text-base text-foreground" : "text-[17px] leading-[22px] text-[#f5f5f5]",
|
||||
)}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{pendingTask.title}
|
||||
</Text>
|
||||
{branch || props.environmentLabel ? (
|
||||
<Text className="mt-1 text-xs text-foreground-muted" numberOfLines={1}>
|
||||
<View className="mt-1 flex-row items-center gap-1.5">
|
||||
{branch ? (
|
||||
<Text className="text-xs text-foreground-muted" style={{ fontFamily: MONO_FONT }}>
|
||||
{branch}
|
||||
</Text>
|
||||
<>
|
||||
{!sidebarPane ? (
|
||||
<SymbolView
|
||||
name="arrow.triangle.branch"
|
||||
size={13}
|
||||
tintColor="#696a70"
|
||||
type="monochrome"
|
||||
/>
|
||||
) : null}
|
||||
<Text
|
||||
className={cn(
|
||||
"min-w-0 shrink",
|
||||
sidebarPane ? "text-xs text-foreground-muted" : "text-sm text-[#77787f]",
|
||||
)}
|
||||
numberOfLines={1}
|
||||
style={{ fontFamily: MONO_FONT }}
|
||||
>
|
||||
{branch}
|
||||
</Text>
|
||||
</>
|
||||
) : null}
|
||||
{branch && props.environmentLabel ? " · " : null}
|
||||
{props.environmentLabel ? (
|
||||
<Text className="text-xs text-foreground-tertiary">{props.environmentLabel}</Text>
|
||||
<View className="ml-auto flex-row items-center gap-1">
|
||||
{!sidebarPane ? (
|
||||
<SymbolView
|
||||
name={staleEnvironment ? "wifi.slash" : "desktopcomputer"}
|
||||
size={13}
|
||||
tintColor={staleEnvironment ? "#f87171" : "#696a70"}
|
||||
type="monochrome"
|
||||
/>
|
||||
) : null}
|
||||
<Text
|
||||
className={cn(
|
||||
sidebarPane ? "text-xs" : "text-[13px]",
|
||||
sidebarPane
|
||||
? "text-foreground-tertiary"
|
||||
: staleEnvironment
|
||||
? "text-[#f87171]"
|
||||
: "text-[#696a70]",
|
||||
)}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{props.environmentLabel}
|
||||
</Text>
|
||||
</View>
|
||||
) : null}
|
||||
</Text>
|
||||
</View>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
@@ -289,9 +385,8 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
|
||||
{sidebarPane ? (
|
||||
rowContent
|
||||
) : (
|
||||
<View className="bg-screen">
|
||||
<View className="px-5 py-2.5">{rowContent}</View>
|
||||
<View className="ml-5 h-px bg-border-subtle" />
|
||||
<View style={{ backgroundColor: "#000" }}>
|
||||
<View className="min-h-[92px] px-4 py-2.5">{rowContent}</View>
|
||||
</View>
|
||||
)}
|
||||
</Pressable>
|
||||
@@ -316,13 +411,12 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
readonly project: EnvironmentProject | null;
|
||||
readonly projectTitle?: string;
|
||||
readonly providerDriver: string | null;
|
||||
/** Which machine hosts the thread. Null when only one environment is
|
||||
connected — repeating the same label on every row is noise. Mirrors
|
||||
the web sidebar's remote-environment cloud icon, but as text since
|
||||
phones have no hover tooltips. */
|
||||
/** Which machine hosts the thread. Compact Home always passes this so the
|
||||
merged multi-environment list keeps attribution visible. */
|
||||
readonly environmentLabel: string | null;
|
||||
readonly environmentConnectionState?: EnvironmentConnectionPhase;
|
||||
/** Hosting surface. "screen" (default) renders the compact Home idiom:
|
||||
flat edge-to-edge rows on the screen background with inset hairlines.
|
||||
flat edge-to-edge rows on a true-black background.
|
||||
"sidebar" renders the iPad split-view idiom: rounded rows blending
|
||||
into the drawer surface, selection filled with the accent color —
|
||||
matching the v1 sidebar rows. */
|
||||
@@ -388,7 +482,6 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
onChangeRequestState?.(threadKey, prState);
|
||||
}, [onChangeRequestState, prState, threadKey]);
|
||||
|
||||
const screenColor = useThemeColor("--color-screen");
|
||||
const drawerColor = useThemeColor("--color-drawer");
|
||||
const pressedBackgroundColor = useThemeColor("--color-subtle");
|
||||
const selectedBackgroundColor = useThemeColor("--color-user-bubble");
|
||||
@@ -397,8 +490,14 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
const selected = props.selected === true;
|
||||
|
||||
const status = resolveThreadListV2Status(thread);
|
||||
// Quiescent is the absence of an actionable state, not a persistent
|
||||
// "Done" badge. A stopped session often just means the user opened this
|
||||
// thread before, so using session presence made read rows look completed.
|
||||
const statusLabel = STATUS_LABEL_BY_STATUS[status];
|
||||
const timeLabel = threadTimeLabel(thread);
|
||||
const staleEnvironment =
|
||||
props.environmentConnectionState !== undefined &&
|
||||
props.environmentConnectionState !== "connected";
|
||||
|
||||
const handleDelete = useCallback(() => onDeleteThread(thread), [onDeleteThread, thread]);
|
||||
const handleSettle = useCallback(() => onSettleThread(thread), [onSettleThread, thread]);
|
||||
@@ -581,15 +680,19 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
{props.project ? (
|
||||
<ProjectFavicon
|
||||
environmentId={thread.environmentId}
|
||||
size={15}
|
||||
size={sidebarPane ? 15 : 18}
|
||||
projectTitle={props.projectTitle ?? props.project.title}
|
||||
workspaceRoot={props.project.workspaceRoot}
|
||||
/>
|
||||
) : null}
|
||||
<Text
|
||||
className={cn(
|
||||
"flex-1 text-sm font-t3-medium",
|
||||
selected ? "text-user-bubble-foreground-muted" : "text-foreground-muted",
|
||||
"flex-1 font-t3-medium",
|
||||
selected
|
||||
? "text-sm text-user-bubble-foreground-muted"
|
||||
: sidebarPane
|
||||
? "text-sm text-foreground-muted"
|
||||
: "text-sm text-[#9a9ba1]",
|
||||
)}
|
||||
numberOfLines={1}
|
||||
>
|
||||
@@ -600,19 +703,30 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
) : null}
|
||||
<Text
|
||||
className={cn(
|
||||
"text-xs tabular-nums",
|
||||
selected ? "text-white" : (statusLabel?.className ?? "text-foreground-tertiary"),
|
||||
"tabular-nums",
|
||||
selected
|
||||
? "text-xs text-white"
|
||||
: sidebarPane
|
||||
? cn("text-xs", statusLabel?.className ?? "text-foreground-tertiary")
|
||||
: "text-xs",
|
||||
)}
|
||||
style={
|
||||
selected || sidebarPane ? undefined : { color: statusLabel?.screenColor ?? "#71717a" }
|
||||
}
|
||||
>
|
||||
{statusLabel?.label ?? timeLabel}
|
||||
</Text>
|
||||
</View>
|
||||
<Text
|
||||
className={cn(
|
||||
"mt-1 text-base font-t3-medium",
|
||||
selected ? "text-user-bubble-foreground" : "text-foreground",
|
||||
"mt-1 font-t3-medium",
|
||||
selected
|
||||
? "text-base text-user-bubble-foreground"
|
||||
: sidebarPane
|
||||
? "text-base text-foreground"
|
||||
: "text-[17px] leading-[22px] text-[#f5f5f5]",
|
||||
)}
|
||||
numberOfLines={2}
|
||||
numberOfLines={sidebarPane ? 2 : 1}
|
||||
>
|
||||
{thread.title}
|
||||
</Text>
|
||||
@@ -626,67 +740,112 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
</View>
|
||||
) : null}
|
||||
<View className="mt-1 flex-row items-center gap-2">
|
||||
{status === "failed" && thread.session?.lastError ? (
|
||||
<Text
|
||||
className={cn(
|
||||
"flex-1 text-xs",
|
||||
selected
|
||||
? "text-user-bubble-foreground-muted"
|
||||
: "text-red-600/80 dark:text-red-400/80",
|
||||
)}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{sidebarPane ? (
|
||||
status === "failed" && thread.session?.lastError ? (
|
||||
<Text
|
||||
className={cn(
|
||||
"flex-1 text-xs",
|
||||
selected
|
||||
? "text-user-bubble-foreground-muted"
|
||||
: "text-red-600/80 dark:text-red-400/80",
|
||||
)}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{thread.session.lastError}
|
||||
</Text>
|
||||
) : thread.branch || props.environmentLabel ? (
|
||||
<Text
|
||||
className={cn(
|
||||
"flex-1 text-xs",
|
||||
selected ? "text-user-bubble-foreground-muted" : "text-foreground-muted",
|
||||
)}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{thread.branch ? (
|
||||
<Text
|
||||
className={cn(
|
||||
"text-xs",
|
||||
selected ? "text-user-bubble-foreground-muted" : "text-foreground-muted",
|
||||
)}
|
||||
style={{ fontFamily: MONO_FONT }}
|
||||
>
|
||||
{thread.branch}
|
||||
</Text>
|
||||
) : null}
|
||||
{thread.branch && props.environmentLabel ? " · " : null}
|
||||
{props.environmentLabel ? (
|
||||
<Text
|
||||
className={cn(
|
||||
"text-xs",
|
||||
selected ? "text-user-bubble-foreground-muted" : "text-foreground-tertiary",
|
||||
)}
|
||||
>
|
||||
{props.environmentLabel}
|
||||
</Text>
|
||||
) : null}
|
||||
</Text>
|
||||
) : (
|
||||
<View className="flex-1" />
|
||||
)
|
||||
) : status === "failed" && thread.session?.lastError ? (
|
||||
<Text className="flex-1 text-sm text-[#f87171]" numberOfLines={1}>
|
||||
{thread.session.lastError}
|
||||
</Text>
|
||||
) : thread.branch || props.environmentLabel ? (
|
||||
/* "branch · machine" share one truncating line. The machine sits
|
||||
last so a tight fit cuts the repetitive label, not the branch —
|
||||
and machine-only fills the row for non-git projects. */
|
||||
<Text
|
||||
className={cn(
|
||||
"flex-1 text-xs",
|
||||
selected ? "text-user-bubble-foreground-muted" : "text-foreground-muted",
|
||||
)}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{thread.branch ? (
|
||||
<Text
|
||||
className={cn(
|
||||
"text-xs",
|
||||
selected ? "text-user-bubble-foreground-muted" : "text-foreground-muted",
|
||||
)}
|
||||
style={{ fontFamily: MONO_FONT }}
|
||||
>
|
||||
{thread.branch}
|
||||
</Text>
|
||||
) : null}
|
||||
{thread.branch && props.environmentLabel ? " · " : null}
|
||||
{props.environmentLabel ? (
|
||||
<Text
|
||||
className={cn(
|
||||
"text-xs",
|
||||
selected ? "text-user-bubble-foreground-muted" : "text-foreground-tertiary",
|
||||
)}
|
||||
>
|
||||
{props.environmentLabel}
|
||||
</Text>
|
||||
) : null}
|
||||
</Text>
|
||||
) : (
|
||||
<View className="flex-1" />
|
||||
<View className="min-w-0 flex-1 flex-row items-center gap-1.5">
|
||||
{thread.branch ? (
|
||||
<>
|
||||
<SymbolView
|
||||
name="arrow.triangle.branch"
|
||||
size={13}
|
||||
tintColor="#696a70"
|
||||
type="monochrome"
|
||||
/>
|
||||
<Text
|
||||
className="min-w-0 shrink text-sm text-[#77787f]"
|
||||
numberOfLines={1}
|
||||
style={{ fontFamily: MONO_FONT }}
|
||||
>
|
||||
{thread.branch}
|
||||
</Text>
|
||||
</>
|
||||
) : null}
|
||||
</View>
|
||||
)}
|
||||
{pr ? (
|
||||
<Text
|
||||
accessibilityLabel={pr.accessibilityLabel}
|
||||
className={cn("text-xs", selected ? "text-white" : pr.textClassName)}
|
||||
className={cn(
|
||||
"text-xs",
|
||||
selected ? "text-white" : sidebarPane ? pr.textClassName : "text-[#71717a]",
|
||||
)}
|
||||
style={{ fontFamily: MONO_FONT }}
|
||||
>
|
||||
#{pr.label}
|
||||
</Text>
|
||||
) : null}
|
||||
{!sidebarPane && props.environmentLabel ? (
|
||||
<View className="flex-row items-center gap-1">
|
||||
<SymbolView
|
||||
name={staleEnvironment ? "wifi.slash" : "desktopcomputer"}
|
||||
size={13}
|
||||
tintColor={staleEnvironment ? "#f87171" : "#696a70"}
|
||||
type="monochrome"
|
||||
/>
|
||||
<Text
|
||||
className={cn(
|
||||
"max-w-28 text-[13px]",
|
||||
staleEnvironment ? "text-[#f87171]" : "text-[#696a70]",
|
||||
)}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{props.environmentLabel}
|
||||
</Text>
|
||||
</View>
|
||||
) : null}
|
||||
{props.providerDriver ? (
|
||||
<View className="opacity-60">
|
||||
<ProviderIcon provider={props.providerDriver} size={14} />
|
||||
<ProviderIcon provider={props.providerDriver} size={16} />
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
@@ -722,13 +881,8 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
{sidebarPane ? (
|
||||
cardContent
|
||||
) : (
|
||||
/* Flat native list rows: no tonal containers — colored status
|
||||
labels and text hierarchy carry state, an inset hairline
|
||||
separates rows. The opaque screen background stays so swipe
|
||||
actions reveal behind the row. */
|
||||
<View className="bg-screen">
|
||||
<View className="px-5 py-2.5">{cardContent}</View>
|
||||
<View className="ml-5 h-px bg-border-subtle" />
|
||||
<View style={{ backgroundColor: "#000" }}>
|
||||
<View className="min-h-[92px] px-4 py-2.5">{cardContent}</View>
|
||||
</View>
|
||||
)}
|
||||
</Pressable>
|
||||
@@ -738,7 +892,6 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
accessibilityLabel={thread.title}
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ selected }}
|
||||
className={sidebarPane ? undefined : "bg-screen"}
|
||||
onPress={() => {
|
||||
close();
|
||||
onSelectThread(thread);
|
||||
@@ -753,21 +906,21 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
: drawerColor,
|
||||
borderRadius: SIDEBAR_V2_ROW_RADIUS,
|
||||
})
|
||||
: ({ pressed }) => ({ opacity: pressed ? 0.7 : 1 })
|
||||
: ({ pressed }) => ({ backgroundColor: "#000", opacity: pressed ? 0.7 : 1 })
|
||||
}
|
||||
>
|
||||
{/* Settled history recedes: dimmed favicon + muted title. */}
|
||||
<View
|
||||
className={cn(
|
||||
"min-h-[44px] flex-row items-center gap-2.5 py-2",
|
||||
sidebarPane ? "px-3" : "px-5",
|
||||
"min-h-[54px] flex-row items-center gap-2.5 py-2.5",
|
||||
sidebarPane ? "px-3" : "px-4",
|
||||
)}
|
||||
>
|
||||
{props.project ? (
|
||||
<View className="opacity-40">
|
||||
<ProjectFavicon
|
||||
environmentId={thread.environmentId}
|
||||
size={15}
|
||||
size={sidebarPane ? 15 : 17}
|
||||
projectTitle={props.projectTitle ?? props.project.title}
|
||||
workspaceRoot={props.project.workspaceRoot}
|
||||
/>
|
||||
@@ -776,8 +929,12 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
<View className="min-w-0 flex-1">
|
||||
<Text
|
||||
className={cn(
|
||||
"text-base",
|
||||
selected ? "text-user-bubble-foreground" : "text-foreground-muted",
|
||||
sidebarPane ? "text-base" : "text-sm",
|
||||
selected
|
||||
? "text-user-bubble-foreground"
|
||||
: sidebarPane
|
||||
? "text-foreground-muted"
|
||||
: "text-[#7d7e84]",
|
||||
)}
|
||||
numberOfLines={1}
|
||||
>
|
||||
@@ -793,12 +950,14 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
</View>
|
||||
<Text
|
||||
className={cn(
|
||||
"text-sm tabular-nums",
|
||||
sidebarPane ? "text-sm tabular-nums" : "text-xs tabular-nums",
|
||||
selected
|
||||
? "text-user-bubble-foreground-muted"
|
||||
: snoozedRow
|
||||
? "text-blue-600 dark:text-blue-400"
|
||||
: "text-foreground-tertiary",
|
||||
: sidebarPane
|
||||
? "text-foreground-tertiary"
|
||||
: "text-[#55565b]",
|
||||
)}
|
||||
style={{ fontFamily: MONO_FONT }}
|
||||
>
|
||||
@@ -813,7 +972,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
return (
|
||||
<>
|
||||
<ThreadSwipeable
|
||||
backgroundColor={sidebarPane ? drawerColor : screenColor}
|
||||
backgroundColor={sidebarPane ? drawerColor : "#000"}
|
||||
compactActions={variant === "slim"}
|
||||
containerStyle={
|
||||
sidebarPane ? { borderRadius: SIDEBAR_V2_ROW_RADIUS, overflow: "hidden" } : undefined
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { formatThreadHeaderElapsed, resolveThreadHeaderStatus } from "./threadHeaderPresentation";
|
||||
|
||||
describe("thread header presentation", () => {
|
||||
it("formats the working timer as compact minutes and seconds", () => {
|
||||
expect(
|
||||
formatThreadHeaderElapsed("2026-07-31T12:00:00.000Z", Date.parse("2026-07-31T12:02:14.000Z")),
|
||||
).toBe("2:14");
|
||||
expect(formatThreadHeaderElapsed("invalid", Date.now())).toBeNull();
|
||||
});
|
||||
|
||||
it("prioritizes actionable states over active work", () => {
|
||||
expect(
|
||||
resolveThreadHeaderStatus({
|
||||
hasPendingApproval: true,
|
||||
hasPendingUserInput: true,
|
||||
active: true,
|
||||
failed: false,
|
||||
activeWorkStartedAt: "2026-07-31T12:00:00.000Z",
|
||||
nowMs: Date.parse("2026-07-31T12:02:14.000Z"),
|
||||
}).kind,
|
||||
).toBe("approval");
|
||||
expect(
|
||||
resolveThreadHeaderStatus({
|
||||
hasPendingApproval: false,
|
||||
hasPendingUserInput: true,
|
||||
active: true,
|
||||
failed: false,
|
||||
activeWorkStartedAt: null,
|
||||
nowMs: 0,
|
||||
}).kind,
|
||||
).toBe("input");
|
||||
});
|
||||
|
||||
it("shows a timed working state and a green done state", () => {
|
||||
expect(
|
||||
resolveThreadHeaderStatus({
|
||||
hasPendingApproval: false,
|
||||
hasPendingUserInput: false,
|
||||
active: true,
|
||||
failed: false,
|
||||
activeWorkStartedAt: "2026-07-31T12:00:00.000Z",
|
||||
nowMs: Date.parse("2026-07-31T12:02:14.000Z"),
|
||||
}),
|
||||
).toMatchObject({ kind: "working", label: "2:14", nativeLabel: "2:14" });
|
||||
expect(
|
||||
resolveThreadHeaderStatus({
|
||||
hasPendingApproval: false,
|
||||
hasPendingUserInput: false,
|
||||
active: false,
|
||||
failed: false,
|
||||
activeWorkStartedAt: null,
|
||||
nowMs: 0,
|
||||
}),
|
||||
).toMatchObject({ kind: "done", label: "Done", nativeLabel: "Done" });
|
||||
});
|
||||
|
||||
it("does not label failed work as done", () => {
|
||||
expect(
|
||||
resolveThreadHeaderStatus({
|
||||
hasPendingApproval: false,
|
||||
hasPendingUserInput: false,
|
||||
active: false,
|
||||
failed: true,
|
||||
activeWorkStartedAt: null,
|
||||
nowMs: 0,
|
||||
}),
|
||||
).toMatchObject({ kind: "failed", label: "Failed" });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
export type ThreadHeaderStatusKind = "approval" | "input" | "working" | "failed" | "done";
|
||||
|
||||
export interface ThreadHeaderStatusPresentation {
|
||||
readonly kind: ThreadHeaderStatusKind;
|
||||
readonly label: string;
|
||||
readonly nativeLabel: string;
|
||||
readonly tintColor: string;
|
||||
}
|
||||
|
||||
export function formatThreadHeaderElapsed(startedAt: string | null, nowMs: number): string | null {
|
||||
if (!startedAt) {
|
||||
return null;
|
||||
}
|
||||
const startedAtMs = Date.parse(startedAt);
|
||||
if (Number.isNaN(startedAtMs)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const totalSeconds = Math.max(0, Math.floor((nowMs - startedAtMs) / 1_000));
|
||||
const minutes = Math.floor(totalSeconds / 60);
|
||||
const seconds = totalSeconds % 60;
|
||||
return `${minutes}:${String(seconds).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
export function resolveThreadHeaderStatus(input: {
|
||||
readonly hasPendingApproval: boolean;
|
||||
readonly hasPendingUserInput: boolean;
|
||||
readonly active: boolean;
|
||||
readonly failed: boolean;
|
||||
readonly activeWorkStartedAt: string | null;
|
||||
readonly nowMs: number;
|
||||
}): ThreadHeaderStatusPresentation {
|
||||
if (input.hasPendingApproval) {
|
||||
return {
|
||||
kind: "approval",
|
||||
label: "Approval",
|
||||
nativeLabel: "Approval",
|
||||
tintColor: "#ffd60a",
|
||||
};
|
||||
}
|
||||
if (input.hasPendingUserInput) {
|
||||
return {
|
||||
kind: "input",
|
||||
label: "Input",
|
||||
nativeLabel: "Input",
|
||||
tintColor: "#7d7aff",
|
||||
};
|
||||
}
|
||||
if (input.active) {
|
||||
const elapsed = formatThreadHeaderElapsed(input.activeWorkStartedAt, input.nowMs);
|
||||
return {
|
||||
kind: "working",
|
||||
label: elapsed ?? "Working",
|
||||
nativeLabel: elapsed ?? "Working",
|
||||
tintColor: "#0a84ff",
|
||||
};
|
||||
}
|
||||
if (input.failed) {
|
||||
return {
|
||||
kind: "failed",
|
||||
label: "Failed",
|
||||
nativeLabel: "Failed",
|
||||
tintColor: "#f87171",
|
||||
};
|
||||
}
|
||||
return {
|
||||
kind: "done",
|
||||
label: "Done",
|
||||
nativeLabel: "Done",
|
||||
tintColor: "#30d158",
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { useAtomSet, useAtomValue } from "@effect/atom-react";
|
||||
import type { EnvironmentId } from "@t3tools/contracts";
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { AsyncResult } from "effect/unstable/reactivity";
|
||||
|
||||
import type { ModelOption } from "../../lib/modelOptions";
|
||||
import type { Preferences } from "../../persistence/mobile-preferences";
|
||||
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
|
||||
|
||||
/** Persists model favorites on this device without inventing a server setting. */
|
||||
export function useModelFavorites(environmentId: EnvironmentId | null) {
|
||||
const preferencesResult = useAtomValue(mobilePreferencesAtom);
|
||||
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
|
||||
const favoritesReady = AsyncResult.isSuccess(preferencesResult);
|
||||
const storedKeys = favoritesReady ? (preferencesResult.value.favoriteModelKeys ?? []) : [];
|
||||
const environmentPrefix = environmentId === null ? null : `${environmentId}:`;
|
||||
|
||||
const favoriteModelKeys = useMemo(() => {
|
||||
if (environmentPrefix === null) return new Set<string>();
|
||||
return new Set(
|
||||
storedKeys.flatMap((key) =>
|
||||
key.startsWith(environmentPrefix) ? [key.slice(environmentPrefix.length)] : [],
|
||||
),
|
||||
);
|
||||
}, [environmentPrefix, storedKeys]);
|
||||
|
||||
const toggleFavorite = useCallback(
|
||||
(option: ModelOption) => {
|
||||
if (environmentPrefix === null || !favoritesReady) return;
|
||||
const scopedKey = `${environmentPrefix}${option.key}`;
|
||||
savePreferences((current: Preferences) => {
|
||||
const currentKeys = current.favoriteModelKeys ?? [];
|
||||
return {
|
||||
favoriteModelKeys: currentKeys.includes(scopedKey)
|
||||
? currentKeys.filter((key) => key !== scopedKey)
|
||||
: [...currentKeys, scopedKey],
|
||||
};
|
||||
});
|
||||
},
|
||||
[environmentPrefix, favoritesReady, savePreferences],
|
||||
);
|
||||
|
||||
return { favoriteModelKeys, favoritesReady, toggleFavorite };
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import { ProviderInstanceId, type ServerConfig } from "@t3tools/contracts";
|
||||
import {
|
||||
buildModelMenuActions,
|
||||
buildModelOptions,
|
||||
buildModelPickerProviderGroups,
|
||||
groupByProvider,
|
||||
resolveSelectableModelSelection,
|
||||
} from "./modelOptions";
|
||||
@@ -88,6 +89,46 @@ describe("mobile model options", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps legacy models folded into their provider while search can reveal them", () => {
|
||||
const config = {
|
||||
providers: [
|
||||
{
|
||||
instanceId: "codex",
|
||||
driver: "codex",
|
||||
displayName: "Codex",
|
||||
enabled: true,
|
||||
installed: true,
|
||||
auth: { status: "authenticated" },
|
||||
models: [
|
||||
{
|
||||
slug: "gpt-current",
|
||||
name: "GPT Current",
|
||||
isCustom: false,
|
||||
capabilities: null,
|
||||
},
|
||||
{
|
||||
slug: "gpt-legacy",
|
||||
name: "GPT Legacy",
|
||||
isCustom: false,
|
||||
isLegacy: true,
|
||||
capabilities: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
} as unknown as ServerConfig;
|
||||
|
||||
const groups = groupByProvider(buildModelOptions(config, null));
|
||||
expect(buildModelPickerProviderGroups(groups, "")[0]).toMatchObject({
|
||||
currentModels: [{ label: "GPT Current" }],
|
||||
legacyModels: [{ label: "GPT Legacy" }],
|
||||
});
|
||||
expect(buildModelPickerProviderGroups(groups, "legacy")[0]).toMatchObject({
|
||||
currentModels: [],
|
||||
legacyModels: [{ label: "GPT Legacy" }],
|
||||
});
|
||||
});
|
||||
|
||||
it("normalizes a legacy fallback selection against current capabilities", () => {
|
||||
const config = {
|
||||
providers: [
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type {
|
||||
ModelCapabilities,
|
||||
ModelSelection,
|
||||
ProviderInstanceId,
|
||||
ServerConfig as T3ServerConfig,
|
||||
} from "@t3tools/contracts";
|
||||
import type { MenuAction } from "@react-native-menu/menu";
|
||||
@@ -13,7 +14,7 @@ export type ModelOption = {
|
||||
readonly key: string;
|
||||
readonly label: string;
|
||||
readonly subtitle: string;
|
||||
readonly providerKey: string;
|
||||
readonly providerKey: ProviderInstanceId;
|
||||
readonly providerLabel: string;
|
||||
readonly providerDriver: string;
|
||||
readonly isDefault: boolean;
|
||||
@@ -23,11 +24,16 @@ export type ModelOption = {
|
||||
};
|
||||
|
||||
export type ProviderGroup = {
|
||||
readonly providerKey: string;
|
||||
readonly providerKey: ProviderInstanceId;
|
||||
readonly providerLabel: string;
|
||||
readonly models: ReadonlyArray<ModelOption>;
|
||||
};
|
||||
|
||||
export type ModelPickerProviderGroup = ProviderGroup & {
|
||||
readonly currentModels: ReadonlyArray<ModelOption>;
|
||||
readonly legacyModels: ReadonlyArray<ModelOption>;
|
||||
};
|
||||
|
||||
function providerDisplayLabel(provider: {
|
||||
readonly displayName?: string | undefined;
|
||||
readonly driver: string;
|
||||
@@ -149,7 +155,7 @@ export function buildModelOptions(
|
||||
}
|
||||
|
||||
export function groupByProvider(options: ReadonlyArray<ModelOption>): ReadonlyArray<ProviderGroup> {
|
||||
const groups = new Map<string, { providerLabel: string; models: ModelOption[] }>();
|
||||
const groups = new Map<ProviderInstanceId, { providerLabel: string; models: ModelOption[] }>();
|
||||
for (const option of options) {
|
||||
const existing = groups.get(option.providerKey);
|
||||
if (existing) {
|
||||
@@ -169,6 +175,37 @@ export function groupByProvider(options: ReadonlyArray<ModelOption>): ReadonlyAr
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the provider sections used by the full-screen mobile picker. Legacy
|
||||
* models stay separate so the UI can keep them folded until requested while
|
||||
* search can still reveal a matching legacy model immediately.
|
||||
*/
|
||||
export function buildModelPickerProviderGroups(
|
||||
groups: ReadonlyArray<ProviderGroup>,
|
||||
query: string,
|
||||
): ReadonlyArray<ModelPickerProviderGroup> {
|
||||
const tokens = query.trim().toLocaleLowerCase().split(/\s+/u).filter(Boolean);
|
||||
const matches = (option: ModelOption) => {
|
||||
if (tokens.length === 0) return true;
|
||||
const searchable = [
|
||||
option.label,
|
||||
option.selection.model,
|
||||
option.providerLabel,
|
||||
option.providerDriver,
|
||||
]
|
||||
.join(" ")
|
||||
.toLocaleLowerCase();
|
||||
return tokens.every((token) => searchable.includes(token));
|
||||
};
|
||||
|
||||
return groups.flatMap((group) => {
|
||||
const currentModels = group.models.filter((model) => !model.isLegacy && matches(model));
|
||||
const legacyModels = group.models.filter((model) => model.isLegacy && matches(model));
|
||||
if (currentModels.length === 0 && legacyModels.length === 0) return [];
|
||||
return [{ ...group, currentModels, legacyModels }];
|
||||
});
|
||||
}
|
||||
|
||||
function modelMenuAction(option: ModelOption, selectedModel: ModelSelection | null): MenuAction {
|
||||
return {
|
||||
id: `model:${option.key}`,
|
||||
|
||||
@@ -22,6 +22,8 @@ export interface Preferences {
|
||||
readonly codeWordBreak?: boolean;
|
||||
readonly connectOnboardingOptOutAccounts?: ReadonlyArray<string>;
|
||||
readonly collapsedProjectGroups?: readonly string[];
|
||||
/** Device-local model favorites, scoped as environment:model-option keys. */
|
||||
readonly favoriteModelKeys?: readonly string[];
|
||||
readonly projectGroupingEnabled?: boolean;
|
||||
/**
|
||||
* Device-local mirror of the web beta's `sidebarV2Enabled`. Mobile has no
|
||||
@@ -79,6 +81,7 @@ function sanitizePreferences(parsed: Preferences): Preferences {
|
||||
codeWordBreak?: boolean;
|
||||
connectOnboardingOptOutAccounts?: ReadonlyArray<string>;
|
||||
collapsedProjectGroups?: readonly string[];
|
||||
favoriteModelKeys?: readonly string[];
|
||||
projectGroupingEnabled?: boolean;
|
||||
threadListV2Enabled?: boolean;
|
||||
} = {};
|
||||
@@ -107,6 +110,11 @@ function sanitizePreferences(parsed: Preferences): Preferences {
|
||||
(key): key is string => typeof key === "string",
|
||||
);
|
||||
}
|
||||
if (Array.isArray(parsed.favoriteModelKeys)) {
|
||||
preferences.favoriteModelKeys = parsed.favoriteModelKeys.filter(
|
||||
(key): key is string => typeof key === "string",
|
||||
);
|
||||
}
|
||||
if (typeof parsed.projectGroupingEnabled === "boolean") {
|
||||
preferences.projectGroupingEnabled = parsed.projectGroupingEnabled;
|
||||
}
|
||||
|
||||
@@ -124,6 +124,36 @@ describe("mobile preferences state", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("applies functional preference updates against the latest optimistic value", () =>
|
||||
Effect.gen(function* () {
|
||||
const state = makePreferencesState({
|
||||
load: Effect.succeed({ favoriteModelKeys: ["env:codex:gpt-5"] }),
|
||||
savePatch: (patch) => Effect.succeed(patch),
|
||||
});
|
||||
const registry = AtomRegistry.make();
|
||||
const unmountPreferences = registry.mount(state.preferencesAtom);
|
||||
const unmountUpdate = registry.mount(state.updatePreferencesAtom);
|
||||
|
||||
yield* AtomRegistry.getResult(registry, state.preferencesAtom, {
|
||||
suspendOnWaiting: true,
|
||||
});
|
||||
registry.set(state.updatePreferencesAtom, (current) => ({
|
||||
favoriteModelKeys: [...(current.favoriteModelKeys ?? []), "env:claude:opus"],
|
||||
}));
|
||||
registry.set(state.updatePreferencesAtom, (current) => ({
|
||||
favoriteModelKeys: [...(current.favoriteModelKeys ?? []), "other:codex:gpt-6"],
|
||||
}));
|
||||
|
||||
expect(Option.getOrThrow(AsyncResult.value(registry.get(state.preferencesAtom)))).toEqual({
|
||||
favoriteModelKeys: ["env:codex:gpt-5", "env:claude:opus", "other:codex:gpt-6"],
|
||||
});
|
||||
|
||||
unmountUpdate();
|
||||
unmountPreferences();
|
||||
registry.dispose();
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("falls back to empty preferences when secure storage cannot be read", () =>
|
||||
Effect.gen(function* () {
|
||||
const state = makePreferencesState({
|
||||
|
||||
@@ -15,6 +15,10 @@ interface OptimisticPreferences {
|
||||
readonly versions: Partial<Record<keyof Preferences, number>>;
|
||||
}
|
||||
|
||||
export type PreferencesUpdate =
|
||||
| Partial<Preferences>
|
||||
| ((current: Preferences) => Partial<Preferences>);
|
||||
|
||||
/**
|
||||
* Owns the device preference blob for the lifetime of the app registry.
|
||||
* Optimistic patches are kept separately so writes made while persistence is
|
||||
@@ -57,7 +61,15 @@ export function createMobilePreferencesState(runtime: Atom.AtomRuntime<MobilePre
|
||||
|
||||
const updatePreferencesAtom = runtime
|
||||
.fn(
|
||||
(patch: Partial<Preferences>, get) => {
|
||||
(update: PreferencesUpdate, get) => {
|
||||
const preferences = get(preferencesAtom);
|
||||
let patch: Partial<Preferences>;
|
||||
if (typeof update === "function") {
|
||||
if (!AsyncResult.isSuccess(preferences)) return Effect.void;
|
||||
patch = update(preferences.value);
|
||||
} else {
|
||||
patch = update;
|
||||
}
|
||||
const version = ++nextPatchVersion;
|
||||
const current = get(optimisticPatchAtom);
|
||||
const versions = { ...current.versions };
|
||||
|
||||
@@ -168,6 +168,7 @@ export function useSelectedThreadRequests() {
|
||||
|
||||
return {
|
||||
activePendingApproval,
|
||||
activePendingApprovalCount: activePendingApprovals.length,
|
||||
activePendingUserInput,
|
||||
activePendingUserInputDrafts,
|
||||
activePendingUserInputAnswers,
|
||||
|
||||
Reference in new issue
Block a user