1717 UiPathRuntimeContext ,
1818 UiPathRuntimeError ,
1919 UiPathRuntimeFactory ,
20+ UiPathRuntimeStatus ,
2021)
2122from ._components ._details import RunDetailsPanel
2223from ._components ._history import RunHistoryPanel
2324from ._components ._new import NewRunPanel
25+ from ._components ._resume import ResumePanel
2426from ._models ._execution import ExecutionRun
2527from ._models ._messages import LogMessage , TraceMessage
2628from ._traces ._exporter import RunContextExporter
@@ -86,6 +88,8 @@ async def on_button_pressed(self, event: Button.Pressed) -> None:
8688 await self .action_execute_run ()
8789 elif event .button .id == "cancel-btn" :
8890 await self .action_cancel ()
91+ elif event .button .id == "resume-btn" :
92+ await self .action_resume ()
8993
9094 async def on_list_view_selected (self , event : ListView .Selected ) -> None :
9195 """Handle run selection from history."""
@@ -109,6 +113,19 @@ async def action_cancel(self) -> None:
109113 """Cancel and return to new run view."""
110114 await self .action_new_run ()
111115
116+ async def action_resume (self ) -> None :
117+ """Resume the suspended run."""
118+ details_panel = self .query_one ("#details-panel" , RunDetailsPanel )
119+ if details_panel and details_panel .current_run :
120+ input : Dict [str , Any ] = {}
121+ input_data = self .query_one ("#resume-panel" , ResumePanel ).get_input_values ()
122+ try :
123+ input = json .loads (input_data )
124+ except json .JSONDecodeError :
125+ return
126+ details_panel .current_run .input_data = input
127+ asyncio .create_task (self ._execute_runtime (details_panel .current_run ))
128+
112129 async def action_execute_run (self ) -> None :
113130 """Execute a new run with UiPath runtime."""
114131 new_run_panel = self .query_one ("#new-run-panel" , NewRunPanel )
@@ -153,17 +170,27 @@ async def _execute_runtime(self, run: ExecutionRun):
153170 ),
154171 )
155172
156- self ._add_info_log (run , f"Starting execution: { run .entrypoint } " )
173+ if run .status == "suspended" :
174+ context .resume = True
175+ self ._add_info_log (run , f"Resuming execution: { run .entrypoint } " )
176+ else :
177+ self ._add_info_log (run , f"Starting execution: { run .entrypoint } " )
178+
179+ run .status = "running"
180+ run .start_time = datetime .now ()
157181
158182 result = await self .runtime_factory .execute_in_root_span (context )
159183
160184 if result is not None :
161- run .output_data = result .output
185+ if result .status == UiPathRuntimeStatus .SUSPENDED .value :
186+ run .status = "suspended"
187+ else :
188+ run .output_data = result .output
189+ run .status = "completed"
162190 if run .output_data :
163191 self ._add_info_log (run , f"Execution result: { run .output_data } " )
164192
165193 self ._add_info_log (run , "✅ Execution completed successfully" )
166- run .status = "completed"
167194 run .end_time = datetime .now ()
168195
169196 except UiPathRuntimeError as e :
0 commit comments