Repository navigation
Conversation
e98f3d3 to
786e293
Compare
✅ Integration test reportCommit: bc4d7d7
Top 40 slowest tests (at least 2 minutes):
|
|
/review |
786e293 to
abd2eff
Compare
abd2eff to
6faf163
Compare
6faf163 to
bc4d7d7
Compare
|
/review |
There was a problem hiding this comment.
Automated review at bc4d7d7. Each finding was verified against the code.
Not ready yet: part of the automated review did not complete.
This PR replaces direct v1 key-type switches in the prompt, select and pager models with a new teainput.Decode decoder that returns keystroke names, preparing for a Bubble Tea v2 migration. The change is well-structured and well-tested. One edge case in the decoder's Alt+rune branch doesn't normalize a space rune to "space", which could silently break the pager's "alt+space" match on terminals that deliver Alt+Space as KeyRunes.
| case tea.KeyRunes: | ||
| if k.Alt { | ||
| if len(k.Runes) == 1 { | ||
| return Event{Key: "alt+" + string(k.Runes)}, true |
There was a problem hiding this comment.
[nice to have] When Alt+Space arrives as tea.KeyRunes with Runes: []rune(" ") and Alt: true, this returns Event{Key: "alt+ "} (literal space character). The non-Alt branch normalizes space via printable() (line 59), and the KeySpace branch returns "alt+space" explicitly (line 64), but this Alt+rune branch doesn't. The pager matches "alt+space" to advance (pager.go:201), so if a terminal delivers Alt+Space through this path the keypress silently does nothing. Normalizing the space rune here would close the gap:
if len(k.Runes) == 1 {
name := printable(string(k.Runes)).Key
return Event{Key: "alt+" + name}, true
}An "alt space as rune" test case alongside the existing "space as rune" (teainput_test.go:20) would pin it.
| @@ -0,0 +1,75 @@ | |||
| package teainput | |||
There was a problem hiding this comment.
[nit] The testing rules ask for package teainput_test (external-test package). This file only accesses exported identifiers (Decode, Press, Type, Paste, Event), so it can use the _test suffix. Separately, the same rules expect a press_test.go alongside press.go; moving TestPressRoundTrips there would satisfy both.
Models switch on keystroke names from teainput.Decode instead of v1 key types. Behaviour is v1's, with one fix: several runes arriving in one read are text and carry no key name, so typing "enter" fast no longer submits a prompt. A single rune is still a key press. Alt is kept in the name only where v1 checked it: Alt+rune, Alt+space, Alt+backspace and Alt+tab stay inert, and Alt+space still advances the pager. Other Alt combinations act as the plain key, as in v1. A paste is handled as v1 handled it: prompt inserts it, select treats it as typed text, and the pager ignores it. The existing burst pins (prompt "enter", select "down") and the new teainput tests pin the text. No golden moves. Co-authored-by: Isaac <no-reply@databricks.com>
bc4d7d7 to
7b5134c
Compare
Changes
Prompt, select and the pager switch on keystroke names from a new
libs/cmdio/teainputpackage instead of v1 key types:teainput.Decodeturns a bubbletea message into anEventwithKey(keystroke name),Text(printable text) andPaste. Key names follow bubbletea v2 (enter,ctrl+c,space,alt+backspace).Why
This is v1 behaviour on the new decoder, so the v2 move only changes the decoder. Fixed on the way: a burst of text that spells a key name (
enter,down) used to act as that key. v1 typed it as text; the decoder had given it the key's name, so a fastentersubmitted a prompt. Now a burst is text.Tests
go build ./..., golangci-lint (0 issues), gofmt clean.TERM=xterm-256color go test -race -count=3 ./libs/cmdio/...passes.teainputtests cover the decoder, including bursts (enter,down,ctrl+c) and paste.TestKeysPin_PromptBurstKeyName,TestKeysPin_SelectFilterBurstKeyName) pass with the same text as v1.-update. No golden changes.Stack: based on
pietern/charm-v2/03a-render-split.Manual checks for real terminals:
databricks selftest tui prompt, then typeenterquickly (or paste it) and press Enter:Entered: enter(v1 and this branch).This pull request and its description were written by Isaac.