docs: document Alt+Enter multiline input
maintainer edit: document the supported interactive CLI multiline shortcut and trim comments left after removing Shift+Enter support.
This commit is contained in:
@@ -80,6 +80,8 @@ Default paths:
|
|||||||
| `nanobot agent --no-markdown` | Print plain text instead of Rich-rendered Markdown |
|
| `nanobot agent --no-markdown` | Print plain text instead of Rich-rendered Markdown |
|
||||||
| `nanobot agent --logs` | Show runtime logs while chatting |
|
| `nanobot agent --logs` | Show runtime logs while chatting |
|
||||||
|
|
||||||
|
In interactive mode, `Enter` sends the current message. Press `Alt+Enter` to add a newline before sending.
|
||||||
|
|
||||||
Interactive mode exits with `exit`, `quit`, `/exit`, `/quit`, `:q`, or `Ctrl+D`.
|
Interactive mode exits with `exit`, `quit`, `/exit`, `/quit`, `:q`, or `Ctrl+D`.
|
||||||
|
|
||||||
## WebUI
|
## WebUI
|
||||||
|
|||||||
@@ -278,6 +278,8 @@ Then update ~/.nanobot/config.json to add a model preset named "primary" for my
|
|||||||
Tell me exactly what changed and whether I need to run /restart.
|
Tell me exactly what changed and whether I need to run /restart.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In interactive mode, `Enter` sends the current message. Press `Alt+Enter` to add a newline before sending.
|
||||||
|
|
||||||
Exit interactive mode with `exit`, `quit`, `/exit`, `/quit`, `:q`, or `Ctrl+D`.
|
Exit interactive mode with `exit`, `quit`, `/exit`, `/quit`, `:q`, or `Ctrl+D`.
|
||||||
|
|
||||||
## 7. Choose Your Next Step
|
## 7. Choose Your Next Step
|
||||||
|
|||||||
@@ -309,9 +309,7 @@ def _build_cli_key_bindings() -> KeyBindings:
|
|||||||
* Enter -> submit the current input (keeps the familiar
|
* Enter -> submit the current input (keeps the familiar
|
||||||
single-line Enter-to-send feel even though the buffer
|
single-line Enter-to-send feel even though the buffer
|
||||||
is multiline-capable).
|
is multiline-capable).
|
||||||
* Alt+Enter -> insert a newline. Universally supported across
|
* Alt+Enter -> insert a newline for multi-line input.
|
||||||
terminal emulators, so this is the reliable way to
|
|
||||||
compose multi-line input.
|
|
||||||
"""
|
"""
|
||||||
kb = KeyBindings()
|
kb = KeyBindings()
|
||||||
|
|
||||||
@@ -323,11 +321,7 @@ def _build_cli_key_bindings() -> KeyBindings:
|
|||||||
def _(event):
|
def _(event):
|
||||||
event.current_buffer.insert_text("\n")
|
event.current_buffer.insert_text("\n")
|
||||||
|
|
||||||
# On the same LF-as-Enter terminals (WSL) we preserve plain Enter for,
|
# LF-as-Enter terminals send Alt+Enter as ESC + LF rather than ESC + CR.
|
||||||
# Alt+Enter arrives as ESC + LF ("\x1b\x0a" = Escape + ControlJ) rather than
|
|
||||||
# ESC + CR, so the "escape","enter" binding above never matches: Escape is
|
|
||||||
# swallowed and the bare LF triggers prompt_toolkit's default submit. Bind
|
|
||||||
# ESC + ControlJ too so Alt+Enter reliably inserts a newline there as well.
|
|
||||||
@kb.add("escape", Keys.ControlJ) # Alt+Enter on LF-as-Enter terminals
|
@kb.add("escape", Keys.ControlJ) # Alt+Enter on LF-as-Enter terminals
|
||||||
def _(event):
|
def _(event):
|
||||||
event.current_buffer.insert_text("\n")
|
event.current_buffer.insert_text("\n")
|
||||||
|
|||||||
@@ -112,13 +112,7 @@ async def test_raw_lf_enter_still_submits_like_wsl_terminals():
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_alt_enter_inserts_newline_on_lf_terminals():
|
async def test_alt_enter_inserts_newline_on_lf_terminals():
|
||||||
"""On LF-as-Enter terminals (WSL), Alt+Enter arrives as ESC + LF
|
"""LF-as-Enter terminals send Alt+Enter as ESC + LF, which needs its own binding."""
|
||||||
("\\x1b\\x0a" = Escape + ControlJ) rather than the ESC + CR that the
|
|
||||||
"escape","enter" binding matches. Without a dedicated ESC + ControlJ
|
|
||||||
binding the Escape is swallowed and the bare LF submits, so the documented
|
|
||||||
Alt+Enter newline fallback breaks on exactly the terminal path plain Enter
|
|
||||||
is preserved for. Drive a real PromptSession to prove it inserts a newline.
|
|
||||||
"""
|
|
||||||
from prompt_toolkit.application import create_app_session
|
from prompt_toolkit.application import create_app_session
|
||||||
from prompt_toolkit.input import create_pipe_input
|
from prompt_toolkit.input import create_pipe_input
|
||||||
from prompt_toolkit.output import DummyOutput
|
from prompt_toolkit.output import DummyOutput
|
||||||
|
|||||||
Reference in New Issue
Block a user