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(core): keep rebuild platform sink until replacement starts

cyh1122abe0e88b
diff --git a/core/controller.py b/core/controller.py
index d8ceef1c4..015cc2bcd 100644
--- a/core/controller.py
+++ b/core/controller.py
@@ -403,7 +403,7 @@ class Controller:
for platform in removed + rebuilt:
await asyncio.to_thread(self.im_client.remove_client, platform)
self.im_clients.pop(platform, None)
- if platform in removed:
+ if platform in removed or platform in rebuilt:
self._removed_im_clients[platform] = RemovedPlatformIMClient(platform)
self.enabled_platforms = next_enabled
@@ -419,10 +419,10 @@ class Controller:
self._ensure_agent_route_for_platform("avibe")
for platform in rebuilt + added:
- self._removed_im_clients.pop(platform, None)
client = self._build_platform_client(platform, new_config)
self.im_clients[platform] = client
self.im_client.add_client(platform, client)
+ self._removed_im_clients.pop(platform, None)
self.im_client.set_primary_platform(next_primary)
self._sync_config_references(new_config)
diff --git a/tests/test_controller_platform_reconcile.py b/tests/test_controller_platform_reconcile.py
index b94e51add..1801849eb 100644
--- a/tests/test_controller_platform_reconcile.py
+++ b/tests/test_controller_platform_reconcile.py
@@ -232,6 +232,30 @@ def test_reconcile_rebuilds_enabled_platform_on_credential_change(monkeypatch):
assert controller.im_clients["slack"].config.bot_token == "xoxb-new"
+def test_reconcile_rebuild_installs_sink_before_new_client(monkeypatch):
+ monkeypatch.setattr("core.controller.get_platform_descriptor", lambda platform: _Descriptor(platform))
+ controller = _controller(_config(["slack"]))
+ old_client = controller.im_clients["slack"]
+ seen_during_rebuild: list[BaseIMClient] = []
+
+ def _build_platform_client(platform, config):
+ seen_during_rebuild.append(
+ controller.get_im_client_for_context(MessageContext(user_id="u", channel_id="c", platform=platform))
+ )
+ return _Client(platform, getattr(config, platform))
+
+ controller._build_platform_client = _build_platform_client
+
+ result = asyncio.run(controller.reconcile_platforms(_config(["slack"], slack_token="xoxb-new")))
+
+ assert result["rebuilt"] == ["slack"]
+ assert old_client.stopped is True
+ assert len(seen_during_rebuild) == 1
+ assert seen_during_rebuild[0] is not old_client
+ assert seen_during_rebuild[0] is not controller.im_clients["slack"]
+ assert asyncio.run(seen_during_rebuild[0].send_message(MessageContext(user_id="u", channel_id="c", platform="slack"), "late")) is None
+
+
def test_reconcile_noop_when_runtime_fields_do_not_change(monkeypatch):
monkeypatch.setattr("core.controller.get_platform_descriptor", lambda platform: _Descriptor(platform))
controller = _controller(_config(["slack"]))