From 403f0a07be19d51dc66f19b33c3c2972f59f907a Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Wed, 16 Jul 2025 11:43:18 +0200 Subject: [PATCH] fix(sessions): remove popups from welcome screen (#4294) * remove popups from welcome screen * docs(changelog): add pr --- CHANGELOG.md | 1 + src/commands.rs | 7 +++ zellij-client/src/lib.rs | 3 ++ .../src/web_client/server_listener.rs | 17 +++---- .../src/web_client/session_management.rs | 47 ++++++++++++------- zellij-client/src/web_client/types.rs | 3 ++ .../src/web_client/unit/web_client_tests.rs | 1 + zellij-server/src/lib.rs | 31 ++++++++++-- zellij-server/src/route.rs | 2 + zellij-utils/src/ipc.rs | 1 + 10 files changed, 84 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2abd6bd3..443ff569 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) * fix: don't serialize when only ui elements present and provide post command disovery hook (https://github.com/zellij-org/zellij/pull/4276) * fix: use plugin `/host` folder as cwd when opening new panes (https://github.com/zellij-org/zellij/pull/4290) * fix: better command detection when serializing layouts for resurrection (https://github.com/zellij-org/zellij/pull/4287) +* fix: don't show popups in the welcome screen (https://github.com/zellij-org/zellij/pull/4294) ## [0.42.2] - 2025-04-15 * refactor(terminal): track scroll_region as tuple rather than Option (https://github.com/zellij-org/zellij/pull/4082) diff --git a/src/commands.rs b/src/commands.rs index 65134f08..952102c8 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -576,6 +576,8 @@ pub(crate) fn start_client(opts: CliArgs) { process::exit(1); }, }; + let layout_is_welcome_screen = opts.layout == Some(PathBuf::from("welcome")) + || config.options.default_layout == Some(PathBuf::from("welcome")); let mut reconnect_to_session: Option = None; let os_input = get_os_input(get_client_os_input); @@ -750,6 +752,7 @@ pub(crate) fn start_client(opts: CliArgs) { pane_id_to_focus, is_a_reconnect, should_create_detached, + layout_is_welcome_screen, ); } else { if let Some(session_name) = opts.session.clone() { @@ -765,6 +768,7 @@ pub(crate) fn start_client(opts: CliArgs) { None, is_a_reconnect, should_create_detached, + layout_is_welcome_screen, ); } else { if let Some(session_name) = config_options.session_name.as_ref() { @@ -806,6 +810,7 @@ pub(crate) fn start_client(opts: CliArgs) { None, is_a_reconnect, should_create_detached, + layout_is_welcome_screen, ); }, _ => { @@ -821,6 +826,7 @@ pub(crate) fn start_client(opts: CliArgs) { None, is_a_reconnect, should_create_detached, + layout_is_welcome_screen, ); }, } @@ -845,6 +851,7 @@ pub(crate) fn start_client(opts: CliArgs) { None, is_a_reconnect, should_create_detached, + layout_is_welcome_screen, ); } } diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs index 4efd3ada..8bafcc74 100644 --- a/zellij-client/src/lib.rs +++ b/zellij-client/src/lib.rs @@ -217,6 +217,7 @@ pub fn start_client( pane_id_to_focus: Option<(u32, bool)>, // (pane_id, is_plugin) is_a_reconnect: bool, start_detached_and_exit: bool, + layout_is_welcome_screen: bool, ) -> Option { if start_detached_and_exit { start_server_detached(os_input, opts, config, config_options, info, layout); @@ -339,6 +340,7 @@ pub fn start_client( Box::new(config.plugins.clone()), is_web_client, should_launch_setup_wizard, + layout_is_welcome_screen, ), ipc_pipe, ) @@ -741,6 +743,7 @@ pub fn start_server_detached( Box::new(config.plugins.clone()), is_web_client, should_launch_setup_wizard, + false, ), ipc_pipe, ) diff --git a/zellij-client/src/web_client/server_listener.rs b/zellij-client/src/web_client/server_listener.rs index 8e73c0ff..458e314b 100644 --- a/zellij-client/src/web_client/server_listener.rs +++ b/zellij-client/src/web_client/server_listener.rs @@ -33,14 +33,14 @@ pub fn zellij_server_listener( move || { let mut client_connection_bus = ClientConnectionBus::new(&web_client_id, &connection_table); - let mut reconnect_to_session = match build_initial_connection(session_name, &config) - { - Ok(initial_session_connection) => initial_session_connection, - Err(e) => { - log::error!("{}", e); - return; - }, - }; + let (mut reconnect_to_session, is_welcome_screen) = + match build_initial_connection(session_name, &config) { + Ok(initial_session_connection) => initial_session_connection, + Err(e) => { + log::error!("{}", e); + return; + }, + }; 'reconnect_loop: loop { let reconnect_info = reconnect_to_session.take(); let path = { @@ -91,6 +91,7 @@ pub fn zellij_server_listener( is_web_client, os_input.clone(), reconnect_info.as_ref().and_then(|r| r.layout.clone()), + is_welcome_screen, ); os_input.connect_to_server(&zellij_ipc_pipe); diff --git a/zellij-client/src/web_client/session_management.rs b/zellij-client/src/web_client/session_management.rs index 718d3f7d..c46224fd 100644 --- a/zellij-client/src/web_client/session_management.rs +++ b/zellij-client/src/web_client/session_management.rs @@ -19,7 +19,8 @@ use zellij_utils::{ pub fn build_initial_connection( session_name: Option, config: &Config, -) -> Result, &'static str> { +) -> Result<(Option, bool), &'static str> { + // bool -> is_welcome_screen let should_start_with_welcome_screen = session_name.is_none(); let default_layout_from_config = LayoutInfo::from_config(&config.options.layout_dir, &config.options.default_layout); @@ -28,24 +29,33 @@ pub fn build_initial_connection( else { return Err("Failed to generate unique session name, bailing."); }; - Ok(Some(ConnectToSession { - name: Some(initial_session_name.clone()), - layout: Some(LayoutInfo::BuiltIn("welcome".to_owned())), - ..Default::default() - })) + Ok(( + Some(ConnectToSession { + name: Some(initial_session_name.clone()), + layout: Some(LayoutInfo::BuiltIn("welcome".to_owned())), + ..Default::default() + }), + should_start_with_welcome_screen, + )) } else if let Some(session_name) = session_name { - Ok(Some(ConnectToSession { - name: Some(session_name.clone()), - layout: default_layout_from_config, - ..Default::default() - })) + Ok(( + Some(ConnectToSession { + name: Some(session_name.clone()), + layout: default_layout_from_config, + ..Default::default() + }), + should_start_with_welcome_screen, + )) } else if default_layout_from_config.is_some() { - Ok(Some(ConnectToSession { - layout: default_layout_from_config, - ..Default::default() - })) + Ok(( + Some(ConnectToSession { + layout: default_layout_from_config, + ..Default::default() + }), + should_start_with_welcome_screen, + )) } else { - Ok(None) + Ok((None, should_start_with_welcome_screen)) } } @@ -90,6 +100,7 @@ pub fn spawn_session_if_needed( is_web_client: bool, os_input: Box, requested_layout: Option, + is_welcome_screen: bool, ) -> (ClientToServerMsg, PathBuf) { if session_exists(&session_name).unwrap_or(false) { ipc_pipe_and_first_message_for_existing_session( @@ -117,6 +128,7 @@ pub fn spawn_session_if_needed( config_options.clone(), Some(resurrection_layout), client_attributes, + is_welcome_screen, ), None => { let new_session_layout = layout_for_new_session(&config, requested_layout); @@ -128,6 +140,7 @@ pub fn spawn_session_if_needed( config_options.clone(), new_session_layout.ok().map(|(l, _c)| l), client_attributes, + is_welcome_screen, ) }, } @@ -141,6 +154,7 @@ fn spawn_new_session( config_opts: Options, layout: Option, client_attributes: ClientAttributes, + is_welcome_screen: bool, ) -> (ClientToServerMsg, PathBuf) { let debug = false; envs::set_session_name(name.to_owned()); @@ -176,6 +190,7 @@ fn spawn_new_session( Box::new(config.plugins.clone()), should_launch_setup_wizard, is_web_client, + is_welcome_screen, ), zellij_ipc_pipe, ) diff --git a/zellij-client/src/web_client/types.rs b/zellij-client/src/web_client/types.rs index 57204231..1a197d0d 100644 --- a/zellij-client/src/web_client/types.rs +++ b/zellij-client/src/web_client/types.rs @@ -44,6 +44,7 @@ pub trait SessionManager: Send + Sync + std::fmt::Debug { is_web_client: bool, os_input: Box, requested_layout: Option, + is_welcome_screen: bool, ) -> (ClientToServerMsg, PathBuf); } @@ -73,6 +74,7 @@ impl SessionManager for RealSessionManager { is_web_client: bool, os_input: Box, requested_layout: Option, + is_welcome_screen: bool, ) -> (ClientToServerMsg, PathBuf) { crate::web_client::session_management::spawn_session_if_needed( session_name, @@ -83,6 +85,7 @@ impl SessionManager for RealSessionManager { is_web_client, os_input, requested_layout, + is_welcome_screen, ) } } diff --git a/zellij-client/src/web_client/unit/web_client_tests.rs b/zellij-client/src/web_client/unit/web_client_tests.rs index b66bb246..c6967886 100644 --- a/zellij-client/src/web_client/unit/web_client_tests.rs +++ b/zellij-client/src/web_client/unit/web_client_tests.rs @@ -1297,6 +1297,7 @@ impl SessionManager for MockSessionManager { is_web_client: bool, _os_input: Box, _requested_layout: Option, + _is_welcome_screen: bool, ) -> (ClientToServerMsg, PathBuf) { let mock_ipc_path = PathBuf::from(format!("/tmp/mock_zellij_{}", session_name)); diff --git a/zellij-server/src/lib.rs b/zellij-server/src/lib.rs index 589670f5..f5004eb8 100644 --- a/zellij-server/src/lib.rs +++ b/zellij-server/src/lib.rs @@ -79,6 +79,7 @@ pub enum ServerInstruction { Box, bool, // should launch setup wizard bool, // is_web_client + bool, // layout_is_welcome_screen ClientId, ), Render(Option>), @@ -668,6 +669,7 @@ pub fn start_server(mut os_input: Box, socket_path: PathBuf) { plugin_aliases, should_launch_setup_wizard, is_web_client, + layout_is_welcome_screen, client_id, ) => { let mut session = init_session( @@ -762,10 +764,16 @@ pub fn start_server(mut os_input: Box, socket_path: PathBuf) { // intrusive let setup_wizard = setup_wizard_floating_pane(); floating_panes.push(setup_wizard); - } else if should_show_release_notes(runtime_config_options.show_release_notes) { + } else if should_show_release_notes( + runtime_config_options.show_release_notes, + layout_is_welcome_screen, + ) { let about = about_floating_pane(); floating_panes.push(about); - } else if should_show_startup_tip(runtime_config_options.show_startup_tips) { + } else if should_show_startup_tip( + runtime_config_options.show_startup_tips, + layout_is_welcome_screen, + ) { let tip = tip_floating_pane(); floating_panes.push(tip); } @@ -1708,7 +1716,13 @@ fn tip_floating_pane() -> FloatingPaneLayout { about_pane } -fn should_show_release_notes(should_show_release_notes_config: Option) -> bool { +fn should_show_release_notes( + should_show_release_notes_config: Option, + layout_is_welcome_screen: bool, +) -> bool { + if layout_is_welcome_screen { + return false; + } if let Some(should_show_release_notes_config) = should_show_release_notes_config { if !should_show_release_notes_config { // if we were explicitly told not to show release notes, we don't show them, @@ -1731,8 +1745,15 @@ fn should_show_release_notes(should_show_release_notes_config: Option) -> } } -fn should_show_startup_tip(should_show_startup_tip_config: Option) -> bool { - should_show_startup_tip_config.unwrap_or(true) +fn should_show_startup_tip( + should_show_startup_tip_config: Option, + layout_is_welcome_screen: bool, +) -> bool { + if layout_is_welcome_screen { + false + } else { + should_show_startup_tip_config.unwrap_or(true) + } } #[cfg(not(feature = "singlepass"))] diff --git a/zellij-server/src/route.rs b/zellij-server/src/route.rs index b21535b0..889907f0 100644 --- a/zellij-server/src/route.rs +++ b/zellij-server/src/route.rs @@ -1109,6 +1109,7 @@ pub(crate) fn route_thread_main( plugin_aliases, should_launch_setup_wizard, is_web_client, + layout_is_welcome_screen, ) => { let new_client_instruction = ServerInstruction::NewClient( client_attributes, @@ -1119,6 +1120,7 @@ pub(crate) fn route_thread_main( plugin_aliases, should_launch_setup_wizard, is_web_client, + layout_is_welcome_screen, client_id, ); to_server diff --git a/zellij-utils/src/ipc.rs b/zellij-utils/src/ipc.rs index 35699182..a9e374f2 100644 --- a/zellij-utils/src/ipc.rs +++ b/zellij-utils/src/ipc.rs @@ -80,6 +80,7 @@ pub enum ClientToServerMsg { Box, bool, // should launch setup wizard bool, // is_web_client + bool, // layout_is_welcome_screen ), AttachClient( ClientAttributes,