Skip to content

Self-hosted AI workspace.

Python

fix: ui_control rejects the advertised rag toggle (#1763)

Afonso Coutinho913dc67384b9
diff --git a/src/ai_interaction.py b/src/ai_interaction.py
index 9063cedcb..2b3e94988 100644
--- a/src/ai_interaction.py
+++ b/src/ai_interaction.py
@@ -1288,7 +1288,7 @@ async def do_ui_control(content: str, session_id: Optional[str] = None) -> Dict:
"private": "incognito",
}
toggle_name = _toggle_aliases.get(toggle_name, toggle_name)
- valid_toggles = {"web", "bash", "research", "incognito", "document_editor"}
+ valid_toggles = {"web", "bash", "rag", "research", "incognito", "document_editor"}
if toggle_name not in valid_toggles:
return {"error": f"Unknown toggle '{toggle_name}'. Valid: {', '.join(sorted(valid_toggles))}"}
return {
diff --git a/tests/test_ui_control_rag_toggle.py b/tests/test_ui_control_rag_toggle.py
new file mode 100644
index 000000000..01b5afdca
--- /dev/null
+++ b/tests/test_ui_control_rag_toggle.py
@@ -0,0 +1,36 @@
+"""The `rag` UI toggle must be accepted.
+
+do_ui_control advertises `rag` as a valid toggle in its own docstring and in
+get_toggles ("Available toggles: web, bash, rag, ..."), and the frontend
+fully wires it (chatStream.js maps rag -> rag-toggle / rag-indicator-btn).
+But valid_toggles omitted "rag", so `toggle rag on` returned an "Unknown
+toggle" error - the advertised capability was dead.
+"""
+import asyncio
+
+from src.ai_interaction import do_ui_control
+
+
+def test_toggle_rag_on_is_accepted():
+ r = asyncio.run(do_ui_control("toggle rag on"))
+ assert r.get("ui_event") == "toggle"
+ assert r.get("toggle_name") == "rag"
+ assert r.get("state") is True
+ assert "error" not in r
+
+
+def test_toggle_rag_off_is_accepted():
+ r = asyncio.run(do_ui_control("toggle rag off"))
+ assert r.get("toggle_name") == "rag"
+ assert r.get("state") is False
+ assert "error" not in r
+
+
+def test_unknown_toggle_still_rejected():
+ r = asyncio.run(do_ui_control("toggle bogus on"))
+ assert "error" in r
+
+
+def test_existing_toggle_still_works():
+ r = asyncio.run(do_ui_control("toggle web on"))
+ assert r.get("toggle_name") == "web" and r.get("state") is True