Skip to content

Commit 9099837

Browse files
committed
fix: dev terminal run history race condition
1 parent be12b16 commit 9099837

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

src/uipath/_cli/_dev/_terminal/_components/_history.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,33 @@ def clear_runs(self):
7373
self.refresh_list()
7474

7575
def _refresh_running_items(self) -> None:
76+
"""Refresh display names for running items only."""
7677
if not any(run.status == "running" for run in self.runs):
77-
return None # No running items, skip update
78+
return None
7879

79-
run_list = self.query_one("#run-list", ListView)
80+
try:
81+
run_list = self.query_one("#run-list", ListView)
82+
except Exception:
83+
return None
84+
85+
# Take a snapshot of items to avoid mid-iteration changes
86+
items_snapshot = list(run_list.children)
87+
88+
for item in items_snapshot:
89+
if not hasattr(item, "run_id"):
90+
continue
8091

81-
for item in run_list.children:
8292
run = self.get_run_by_id(item.run_id) # type: ignore[attr-defined]
83-
if run and run.status == "running":
93+
if not run or run.status != "running":
94+
continue
95+
96+
# Check if item still exists in the list (wasn't removed)
97+
if item not in run_list.children:
98+
continue
99+
100+
try:
84101
static = item.query_one(Static)
85102
static.update(run.display_name)
103+
except Exception:
104+
# Item structure changed or was removed
105+
continue

0 commit comments

Comments
 (0)