@@ -127,27 +127,29 @@ def _maybe_create_execution_output(
127127 runtime_config_path : Path ,
128128 resolved_output : Path ,
129129 execution_mode : str ,
130+ cache_source_output : Optional [Path ] = None ,
130131 ) -> tuple [Path , Optional [str ], Dict [str , Any ]]:
131132 """Default UI behavior: branch to a new output when signatures changed."""
132133 if execution_mode != "auto_new_on_change" :
133134 return resolved_output , None , {}
135+ source_output = cache_source_output or resolved_output
134136 try :
135137 config = ConfigManager ().load_from_file (runtime_config_path )
136- config .output .directory = str (resolved_output )
137- preview = preview_execution_changes (config , resolved_output )
138+ config .output .directory = str (source_output )
139+ preview = preview_execution_changes (config , source_output )
138140 except Exception :
139141 return resolved_output , None , {}
140142
141143 if not preview .get ("changed_stages" ):
142- return resolved_output , None , preview
144+ return source_output , None , preview
143145
144146 execution_name = (
145147 time .strftime ("%Y%m%d-%H%M%S" )
146148 + "-"
147149 + str (preview .get ("stage_hashes" , {}).get ("output" , "" ))[:8 ]
148150 )
149151 branched_output = resolved_output / "executions" / execution_name
150- return branched_output , str (resolved_output ), preview
152+ return branched_output , str (source_output ), preview
151153
152154 def _build_meta_command (
153155 self ,
@@ -318,11 +320,20 @@ def start_pipeline_run(
318320 cache_preview : Dict [str , Any ] = {}
319321 branched_from : Optional [str ] = None
320322 if not output_folder :
323+ previous_output_raw = str (project .get ("last_output_folder" ) or "" ).strip ()
324+ previous_output = (
325+ Path (previous_output_raw ).expanduser ().resolve ()
326+ if previous_output_raw
327+ else None
328+ )
329+ if previous_output and not previous_output .exists ():
330+ previous_output = None
321331 resolved_output , branched_from , cache_preview = (
322332 self ._maybe_create_execution_output (
323333 runtime_config_path ,
324334 resolved_output ,
325335 execution_mode ,
336+ cache_source_output = previous_output ,
326337 )
327338 )
328339 if branched_from and not copy_valid_cache_from :
@@ -372,6 +383,7 @@ def start_meta_run(
372383 self ,
373384 project : Dict [str , Any ],
374385 output_folder : str ,
386+ source_run_id : Optional [str ],
375387 estimator : str ,
376388 estimator_args : str ,
377389 corrector : str ,
@@ -390,6 +402,8 @@ def start_meta_run(
390402 mode = "meta" ,
391403 output_folder = output_path ,
392404 )
405+ metadata ["source_run_id" ] = source_run_id
406+ metadata ["source_output_folder" ] = output_path
393407
394408 cmd = self ._build_meta_command (
395409 output_folder = output_path ,
@@ -413,7 +427,7 @@ def start_meta_run(
413427 project ["id" ],
414428 {
415429 "run_ids" : run_ids ,
416- "last_output_folder " : output_path ,
430+ "last_meta_output_folder " : output_path ,
417431 },
418432 )
419433
0 commit comments