Repository navigation
Description
Bug description
shift+enter inserts a newline in the mecatui prompt only on terminals that can
physically send a distinguishable code for it. On terminals that cannot — a
terminal without the Kitty keyboard protocol or modifyOtherKeys, including
macOS Terminal.app and terminal emulators bundled inside editors and IDEs — the
key does nothing, or submits.
ctrl+j already works everywhere and is bound as an alias
(cmd/mecatui/ui/keys.go (defaultKeys), Newline:
key.WithKeys("shift+enter", "ctrl+j")), and Newline is rebindable via
--keymap. So the capability is present; the problem is entirely
discoverability. The one hint the user actually sees advertises the chord that
does not work, and the chord that does is hidden.
The prompt placeholder is the most visible surface in the TUI and renders only
the binding's FIRST chord:
// cmd/mecatui/ui/model.go
Placeholder: "Ask mecatl to do something… (" + hk.submit + " to send · " +
hk.newlineFirst + " for newline · " + hk.help + " for help)",hk.newlineFirst is shift+enter. The ctrl+j alias appears only in the help
overlay (cmd/mecatui/ui/help.go, rendered as newline (also ctrl+j)), which a
user has to already suspect something is wrong to go open. A user on an
incapable terminal is shown a broken instruction, gets no feedback when the key
does nothing, and has no reason to think an alternative exists. The reasonable
conclusion is that multi-line input is broken or unsupported, not that a second
chord is one overlay away.
The placeholder is also built once in New(), before the terminal has answered
any capability query, so today it cannot adapt even in principle.
Steps to reproduce
- Run
mecatuiin a terminal that does not send a distinguishable
shift+enter— macOS Terminal.app, or a terminal emulator embedded in an
editor/IDE. - Type some text and press
shift+enter.
Expected behavior
The prompt advertises a newline chord that works in the terminal the user is
actually running in.
Actual behavior
Nothing happens (or the prompt submits). The placeholder keeps advertising
shift+enter. Discovering the working ctrl+j requires opening the help
overlay.
Additional context
The capability signal already arrives and is already partly consumed.
cmd/mecatui/ui/view.go requests ReportEventTypes, and the terminal's reply
reaches cmd/mecatui/ui/update.go (onKeyboardProtocolMsg), which reads
SupportsEventTypes() for the double-escape gesture. The same
tea.KeyboardEnhancementsMsg also carries SupportsKeyDisambiguation() — the
capability that makes shift+enter distinguishable from enter — and it is
currently ignored.
Design questions worth settling before implementation:
- Which way does the default point? A terminal with no enhancement support
may never reply at all, so absence of the message is the signal, not a
negative reply. Defaulting the hint to the universally-workingctrl+jand
upgrading toshift+enteronce disambiguation is confirmed degrades safely in
both directions; defaulting toshift+enterand downgrading on a timeout
needs a timeout nobody has to tune. The first shape looks better but changes
what every capable-terminal user reads at startup, which is a real tradeoff. - Does
SupportsKeyDisambiguation()fully cover it?modifyOtherKeysis a
separate path — the codebase already handles one of its encodings
(xtermModifyOtherKeysCtrlJincmd/mecatui/ui/update.go) — so a terminal may
send a usableshift+enterwithout reporting Kitty disambiguation. If so, the
capability check is a conservative approximation and the hint could
under-promise on some terminals. Worth confirming against real emulators
rather than assuming. - Is the placeholder the only surface? The welcome splash
(cmd/mecatui/ui/welcome/welcome.go) carries its own submit hint, so whatever
rule is chosen should apply in one place rather than being duplicated. - Should a dead keypress say anything? On an incapable terminal the keypress
is invisible to the app — nothing is received to respond to — so this probably
cannot be a runtime hint and the startup-time hint has to carry it. Worth
confirming that is actually true before designing around it.
Whatever shape is chosen, the help overlay's existing (also ctrl+j) rendering
is driven from the live binding, so a --keymap rebind should keep flowing
through to every hint rather than acquiring a second hardcoded chord.
Environment
- OS/version: macOS
- Deployment shape: mecatui
Activity