Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(controller): skip codex cleanup when disabled

cyh86fdae4e36aa
diff --git a/core/controller.py b/core/controller.py
index 67cdebebe..33f7cfb5f 100644
--- a/core/controller.py
+++ b/core/controller.py
@@ -401,8 +401,7 @@ class Controller:
except Exception as e:
logger.error("Failed to start watch service: %s", e, exc_info=True)
- claude_timeout = int(max(0, getattr(self.config.claude, "idle_timeout_seconds", 600) or 0))
- codex_timeout = int(max(0, getattr(getattr(self.config, "codex", None), "idle_timeout_seconds", 600) or 0))
+ claude_timeout, codex_timeout = self._get_idle_cleanup_timeouts()
if (claude_timeout > 0 or codex_timeout > 0) and (
self.cleanup_task is None or self.cleanup_task.done()
):
@@ -592,10 +591,17 @@ class Controller:
self._loop.close()
self._loop = None
+ def _get_idle_cleanup_timeouts(self) -> tuple[int, int]:
+ """Return normalized idle cleanup timeouts for Claude and Codex."""
+ claude_config = getattr(self.config, "claude", None)
+ codex_config = getattr(self.config, "codex", None)
+ claude_timeout = int(max(0, getattr(claude_config, "idle_timeout_seconds", 600) or 0))
+ codex_timeout = int(max(0, getattr(codex_config, "idle_timeout_seconds", 0) or 0))
+ return claude_timeout, codex_timeout
+
async def periodic_cleanup(self):
"""Sweep idle backend runtime state without interrupting active work."""
- claude_timeout = int(max(0, getattr(self.config.claude, "idle_timeout_seconds", 600) or 0))
- codex_timeout = int(max(0, getattr(getattr(self.config, "codex", None), "idle_timeout_seconds", 600) or 0))
+ claude_timeout, codex_timeout = self._get_idle_cleanup_timeouts()
enabled_timeouts = [timeout for timeout in (claude_timeout, codex_timeout) if timeout > 0]
if not enabled_timeouts:
logger.info("Idle cleanup disabled for Claude and Codex.")
diff --git a/tests/test_controller_idle_cleanup.py b/tests/test_controller_idle_cleanup.py
new file mode 100644
index 000000000..90b59f5df
--- /dev/null
+++ b/tests/test_controller_idle_cleanup.py
@@ -0,0 +1,29 @@
+from types import SimpleNamespace
+
+from core.controller import Controller
+
+
+def test_idle_cleanup_timeouts_disable_codex_when_backend_config_absent() -> None:
+ controller = object.__new__(Controller)
+ controller.config = SimpleNamespace(
+ claude=SimpleNamespace(idle_timeout_seconds=0),
+ codex=None,
+ )
+
+ claude_timeout, codex_timeout = Controller._get_idle_cleanup_timeouts(controller)
+
+ assert claude_timeout == 0
+ assert codex_timeout == 0
+
+
+def test_idle_cleanup_timeouts_preserve_explicit_codex_timeout() -> None:
+ controller = object.__new__(Controller)
+ controller.config = SimpleNamespace(
+ claude=SimpleNamespace(idle_timeout_seconds=300),
+ codex=SimpleNamespace(idle_timeout_seconds=900),
+ )
+
+ claude_timeout, codex_timeout = Controller._get_idle_cleanup_timeouts(controller)
+
+ assert claude_timeout == 300
+ assert codex_timeout == 900