Skip to content

Commit 3d7c03c

Browse files
committed
fix: handle debug with api triggers
1 parent 305f867 commit 3d7c03c

File tree

7 files changed

+53
-23
lines changed

7 files changed

+53
-23
lines changed

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
[project]
22
name = "uipath-dev"
3-
version = "0.0.11"
3+
version = "0.0.12"
44
description = "UiPath Developer Console"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
77
dependencies = [
8-
"uipath-core>=0.0.9, <0.1.0",
9-
"uipath-runtime>=0.1.3, <0.2.0",
8+
"uipath-runtime==0.2.0.dev1000410126",
109
"textual>=6.7.1, <7.0.0",
1110
"pyperclip>=1.11.0, <2.0.0",
1211
]
@@ -113,3 +112,6 @@ name = "testpypi"
113112
url = "https://test.pypi.org/simple/"
114113
publish-url = "https://test.pypi.org/legacy/"
115114
explicit = true
115+
116+
[tool.uv.sources]
117+
uipath-runtime = { index = "testpypi" }

src/uipath/dev/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ async def handle_chat_input(self, event: Input.Submitted) -> None:
145145
return
146146

147147
if details_panel.current_run.status == "suspended":
148-
details_panel.current_run.resume_data = {"value": user_text}
148+
resume_input: dict[str, Any] | str = {}
149+
try:
150+
resume_input = json.loads(user_text)
151+
except json.JSONDecodeError:
152+
resume_input = user_text
153+
details_panel.current_run.resume_data = resume_input
149154
else:
150155
msg = get_user_message(user_text)
151156
msg_ev = get_user_message_event(user_text)

src/uipath/dev/models/execution.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(
3636
self.entrypoint = entrypoint
3737
self.input_data = input_data
3838
self.mode = mode
39-
self.resume_data: dict[str, Any] | None = None
39+
self.resume_data: dict[str, Any] | str | None = None
4040
self.output_data: dict[str, Any] | str | None = None
4141
self.start_time = datetime.now()
4242
self.end_time: datetime | None = None
@@ -98,4 +98,6 @@ def messages(self) -> list[UiPathConversationMessage]:
9898

9999
def add_event(self, event: Any) -> UiPathConversationMessage | None:
100100
"""Add a conversation event to the run's chat aggregator."""
101+
if event is None:
102+
return None
101103
return self.chat_events.add(cast(UiPathConversationMessageEvent, event))

src/uipath/dev/services/debug_bridge.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from uipath.runtime.debug import UiPathBreakpointResult, UiPathDebugQuitError
88
from uipath.runtime.events import UiPathRuntimeStateEvent
99
from uipath.runtime.result import UiPathRuntimeResult
10+
from uipath.runtime.resumable import UiPathResumeTriggerType
1011

1112
logger = logging.getLogger(__name__)
1213

@@ -60,6 +61,29 @@ async def emit_breakpoint_hit(
6061
if self.on_breakpoint_hit:
6162
self.on_breakpoint_hit(breakpoint_result)
6263

64+
async def emit_execution_suspended(
65+
self, runtime_result: UiPathRuntimeResult
66+
) -> None:
67+
"""Notify debugger that execution is suspended."""
68+
logger.debug("Execution suspended")
69+
if runtime_result.trigger is None:
70+
return
71+
72+
if runtime_result.trigger.trigger_type == UiPathResumeTriggerType.API:
73+
if self.on_breakpoint_hit:
74+
self.on_breakpoint_hit(
75+
UiPathBreakpointResult(
76+
breakpoint_node="<suspended>",
77+
breakpoint_type="before",
78+
current_state=runtime_result.output,
79+
next_nodes=[],
80+
)
81+
)
82+
83+
async def emit_execution_resumed(self, resume_data: Any) -> None:
84+
"""Notify debugger that execution resumed."""
85+
logger.debug("Execution resumed")
86+
6387
async def emit_execution_completed(
6488
self, runtime_result: UiPathRuntimeResult
6589
) -> None:

src/uipath/dev/services/run_service.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ def get_run(self, run_id: str) -> ExecutionRun | None:
8686
return self.runs.get(run_id)
8787

8888
async def execute(self, run: ExecutionRun) -> None:
89-
"""Execute or resume a run.
90-
91-
This is the extracted version of the old `_execute_runtime` method.
92-
"""
89+
"""Execute or resume a run."""
9390
new_runtime: UiPathRuntimeProtocol | None = None
9491
try:
9592
execution_input: dict[str, Any] | None = {}
@@ -179,14 +176,15 @@ async def execute(self, run: ExecutionRun) -> None:
179176
):
180177
run.status = "suspended"
181178
else:
182-
if result.output is None:
183-
run.output_data = {}
184-
elif isinstance(result.output, BaseModel):
185-
run.output_data = result.output.model_dump()
186-
else:
187-
run.output_data = result.output
188179
run.status = "completed"
189180

181+
if result.output is None:
182+
run.output_data = {}
183+
elif isinstance(result.output, BaseModel):
184+
run.output_data = result.output.model_dump()
185+
else:
186+
run.output_data = result.output
187+
190188
if run.output_data:
191189
self._add_info_log(run, f"Execution result: {run.output_data}")
192190

src/uipath/dev/ui/panels/run_details_panel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ def add_chat_message(
436436

437437
if not self.current_run or chat_msg.run_id != self.current_run.id:
438438
return
439+
439440
self._chat_panel.add_chat_message(chat_msg)
440441

441442
def add_trace(self, trace_msg: TraceMessage):

uv.lock

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

0 commit comments

Comments
 (0)