Skip to content

Agent Zero AI framework

bugfix - tty + component

frdel3db799fb2e96
diff --git a/python/helpers/tty_session.py b/python/helpers/tty_session.py
index 9a8bc3359..68b546f67 100644
--- a/python/helpers/tty_session.py
+++ b/python/helpers/tty_session.py
@@ -79,9 +79,25 @@ class TTYSession:
return await self._proc.wait()
def kill(self):
+ """Force-kill the running child process.
+
+ This is best-effort: if the process has already terminated (which can
+ happen if *close()* was called elsewhere or the child exited by
+ itself) we silently ignore the *ProcessLookupError* raised by
+ *asyncio.subprocess.Process.kill()*. This prevents race conditions
+ where multiple coroutines attempt to close the same session.
+ """
if self._proc is None:
- raise RuntimeError("TTYSpawn is not started")
- self._proc.kill()
+ # Already closed or never started – nothing to do
+ return
+
+ # Only attempt to kill if the process is still running
+ if getattr(self._proc, "returncode", None) is None:
+ try:
+ self._proc.kill()
+ except ProcessLookupError:
+ # Child already gone – treat as successfully killed
+ pass
async def read(self, timeout=None):
# Return any decoded text the child produced, or None on timeout
diff --git a/webui/js/components.js b/webui/js/components.js
index b1031b042..926c78e8d 100644
--- a/webui/js/components.js
+++ b/webui/js/components.js
@@ -165,7 +165,7 @@ export async function importComponent(path, targetElement) {
await Promise.all(loadPromises);
// Remove loading indicator
- const loadingEl = targetElement.querySelector(".loading");
+ const loadingEl = targetElement.querySelector(':scope > .loading');
if (loadingEl) {
targetElement.removeChild(loadingEl);
}