11import React from "react" ;
22import { render } from "ink" ;
3- import { runSSHSession , type SSHSessionConfig } from "../utils/sshSession.js" ;
43import { enterAlternateScreen , exitAlternateScreen } from "../utils/screen.js" ;
54
65import { Router } from "../router/Router.js" ;
76import { NavigationProvider } from "../store/navigationStore.js" ;
87import type { ScreenName } from "../store/navigationStore.js" ;
98
10- interface AppProps {
11- onSSHRequest : ( config : SSHSessionConfig ) => void ;
12- initialScreen ?: ScreenName ;
13- focusDevboxId ?: string ;
14- }
15-
16- function AppInner ( {
17- onSSHRequest,
18- } : {
19- onSSHRequest : ( config : SSHSessionConfig ) => void ;
20- } ) {
9+ function AppInner ( ) {
2110 // NavigationProvider already handles initialScreen and initialParams
2211 // No need for useEffect here - provider sets state on mount
23- return < Router onSSHRequest = { onSSHRequest } /> ;
12+ return < Router /> ;
2413}
2514
2615function App ( {
27- onSSHRequest,
2816 initialScreen = "menu" ,
2917 focusDevboxId,
30- } : AppProps ) {
18+ } : {
19+ initialScreen ?: ScreenName ;
20+ focusDevboxId ?: string ;
21+ } ) {
3122 return (
3223 < NavigationProvider
3324 initialScreen = { initialScreen }
3425 initialParams = { focusDevboxId ? { focusDevboxId } : { } }
3526 >
36- < AppInner onSSHRequest = { onSSHRequest } />
27+ < AppInner />
3728 </ NavigationProvider >
3829 ) ;
3930}
@@ -43,60 +34,27 @@ export async function runMainMenu(
4334 focusDevboxId ?: string ,
4435) {
4536 // Enter alternate screen buffer for fullscreen experience (like top/vim)
46- enterAlternateScreen ( ) ;
47-
48- let sshSessionConfig : SSHSessionConfig | null = null ;
49- let shouldContinue = true ;
50- let currentInitialScreen = initialScreen ;
51- let currentFocusDevboxId = focusDevboxId ;
52-
53- while ( shouldContinue ) {
54- sshSessionConfig = null ;
55-
56- try {
57- const { waitUntilExit } = render (
58- < App
59- key = { `app-${ currentInitialScreen } -${ currentFocusDevboxId } ` }
60- onSSHRequest = { ( config ) => {
61- sshSessionConfig = config ;
62- } }
63- initialScreen = { currentInitialScreen }
64- focusDevboxId = { currentFocusDevboxId }
65- /> ,
66- {
67- patchConsole : false ,
68- exitOnCtrlC : false ,
69- } ,
70- ) ;
71- await waitUntilExit ( ) ;
72- shouldContinue = false ;
73- } catch ( error ) {
74- console . error ( "Error in menu:" , error ) ;
75- shouldContinue = false ;
76- }
77-
78- // If SSH was requested, handle it now after Ink has exited
79- if ( sshSessionConfig ) {
80- const result = await runSSHSession ( sshSessionConfig ) ;
81-
82- if ( result . shouldRestart ) {
83- console . log ( `\nSSH session ended. Returning to menu...\n` ) ;
84- await new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) ) ;
85-
86- currentInitialScreen = "devbox-list" ;
87- currentFocusDevboxId = result . returnToDevboxId ;
88- shouldContinue = true ;
89- } else {
90- shouldContinue = false ;
91- }
92- }
37+ //enterAlternateScreen();
38+
39+ try {
40+ const { waitUntilExit } = render (
41+ < App
42+ key = { `app-${ initialScreen } -${ focusDevboxId } ` }
43+ initialScreen = { initialScreen }
44+ focusDevboxId = { focusDevboxId }
45+ /> ,
46+ {
47+ patchConsole : false ,
48+ exitOnCtrlC : false ,
49+ } ,
50+ ) ;
51+ await waitUntilExit ( ) ;
52+ } catch ( error ) {
53+ console . error ( "Error in menu:" , error ) ;
9354 }
9455
95- // Disable synchronous updates
96- // disableSynchronousUpdates();
97-
9856 // Exit alternate screen buffer
99- exitAlternateScreen ( ) ;
57+ // exitAlternateScreen();
10058
10159 process . exit ( 0 ) ;
10260}
0 commit comments