@@ -123,6 +123,7 @@ def load_plugins(
123123 module_name = "." .join (module_name [:- 1 ])
124124 plugin_name = plugin .split ("." )[- 1 ]
125125 except AttributeError as error :
126+ logger .exception ("plugin load failed" )
126127 tmuxp_echo (
127128 colors .error ("[Plugin Error]" )
128129 + f" Couldn't load { plugin } \n "
@@ -139,12 +140,16 @@ def load_plugins(
139140 default = True ,
140141 color_mode = colors .mode ,
141142 ):
143+ logger .warning (
144+ "plugin version constraint not met, user declined skip" ,
145+ )
142146 tmuxp_echo (
143147 colors .warning ("[Not Skipping]" )
144148 + " Plugin versions constraint not met. Exiting..." ,
145149 )
146150 sys .exit (1 )
147151 except (ImportError , AttributeError ) as error :
152+ logger .exception ("plugin import failed" )
148153 tmuxp_echo (
149154 colors .error ("[Plugin Error]" )
150155 + f" Couldn't load { plugin } \n "
@@ -178,7 +183,8 @@ def _reattach(builder: WorkspaceBuilder, colors: Colors | None = None) -> None:
178183 plugin .reattach (builder .session )
179184 proc = builder .session .cmd ("display-message" , "-p" , "'#S'" )
180185 for line in proc .stdout :
181- print (colors .info (line ) if colors else line ) # NOQA: T201 RUF100
186+ tmuxp_echo (colors .info (line ) if colors else line )
187+ logger .debug ("reattach display-message output: %s" , line .strip ())
182188
183189 if "TMUX" in os .environ :
184190 builder .session .switch_client ()
@@ -225,7 +231,8 @@ def _load_detached(builder: WorkspaceBuilder, colors: Colors | None = None) -> N
225231 assert builder .session is not None
226232
227233 msg = "Session created in detached state."
228- print (colors .info (msg ) if colors else msg ) # NOQA: T201 RUF100
234+ tmuxp_echo (colors .info (msg ) if colors else msg )
235+ logger .info ("session created in detached state" )
229236
230237
231238def _load_append_windows_to_current_session (builder : WorkspaceBuilder ) -> None :
@@ -347,10 +354,9 @@ def load_workspace(
347354 if isinstance (workspace_file , (str , os .PathLike )):
348355 workspace_file = pathlib .Path (workspace_file )
349356
350- tmuxp_echo (
351- cli_colors .info ("[Loading]" )
352- + " "
353- + cli_colors .highlight (str (PrivatePath (workspace_file ))),
357+ logger .info (
358+ "loading workspace" ,
359+ extra = {"tmux_config_path" : str (workspace_file )},
354360 )
355361
356362 # ConfigReader allows us to open a yaml or json file as a dict
@@ -378,13 +384,18 @@ def load_workspace(
378384
379385 shutil .which ("tmux" ) # raise exception if tmux not found
380386
381- try : # load WorkspaceBuilder object for tmuxp workspace / tmux server
387+ # WorkspaceBuilder creation — outside spinner so plugin prompts are safe
388+ try :
382389 builder = WorkspaceBuilder (
383390 session_config = expanded_workspace ,
384391 plugins = load_plugins (expanded_workspace , colors = cli_colors ),
385392 server = t ,
386393 )
387394 except exc .EmptyWorkspaceException :
395+ logger .warning (
396+ "workspace file is empty" ,
397+ extra = {"tmux_config_path" : str (workspace_file )},
398+ )
388399 tmuxp_echo (
389400 cli_colors .warning ("[Warning]" )
390401 + f" { PrivatePath (workspace_file )} is empty or parsed no workspace data" ,
@@ -393,7 +404,7 @@ def load_workspace(
393404
394405 session_name = expanded_workspace ["session_name" ]
395406
396- # if the session already exists, prompt the user to attach
407+ # Session-exists check — outside spinner so prompt_yes_no is safe
397408 if builder .session_exists (session_name ) and not append :
398409 if not detached and (
399410 answer_yes
@@ -442,9 +453,7 @@ def load_workspace(
442453 _load_attached (builder , detached )
443454
444455 except exc .TmuxpException as e :
445- import traceback
446-
447- tmuxp_echo (traceback .format_exc ())
456+ logger .exception ("workspace build failed" )
448457 tmuxp_echo (cli_colors .error ("[Error]" ) + f" { e } " )
449458
450459 choice = prompt_choices (
@@ -459,6 +468,7 @@ def load_workspace(
459468 if builder .session is not None :
460469 builder .session .kill ()
461470 tmuxp_echo (cli_colors .muted ("Session killed." ))
471+ logger .info ("session killed by user after build error" )
462472 elif choice == "a" :
463473 _reattach (builder , cli_colors )
464474 else :
0 commit comments