The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webapp): a profile socket naming the launch profile runs in the launch scope
Tekniumfca91b93d7f0
diff --git a/tests/tui_gateway/test_legacy_fallback_launch_explicit_profile.py b/tests/tui_gateway/test_legacy_fallback_launch_explicit_profile.pyindex a9c0c705f6c..d60b50dd5a6 100644--- a/tests/tui_gateway/test_legacy_fallback_launch_explicit_profile.py+++ b/tests/tui_gateway/test_legacy_fallback_launch_explicit_profile.py@@ -76,3 +76,19 @@ def test_explicit_profile_that_does_not_resolve_is_refused_before_the_handler(hoassert reply["error"]["code"] == 4064, replyassert seen == []+++def test_a_secondary_socket_naming_the_launch_profile_runs_in_the_launch_scope(homes):+ """Reverse direction: a profile-bound socket runs in that profile's scope, so a verb naming the+ launch profile must not keep the secondary's secrets and home."""+ from gateway.runtime_bootstrap import _PURPOSE_CAPABILITIES+ from tui_gateway.ws_legacy_fallback import dispatch_legacy+ server, launch, bee, seen = homes+ actor = types.SimpleNamespace(profile_id=str(bee), capabilities=frozenset(_PURPOSE_CAPABILITIES["interactive"]))+ written, done = [], threading.Event()+ transport = types.SimpleNamespace(write=lambda frame: written.append(frame) or done.set() or True)+ with server._session_profile_runtime_scope({"profile_home": str(bee)}):+ reply = dispatch_legacy(server, {"jsonrpc": "2.0", "id": 1, "method": "probe.portal",+ "params": {"profile": "default"}}, transport, actor)+ assert "result" in (reply if reply is not None else (done.wait(10) and written[0]))+ assert seen == [(launch.resolve(), LAUNCH_PORTAL)]diff --git a/tui_gateway/ws_legacy_fallback.py b/tui_gateway/ws_legacy_fallback.pyindex 5e0e53c9cf7..e75000f872d 100644--- a/tui_gateway/ws_legacy_fallback.py+++ b/tui_gateway/ws_legacy_fallback.py@@ -165,8 +165,10 @@ def dispatch_legacy(server: Any, req: dict, transport: Any, actor: Any) -> dictreq, target = _ticket_profile_request(server, req, home)if target is None:return req- if target:- scope = server._session_profile_runtime_scope({"profile_home": target})+ # "" = an explicit ``profile`` naming the launch home: the socket runs in the ticket's+ # scope (``chat_ws.gateway_ws``), so bind the launch scope or a handler that ignores+ # ``profile`` would read and write the secondary profile's state.+ scope = server._session_profile_runtime_scope({"profile_home": target or server._launch_home()})elif (req.get("method") not in _SESSION_FALLBACK_ALLOWEDand (explicit := _explicit_profile_request(server, req)) is not None):# A launch-profile socket runs in the launch scope (``chat_ws.gateway_ws``), so a verb that