The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bot-screen): the install sudo card no longer follows a client-supplied session_id
teknium1435c7031918b
diff --git a/tests/tui_gateway/test_display_methods.py b/tests/tui_gateway/test_display_methods.pyindex 1c3bd858614..6594a594523 100644--- a/tests/tui_gateway/test_display_methods.py+++ b/tests/tui_gateway/test_display_methods.py@@ -173,3 +173,33 @@ def test_lease_acquire_and_release_only_honour_an_id_this_connection_minted(monkassert stolen["error"]["data"]["code"] == "viewer_mismatch"assert _fresh_lease.get().holder == _fresh_lease.HUMANassert rpc(mine, "display.lease.release", {"viewer_id": minted})["result"]["lease"]["holder"] == _fresh_lease.AGENT+++def test_install_sudo_card_ignores_a_client_supplied_session_id(monkeypatch):+ """The sudo card is app-level: it goes to the connection that clicked Install (copy_context+ pins the transport). Honouring params.session_id let a caller route the masked password card+ into ANOTHER window's chat."""+ import tui_gateway.server as server+ from tools.bot_desktop import install, runtime++ monkeypatch.setattr(runtime, "is_supported_host", lambda: True)+ monkeypatch.setattr(runtime, "install_command", lambda: "sudo apt-get install -y x")+ monkeypatch.setattr(server, "_broadcast_global_event", lambda *a, **k: None)+ asked = threading.Event()+ blocks = []++ def fake_block(event, sid, payload, timeout=300, batch_qids=None):+ blocks.append((event, sid))+ asked.set()+ return ""++ def fake_install(*, ask_password, on_line, timeout_seconds=900.0, claimed=False):+ ask_password()+ return -1++ monkeypatch.setattr(server, "_block", fake_block)+ monkeypatch.setattr(install, "install_packages", fake_install)+ resp = _call(server, "display.install", {"session_id": "victim-session"})+ assert resp["result"]["started"], resp+ assert asked.wait(5)+ assert blocks and all(sid != "victim-session" for _ev, sid in blocks), blocksdiff --git a/tui_gateway/methods_display.py b/tui_gateway/methods_display.pyindex 79d15e4eb3e..299c93cbae0 100644--- a/tui_gateway/methods_display.py+++ b/tui_gateway/methods_display.py@@ -183,10 +183,12 @@ def _(rid, params: dict) -> dict:if _bd_runtime.install_command() is None:return _err(rid, _DISPLAY_ERR, "no supported package manager (apt-get, dnf, pacman) on this host")profile_key = hermes_home_key()- sid = str(params.get("session_id") or "")def _ask_password() -> str:- return _block("display.install.sudo.request", sid, {"profile_key": profile_key}, timeout=300)+ # App-level card, no session: it reaches the connection that clicked Install through the+ # transport copy_context() carries below. A client-supplied session_id could route the+ # masked password card into another window's chat, so none is accepted.+ return _block("display.install.sudo.request", "", {"profile_key": profile_key}, timeout=300)def _line(text: str) -> None:_broadcast_global_event("display.install.log", {"profile_key": profile_key, "line": text})