Skip to content

Commit 2a0af87

Browse files
authored
Merge pull request #639 from UiPath/fix/dev_list_race_condition
fix: dev terminal run history race condition
2 parents 7b6903f + f1afaf0 commit 2a0af87

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

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

Lines changed: 25 additions & 5 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
91+
92+
run = self.get_run_by_id(item.run_id)
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
8099

81-
for item in run_list.children:
82-
run = self.get_run_by_id(item.run_id) # type: ignore[attr-defined]
83-
if run and run.status == "running":
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)