Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion hermes_cli/web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5881,7 +5881,9 @@ async def toggle_toolset(name: str, body: ToolsetToggle):
else:
enabled.discard(name)
_save_platform_tools(config, "cli", enabled)
return {"ok": True, "name": name, "enabled": body.enabled}
config_after = load_config()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This read is after the with _profile_scope(body.profile or profile) block. For a named profile, _profile_scope has already restored the prior Hermes-home override, so this can report the dashboard profile’s effective state rather than the profile just updated. Please perform the read inside the existing scope and add a named-profile regression test.

effective = set(_get_platform_tools(config_after, "cli", include_default_mcp_servers=False))
return {"ok": True, "name": name, "enabled": name in effective}


@app.get("/api/tools/toolsets/{name}/config")
Expand Down
18 changes: 18 additions & 0 deletions tests/hermes_cli/test_web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,24 @@ def test_select_toolset_provider_unknown_toolset_returns_400(self):
)
assert resp.status_code == 400

def test_toggle_toolset_platform_restricted_returns_actual_state(self):
"""PUT for a platform-restricted toolset must return enabled=false.

discord_admin is restricted to the 'discord' platform.
_save_platform_tools silently drops it for the 'cli' platform, so the
response must reflect what was actually persisted — not the requested state.
Closes #37609.
"""
resp = self.client.put("/api/tools/toolsets/discord_admin", json={"enabled": True})
assert resp.status_code == 200
body = resp.json()
assert body["ok"] is True
assert body["name"] == "discord_admin"
assert body["enabled"] is False

listing = {t["name"]: t for t in self.client.get("/api/tools/toolsets").json()}
assert listing["discord_admin"]["enabled"] is False

def test_config_raw_get(self):
resp = self.client.get("/api/config/raw")
assert resp.status_code == 200
Expand Down
Loading