import { hydrateBrowseMemory, useBrowseMemory, browseKey, browsePreference, browseScope, saveHostMode } from './src/services/browse-memory' import { startBrowseTracking } from './src/services/browse-tracking' import { useEffect, useRef, useState } from 'react' import { AppState, BackHandler, Linking, StyleSheet, Text, View } from 'react-native' import NetInfo from '@react-native-community/netinfo' import { useLocales } from 'expo-localization' import * as SplashScreen from 'expo-splash-screen' import { StatusBar } from 'expo-status-bar' import { SafeAreaProvider, SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context' import { ChatScreen } from './src/screens/chat-screen' import { ConnectionScreen, DeviceDetailScreen } from './src/screens/device-screens' import { HostSwitcherSheet } from './src/screens/host-switcher-sheet' import { RemoteHostsScreen } from './src/screens/remote-hosts-screen' import { AboutScreen, DiagnosticsScreen, HomeActionsMenu, ServerSetupScreen, SettingsScreen, useStartupUpdateCheck } from './src/screens/setup-screens' import { stopConnectionRecovery, useAppStore } from './src/state/store' import { ForegroundConnectionRecovery } from './src/services/connection-recovery' import { resolveStartupAutoConnect } from './src/lib/auto-connect' import { networkRouteForNativeType, shouldReconnectForNetworkRoute, type NetworkRoute, } from './src/lib/network-route' import { Button, ErrorBanner } from './src/ui/components' import { spacing, type } from './src/ui/theme' import { ThemeProvider, useTheme, type ThemeColors } from './src/ui/theme-context' import { MermaidRendererHost } from './src/ui/mermaid/mermaid-renderer' import { useThemedStyles } from './src/ui/use-themed-styles' import { strings as zhCN } from './src/locales/i18n' import { sessionBackendFromId } from './src/lib/session-backend' // Keep the native first frame visible until boot completes. The native splash // is the only startup view; the app then enters the login or chat route. void SplashScreen.preventAutoHideAsync().catch(() => undefined) type Route = | { name: 'server' } | { name: 'remote-hosts' } | { name: 'device'; deviceId: string } | { name: 'connecting'; deviceId: string; sheet?: boolean; focusWorkspaceKey?: string; sessionId?: string } | { name: 'chat'; botConversationId?: string; externalOpenRevision?: number } | { name: 'settings' } | { name: 'diagnostics' } | { name: 'about' } export default function App() { const locales = useLocales() const syncSystemLocales = useAppStore(state => state.syncSystemLocales) const localeTags = locales.map(locale => locale.languageTag) const localeKey = localeTags.join('|') useEffect(() => { syncSystemLocales(localeTags) }, [localeKey, syncSystemLocales]) return ( ) } function AppShell() { const { colors } = useTheme() const styles = useThemedStyles(createStyles) return ( <> ) } function ThemedStatusBar() { const { scheme } = useTheme() const statusBarVisible = useAppStore(state => state.statusBarVisible) return