Files
isparkclaw-webui/tests/test_issue632.py
nesquena-hermes 811424a87b feat(reasoning): full /reasoning CLI parity — show|hide + effort levels via config.yaml (#812)
Closes #461

Adds full /reasoning CLI parity to the WebUI slash command system:

- /reasoning show|on → window._showThinking = true; writes display.show_reasoning to config.yaml (same key as CLI); mirrors to settings.json for boot.js
- /reasoning hide|off → same in reverse; re-renders immediately
- /reasoning none|minimal|low|medium|high|xhigh → POST /api/reasoning → writes agent.reasoning_effort to config.yaml; takes effect next turn (matching CLI semantics)
- /reasoning (no args) → GET /api/reasoning → live status toast from config.yaml
- Autocomplete shows all 8 options: show|hide|none|minimal|low|medium|high|xhigh
- Profile-isolated: _get_config_path() is thread-local so per-profile settings never bleed across
- Boot hydration: window._showThinking initialised from settings.json show_thinking on page load
- Inspect.signature guard in streaming.py so older hermes-agent builds don't TypeError

28 new tests, 1708/1708 total passing. Full browser QA on port 8789 with isolated state. CLI/config.yaml sync verified with hermes_constants.parse_reasoning_effort().
2026-04-21 15:26:52 -07:00

60 lines
2.6 KiB
Python

"""
Issue #632: slash autocomplete should suggest second-level arguments.
Covers:
- commands.js exposes a dedicated slash autocomplete parser/loader
- /model sub-args hydrate from /api/models
- /personality sub-args hydrate from /api/personalities
- /reasoning provides static low/medium/high suggestions without becoming a
locally executed built-in command
- boot.js uses the async slash autocomplete helper while typing
"""
import pathlib
REPO_ROOT = pathlib.Path(__file__).parent.parent
COMMANDS_JS = (REPO_ROOT / "static" / "commands.js").read_text(encoding="utf-8")
BOOT_JS = (REPO_ROOT / "static" / "boot.js").read_text(encoding="utf-8")
STYLE_CSS = (REPO_ROOT / "static" / "style.css").read_text(encoding="utf-8")
def test_subarg_registry_exists_and_reasoning_is_promoted_to_builtin():
# SLASH_SUBARG_SOURCES still exists for model and personality
assert "const SLASH_SUBARG_SOURCES=" in COMMANDS_JS
# /reasoning is now a proper builtin command with a fn: handler (cmdReasoning)
# so it is in the COMMANDS array, not SLASH_SUBARG_SOURCES
assert "{name:'reasoning'" in COMMANDS_JS, \
"/reasoning must be registered as a local built-in command with fn: handler"
assert "fn:cmdReasoning" in COMMANDS_JS, \
"/reasoning entry must reference cmdReasoning function"
assert "function cmdReasoning" in COMMANDS_JS, \
"cmdReasoning function must be defined"
# source:'subarg-command' is still used for model/personality in SLASH_SUBARG_SOURCES
assert "source:'subarg-command'" in COMMANDS_JS
def test_model_and_personality_subargs_load_from_existing_apis():
assert "_loadSlashModelSubArgs" in COMMANDS_JS
assert "api('/api/models')" in COMMANDS_JS
assert "_loadSlashPersonalitySubArgs" in COMMANDS_JS
assert "api('/api/personalities')" in COMMANDS_JS
def test_slash_autocomplete_parses_second_level_arguments():
assert "function _parseSlashAutocomplete" in COMMANDS_JS
assert "return {kind:'subargs'" in COMMANDS_JS
assert "getSlashAutocompleteMatches" in COMMANDS_JS
def test_boot_uses_async_slash_autocomplete_helper():
assert "getSlashAutocompleteMatches(text).then(matches=>" in BOOT_JS
def test_subarg_dropdown_has_distinct_parent_and_argument_styling():
assert ".cmd-item-parent" in STYLE_CSS
assert ".cmd-item-subarg" in STYLE_CSS
assert ".cmd-item.selected{background:var(--accent-bg);" in STYLE_CSS
assert "_cmdSelectedIdx=matches.length?0:-1;" in COMMANDS_JS
assert "getSlashAutocompleteMatches(nextValue).then(matches=>" in COMMANDS_JS, \
"selecting a first-level command with sub-args should immediately open second-level suggestions"