@@ -20,8 +20,10 @@ pub enum BackendEvent {
2020 LoadSession {
2121 session_id : String ,
2222 } ,
23+
2324 CreateNewSession {
2425 name : Option < String > ,
26+ initial_project : Option < String > ,
2527 } ,
2628 DeleteSession {
2729 session_id : String ,
@@ -161,9 +163,10 @@ pub async fn handle_backend_events(
161163 let response = match event {
162164 BackendEvent :: ListSessions => Some ( handle_list_sessions ( & multi_session_manager) . await ) ,
163165
164- BackendEvent :: CreateNewSession { name } => {
165- Some ( handle_create_session ( & multi_session_manager, name) . await )
166- }
166+ BackendEvent :: CreateNewSession {
167+ name,
168+ initial_project,
169+ } => Some ( handle_create_session ( & multi_session_manager, name, initial_project) . await ) ,
167170
168171 BackendEvent :: LoadSession { session_id } => {
169172 handle_load_session ( & multi_session_manager, & session_id, & ui) . await
@@ -275,10 +278,18 @@ async fn handle_list_sessions(
275278async fn handle_create_session (
276279 multi_session_manager : & Arc < Mutex < SessionManager > > ,
277280 name : Option < String > ,
281+ initial_project : Option < String > ,
278282) -> BackendResponse {
279283 let create_result = {
280284 let mut manager = multi_session_manager. lock ( ) . await ;
281- manager. create_session ( name. clone ( ) )
285+ if let Some ( project) = initial_project {
286+ // Create a session config override with the specified project
287+ let mut config = manager. session_config_template ( ) . clone ( ) ;
288+ config. initial_project = project;
289+ manager. create_session_with_config ( name. clone ( ) , Some ( config) , None )
290+ } else {
291+ manager. create_session ( name. clone ( ) )
292+ }
282293 } ;
283294
284295 match create_result {
0 commit comments