Typing `/model` and pressing Enter did nothing in the TUI; the picker only opened via `/model --save` or `/model <name>`. The completion popup matched both `/model` and `/model-fallback` by prefix, so the exact-match-hide guard (which required a single match) never fired. With the popup still visible, the TUI's Enter handler completed the text instead of submitting the command, so it never executed. Treat the typed prefix as an exact match whenever it equals any matched command name, not only when it is the sole match. This hides the popup on a complete command name so Enter submits it, even when a longer command shares the prefix.
This commit is contained in:
@@ -29,6 +29,20 @@ class TestSlashCommandCompleter:
|
||||
completions = list(completer.get_completions(_doc("/help"), None))
|
||||
assert completions == []
|
||||
|
||||
def test_exact_command_hides_even_when_prefix_of_another(self):
|
||||
"""Regression for #293: ``/model`` must hide on exact match so Enter
|
||||
submits it, even though ``/model-fallback`` shares the prefix. Before
|
||||
the fix the popup stayed visible (two prefix matches) and the TUI's
|
||||
Enter handler completed the text instead of executing the command.
|
||||
"""
|
||||
completer = SlashCommandCompleter()
|
||||
# Sanity: both commands share the prefix, so a partial prefix lists both.
|
||||
partial = {c.text for c in completer.get_completions(_doc("/mode"), None)}
|
||||
assert {"/model", "/model-fallback"} <= partial
|
||||
# Exact ``/model`` with no trailing space → hide.
|
||||
completions = list(completer.get_completions(_doc("/model"), None))
|
||||
assert completions == []
|
||||
|
||||
def test_non_slash_returns_empty(self):
|
||||
completer = SlashCommandCompleter()
|
||||
completions = list(completer.get_completions(_doc("hello"), None))
|
||||
|
||||
Reference in New Issue
Block a user