From d7f7b9a5b8f81e6045a459bb28b7aaa2fac5229d Mon Sep 17 00:00:00 2001 From: Erosika Date: Fri, 4 Sep 2026 14:38:01 -0400 Subject: [PATCH] test(honcho): pin the peers-map browse client to the browsed workspace a browse used to be able to list whatever workspace the process built its first client for. get_honcho_client now keys its cache on workspace_id, so the override already gets its own client; this test keeps it that way. --- tests/honcho_plugin/test_peers_map.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/honcho_plugin/test_peers_map.py b/tests/honcho_plugin/test_peers_map.py index 2e5ff3c2e6..0df0035d28 100644 --- a/tests/honcho_plugin/test_peers_map.py +++ b/tests/honcho_plugin/test_peers_map.py @@ -392,6 +392,26 @@ class TestWorkspaceSwitch: ) assert written["cfg"]["hosts"]["hermes"]["workspace"] == "cosmania-dex" + def test_browse_client_is_built_for_the_browsed_workspace(self, monkeypatch): + """The browse client must carry the browsed workspace, not the configured one. + get_honcho_client keys its cache on workspace_id, so this is what keeps a browse + from reusing the profile's own client.""" + import plugins.memory.honcho.client as client_mod + + seen = [] + base = client_mod.HonchoClientConfig(host="hermes", workspace_id="hermes", api_key="k") + monkeypatch.setattr(client_mod.HonchoClientConfig, "from_global_config", + classmethod(lambda cls, host=None, config_path=None: base)) + monkeypatch.setattr(client_mod, "get_honcho_client", lambda cfg: seen.append(cfg) or object()) + monkeypatch.setattr(honcho_cli, "_host_key", lambda: "hermes") + + _, own = honcho_cli._peers_map_client() + _, browsed = honcho_cli._peers_map_client(workspace="cosmania-dex") + + assert own.workspace_id == "hermes" + assert browsed.workspace_id == "cosmania-dex" + assert [c.workspace_id for c in seen] == ["hermes", "cosmania-dex"] + def test_declined_switch_leaves_config_untouched(self, monkeypatch, tmp_path): cfg = {"apiKey": "***", "hosts": {"hermes": {"peerName": "eri"}}} written = self._run(