@@ -8,12 +8,15 @@ import { ConfigContext, useConfig, saveConfig } from './src/store/config';
88import { SessionContext , useSessions } from './src/store/sessions' ;
99import { MessageQueueContext , useMessageQueue } from './src/store/message-queue' ;
1010import { ConnectionManagerContext , useConnectionManagerProvider } from './src/store/connectionManager' ;
11+ import { TunnelConnectionContext , useTunnelConnectionProvider } from './src/store/tunnelConnection' ;
1112import { View , Image , Text , StyleSheet } from 'react-native' ;
1213import { SafeAreaProvider } from 'react-native-safe-area-context' ;
1314import { ThemeProvider , useTheme } from './src/ui/ThemeProvider' ;
15+ import { ConnectionStatusIndicator } from './src/ui/ConnectionStatusIndicator' ;
1416import * as Linking from 'expo-linking' ;
1517import { useEffect , useMemo } from 'react' ;
1618
19+
1720const speakMCPIcon = require ( './assets/speakmcp-icon.png' ) ;
1821const darkSpinner = require ( './assets/loading-spinner.gif' ) ;
1922const lightSpinner = require ( './assets/light-spinner.gif' ) ;
@@ -47,6 +50,9 @@ function Navigation() {
4750 const sessionStore = useSessions ( ) ;
4851 const messageQueueStore = useMessageQueue ( ) ;
4952
53+ // Initialize tunnel connection manager for persistence and auto-reconnection
54+ const tunnelConnection = useTunnelConnectionProvider ( ) ;
55+
5056 // Create connection manager config from app config
5157 const clientConfig = useMemo ( ( ) => ( {
5258 baseUrl : cfg . config . baseUrl ,
@@ -125,36 +131,45 @@ function Navigation() {
125131 < SessionContext . Provider value = { sessionStore } >
126132 < MessageQueueContext . Provider value = { messageQueueStore } >
127133 < ConnectionManagerContext . Provider value = { connectionManager } >
128- < NavigationContainer theme = { navTheme } >
129- < Stack . Navigator
130- initialRouteName = "Settings"
131- screenOptions = { {
132- headerTitleStyle : { ...theme . typography . h2 } ,
133- headerStyle : { backgroundColor : theme . colors . card } ,
134- headerTintColor : theme . colors . foreground ,
135- contentStyle : { backgroundColor : theme . colors . background } ,
136- headerLeft : ( ) => (
137- < Image
138- source = { speakMCPIcon }
139- style = { { width : 28 , height : 28 , marginLeft : 12 , marginRight : 8 } }
140- resizeMode = "contain"
141- />
142- ) ,
143- } }
144- >
145- < Stack . Screen
146- name = "Settings"
147- component = { SettingsScreen }
148- options = { { title : 'SpeakMCP' } }
149- />
150- < Stack . Screen
151- name = "Sessions"
152- component = { SessionListScreen }
153- options = { { title : 'Chats' } }
154- />
155- < Stack . Screen name = "Chat" component = { ChatScreen } />
156- </ Stack . Navigator >
157- </ NavigationContainer >
134+ < TunnelConnectionContext . Provider value = { tunnelConnection } >
135+ < NavigationContainer theme = { navTheme } >
136+ < Stack . Navigator
137+ initialRouteName = "Settings"
138+ screenOptions = { {
139+ headerTitleStyle : { ...theme . typography . h2 } ,
140+ headerStyle : { backgroundColor : theme . colors . card } ,
141+ headerTintColor : theme . colors . foreground ,
142+ contentStyle : { backgroundColor : theme . colors . background } ,
143+ headerLeft : ( ) => (
144+ < Image
145+ source = { speakMCPIcon }
146+ style = { { width : 28 , height : 28 , marginLeft : 12 , marginRight : 8 } }
147+ resizeMode = "contain"
148+ />
149+ ) ,
150+ headerRight : ( ) => (
151+ < ConnectionStatusIndicator
152+ state = { tunnelConnection . connectionInfo . state }
153+ retryCount = { tunnelConnection . connectionInfo . retryCount }
154+ compact
155+ />
156+ ) ,
157+ } }
158+ >
159+ < Stack . Screen
160+ name = "Settings"
161+ component = { SettingsScreen }
162+ options = { { title : 'SpeakMCP' } }
163+ />
164+ < Stack . Screen
165+ name = "Sessions"
166+ component = { SessionListScreen }
167+ options = { { title : 'Chats' } }
168+ />
169+ < Stack . Screen name = "Chat" component = { ChatScreen } />
170+ </ Stack . Navigator >
171+ </ NavigationContainer >
172+ </ TunnelConnectionContext . Provider >
158173 </ ConnectionManagerContext . Provider >
159174 </ MessageQueueContext . Provider >
160175 </ SessionContext . Provider >
0 commit comments