fix: ui_control rejects the advertised rag toggle (#1763)
This commit is contained in:
@@ -1288,7 +1288,7 @@ async def do_ui_control(content: str, session_id: Optional[str] = None) -> Dict:
|
|||||||
"private": "incognito",
|
"private": "incognito",
|
||||||
}
|
}
|
||||||
toggle_name = _toggle_aliases.get(toggle_name, toggle_name)
|
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:
|
if toggle_name not in valid_toggles:
|
||||||
return {"error": f"Unknown toggle '{toggle_name}'. Valid: {', '.join(sorted(valid_toggles))}"}
|
return {"error": f"Unknown toggle '{toggle_name}'. Valid: {', '.join(sorted(valid_toggles))}"}
|
||||||
return {
|
return {
|
||||||
|
|||||||
36
tests/test_ui_control_rag_toggle.py
Normal file
36
tests/test_ui_control_rag_toggle.py
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user