Repository navigation
fix(mecatui): make the newline chord reachable and the hint honest on every terminal - #1550
Conversation
jhrozek
left a comment
There was a problem hiding this comment.
Panel review follow-up: two independently-verified test-coverage gaps and one doc-wording nit surfaced while cross-checking a second review pass. No blockers — these are additive.
JAORMX
left a comment
There was a problem hiding this comment.
Reviewed fcff829 against 34d905f in a separate detached worktree, with independent Spec, Standards, Test adequacy, UX, Architecture, Reuse, and Duplication reviewers. The test/reuse reviewers initially encountered provider failures; both completed after targeted fresh retries. No local tests or linters ran. Current CI is green; live e2e is skipped.
The default-key path looks good: four newline chords share dispatch, plain Enter remains submit, positive/negative/late capability replies update state coherently, and the placeholder is correctly included in the render-cache key. The rendered-hint regression test is particularly useful.
One requested fix before approval: the new fallback selector treats every non-Enter chord as legacy-safe. An accepted custom binding can therefore continue advertising an unencodable chord even when a working ctrl+j fallback is configured. This is a concrete gap in the advertised live-keymap fallback behavior, not a request to change the deliberate optimistic startup policy.
Panel axes:
- Spec: default behavior and main/recovery paths satisfy #1500; only stale two-chord dispatch comments were noted as advisory.
- Standards: non-blocking reference synchronization: the linked exhaustive developer key tables still list the old two defaults.
- Test adequacy: missing custom modifier-chord boundary case, independently confirming the fallback gap. Existing reducer, timer, render, and dispatch tests have useful coverage.
- Domain: the custom-chord classification issue is blocking; the Kitty-vs-modifyOtherKeys wording and inverted boolean parameter name are non-blocking. No actionable reuse or duplication findings.
I checked the upstream Kitty protocol and the pinned Bubble Tea/Ultraviolet input code. A missing Kitty reply is not proof that modifyOtherKeys is unavailable. The conservative ctrl+j fallback itself remains safe; this is a wording/guarantee issue, not a demand for another protocol probe. The documented tmux residual, static help overlay, and deferred terminal-config writer do not block this review.
PANEL: ship_blockers=1 important=3 advisory=2 reviewer_failures=0
|
Addressed the review in two commits. 1015376 — the blocking finding. The same commit drops the "proved it cannot deliver" framing everywhere it appeared. You were right that a missing Kitty reply is not evidence about modifyOtherKeys, so the comments, the placeholder rationale and the user docs now say the capability is unconfirmed and d35a7e1 — the coverage and reference gaps. Also added One residual, flagged in-thread: the
|
Enter's legacy encoding is a bare CR with no room for a modifier, so a terminal without the Kitty keyboard protocol or modifyOtherKeys cannot send shift+enter at all. Bubble Tea requests both protocols on every frame and already decodes ctrl+enter and alt+enter cleanly, so both chords were arriving at the prompt and being dropped. alt+enter is the one that adds reach rather than convenience: it is what ESC CR decodes to, which is what "Use Option as Meta Key" sends on macOS Terminal.app and what a terminal-side shift+enter rebind produces. A terminal that cannot encode shift+enter natively can now be configured to deliver it. Verified end to end by injecting the real byte sequences into mecatui running in a pty: ESC[13;2u, ESC[27;2;13~, ESC[13;5u, ESC CR, and 0x0A all insert a newline; a bare CR still submits. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The prompt placeholder advertised shift+enter unconditionally, including on terminals that cannot encode it, where the key does nothing or submits. The placeholder was also built once in New, before the terminal has answered any capability query, so it could not adapt even in principle. The hint now names shift+enter and corrects itself to the binding's first legacy-safe chord once the terminal has PROVED it cannot deliver one: an explicit reply reporting no enhancements settles it immediately, and silence settles it at a deadline, since silence is the only negative signal a terminal gives. The optimistic default keeps capable terminals, which are the overwhelming majority, reading the chord they want. Both signals settle through one function, so the reply path and the deadline path cannot drift. The chord comes from the live binding, so a --keymap rebind flows through instead of the hint growing a second hardcoded chord. Composition arms the deadline only when stdout is a real TTY, mirroring ThemeAutoDetect: there is nothing to answer on redirected output, and Init's existing contract stays intact. inputRenderKey gains a placeholder slot. Its validity key documented the placeholder as fixed per process, which this change makes false: the correction arrives on a timer with no other model change behind it, so without the slot the corrected hint sat in the model unpainted until unrelated input re-keyed the cache. Caught by running the real binary in a pty, where the hint only flipped after a keystroke; the model-level tests all passed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Keybindings owns the treatment: which chords a terminal can deliver and why, what the prompt hint means, how to configure a terminal so shift+enter reaches mecatui, and the tmux caveat (tmux answers the capability query on its own behalf, so the hint can name shift+enter while tmux collapses it). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…encode The fallback selector answered "legacy-safe" for every chord that was not a modified Enter, which is too narrow a rule. A legacy terminal encodes ctrl+shift+x as the same control byte as ctrl+x, so `--keymap Newline=ctrl+shift+x,ctrl+j` kept advertising ctrl+shift+x after the deadline and skipped the working ctrl+j — the exact broken-hint problem this path exists to fix, preserved for a supported custom binding. Replace the denylist with an allowlist, chordSurvivesLegacyEncoding: a chord qualifies only when a legacy terminal carries it unambiguously — a bare key, ctrl+<letter> minus h/i/m (whose control bytes ARE backspace/tab/CR, so they arrive as those keys), or either behind a single alt (ESC prefix). Everything else, including the ctrl+shift and shift+letter collisions, is disqualified. The cost of being wrong is asymmetric: a fallback that cannot be delivered is worse than declining to offer one. Also stop calling an unanswered probe a proof. The reply consumed here is the Kitty protocol's `CSI ? flags u` response; the pinned Ultraviolet decoder reports xterm's modifyOtherKeys separately, as an event this reducer does not read. A modifyOtherKeys-capable terminal can therefore deliver shift+enter and still let the deadline pass. The fallback stays (it is usable, and the asymmetry above still holds), but the comments, the placeholder rationale and the user-facing docs now say "unconfirmed", not "cannot deliver". promptPlaceholder's boolean is renamed legacyOnly to match the selector's vocabulary. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…key tables The `ProbeKeyboardCapability: stdoutIsTTY` wiring had no test: reverting it to a hardcoded true, arming the deadline on redirected stdout, failed nothing. Fold the rule into resolveKeyboardProbe and pin it, mirroring the resolveThemeAutoDetect seam next to it. (Like that sibling, this covers the gate's rule rather than the call site — main.go's deps literal has no test seam of its own.) docs/tui.md's two key tables still listed Newline as shift+enter/ctrl+J, which the user guide links to as the exhaustive reference. Both now carry all four chords and the rule that decides which one the hint advertises. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
d35a7e1 to
e05b546
Compare
jhrozek
left a comment
There was a problem hiding this comment.
Panel review (Spec/Standards/Test adequacy/Domain: software-architect, library-reuse-reviewer, code-duplication-reviewer) plus cross-check against a second independent review found no blockers on the current branch. All findings from both review rounds — the legacy-safe-chord classification bug, the TTY-gate test gap, and the remapped-chord dispatch test gap — are addressed in the latest commits (1eb0c252a, e05b54690). go test ./cmd/mecatui/... is green.
Reviews is attended. Dismissing since Jakub already re-reviewed
Fixes #1500.
The constraint this is shaped around
enteris a single carriage-return byte in legacy terminal encoding, with no room for a modifier bit. A terminal without the Kitty keyboard protocol or xterm'smodifyOtherKeystherefore cannot sendshift+enterat all: the keypress is not merely unbound, it is invisible, so nothing arrives for the app to respond to or to warn about.ctrl+enteris in exactly the same position. Onlyctrl+j(a plain LF byte) andalt+enter(an ESC prefix) survive.That rules out two shapes the issue considered. There is no runtime hint for a dead keypress, and a purely in-app fix cannot make
shift+enterwork where the terminal cannot encode it.What this changes
1.
Newlinebinds four chords (cmd/mecatui/ui/keys.go):shift+enter,ctrl+j,ctrl+enter,alt+enter. Bubble Tea requests both protocols on every frame and already decodes all four cleanly, soctrl+enterandalt+enterwere arriving at the prompt and being dropped on the floor.alt+enteris the one that adds reach rather than convenience. It is whatESC CRdecodes to, which is what "Use Option as Meta Key" sends on macOS Terminal.app, and what a terminal-sideshift+enterrebind produces. So a terminal that cannot encodeshift+enternatively can now be configured to deliver it, which is the only wayshift+entercan be made to work there.2. The prompt hint corrects itself (
cmd/mecatui/ui/update.go,model.go). It namesshift+enterand falls back to the binding's first legacy-safe chord once the terminal has proved it cannot deliver one. Two signals settle it, through one function so they cannot drift:KeyboardEnhancementsMsgreporting no enhancements settles it immediately;The default is optimistic deliberately. Defaulting to the fallback would have changed what every capable-terminal user reads at startup, and capable terminals are now the overwhelming majority. The chord comes from the live binding, so a
--keymaprebind flows through rather than the hint growing a second hardcoded chord.Composition arms the deadline only when stdout is a real TTY, mirroring
ThemeAutoDetect: there is nothing to answer on redirected output, andInit's existing contract (tests assert it returns the startup command) stays intact.3.
inputRenderKeygains aplaceholderslot (cmd/mecatui/ui/render.go,view.go). Its validity key documented the placeholder as "fixed per process", which change 2 makes false. See "How this was caught" below.Verification
Byte sequences injected into
bin/mecatui --mockrunning in a real pty, which is the layer the bug lives at:ESC[13;2uESC[27;2;13~0x0AESC[13;5uESC CR0x0DNew tests in
cmd/mecatui/ui/newline_hint_test.gocover the chord classifier, the hint rule under--keymaprebinds, both settle signals, a late reply that loses the race with the deadline, theInitarming and its TTY gate, all four chords through the real dispatch path, and that a bareenterstill submits. Each was mutation-checked: reverting the corresponding production change fails it.task lint,task docs, andtask site:buildpass, as doestask testexcept for pre-existing failures incmd/mecatui,cmd/mecatui/embed,internal/app, anddeploy/helm/mecak8s(provider credentials, port binding, helm). I confirmed the first two by reverting to a clean tree; this diff touches no file ininternal/appordeploy/helm/mecak8s, and neither can import acmd/main, so their working tree is already HEAD.go run ./cmd/mecademostill prints a full offline session.Goldens: two files, one line each, the help overlay's newline row picking up the new chords.
How the render-cache bug was caught
Worth flagging because it argues for the pty test rather than the unit tests. Every model-level test passed while the real binary was still wrong: the corrected chord reached the model, but
renderInput's memoized output kept the stale line, so the hint only flipped after an unrelated keystroke happened to re-key the cache. That is precisely when the user no longer needs it. The correction arrives on a timer with no other model change behind it, which is the one case the "re-keyed in the same reducer step" argument aboveinputRenderKeydid not cover.TestCorrectedHintIsActuallyPaintedasserts the rendered region rather than the model field.Residuals and scope
extended-keys offthe hint can nameshift+enterwhile tmux collapses it to a bareenter. I measured this: a realS-Entersubmitted the prompt. Documented, with the twosetlines that fix it. mecatui cannot detect it, since tmux's answer is the only one it gets.shift+enterin their own terminal.shift+enterin its key column, listing the rest as "(also …)". It shows every chord on one line, so it is honest; making it adapt too means rebuilding the renderer's cachedhelpKeyson the capability signal, which is a wider change than this issue needs./terminal-setupequivalent. Documented the per-terminal config instead. A command that writes third-party app configs needs backups, per-app detection, and its own issue.🤖 Generated with Claude Code