diff --git a/clients/terminal/tui/widgets/input_box.py b/clients/terminal/tui/widgets/input_box.py index 2c1fe7f..11d5e6f 100644 --- a/clients/terminal/tui/widgets/input_box.py +++ b/clients/terminal/tui/widgets/input_box.py @@ -1,9 +1,14 @@ """Input box widget for the TUI. -A multi-line prompt: ``Enter`` sends the message, ``Ctrl+Enter`` inserts a hard -line break, and long lines soft-wrap visually (``TextArea`` defaults to -``soft_wrap=True``). The field grows with content up to ``max-height`` and then -scrolls internally. +A multi-line prompt: ``Enter`` sends the message and long lines soft-wrap +visually (``TextArea`` defaults to ``soft_wrap=True``). The field grows with +content up to ``max-height`` and then scrolls internally. + +A hard line break cannot be inserted via a modifier+Enter combo because the +common terminals do not distinguish Ctrl/Alt/Shift+Enter from plain Enter (they +all send ``\\r``), so any such binding would collide with the submit key. Soft +wrap covers the visual multiline case; revisit if a distinguishable newline key +is needed. """ from __future__ import annotations @@ -17,7 +22,7 @@ class _PromptInput(TextArea): - """Multi-line text area that submits on Enter and breaks on Ctrl+Enter.""" + """Multi-line text area that submits on Enter.""" async def _on_key(self, event: events.Key) -> None: # Intercept before TextArea's own _on_key, which maps "enter" -> "\n". @@ -26,11 +31,6 @@ event.prevent_default() self.action_submit() return - if event.key == "ctrl+enter": - event.stop() - event.prevent_default() - self.insert("\n") - return await super()._on_key(event) def action_submit(self) -> None: @@ -72,7 +72,7 @@ super().__init__() self._input = _PromptInput( text="", - placeholder="Ask anything... (Enter to send, Ctrl+Enter for a new line)", + placeholder="Ask anything... (Enter to send)", classes="input-field", show_line_numbers=False, soft_wrap=True, diff --git a/tests/clients/test_tui_app.py b/tests/clients/test_tui_app.py index 8e9fdb7..10e42fd 100644 --- a/tests/clients/test_tui_app.py +++ b/tests/clients/test_tui_app.py @@ -98,25 +98,6 @@ @pytest.mark.anyio -async def test_ctrl_enter_inserts_newline_without_submitting() -> None: - """Ctrl+Enter inserts a hard line break; Enter is what submits.""" - async with NaviCodeTui(new_session=True).run_test() as pilot: - await pilot.pause() - input_box = pilot.app.query_one("InputBox") - input_box._input.focus() - await pilot.press("h", "i") - await pilot.press("ctrl+enter") - await pilot.press("t", "h", "e", "r", "e") - await pilot.pause() - # A newline was inserted, not submitted. - assert input_box._input.text == "hi\nthere" - chat = pilot.app.query_one("ChatPanel") - assert not any( - item.kind == "user_message" for item in chat._model.items - ) - - -@pytest.mark.anyio async def test_enter_submits_multiline_text() -> None: """Enter submits the full multi-line buffer (newlines preserved).""" async with NaviCodeTui(new_session=True).run_test() as pilot: