Files
hermes-webui/tests/test_issue632.py
T
nesquena-hermes f35ac3a727 fix(ui): streamline slash sub-argument autocomplete (#771)
Adds sub-argument suggestions for /model, /personality, /reasoning slash commands. /reasoning is now discoverable from the first slash. Keyboard navigation pre-selects the first item. Fixes bug where no-arg commands (/clear, /new, /stop, etc.) would loop the dropdown on selection.

Fixes #632

Co-authored-by: franksong2702 <franksong2702@users.noreply.github.com>
2026-04-20 22:04:28 +00:00

54 lines
2.3 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_without_promoting_reasoning_to_builtin():
assert "const SLASH_SUBARG_SOURCES=" in COMMANDS_JS
assert "reasoning:{desc:'Set reasoning effort', subArgs:['low','medium','high']}" in COMMANDS_JS
assert "{name:'reasoning'" not in COMMANDS_JS, \
"/reasoning suggestions must not register as a local built-in command"
assert "source:'subarg-command'" in COMMANDS_JS, \
"top-level autocomplete should still surface subarg-only commands like /reasoning"
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"