@@ -43,7 +43,7 @@ impl LayoutConfig {
4343 }
4444
4545 /// Apply layout to tmux
46- pub fn apply_to_tmux ( & self ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
46+ pub fn apply_to_tmux ( & self , delay : u64 ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
4747 // Check if directory exists
4848 let target_dir = Path :: new ( & self . workspace . directory ) ;
4949 if !target_dir. exists ( ) {
@@ -69,7 +69,7 @@ impl LayoutConfig {
6969 self . adjust_pane_sizes ( ) ?;
7070
7171 // Execute commands in each pane
72- self . execute_commands ( ) ?;
72+ self . execute_commands ( delay ) ?;
7373
7474 // Set focus
7575 self . set_focus ( ) ?;
@@ -118,8 +118,8 @@ impl LayoutConfig {
118118
119119 /// Adjust pane sizes after layout is applied
120120 fn adjust_pane_sizes ( & self ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
121- // Wait a moment for layout to settle
122- std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 100 ) ) ;
121+ // Wait for layout to settle
122+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 500 ) ) ;
123123
124124 // First pass: adjust individual pane sizes
125125 for ( index, pane) in self . panes . iter ( ) . enumerate ( ) {
@@ -208,13 +208,23 @@ impl LayoutConfig {
208208 }
209209
210210 /// Execute commands in each pane
211- fn execute_commands ( & self ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
211+ fn execute_commands ( & self , delay : u64 ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
212+ // Wait for all panes to settle after creation and resizing
213+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( delay) ) ;
214+
212215 for ( index, pane) in self . panes . iter ( ) . enumerate ( ) {
216+ if pane. commands . is_empty ( ) {
217+ continue ;
218+ }
219+
213220 // Select pane
214221 Command :: new ( "tmux" )
215222 . args ( [ "select-pane" , "-t" , & index. to_string ( ) ] )
216223 . status ( ) ?;
217224
225+ // Delay between pane selection and command execution
226+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 300 ) ) ;
227+
218228 // Execute commands
219229 for command in & pane. commands {
220230 Command :: new ( "tmux" )
0 commit comments