Migrate to Charm v2 (bubbletea, bubbles, lipgloss) - #14
Gaurav-Gosain wants to merge 2 commits into
Conversation
Bumps the TUI dependencies from the old github.com/charmbracelet/...
v1 modules to the new charm.land/.../v2 modules:
charm.land/bubbletea/v2 v2.0.6
charm.land/bubbles/v2 v2.1.0
charm.land/lipgloss/v2 v2.0.3
The migration touches only the jsonview package, which is the sole
consumer of bubbletea/bubbles/lipgloss. Notable v2 API changes
applied:
- tea.KeyMsg renamed to tea.KeyPressMsg
- Model.View() now returns tea.View, wrapped via tea.NewView
- viewport.New(w, h) replaced with viewport.New(WithWidth, WithHeight)
- Width/Height fields replaced with SetWidth/SetHeight methods on
viewport and help
- lipgloss.Color is now a function returning image/color.Color, so
the array/string/object color values move from const to var and
createTable's bgColor parameter is retyped accordingly
x/term is bumped 0.2.1 to 0.2.2 to align with the indirect deps
pulled in by charm v2.
go build, go vet, and the jsonview tests all pass.
In v1, viewport.View() rendered content even when its width was 0, which is what the explorer's TableView relied on, since Resize never called SetWidth on the table. In v2, viewport.View() short-circuits to an empty string when either dimension is 0, so rows stopped rendering after the migration. Setting the table width to the full window width fixes the empty rows but makes the underlying viewport pad each row to that width, which made the selected-row highlight overflow past the surrounding rounded border. Size the table to the natural content width (sum of column widths plus cell padding) so rows render and the highlight stays within the border.
|
Hello! One of the Bubble Tea/Lip Gloss authors here. Just chiming in to say that the main benefits you'll get from the upgrade here is rendering performance and correctness in terms of glyph rendering, particularly with non-latin characters such as Chinese, Japanese, Korean and so on. |
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
saioai
left a comment
There was a problem hiding this comment.
--format pretty now writes color codes into pipes and files even with NO_COLOR=1. please preserve plain output, add a regression test, and rebase onto current main.
Summary
Bumps the TUI dependencies from the old
github.com/charmbracelet/...v1 modules to the newcharm.land/.../v2modules at the latest stable versions:charm.land/bubbletea/v2v2.0.6charm.land/bubbles/v2v2.1.0charm.land/lipgloss/v2v2.0.3github.com/charmbracelet/x/termis also bumped from 0.2.1 to 0.2.2 to line up with the indirect deps that come with charm v2.Scope
The migration only touches the
internal/jsonviewpackage, which is the sole consumer of bubbletea/bubbles/lipgloss in this repo. The other 4 files modified arego.modandgo.sumfor the dep bump, and the test file for the import path swap.Notable v2 API changes applied
tea.KeyMsgrenamed totea.KeyPressMsgModel.View()now returnstea.View, wrapped viatea.NewViewviewport.New(w, h)replaced withviewport.New(WithWidth(w), WithHeight(h))Width/Heightfields replaced withSetWidth/SetHeightmethods on viewport and helplipgloss.Coloris now a function returningimage/color.Color, so thearrayColor/stringColor/objectColorvalues move fromconsttovar, andcreateTable'sbgColorparameter is retyped fromlipgloss.Colortocolor.ColorReference for the full set of v2 breaking changes: the upgrade guides shipped with each module (
UPGRADE_GUIDE_V2.md).Test plan