feat(tui): add clickable runtime controls
This commit is contained in:
@@ -1013,6 +1013,10 @@ class WebSocketChannel(BaseChannel):
|
||||
if scope is None:
|
||||
return
|
||||
self._workspaces.persist_scope(cid, scope)
|
||||
# Other clients on the same gateway only need an invalidation; they
|
||||
# can reload the authoritative session row without receiving a
|
||||
# local project path that belongs to another connection.
|
||||
await self.send_session_updated(cid, scope="metadata")
|
||||
await self._send_event(
|
||||
connection,
|
||||
"session_updated",
|
||||
|
||||
@@ -1465,6 +1465,47 @@ async def test_webui_message_scope_inherits_persisted_session_scope(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_workspace_scope_change_invalidates_other_attached_clients(
|
||||
bus: MagicMock,
|
||||
tmp_path,
|
||||
) -> None:
|
||||
sessions = SessionManager(tmp_path / "sessions")
|
||||
channel = WebSocketChannel(
|
||||
{"enabled": True, "allowFrom": ["*"], "host": "127.0.0.1"},
|
||||
bus,
|
||||
gateway=_basic_handler(bus, session_manager=sessions, workspace_path=tmp_path),
|
||||
)
|
||||
origin = AsyncMock()
|
||||
origin.remote_address = ("127.0.0.1", 50123)
|
||||
peer = AsyncMock()
|
||||
peer.remote_address = ("127.0.0.1", 50124)
|
||||
channel._attach(origin, "shared")
|
||||
channel._attach(peer, "shared")
|
||||
|
||||
await channel._dispatch_envelope(
|
||||
origin,
|
||||
"terminal-a",
|
||||
{
|
||||
"type": "set_workspace_scope",
|
||||
"chat_id": "shared",
|
||||
"workspace_scope": {
|
||||
"project_path": str(tmp_path),
|
||||
"access_mode": "full",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
peer_event = json.loads(peer.send.await_args.args[0])
|
||||
assert peer_event == {
|
||||
"event": "session_updated",
|
||||
"chat_id": "shared",
|
||||
"scope": "metadata",
|
||||
}
|
||||
origin_event = json.loads(origin.send.await_args.args[0])
|
||||
assert origin_event["workspace_scope"]["access_mode"] == "full"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_webui_scope_expands_home_project_path(
|
||||
bus: MagicMock,
|
||||
|
||||
Reference in New Issue
Block a user