GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — opencode-mobile/runtime/shell/app-shell.tsx at main · drpr/opencode-mobile

Expand file tree

/

app-shell.tsx

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
240 lines (214 loc) · 9.83 KB
/

app-shell.tsx

Copy path

File metadata and controls

240 lines (214 loc) · 9.83 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
import { cn } from '@/shared/ui/cn';
import Constants from 'expo-constants';
import { DarkTheme, DefaultTheme, LocaleProvider, Stack, ThemeProvider, usePathname, useRootNavigationState, useRouter } from 'expo-router';
import * as SplashScreen from 'expo-splash-screen';
import { StatusBar } from 'expo-status-bar';
import * as SystemUI from 'expo-system-ui';
import { useEffect, useLayoutEffect, useMemo, useRef } from 'react';
import { ActivityIndicator, Platform, View } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { useTranslation } from 'react-i18next';
import { PortalHost } from '@/shared/ui/portal';
import '@/global.css';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { DEFAULT_ACCENT_COLOR } from '@/shared/ui/theme/appearance';
import { getColors } from '@/shared/ui/theme/theme';
import { usePalette } from '@/shared/ui/theme/use-palette';
import { useNotificationRoute } from '@/features/notifications/index';
import { useQuickActionRoute } from '@/features/sessions/index';
import { useSystemColorScheme } from '@/shared/ui/theme/use-system-color-scheme';
import { ingestRecordedJsError, installGlobalErrorHandler } from '@/shared/platform/error-reporting';
import { setSystemPath } from '@/shared/platform/system-path';
import { initializeObservability, observability, preferencesFromChatPreferences } from '@/shared/observability';
import { installObservabilityLifecycle } from '@/shared/observability/lifecycle';
import '@/shared/i18n/index';
import { getLanguageDirection } from '@/shared/i18n/languages';
import { isConnectEnabled } from '@/shared/contracts/cloud-link';
import { MISSION_PATH } from '@/shared/contracts/mission-control';
import { AppearanceProvider } from '@/shared/ui/theme/appearance-context';
import { useOnboarding } from '@/features/onboarding/context';
import { usePreferences } from '@/shared/preferences/context';
import { useUpdates } from '@/features/updates/context';
import { UpdateNotice } from '@/features/updates/index';
import { OpencodeProvider } from '@/runtime/composition/opencode-provider';
export const unstable_settings = {
anchor: '(tabs)',
};
export { ErrorBoundary } from 'expo-router';
// Keep the native splash up until AsyncStorage/SecureStore hydration and the
// onboarding decision are known, so neither the assistant nor the app flashes.
void SplashScreen.preventAutoHideAsync().catch(() => undefined);
export default function RootLayout() {
const isE2EMode = Boolean(Constants.expoConfig?.extra?.e2eMode);
const { i18n } = useTranslation();
const language = i18n.resolvedLanguage || i18n.language || 'en';
const direction = getLanguageDirection(language);
useEffect(() => {
if (Platform.OS !== 'web' || !globalThis.document?.documentElement) return;
globalThis.document.documentElement.lang = language;
globalThis.document.documentElement.dir = direction;
}, [direction, language]);
useEffect(() => {
observability.markStartup('root-render');
void initializeObservability()
.then(() => {
installObservabilityLifecycle(observability);
return ingestRecordedJsError();
})
.catch(() => undefined);
}, []);
useEffect(() => {
if (Platform.OS === 'web' || isE2EMode) {
return;
}
installGlobalErrorHandler();
void import('@/features/notifications/services/notifications')
.then(({ initializeNotifications }) => initializeNotifications())
.catch(() => undefined);
void import('@/shared/platform/voice/tts/player')
.then(({ cleanupLocalTtsAudioCache }) => cleanupLocalTtsAudioCache())
.catch(() => undefined);
}, [isE2EMode]);
return (
<GestureHandlerRootView className={cn(stylesClasses.root)}>
{/* Android renders an empty app tree when direction is applied to this gesture root. */}
<View style={{ flex: 1, direction }}>
<LocaleProvider direction={direction}>
<SafeAreaProvider>
<OpencodeProvider>
<AppearanceHost />
</OpencodeProvider>
</SafeAreaProvider>
</LocaleProvider>
</View>
</GestureHandlerRootView>
);
}
// Preferences live in the provider, so the themed shell must sit inside it.
// AppearanceProvider publishes the effective scheme/accent to useColorScheme
// and usePalette for every screen and component below.
function AppearanceHost() {
const { chatPreferences } = usePreferences();
const { isHydrated } = useOnboarding();
const systemScheme = useSystemColorScheme();
const scheme = chatPreferences.themeMode === 'light' || chatPreferences.themeMode === 'dark'
? chatPreferences.themeMode
: systemScheme;
const accent = chatPreferences.accentColor ?? DEFAULT_ACCENT_COLOR;
const palette = useMemo(() => getColors(scheme, accent), [accent, scheme]);
const navigationTheme = useMemo(() => {
const base = scheme === 'dark' ? DarkTheme : DefaultTheme;
return { ...base, colors: { ...base.colors, background: palette.background, card: palette.surface, text: palette.text, border: palette.border, primary: palette.tint, notification: palette.danger } };
}, [palette, scheme]);
const appearance = useMemo(() => ({ scheme, accent, palette }), [accent, palette, scheme]);
// Observability preferences live with the existing global preferences. Wait
// for hydration so a user who disabled local recording is never briefly
// recorded under the defaults.
useEffect(() => {
if (!isHydrated) return;
observability.configure(preferencesFromChatPreferences(chatPreferences));
}, [
isHydrated,
chatPreferences,
chatPreferences.diagnosticsEnabled,
chatPreferences.diagnosticsLevel,
chatPreferences.remoteTelemetryEnabled,
chatPreferences.remoteCrashReports,
chatPreferences.remotePerformance,
]);
// Keep window-level chrome (web overscroll, native root view) on the themed
// surface so navigation and safe-area edges never flash the OS color.
useEffect(() => {
if (Platform.OS === 'web') {
if (globalThis.document?.documentElement) globalThis.document.documentElement.style.backgroundColor = palette.background;
if (globalThis.document?.body) globalThis.document.body.style.backgroundColor = palette.background;
return;
}
void SystemUI.setBackgroundColorAsync(palette.background).catch(() => undefined);
}, [palette.background]);
return (
<AppearanceProvider value={appearance}>
<ThemeProvider value={navigationTheme}>
<RootNavigator />
<UpdateHost />
<SystemPathHost />
<StatusBar style={scheme === 'dark' ? 'light' : 'dark'} />
<PortalHost />
</ThemeProvider>
</AppearanceProvider>
);
}
// Records the visible route so the OpenID Connect browser callback returns to
// the screen that started sign-in instead of an unmatched deep link.
function SystemPathHost() {
const pathname = usePathname();
useEffect(() => { setSystemPath(pathname); }, [pathname]);
return null;
}
function UpdateHost() {
const pathname = usePathname();
const updates = useUpdates();
const { setSurfaceActive } = updates;
const eligible = ['/', '/projects', '/settings', '/terminal', MISSION_PATH].includes(pathname);
useLayoutEffect(() => {
setSurfaceActive(eligible);
return () => setSurfaceActive(false);
}, [eligible, setSurfaceActive]);
return <UpdateNotice {...updates} onUpdate={() => { void updates.update(); }} onLater={updates.later} onDismissError={updates.clearError} />;
}
// The onboarding decision depends on persisted state, so routing waits for
// hydration. `Stack.Protected` swaps the assistant in and out without mounting
// the tab navigator behind it, which prevents any onboarding/app flash.
function RootNavigator() {
const palette = usePalette();
const { isHydrated, onboardingCompleted, onboardingActive } = useOnboarding();
const { chatPreferences: { openingScreen } } = usePreferences();
const pathname = usePathname();
const router = useRouter();
const rootKey = useRootNavigationState()?.key;
const startup = useRef<'pending' | 'routing' | 'ready'>('pending');
useNotificationRoute();
useQuickActionRoute(isHydrated);
useEffect(() => {
if (!isHydrated || !rootKey || startup.current === 'ready') return;
if (startup.current === 'pending' && onboardingCompleted && !onboardingActive && pathname === '/' && openingScreen === 'mission') {
startup.current = 'routing';
router.replace(MISSION_PATH);
return;
}
if (startup.current === 'routing' && pathname === '/') return;
startup.current = 'ready';
observability.markStartup('workspace-ready');
void SplashScreen.hideAsync()
.then(() => observability.markStartup('interactive'))
.catch(() => undefined);
}, [isHydrated, onboardingCompleted, onboardingActive, openingScreen, pathname, rootKey, router]);
if (!isHydrated) {
return (
<View className={cn(stylesClasses.hydration, "bg-background")}>
<ActivityIndicator size="large" color={palette.tint} />
</View>
);
}
const onboardingVisible = !onboardingCompleted || onboardingActive;
return (
<Stack>
<Stack.Protected guard={onboardingCompleted} redirectTo="/onboarding">
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<Stack.Screen name="session/[id]" options={{ headerShown: false }} />
</Stack.Protected>
<Stack.Protected guard={onboardingVisible}>
<Stack.Screen name="onboarding" options={{ headerShown: false }} />
</Stack.Protected>
<Stack.Protected guard={isConnectEnabled()}>
<Stack.Screen name="pair" options={{ headerShown: false }} />
<Stack.Screen name="service" options={{ headerShown: false }} />
</Stack.Protected>
<Stack.Screen name="share" options={{ headerShown: false }} />
</Stack>
);
}
const stylesClasses = {
"root": "flex-1",
"hydration": "items-center flex-1 justify-center"
} as const;
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.