diff --git a/apps/mobile/global.css b/apps/mobile/global.css index 6d36bf77ca..10d7805f59 100644 --- a/apps/mobile/global.css +++ b/apps/mobile/global.css @@ -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 */ diff --git a/apps/mobile/src/components/CompactBrandTitle.tsx b/apps/mobile/src/components/CompactBrandTitle.tsx index f0710e85d3..a959fa7bd3 100644 --- a/apps/mobile/src/components/CompactBrandTitle.tsx +++ b/apps/mobile/src/components/CompactBrandTitle.tsx @@ -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 - - - {stageLabel} - - ); } diff --git a/apps/mobile/src/components/ComposerToolbarTrigger.tsx b/apps/mobile/src/components/ComposerToolbarTrigger.tsx index 2018762496..21a0be38cb 100644 --- a/apps/mobile/src/components/ComposerToolbarTrigger.tsx +++ b/apps/mobile/src/components/ComposerToolbarTrigger.tsx @@ -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; }) { @@ -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 ( [ { 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 ? ( - {props.iconNode} + + {props.iconNode} + ) : props.icon ? ( - + ) : null} {props.label ? ( + + + {normalizedPercentage > 0 ? ( + + ) : null} + + + ); +} + export const ComposerToolbarTrigger = ComposerToolbarButton; diff --git a/apps/mobile/src/features/home/HomeHeader.tsx b/apps/mobile/src/features/home/HomeHeader.tsx index a209dbd762..cb7d604b20 100644 --- a/apps/mobile/src/features/home/HomeHeader.tsx +++ b/apps/mobile/src/features/home/HomeHeader.tsx @@ -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; readonly projects: ReadonlyArray; readonly searchQuery: string; @@ -48,33 +44,25 @@ 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 ; - } - - return ; -} - -type HomeHeaderProps = Parameters[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(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); + return true; + }, []); + useHardwareKeyboardCommand("focusSearch", focusSearch); + useEffect(() => { + if (searchVisible) searchInputRef.current?.focus(); + }, [searchVisible]); + const menuActions = useMemo( () => [ { @@ -84,12 +72,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 +94,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 +113,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 +122,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 +138,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 +169,6 @@ function AndroidHomeHeader(props: HomeHeaderProps) { } return; } - const projectSort = PROJECT_SORT_OPTIONS.find( (option) => id === `project-sort:${option.value}`, ); @@ -185,281 +176,155 @@ 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 selectedProjectLabel = + props.projects.find((project) => project.key === props.selectedProjectKey)?.label ?? + "All projects"; + return ( <> - - - - {/* Mirrors the desktop SidebarBrand: T3 mark + muted "Code". */} - - - Code - - - - {stageLabel} - - - - - - - - - - {/* Built identically to the filter button so the two circles - match exactly (ControlPill sizes via Tailwind classes and - resolves to a different box). */} - + + - - - - - - - props.onReconnectEnvironment(troubledEnvironment.environmentId) + : undefined + } + variant="header" + fallback={ + + + + Code + + + } /> - {props.searchQuery.length > 0 ? ( - props.onSearchQueryChange("")} - > - - - ) : null} + { + if (searchVisible) { + props.onSearchQueryChange(""); + setSearchVisible(false); + } else { + setSearchVisible(true); + } + }} + > + + + + + + + + + + + {searchVisible ? ( + <> + + + + ) : ( + + + + + + {selectedProjectLabel} + + + {props.selectedEnvironmentId !== null && troubledEnvironment ? ( + + {troubledEnvironment.label} + + ) : null} + + + + )} ); } - -function IosHomeHeader(props: HomeHeaderProps) { - const searchBarRef = useRef(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 ( - <> - [ - 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 : ( - - - - Environment - props.onEnvironmentChange(null)} - subtitle="Show threads from every environment" - > - All environments - - {props.environments.map((environment) => ( - props.onEnvironmentChange(environment.environmentId)} - > - {environment.label} - - ))} - - - {props.projects.length > 0 ? ( - - Project - props.onProjectChange(null)} - subtitle="Show threads from every project" - > - All projects - - {props.projects.map((project) => ( - props.onProjectChange(project.key)} - > - {project.label} - - ))} - - ) : null} - - {threadListV2Enabled ? null : ( - - Sort projects - {PROJECT_SORT_OPTIONS.map((option) => ( - props.onProjectSortOrderChange(option.value)} - > - {option.label} - - ))} - - )} - - {threadListV2Enabled ? null : ( - - Sort threads - {THREAD_SORT_OPTIONS.map((option) => ( - props.onThreadSortOrderChange(option.value)} - > - {option.label} - - ))} - - )} - - - - - )} - - ); -} diff --git a/apps/mobile/src/features/home/HomeRouteScreen.tsx b/apps/mobile/src/features/home/HomeRouteScreen.tsx index 16a3efde6d..c39729ef52 100644 --- a/apps/mobile/src/features/home/HomeRouteScreen.tsx +++ b/apps/mobile/src/features/home/HomeRouteScreen.tsx @@ -2,18 +2,20 @@ 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"; @@ -29,6 +31,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(""); @@ -103,7 +106,12 @@ export function HomeRouteScreen() { return ( <> [] }} + options={{ + headerShown: true, + title: "", + headerTitle: "", + unstable_headerLeftItems: () => [], + }} /> navigation.navigate("NewTaskSheet", { screen: "NewTask" })} - > - <> - {/* Restore the compact title after the split branch blanks the detail header. */} - - navigation.navigate("SettingsSheet", { screen: "Settings" })} - onProjectSortOrderChange={setProjectSortOrder} - onSearchQueryChange={setSearchQuery} - onStartNewTask={() => navigation.navigate("NewTaskSheet", { screen: "NewTask" })} - onThreadSortOrderChange={setThreadSortOrder} - /> + + navigation.navigate("SettingsSheet", { screen: "Settings" })} + onProjectSortOrderChange={setProjectSortOrder} + onReconnectEnvironment={onReconnectEnvironment} + onSearchQueryChange={setSearchQuery} + onThreadSortOrderChange={setThreadSortOrder} + /> - - 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} - /> - - + + 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} + /> + ); } diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsx index 2b58bc342d..3e767263ec 100644 --- a/apps/mobile/src/features/home/HomeScreen.tsx +++ b/apps/mobile/src/features/home/HomeScreen.tsx @@ -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 ; -} - /* ─── Main screen ────────────────────────────────────────────────────── */ export function HomeScreen(props: HomeScreenProps) { @@ -208,11 +194,6 @@ export function HomeScreen(props: HomeScreenProps) { const openSwipeableRef = useRef(null); const listRef = useRef(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" ? ( - - - - ) : null; + const composeAction = ( + ({ + bottom: Math.max(insets.bottom, 16) + 9, + opacity: pressed ? 0.72 : 1, + shadowColor: "#000", + shadowOffset: { width: 0, height: 10 }, + shadowOpacity: 0.7, + shadowRadius: 26, + })} + > + + + ); if (!hasAnyThreads) { return ( - {emptyState.loading && !shouldShowConnectionStatus ? ( - - - - ) : null} - {shouldShowConnectionStatus && Platform.OS === "ios" ? ( - - - - ) : null} - {connectionStatus} + {composeAction} ); } - const listHeader = ( - <> - {Platform.OS === "ios" ? null : } - - {shouldShowConnectionStatus && Platform.OS === "ios" ? ( - - - - ) : 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 ( - + 0 ? ( - {connectionStatus} + {composeAction} ); } return ( - + {/* 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 } /> - {connectionStatus} + {composeAction} ); } diff --git a/apps/mobile/src/features/home/WorkspaceConnectionStatus.test.ts b/apps/mobile/src/features/home/WorkspaceConnectionStatus.test.ts index 8c3c873cc9..7a6a18d2f3 100644 --- a/apps/mobile/src/features/home/WorkspaceConnectionStatus.test.ts +++ b/apps/mobile/src/features/home/WorkspaceConnectionStatus.test.ts @@ -3,6 +3,7 @@ import { describe, expect, it } from "vite-plus/test"; import type { WorkspaceState } from "../../state/workspaceModel"; import { shouldShowWorkspaceConnectionStatus, + workspaceConnectionHeaderPresentation, workspaceConnectionStatusLabel, } from "./workspace-connection-status"; @@ -84,4 +85,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", + }); + }); }); diff --git a/apps/mobile/src/features/home/WorkspaceConnectionStatus.tsx b/apps/mobile/src/features/home/WorkspaceConnectionStatus.tsx index 1e986ad1a5..06fd798f20 100644 --- a/apps/mobile/src/features/home/WorkspaceConnectionStatus.tsx +++ b/apps/mobile/src/features/home/WorkspaceConnectionStatus.tsx @@ -1,17 +1,77 @@ +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 ( + + + + {presentation.label}{" "} + + {presentation.detail} + + + {presentation.tone === "red" && props.onReconnect ? ( + + + Reconnect + + + ) : null} + + ); + } + const isSynchronizing = props.state.networkStatus !== "offline" && props.state.connectionError === null && @@ -41,7 +101,12 @@ export function WorkspaceConnectionStatus(props: { } > {isSynchronizing ? ( - + ) : ( )} diff --git a/apps/mobile/src/features/home/workspace-connection-status.ts b/apps/mobile/src/features/home/workspace-connection-status.ts index d8eed4383b..5f8f730b6a 100644 --- a/apps/mobile/src/features/home/workspace-connection-status.ts +++ b/apps/mobile/src/features/home/workspace-connection-status.ts @@ -1,3 +1,5 @@ +import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection"; + import type { WorkspaceState } from "../../state/workspaceModel"; export function shouldShowWorkspaceConnectionStatus(state: WorkspaceState): boolean { @@ -24,3 +26,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; +} diff --git a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx index 6d204e3a8e..e60e543a55 100644 --- a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx +++ b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx @@ -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, 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 { @@ -15,14 +14,16 @@ import { import { ComposerEditor, type ComposerEditorHandle } from "../../components/ComposerEditor"; import { + ComposerContextRing, ComposerToolbarButton, ComposerToolbarRow, 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 { 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"; @@ -52,18 +52,6 @@ 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"; -} - export function NewTaskDraftScreen(props: { readonly initialProjectRef?: { readonly environmentId?: string; @@ -101,7 +89,6 @@ export function NewTaskDraftScreen(props: { )?.connectionState === "connected"; const promptInputRef = useRef(null); const loadedBranchesProjectKeyRef = useRef(null); - const [isComposerFocused, setIsComposerFocused] = useState(false); const [importingShareKey, setImportingShareKey] = useState(null); const [isCancellingShareImport, setIsCancellingShareImport] = useState(false); const [cancelledIncomingShareId, setCancelledIncomingShareId] = useState(null); @@ -221,11 +208,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 +494,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 | 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) => ({ @@ -669,22 +633,26 @@ 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 workspaceLabel = useMemo( - () => - formatWorkspaceLabel({ - currentBranchName, - selectedBranchName: flow.selectedBranchName, - workspaceMode: flow.workspaceMode, - }), - [currentBranchName, flow.selectedBranchName, flow.workspaceMode], + const accessModeLabel = + flow.runtimeMode === "approval-required" + ? "Supervised" + : flow.runtimeMode === "auto-accept-edits" + ? "Auto-accept" + : flow.runtimeMode === "auto" + ? "Auto" + : "Full access"; + const configurationMenuActions = useMemo( + () => [ + ...optionsMenuActions, + { + id: "options-environment", + title: "Environment", + subtitle: selectedEnvironmentLabel, + subactions: environmentMenuActions, + }, + ...workspaceMenuActions, + ], + [environmentMenuActions, optionsMenuActions, selectedEnvironmentLabel, workspaceMenuActions], ); function handleModelMenuAction(event: string) { if (isIncomingShareTransferPending || !event.startsWith("model:")) { @@ -745,6 +713,12 @@ export function NewTaskDraftScreen(props: { } } + function handleConfigurationMenuAction(event: string) { + handleOptionsMenuAction(event); + handleEnvironmentMenuAction(event); + handleWorkspaceMenuAction(event); + } + async function handlePickImages(): Promise { if (isIncomingShareTransferPending) { return; @@ -911,24 +885,13 @@ export function NewTaskDraftScreen(props: { if (!selectedProject) { return ( - - {Platform.OS === "android" ? ( - <> - - navigation.goBack()} /> - - ) : ( - - )} + + ); } - 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,47 +903,34 @@ export function NewTaskDraftScreen(props: { const promptEditor = ( 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, @tag files, / for commands" + contentInsetVertical={0} + style={{ + minHeight: 84, + maxHeight: 176, + paddingHorizontal: 4, + paddingVertical: 4, + }} + textStyle={{ ...bodyText, color: foregroundColor }} /> ); const toolbarPills = ( <> void handlePickImages()} showChevron={false} - disabled={isIncomingShareTransferPending} /> } label={flow.selectedModelOption?.label ?? "Model"} + variant="ghost" /> handleOptionsMenuAction(nativeEvent.event)} + actions={configurationMenuActions} + onPressAction={({ nativeEvent }) => handleConfigurationMenuAction(nativeEvent.event)} > - - handleEnvironmentMenuAction(nativeEvent.event)} - > - - - handleWorkspaceMenuAction(nativeEvent.event)} - > - @@ -1034,7 +964,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,113 +972,114 @@ 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 ( - - - navigation.goBack()} /> - - - - - + + + + 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, }} > - Cancel + + + + + + What should we build + + + - {isExpanded && flow.attachments.length > 0 ? ( - - undefined : flow.removeAttachment - } - /> - - ) : null} - {promptEditor} - {!isExpanded ? ( - void handleStart()} - /> - ) : null} - - - {isExpanded ? ( - - - {toolbarPills} - - {startButton} - - ) : null} - - - - ); - } - - return ( - - - - - {promptEditor} - - - {flow.attachments.length > 0 ? ( - - undefined : flow.removeAttachment} - imageSize={88} - imageBorderRadius={20} - /> + in{" "} + + + + {selectedProject.title} + - ) : null} - - - {toolbarPills} - - {startButton} - + ? + + + + + on {selectedEnvironmentLabel} + + + + + + {flow.attachments.length > 0 ? ( + + undefined : flow.removeAttachment + } + /> + + ) : null} + {promptEditor} + + + {toolbarPills} + + + {startButton} + + diff --git a/apps/mobile/src/features/threads/PendingApprovalCard.tsx b/apps/mobile/src/features/threads/PendingApprovalCard.tsx index caf9bd4cd0..5de63e143d 100644 --- a/apps/mobile/src/features/threads/PendingApprovalCard.tsx +++ b/apps/mobile/src/features/threads/PendingApprovalCard.tsx @@ -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; } +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; + 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 ( - - - Approval needed - - - {props.approval.requestKind} - - {props.approval.detail ? ( - - {props.approval.detail} - - ) : null} - - void props.onRespond(props.approval.requestId, "accept")} - > - Allow once - - void props.onRespond(props.approval.requestId, "acceptForSession")} - > - - Allow session + + + + + Pending approval - - void props.onRespond(props.approval.requestId, "decline")} - > - Decline - + + 1/{Math.max(1, props.approvalCount)} + + + {copy.title} + + + {copy.eyebrow} + + + {props.approval.detail ?? "Review the requested operation before continuing."} + + + + + + + respond("accept")} + > + Approve once + + respond("acceptForSession")} + > + Always allow + + + + respond("decline")} + > + Decline + + respond("cancel")} + > + Cancel turn + + ); diff --git a/apps/mobile/src/features/threads/PendingUserInputCard.tsx b/apps/mobile/src/features/threads/PendingUserInputCard.tsx index 4d2c2c8415..2c344e3645 100644 --- a/apps/mobile/src/features/threads/PendingUserInputCard.tsx +++ b/apps/mobile/src/features/threads/PendingUserInputCard.tsx @@ -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,155 @@ export interface PendingUserInputCardProps { readonly onSubmit: () => Promise; } +function hasDraftAnswer(draft: PendingUserInputDraftAnswer | undefined): boolean { + return Boolean(draft?.customAnswer?.trim() || draft?.selectedOptionLabel?.trim()); +} + +function firstUnansweredQuestionIndex( + questions: PendingUserInput["questions"], + drafts: Record, +): 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 canAdvance = hasDraftAnswer(draft); + + if (!activeQuestion) { + return null; + } + + const handleAdvance = () => { + if (!canAdvance || isResponding) { + return; + } + if (!isLastQuestion) { + setQuestionIndex((current) => + Math.min(current + 1, props.pendingUserInput.questions.length - 1), + ); + return; + } + if (props.answers) { + void props.onSubmit(); + } + }; + return ( - - - User input needed - - - Fill in the pending answers - - {props.pendingUserInput.questions.map((question) => { - const draft = props.drafts[question.id]; - return ( - - - {question.header} - - - {question.question} - - - {question.options.map((option) => { - const selected = - draft?.selectedOptionLabel === option.label && !draft.customAnswer?.trim().length; - return ( - - props.onSelectOption( - props.pendingUserInput.requestId, - question.id, - option.label, - ) - } - > - - {option.label} - - - ); - })} - - - props.onChangeCustomAnswer(props.pendingUserInput.requestId, question.id, value) + + + + + {activeQuestion.header} + + + {questionIndex + 1}/{props.pendingUserInput.questions.length} + + + + {activeQuestion.question} + + + + + {activeQuestion.options.map((option, index) => { + const selected = + draft?.selectedOptionLabel === option.label && !draft.customAnswer?.trim().length; + return ( + + 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" - /> - - ); - })} - void props.onSubmit()} - > - Submit answers - + > + + {option.label} + {option.description !== option.label ? ( + + {option.description} + + ) : null} + + {selected ? ( + + ) : index < 9 ? ( + + + {index + 1} + + + ) : null} + + ); + })} + + + 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" + /> + + + + + + {isLastQuestion ? "Submit answers" : "Next question"} + + + ); } diff --git a/apps/mobile/src/features/threads/ThreadComposer.tsx b/apps/mobile/src/features/threads/ThreadComposer.tsx index aab896efe0..c8282da96b 100644 --- a/apps/mobile/src/features/threads/ThreadComposer.tsx +++ b/apps/mobile/src/features/threads/ThreadComposer.tsx @@ -16,15 +16,7 @@ import { } from "@t3tools/shared/composerTrigger"; import type { ReactNode } from "react"; import { memo, useCallback, useEffect, useMemo, useRef, useState, type RefObject } from "react"; -import { - ActivityIndicator, - Image, - Platform, - Pressable, - useColorScheme, - View, - type ViewStyle, -} from "react-native"; +import { Image, Platform, Pressable, useColorScheme, View, type ViewStyle } from "react-native"; import ImageViewing from "react-native-image-viewing"; import Animated, { FadeIn, @@ -45,12 +37,13 @@ import { type ComposerEditorSelection, } from "../../components/ComposerEditor"; import { + ComposerContextRing, ComposerToolbarButton, ComposerToolbarRow, ComposerToolbarScroller, ComposerToolbarTrigger, } from "../../components/ComposerToolbarTrigger"; -import { ControlPill, ControlPillMenu } from "../../components/ControlPill"; +import { ControlPillMenu } from "../../components/ControlPill"; import { ProviderIcon } from "../../components/ProviderIcon"; import type { DraftComposerImageAttachment } from "../../lib/composerImages"; import { buildModelMenuActions, buildModelOptions, groupByProvider } from "../../lib/modelOptions"; @@ -64,7 +57,6 @@ import { import { applyProviderOptionMenuEvent, buildProviderOptionMenuActions, - providerOptionsConfigurationLabel, resolveProviderOptionDescriptors, } from "../../lib/providerOptions"; import { useComposerPathSearch } from "../../state/use-composer-path-search"; @@ -74,13 +66,13 @@ import { ComposerCommandPopover, type ComposerCommandItem } from "./ComposerComm * 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 = 212; export interface ThreadComposerProps { readonly draftMessage: string; @@ -168,7 +160,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 +241,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 ? ( - - ) : ( - - )} + { if (!props.serverConfig) return null; @@ -601,10 +601,6 @@ 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], @@ -693,9 +689,9 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer return ( @@ -772,7 +771,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,8 +783,8 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer style={ isExpanded ? { - minHeight: 80, - maxHeight: 160, + minHeight: 84, + maxHeight: 176, paddingHorizontal: 4, paddingVertical: 4, } @@ -822,13 +821,21 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer {!isExpanded ? ( {showStopAction ? ( - + ) : ( - )} @@ -836,7 +843,6 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer {isExpanded ? ( - // Toolbar row — matches draft page layout (expanded only) + } label={currentModelOption?.label ?? currentModelSelection.model} + variant="ghost" /> + {showStopAction ? ( ) : null} - {/* Queue count */} {props.queueCount > 0 ? ( - + {props.queueCount} queued message{props.queueCount === 1 ? "" : "s"} will send automatically. diff --git a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx index 5cb04290f6..0c8c0cb6eb 100644 --- a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx @@ -51,6 +51,7 @@ export interface ThreadDetailScreenProps { readonly selectedThreadFeed: ReadonlyArray; readonly activeWorkStartedAt: string | null; readonly activePendingApproval: PendingApproval | null; + readonly activePendingApprovalCount: number; readonly respondingApprovalId: ApprovalRequestId | null; readonly activePendingUserInput: PendingUserInput | null; readonly activePendingUserInputDrafts: Record; @@ -181,6 +182,8 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread const lastScrolledAnchorMessageIdRef = useRef(null); const [composerExpanded, setComposerExpanded] = useState(false); const [anchorMessageId, setAnchorMessageId] = useState(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,10 @@ 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.activePendingUserInput ? 430 : 270; + 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 +248,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 +402,23 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread pushes the resting content floor up by the same amount. */} - {props.activePendingApproval || props.activePendingUserInput ? ( + {activePendingRequest ? ( {props.activePendingApproval ? ( - ) : null} - {props.activePendingUserInput ? ( + ) : props.activePendingUserInput ? ( - + {activePendingRequest ? null : ( + + )} ) : null} diff --git a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx index 7fb4740ddc..7e84597fdf 100644 --- a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx @@ -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>; +function isUnknownRecord(value: unknown): value is Record { + return typeof value === "object" && value !== null && !Array.isArray(value); +} + +function ThreadHeaderStatus(props: { + readonly status: ThreadHeaderStatusPresentation; + readonly onPress: () => void; +}) { + return ( + + + {props.status.nativeLabel} + + + ); +} + 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,59 @@ function ThreadRouteContent( ], [navigation], ); + const statusGitHeaderItem = 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 status: ${threadHeaderStatus.label}. Thread actions`, + icon: undefined, + identifier: "thread-right-status", + label: threadHeaderStatus.nativeLabel, + 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", + }, + tintColor: threadHeaderStatus.tintColor, + }; + }, [ + compactRightHeaderItems, + handleOpenFilesInspector, + handleOpenTerminal, + selectedThreadCwd, + selectedThreadProject?.workspaceRoot, + threadHeaderStatus, + ]); + const nativeThreadRightHeaderItems = useMemo(() => { + if (layout.usesSplitView) { + return threadCenterHeaderItems; + } + return statusGitHeaderItem ? [statusGitHeaderItem] : []; + }, [layout.usesSplitView, statusGitHeaderItem, threadCenterHeaderItems]); if (!environmentId || !threadId) { return ; @@ -757,6 +872,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 +914,16 @@ function ThreadRouteContent( <> {activeInspectorRenderer ? : null} (layout.usesSplitView ? threadCenterHeaderItems : compactRightHeaderItems) - : undefined, - unstable_headerSubtitle: usesNativeHeaderGlass ? headerSubtitle : undefined, + Platform.OS === "ios" ? () => nativeThreadRightHeaderItems : undefined, + unstable_headerSubtitle: headerSubtitle.length > 0 ? headerSubtitle : undefined, }} /> @@ -839,6 +952,9 @@ function ThreadRouteContent( subtitle={headerSubtitle} onBack={layout.usesSplitView ? undefined : () => navigation.goBack()} actions={androidHeaderActions} + trailing={ + + } /> ) : null} diff --git a/apps/mobile/src/features/threads/thread-list-v2-items.tsx b/apps/mobile/src/features/threads/thread-list-v2-items.tsx index 6b9dd52512..43d3913b8c 100644 --- a/apps/mobile/src/features/threads/thread-list-v2-items.tsx +++ b/apps/mobile/src/features/threads/thread-list-v2-items.tsx @@ -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 + Record > = { - 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", )} > - {props.label} + + {props.label} + ); @@ -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 })} > - - {props.expanded ? "Snoozed" : `Snoozed (${props.count})`} + + {props.pane === "sidebar" && props.expanded ? "Snoozed" : `Snoozed (${props.count})`} ({ opacity: pressed ? 0.6 : 1 })} > - + {props.expanded ? "Settled" : `Settled (${props.count})`} @@ -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 ? ( ) : null} - + {projectTitle} - Queued + + Queued + {/* 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. */} - + {pendingTask.title} {branch || props.environmentLabel ? ( - + {branch ? ( - - {branch} - + <> + {!sidebarPane ? ( + + ) : null} + + {branch} + + ) : null} - {branch && props.environmentLabel ? " · " : null} {props.environmentLabel ? ( - {props.environmentLabel} + + {!sidebarPane ? ( + + ) : null} + + {props.environmentLabel} + + ) : null} - + ) : null} ); @@ -289,9 +385,8 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props {sidebarPane ? ( rowContent ) : ( - - {rowContent} - + + {rowContent} )} @@ -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 ? ( ) : null} @@ -600,19 +703,30 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { ) : null} {statusLabel?.label ?? timeLabel} {thread.title} @@ -626,67 +740,112 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { ) : null} - {status === "failed" && thread.session?.lastError ? ( - + {sidebarPane ? ( + status === "failed" && thread.session?.lastError ? ( + + {thread.session.lastError} + + ) : thread.branch || props.environmentLabel ? ( + + {thread.branch ? ( + + {thread.branch} + + ) : null} + {thread.branch && props.environmentLabel ? " · " : null} + {props.environmentLabel ? ( + + {props.environmentLabel} + + ) : null} + + ) : ( + + ) + ) : status === "failed" && thread.session?.lastError ? ( + {thread.session.lastError} - ) : 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. */ - - {thread.branch ? ( - - {thread.branch} - - ) : null} - {thread.branch && props.environmentLabel ? " · " : null} - {props.environmentLabel ? ( - - {props.environmentLabel} - - ) : null} - ) : ( - + + {thread.branch ? ( + <> + + + {thread.branch} + + + ) : null} + )} {pr ? ( #{pr.label} ) : null} + {!sidebarPane && props.environmentLabel ? ( + + + + {props.environmentLabel} + + + ) : null} {props.providerDriver ? ( - + ) : null} @@ -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. */ - - {cardContent} - + + {cardContent} )} @@ -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. */} {props.project ? ( @@ -776,8 +929,12 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { @@ -793,12 +950,14 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { @@ -813,7 +972,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { return ( <> { + 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" }); + }); +}); diff --git a/apps/mobile/src/features/threads/threadHeaderPresentation.ts b/apps/mobile/src/features/threads/threadHeaderPresentation.ts new file mode 100644 index 0000000000..2ae2d9f4c6 --- /dev/null +++ b/apps/mobile/src/features/threads/threadHeaderPresentation.ts @@ -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", + }; +} diff --git a/apps/mobile/src/state/use-selected-thread-requests.ts b/apps/mobile/src/state/use-selected-thread-requests.ts index 82ff42f247..b45b325111 100644 --- a/apps/mobile/src/state/use-selected-thread-requests.ts +++ b/apps/mobile/src/state/use-selected-thread-requests.ts @@ -168,6 +168,7 @@ export function useSelectedThreadRequests() { return { activePendingApproval, + activePendingApprovalCount: activePendingApprovals.length, activePendingUserInput, activePendingUserInputDrafts, activePendingUserInputAnswers,