Repository navigation
Conversation
pietern
force-pushed
the
pietern/charm-v2/04-swap
branch
from
November 17, 2026 22:30
e70fa46 to
93defd8
Compare
Collaborator
✅ Integration test reportCommit: 60a6b63
Top 45 slowest tests (at least 2 minutes):
|
Contributor
Author
|
/review |
| g.waiting = true | ||
| g.quit = msg | ||
| go g.send(tea.RequestCursorPosition()) | ||
| time.AfterFunc(g.wait, func() { g.send(replyGuardTimeout{}) }) |
There was a problem hiding this comment.
The time.AfterFunc timer is not stopped when the cursor report arrives and releases the guard at line 81. After the program exits, the timer fires and calls p.Send(replyGuardTimeout{}) on a completed program. Saving the *time.Timer on the struct and calling Stop() in the release branch would avoid the stale callback. Can we add a timer field and stop it at line 81?
pietern
force-pushed
the
pietern/charm-v2/04-swap
branch
from
November 18, 2026 13:07
93defd8 to
60a6b63
Compare
pietern
force-pushed
the
pietern/charm-v2/04-swap
branch
from
November 18, 2026 15:55
60a6b63 to
4b39c09
Compare
…huh) Moves the CLI's TUI code to charm.land/bubbletea/v2, bubbles/v2, lipgloss/v2 and huh/v2, with the behaviour that v1 gave callers kept or deliberately changed and pinned. Swap - Models handle key events through teainput; tea.HideCursor is gone (Bubble Tea hides the cursor while a program runs), so the select modes golden loses one "?25 reset". - Color: the program's profile comes from the stream's cmdio.Renderer (WithColorProfile), floored at ANSI for template helpers, so TERM unset, CI and CLICOLOR=0 keep v1's depth. - tableview.RunWithOptions sends its window size with tea.WithWindowSize, so the first frame is drawn at that size. - cmd/selftest/tui ports to v2: keys prints the message and the decoded event side by side; profile and huh read the background through lipgloss.HasDarkBackground. Quit guard - cmdio.NewTeaProgram defers quitting, on a terminal, until the terminal answers the cursor position request sent at quit time. Terminals answer in order, so the answers to the startup queries are read before the program exits, and nothing is left at the shell prompt. The wait is bounded at 2 s. Shift+Enter - teainput.KeyName reports shift+enter as enter, for terminals that enable the kitty keyboard protocol. huh - Forms go through cmdio.RunHuhField or RunHuhForm, which run with the context's input, stderr, and the stderr color profile. huh's WithProgramOptions replaces its defaults, so the input and output are passed explicitly. The reply guard is not installed for huh: it needs to inject a message when the terminal does not answer, and a huh program does not expose Send. Golden changes are listed in the stack PR body, one per behaviour. Pins that need a terminal have a TTY variant (TestQueriesPin_PromptQuitBeforeRepliesTTY, termtest StdinTTY), and TestNewTeaProgramGuardsTerminalInput covers the constructor with a faked terminal. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
pietern
force-pushed
the
pietern/charm-v2/04-swap
branch
from
November 18, 2026 16:08
4b39c09 to
2c519b9
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Moves the TUI stack to
charm.land/bubbletea/v2,bubbles/v2,lipgloss/v2andhuh/v2, and fixes three things the swap would otherwise regress. The last commit of the stack; the earlier PRs carry the rest of the work.The swap
teainput;tea.HideCursoris gone (bubbletea hides the cursor while a program runs), so the select modes golden loses one?25 reset.WithColorProfile, floored at ANSI for template helpers).colorDepthstill uses termenv, soTERMunset,CI,CLICOLOR=0,TERM=screenand tmux+truecolor keep v1's depth.tableview.RunWithOptionssends its window size withtea.WithWindowSize, so the first frame is drawn at that size (v2 renders before a sent message lands).huh.ThemeFunc, and huh resolves the background itself.cmd/selftest/tuiports to v2 (keysprints the raw v2 key next to the decoded event;profileandhuhread the background throughlipgloss.HasDarkBackground).Fix 1: leftover terminal replies
bubbletea v2 sends queries at startup (DECRQM 2026 and 2027, kitty keyboard flags). A program that quits before the terminal answers left those answers for the shell prompt.
cmdio.NewTeaProgramnow defers the quit, on a terminal only, until the terminal answers a cursor position request sent at quit time. Terminals answer in order, so the earlier answers have been read by then. The wait is bounded at 2 s, and only applies if the terminal never answers that request.Fix 2: Shift+Enter
v2 enables the kitty keyboard protocol, so terminals that report Shift+Enter separately (Ghostty, kitty, WezTerm) send it as its own key.
teainput.KeyNamemapsshift+entertoenter, so prompts and selection lists submit on it.Fix 3: huh forms
Forms go through
cmdio.RunHuhFieldandcmdio.RunHuhForm(19 call sites inlibs/apps/prompt,cmd/apps,cmd/aitools, and the selftest probe). They run with the context's input, stderr and the stderr colour profile. huh'sWithProgramOptionsreplaces its defaults, so input and output are passed explicitly. Not covered: the reply guard. It has to inject a message if the terminal never answers, and a huh program does not exposeSend, so a missed answer would hang the quit. A huh form can still leave a late reply on the shell prompt after a quick quit; that is open.Why
v2 changes the key, cursor, colour and program APIs; the swap has to keep v1's visible behaviour except where a change is deliberate and pinned. The three fixes address regressions that the swap would otherwise ship.
Tests
go build ./..., golangci-lint (0 issues), gofmt clean.TERM=xterm-256color go test -race -count=3 ./libs/cmdio/...passes.libs/tableview,libs/apps/...,cmd/air,cmd/apps,cmd/fs,cmd/aitools,cmd/selftest/...,internal/buildpass.go test ./acceptance/...) passes.GOOS=windows go vet ./libs/cmdio/...andGOOS=darwin go vet ./libs/cmdio/...pass.keys,profile,colors --lipgloss,pager,table,huh,prompt,select,spinner): all exit 0 with the expected output.Golden changes (pins), against the previous branch
Fourteen pin groups change, all intended:
TestModesPin_{Prompt,Select,Pager}/{enter,ctrl-c},TestModesPin_Spinner: v2 sets modifyOtherKeys 2 and kitty push 1 and undoes both on exit; the mouse-mode resets are gone (v2 never sets those modes); select no longer toggles?25twice.TestKeysPin_{Prompt,Select}ShiftEnter/{kitty,modifyOtherKeys}: Shift+Enter submits (Value: xy,zleft unread; the select clears its screen).TestKeysPin_PromptBracketedPasteWithNewline: the screen keeps✔ Value: aaboveb█.TestQueriesPin_PromptQuitBeforeRepliesandTestQueriesPin_SelectQuitBeforeReplies: pipes never install the guard, so these pins now record v2's queries and the unguarded leftover.TestQueriesPin_PromptTerminalAnswersAtOnce: v2's three startup queries are in the golden.TestQueriesPin_PromptUnsolicitedBackgroundReply: the late OSC 11 reply is consumed; the value isab, notab11;rgb:….TestQueriesPin_PromptQuitBeforeRepliesTTY(stdin poses as a terminal through the new termtestStdinTTYoption). The guard holds the quit for the cursor report; leftover is(none).Unchanged and passing: the pager's first-page spinner pins (
TestPagerPin_SpinnerDuringFirstPageandTestPagerPin_EnterWhileFirstPageLoadsstill show several frames without the tick patch), the colour pins, and the Alt pins from #03c.Test-only changes
libs/cmdio/teaprogram_test.go:TestNewTeaProgramGuardsTerminalInputrunsNewTeaProgramwith a faked terminal. It finishes in about 100 ms.Known issues
LogStringinterleave on v2.LogStringwrites to the terminal while a spinner's renderer is drawing, so the first frame can land before the log line (*spinner started, or* Workingspinner started). Under eight parallel-racecopies ofTestColorPin_Spinnerwith-count=25, v2 failed 13 times across 6 of 8 copies; v1 failed zero times. Fixing it means routingLogStringthrough the active program, which has a message-loss window at teardown. Not in this PR.Manual checks on real terminals
Run each with the v1 build (
main, or #7688 for theselftest tuicommands) and with this build.databricks selftest tui prompt, typexy, Shift+Enter,z, Enter. v2:Entered: xy(Shift+Enter submits). Record what v1 prints: without the kitty keyboard protocol these terminals usually send a plain Enter.databricks selftest tui prompt, typeaband Enter at once, then look at the shell prompt. Both: nothing left over, such as^[[?2026;2$y. v1 sends no such queries; v2 waits for the answers before it exits.databricks selftest tui prompt &,kill -TERM %1, thenstty -ain the shell. Open issue: v2 leaves kitty keyboard and modifyOtherKeys on untilreset, as v1 leaves raw mode.databricks selftest tui profileanddatabricks selftest tui colors --lipgloss, withTERMunset,CI=1,CLICOLOR=0,TERM=screen, and tmux withCOLORTERM=truecolor. The depth must match v1's.databricks selftest tui promptunder a terminal that does not answer OSC 11 (for examplescript): the prompt should appear at once, and typed keys are kept.databricks selftest tui pager --items 30 --delay-first 4s: the spinner animates during the first fetch, then the first page and the prompt.databricks selftest tui table --rows 50,/, type text, Alt+F, paste, Enter,q: noalt+for pasted[text]in the search.databricks selftest tui huh --field confirm, on a dark and a light background:dark_backgroundand the blurred-button colour match the background.This pull request and its description were written by Isaac.