Open History to see the last commit
1import { PermissionUpdateNotice } from "./components/PermissionUpdateNotice";
2import * as Linking from "expo-linking";
3import * as SplashScreen from "expo-splash-screen";
4import { useEffect } from "react";
5import { StatusBar } from "react-native";
6import { GestureHandlerRootView } from "react-native-gesture-handler";
7import { KeyboardProvider } from "react-native-keyboard-controller";
8import { SafeAreaProvider } from "react-native-safe-area-context";
9import { createStaticNavigation } from "@react-navigation/native";
10
11import { RegistryContext } from "@effect/atom-react";
12import { ThreadArrangementHost } from "./features/threads/ThreadArrangementSheet";
13import { ConfirmDialogHost } from "./components/ConfirmDialogHost";
14import { CloudAuthProvider } from "./features/cloud/CloudAuthProvider";
15import { prepareNativeShowcaseCapture } from "./features/showcase/nativeShowcaseScene";
16import { IncomingShareProvider } from "./features/sharing/IncomingShareProvider";
17import {
18 AppearancePreferencesProvider,
19 useAppearancePreferences,
20} from "./features/settings/appearance/AppearancePreferencesProvider";
21import { RootStack } from "./Stack";
22import { appAtomRegistry } from "./state/atom-registry";
23import { OverlayPortalHost } from "./components/OverlayPortal";
24import { shouldHandleAppLink } from "./lib/appLinking";
25import { useMobileNavigationTheme } from "./lib/useMobileNavigationTheme";
26import { SubscriptionUsageCoordinator } from "./widgets/SubscriptionUsageCoordinator";
27import { VoiceInputProvider } from "./features/voice-input/VoiceInputProvider";
28import { GlobalVoiceInputControl } from "./features/voice-input/GlobalVoiceInputControl";
29
30import "../global.css";
31
32if (process.env.EXPO_PUBLIC_SHOWCASE === "1") {
33 prepareNativeShowcaseCapture();
34}
35
36void SplashScreen.preventAutoHideAsync().catch(() => {
37 // The native module can be unavailable in non-native test environments.
38});
39
40const appLinking = {
41 prefixes: [Linking.createURL("/"), "t3code://", "t3code-dev://", "t3code-preview://"],
42 // Keep the compact thread list available beneath a directly opened thread.
43 config: { initialRouteName: "Home" },
44 filter: shouldHandleAppLink,
45};
46
47const Navigation = createStaticNavigation(RootStack);
48
49function SplashScreenCoordinator() {
50 const { isReady } = useAppearancePreferences();
51
52 useEffect(() => {
53 if (isReady) void SplashScreen.hide();
54 }, [isReady]);
55
56 return null;
57}
58
59export default function App() {
60 return (
61 <RegistryContext.Provider value={appAtomRegistry}>
62 <CloudAuthProvider>
63 <AppearancePreferencesProvider>
64 <AppContent />
65 </AppearancePreferencesProvider>
66 </CloudAuthProvider>
67 </RegistryContext.Provider>
68 );
69}
70
71function AppContent() {
72 const { themeAppearance } = useAppearancePreferences();
73 const navigationTheme = useMobileNavigationTheme();
74
75 return (
76 <>
77 <SplashScreenCoordinator />
78 <SubscriptionUsageCoordinator />
79 <PermissionUpdateNotice />
80 <GestureHandlerRootView className="flex-1">
81 <KeyboardProvider statusBarTranslucent>
82 <SafeAreaProvider>
83 <VoiceInputProvider>
84 <StatusBar barStyle={themeAppearance === "dark" ? "light-content" : "dark-content"} />
85 {/* The navigation theme drives the NATIVE header appearance: native-stack
86 forwards `dark` as the nav bar's overrideUserInterfaceStyle. Without
87 this, React Navigation defaults to its light theme and every native
88 header (glass buttons, title, materials) is forced light even when
89 the system is in dark mode. */}
90 <GlobalVoiceInputControl>
91 <IncomingShareProvider>
92 <Navigation linking={appLinking} theme={navigationTheme} />
93 </IncomingShareProvider>
94 <ConfirmDialogHost />
95 <ThreadArrangementHost />
96 </GlobalVoiceInputControl>
97 {/* Anchored-menu overlays render here — in-window, so the
98 keyboard stays up while a dropdown is open. */}
99 <OverlayPortalHost />
100 </VoiceInputProvider>
101 </SafeAreaProvider>
102 </KeyboardProvider>
103 </GestureHandlerRootView>
104 </>
105 );
106}