fix(cli): migrate to bubbletea v2 to drop the init-time terminal probe #254
All Vouch review confidence checks passed
Residual risk 0.32 = Change Risk (0.75) × (1 − Review Confidence (0.58)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.75 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.075
Real PR Conversation Timeline
1 comments
"Review active on #254"
general
weight: 0.35
david-long1
Fixes #250.
Every
openapiinvocation, including--versionandspec lint, stalls for about five seconds and leaksESC ] 11 ; ? ESC \ ESC [ 6 ninto stdout when stdout is a terminal but stdin is not (CI log capture,script,expect, editors that shell out). The cause is bubbletea v1'stea_init.go, whoseinit()callslipgloss.HasDarkBackground()eagerly so the terminal answers the background-colour query (OSC 11) before anyProgramtakes over stdin. That runs beforemain, so it fires for every subcommand even though onlyspec exploreandspec snipever draw a TUI, and when no answer comes back termenv waits out its five-secondOSCTimeout. The comment on thatinit()says the workaround would be removed in v2.It was. Bubble Tea v2 has no init-time probe, lipgloss v2 has no package-level renderer and no background detection, and
muesli/termenv(which sent the query) drops out of the dependency graph entirely. This PR movescmd/openapitocharm.land/bubbletea/v2,charm.land/lipgloss/v2andcharm.land/bubbles/v2. Only thecmd/openapimodule depends on charm, so the root module is untouched.API changes applied
github.com/charmbracelet/{bubbletea,lipgloss,bubbles}becomecharm.land/{bubbletea,lipgloss,bubbles}/v2(the v2 modules declare thecharm.landvanity path; thegithub.com/.../v2form does not resolve).Model.View() stringbecomesModel.View() tea.View, wrapping the rendered string withtea.NewView.tea.WithAltScreen()program option is gone; the explore and snip views now setAltScreen = trueon the returnedtea.View. The file-path input prompt never used the alt screen and still does not.tea.KeyMsgis now an interface; the models matchtea.KeyPressMsgand switch onmsg.String()("enter","esc","ctrl+c") instead ofmsg.Typeconstants.lipgloss.Coloris now a function returningcolor.Color, so the method colour map andGetMethodColorusecolor.Colorand calllipgloss.Color(...)per entry.textinput:ti.Width = 60becomesti.SetWidth(60).Space key
In v1,
KeyMsg.String()for the space bar returned" ". In v2 it returns"space", so the fold/select toggle inmodel.gonow matchescase "space":. Every other key the explorer handles (q,?,esc,j/k, arrows,ctrl+d/ctrl+u,g/G,enter,a/A) keeps its v1 string. The only configured selection action key isw, so noActionKeyconfig needed changing, but any futureActionKey{Key: " "}would have to be written as"space". New tests inmodel_keys_test.godriveUpdatewithtea.KeyPressMsg{Code: tea.KeySpace}and cover the fold toggle, the selection toggle, cursor movement, the action key, and the quit keys.Compatibility
spec exploreorspec snipactually runs. Those are scoped to the interactive session and no longer happen at process start..github/dependabot.ymllists only/andjsonschema/oas3/testsundergomod, so the charm dependencies incmd/openapiwill not be bumped automatically. Addingcmd/openapito thatdirectorieslist is a possible follow-up.exhaustivefinding on the oldtea.KeyTypeswitch ininput.gogoes away because the switch is now on strings. No new lint findings are introduced; the remaining hits in the touched files are pre-existing onmain.Testing
Run from
cmd/openapi(the root./...pattern does not descend into this nested module, somise testat the root does not exercise it):Cross-compiles cleanly for
windows/amd64,linux/amd64,linux/arm64anddarwin/amd64.Reproduction of the issue, stdout on a pty and stdin closed, before (
mainat e70ae27) and after this branch:Before:
After:
Before:
After:
The leading
^D^H^Hin both is macOSscriptechoing the EOF from/dev/nulland is not produced by the binary. The^[]11;?^[\(OSC 11 background query) and^[[6n(cursor position report) are gone in the after output, and the five-second stall with them.Before:
9. After:0.TUI smoke test on a three-operation spec, driven through a pty with a 100x30 window:
spec exploreenters the alt screen (ESC[?1049h), draws the header and the operation list,jmoves the highlight to the second row, space unfolds that row (showsSummary: List usersandOperation ID: listUsers), a second space folds it again, andqleaves the alt screen (ESC[?1049l) and exits 0. Themainbuild behaves identically in the same harness.<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Fixes #250 by migrating
cmd/openapito Bubble Tea v2. Bubble Tea v1 ran a terminal background-color probe duringinit(), so everyopenapicommand (even--versionandspec lint) stalled about five seconds and leaked escape sequences when stdout was a terminal but stdin was not. v2 has no init-time probe; the TUI only queries the terminal whenspec exploreorspec snipruns.What changed
cmd/openapitocharm.land/bubbletea/v2,charm.land/lipgloss/v2, andcharm.land/bubbles/v2; only this module depends on charm, so the root module is untouched.tea.ViewwithAltScreen = trueinstead of usingtea.WithAltScreen(), and key handling matchestea.KeyPressMsgstrings where space is"space".Update, including cursor viewport-bounds assertions.Compatibility
lipglossv2 leaves color downsampling to Bubble Tea's renderer, so the TUI palette may render slightly differently on 256- or 16-color terminals." "must be written as"space".<sup>Written for commit 8f742783ba5aeab5ac90f914eedc6d7dda51b15d. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/speakeasy-api/openapi/pull/254?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->