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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(watch): normalize cwd and cleanup loop shutdown
cyhd111b1df5d43
diff --git a/core/controller.py b/core/controller.pyindex 447b15b3d..cddc71cb8 100644--- a/core/controller.py+++ b/core/controller.py@@ -576,6 +576,19 @@ class Controller:"""Best-effort synchronous cleanup without cross-loop awaits"""logger.info("Cleaning up controller resources (sync, best-effort)...")+ def _stop_loop_coroutine(coro, label: str) -> None:+ try:+ loop = self._loop+ if not loop or loop.is_closed():+ return+ if loop.is_running():+ future = asyncio.run_coroutine_threadsafe(coro, loop)+ future.result(timeout=5)+ return+ loop.run_until_complete(coro)+ except Exception as e:+ logger.debug(f"{label} cleanup skipped: {e}")+# Stop update checkertry:update_task = self.update_checker.stop()@@ -589,20 +602,8 @@ class Controller:except Exception as e:logger.debug(f"Update checker cleanup skipped: {e}")- try:- loop = self._loop- if loop and not loop.is_closed():- future = asyncio.run_coroutine_threadsafe(self.scheduled_task_service.stop(), loop)- future.result(timeout=5)- except Exception as e:- logger.debug(f"Scheduled task service cleanup skipped: {e}")- try:- loop = self._loop- if loop and not loop.is_closed():- future = asyncio.run_coroutine_threadsafe(self.watch_service.stop(), loop)- future.result(timeout=5)- except Exception as e:- logger.debug(f"Watch service cleanup skipped: {e}")+ _stop_loop_coroutine(self.scheduled_task_service.stop(), "Scheduled task service")+ _stop_loop_coroutine(self.watch_service.stop(), "Watch service")# Cancel receiver tasks without awaiting (they may belong to other loops)try:diff --git a/tests/test_cli_watch_command.py b/tests/test_cli_watch_command.pyindex e819691f3..3c4b09f65 100644--- a/tests/test_cli_watch_command.py+++ b/tests/test_cli_watch_command.py@@ -205,6 +205,36 @@ def test_watch_add_creates_exec_watch_with_retry_codes(tmp_path: Path, capsys) -assert payload["watch"]["retry_exit_codes"] == [1, 75]+def test_watch_add_persists_absolute_cwd(tmp_path: Path, capsys, monkeypatch: pytest.MonkeyPatch) -> None:+ store = ManagedWatchStore(tmp_path / "watches.json")+ runtime_store = WatchRuntimeStateStore(tmp_path / "watch_runtime.json")+ workdir = tmp_path / "repo"+ workdir.mkdir()+ args = _parse_watch_add(+ [+ "--session-key",+ "slack::channel::C123",+ "--cwd",+ str(workdir.relative_to(tmp_path)),+ "--shell",+ "echo done",+ ]+ )++ monkeypatch.chdir(tmp_path)++ with (+ patch("vibe.cli._ensure_config", return_value=_configured_v2({"slack"})),+ patch("vibe.cli._watch_store", return_value=store),+ patch("vibe.cli._watch_runtime_store", return_value=runtime_store),+ ):+ result = cli.cmd_watch_add(args)++ assert result == 0+ payload = json.loads(capsys.readouterr().out)+ assert payload["watch"]["cwd"] == str(workdir.resolve())++def test_watch_list_brief_includes_runtime_state(tmp_path: Path, capsys) -> None:store = ManagedWatchStore(tmp_path / "watches.json")runtime_store = WatchRuntimeStateStore(tmp_path / "watch_runtime.json")diff --git a/tests/test_controller_dispatch_loop.py b/tests/test_controller_dispatch_loop.pyindex fbc65e76a..edbf18d81 100644--- a/tests/test_controller_dispatch_loop.py+++ b/tests/test_controller_dispatch_loop.py@@ -44,3 +44,32 @@ def test_dispatch_to_controller_loop_runs_callback_on_controller_loop():assert output == "HELLO"assert result["thread"] == "controller-loop"assert result["value"] == "hello"+++def test_cleanup_sync_stops_watch_service_on_stopped_loop() -> None:+ controller = Controller.__new__(Controller)+ loop = asyncio.new_event_loop()+ controller._loop = loop+ stopped: dict[str, bool] = {"watch": False, "tasks": False}++ class _Stopper:+ def __init__(self, key: str) -> None:+ self.key = key++ async def stop(self) -> None:+ stopped[self.key] = True++ controller.scheduled_task_service = _Stopper("tasks")+ controller.watch_service = _Stopper("watch")+ controller.update_checker = type("UpdateChecker", (), {"stop": lambda self: None})()+ controller.receiver_tasks = {}+ controller.im_client = None+ controller._im_thread = None++ try:+ controller.cleanup_sync()+ finally:+ loop.close()++ assert stopped["tasks"] is True+ assert stopped["watch"] is Truediff --git a/vibe/cli.py b/vibe/cli.pyindex c9b2fa635..2fb068297 100644--- a/vibe/cli.py+++ b/vibe/cli.py@@ -1233,7 +1233,7 @@ def cmd_watch_add(args):)cwd = args.cwdif cwd:- resolved = Path(cwd).expanduser()+ resolved = Path(cwd).expanduser().resolve()if not resolved.exists() or not resolved.is_dir():raise TaskCliError(f"watch cwd does not exist: {cwd}",