Skip to content

Commit 040be0d

Browse files
committed
fix: selecting an example from the Command Palette didn't leave the input box focused, breaking Up-arrow history browsing afterward
Real bug found via user testing: the utterance WAS correctly appended to utterance_history when selecting an example (confirmed by the existing test) - the actual break was that Up-arrow did nothing afterward. _navigate_history()'s own focus check ('if self.focused is not input_widget: return') silently no-ops unless the input box itself has keyboard focus, and closing the Command Palette doesn't reliably leave focus there the way typing+Enter naturally does (focus was already on the input box before Enter was pressed). _send_utterance() now explicitly re-focuses the input box at the end - harmless for the typing+Enter path (already focused there), fixes the palette-selection path where it wasn't guaranteed. 264 tests passing (1 new, confirming focus lands on the input box after selecting an example). Version bumped to 0.1.24 for release.
1 parent b3e245f commit 040be0d

4 files changed

Lines changed: 36 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ Confirmed NOT sufficient on its own under rootless Podman specifically
205205
Podman rather than a standard root-owned `dockerd` socket, this may
206206
need more digging into your specific setup.
207207

208-
Images are tagged by version (`:0.1.23`) and `:latest`, built and
208+
Images are tagged by version (`:0.1.24`) and `:latest`, built and
209209
published automatically on every release.
210210

211211
## Why not just fix ovos-cli-client / neon-cli-client?

ovos_tui_client/app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,17 @@ def _send_utterance(self, text: str) -> None:
10691069
self.bus.send_utterance(text)
10701070
self.utterance_history.append(text)
10711071
self.history_index = None
1072+
# Real bug found via user testing: selecting an example from
1073+
# the Command Palette correctly appended to utterance_history
1074+
# (confirmed above), but Up-arrow afterward did nothing -
1075+
# _navigate_history()'s own focus check (`if self.focused is
1076+
# not input_widget: return`) silently no-ops unless the input
1077+
# box itself has keyboard focus, and closing the palette
1078+
# doesn't reliably leave focus there. Explicitly re-focusing
1079+
# here makes history browsing work right after EITHER path
1080+
# (typing+Enter already had focus naturally; this covers the
1081+
# palette-selection path where it wasn't guaranteed).
1082+
self.query_one("#utterance-input", Input).focus()
10721083

10731084
def get_system_commands(self, screen: Screen):
10741085
"""Surfaces the same actions available via F1/F5-F8 in

tests/test_command_palette.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from unittest.mock import MagicMock, patch
99

1010
import pytest
11-
from textual.widgets import RichLog
11+
from textual.widgets import RichLog, Input
1212

1313
from ovos_tui_client.app import OVOSTUIApp, ServiceCommandProvider, SkillCommandProvider, PipelineCommandProvider, ExampleCommandProvider
1414

@@ -274,6 +274,28 @@ async def test_selecting_an_example_sends_it_like_a_typed_utterance(tmp_path):
274274
assert "what's the weather?" in text
275275

276276

277+
@pytest.mark.asyncio
278+
async def test_selecting_an_example_returns_focus_to_the_input_box(tmp_path):
279+
"""Real bug found via user testing: selecting an example DID
280+
correctly append to utterance_history (confirmed by the sibling
281+
test above), but pressing Up afterward did nothing - the Up/Down
282+
handler's own focus check silently no-ops unless the input box
283+
itself has keyboard focus, and closing the Command Palette doesn't
284+
reliably leave focus there. _send_utterance() now explicitly
285+
re-focuses the input box, so history browsing works right after
286+
selecting an example, not just after typing+Enter."""
287+
app = _app_with_fake_bus(tmp_path)
288+
app.skill_examples = {"ovos-skill-weather.openvoiceos": ["what's the weather?"]}
289+
async with app.run_test() as pilot:
290+
provider = ExampleCommandProvider(app.screen)
291+
hits = await _collect_hits(provider, "weather")
292+
hits[0].command()
293+
await pilot.pause()
294+
295+
input_widget = app.query_one("#utterance-input", Input)
296+
assert app.focused is input_widget
297+
298+
277299
@pytest.mark.asyncio
278300
async def test_example_search_has_no_hits_when_cache_is_empty(tmp_path):
279301
"""Not an error - just nothing to offer yet if skill_examples

version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
VERSION_MAJOR = 0
22
VERSION_MINOR = 1
3-
VERSION_BUILD = 23
3+
VERSION_BUILD = 24
44
VERSION_ALPHA = 0
55
# END_VERSION_BLOCK

0 commit comments

Comments
 (0)