Skip to content

Commit 7393b53

Browse files
authored
Merge pull request #20 from UiPath/fix/update_runtime
fix: debug wait for terminate
2 parents 028eec2 + 2f6f5f4 commit 7393b53

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[project]
22
name = "uipath-dev"
3-
version = "0.0.7"
3+
version = "0.0.8"
44
description = "UiPath Developer Console"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
77
dependencies = [
8-
"uipath-runtime>=0.0.21, <0.1.0",
8+
"uipath-runtime>=0.1.0, <0.2.0",
99
"textual>=6.6.0, <7.0.0",
1010
"pyperclip>=1.11.0, <2.0.0",
1111
]

src/uipath/dev/models/execution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(
2828
self.conversational = conversational
2929
self.debug = debug
3030
self.resume_data: dict[str, Any] | None = None
31-
self.output_data: dict[str, Any] | None = None
31+
self.output_data: dict[str, Any] | str | None = None
3232
self.start_time = datetime.now()
3333
self.end_time: datetime | None = None
3434
self.status = "pending" # pending, running, completed, failed, suspended

src/uipath/dev/services/debug_bridge.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self):
1818
"""Initialize the debug bridge."""
1919
self._connected = False
2020
self._resume_event = asyncio.Event()
21-
self._quit_requested = False
21+
self._terminate_event = asyncio.Event()
2222
self._breakpoints: list[str] | Literal["*"] = "*" # Default: step mode
2323

2424
# Callbacks to UI
@@ -31,13 +31,13 @@ def __init__(self):
3131
async def connect(self) -> None:
3232
"""Establish connection to debugger."""
3333
self._connected = True
34-
self._quit_requested = False
3534
logger.debug("Debug bridge connected")
3635

3736
async def disconnect(self) -> None:
3837
"""Close connection to debugger."""
3938
self._connected = False
4039
self._resume_event.set() # Unblock any waiting tasks
40+
self._terminate_event.set()
4141
logger.debug("Debug bridge disconnected")
4242

4343
async def emit_execution_started(self, **kwargs: Any) -> None:
@@ -83,16 +83,20 @@ async def wait_for_resume(self) -> Any:
8383
self._resume_event.clear()
8484
await self._resume_event.wait()
8585

86-
if self._quit_requested:
86+
if self._terminate_event.is_set():
8787
raise UiPathDebugQuitError("Debug session quit requested")
8888

89+
async def wait_for_terminate(self) -> None:
90+
"""Wait for terminate command from debugger."""
91+
await self._terminate_event.wait()
92+
8993
def resume(self) -> None:
9094
"""Signal that execution should resume (called from UI buttons)."""
9195
self._resume_event.set()
9296

9397
def quit(self) -> None:
9498
"""Signal that execution should quit (called from UI stop button)."""
95-
self._quit_requested = True
99+
self._terminate_event.set()
96100
self._resume_event.set()
97101

98102
def get_breakpoints(self) -> list[str] | Literal["*"]:

src/uipath/dev/services/run_service.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import json
56
import traceback
67
from datetime import datetime
78
from typing import Any, Callable
@@ -17,6 +18,7 @@
1718
)
1819
from uipath.runtime.debug import UiPathDebugRuntime
1920
from uipath.runtime.errors import UiPathErrorContract, UiPathRuntimeError
21+
from uipath.runtime.events import UiPathRuntimeStateEvent
2022

2123
from uipath.dev.infrastructure import RunContextExporter, RunContextLogHandler
2224
from uipath.dev.models import ExecutionRun, LogMessage, TraceMessage
@@ -111,8 +113,8 @@ async def execute(self, run: ExecutionRun) -> None:
111113
debug_bridge = TextualDebugBridge()
112114

113115
# Connect callbacks
114-
debug_bridge.on_state_update = lambda event: self._handle_state_update(
115-
run.id, event
116+
debug_bridge.on_state_update = lambda state: self._handle_state_update(
117+
run.id, state
116118
)
117119
debug_bridge.on_breakpoint_hit = lambda bp: self._handle_breakpoint_hit(
118120
run.id, bp
@@ -248,10 +250,11 @@ def get_debug_bridge(self, run_id: str) -> TextualDebugBridge | None:
248250
"""Get the debug bridge for a run."""
249251
return self.debug_bridges.get(run_id)
250252

251-
def _handle_state_update(self, run_id: str, event) -> None:
253+
def _handle_state_update(self, run_id: str, state: UiPathRuntimeStateEvent) -> None:
252254
"""Handle state update from debug runtime."""
253-
# You can add more logic here later if needed
254-
pass
255+
run = self.runs.get(run_id)
256+
if run:
257+
self._add_info_log(run, json.dumps(state.payload))
255258

256259
def _handle_debug_started(self, run_id: str) -> None:
257260
"""Handle debug started event."""

uv.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)