Skip to content

Migrate to Charm v2 (bubbletea, bubbles, lipgloss)#14

Open
Gaurav-Gosain wants to merge 2 commits into
openai:mainfrom
Gaurav-Gosain:migrate-charm-v2
Open

Migrate to Charm v2 (bubbletea, bubbles, lipgloss)#14
Gaurav-Gosain wants to merge 2 commits into
openai:mainfrom
Gaurav-Gosain:migrate-charm-v2

Conversation

@Gaurav-Gosain
Copy link
Copy Markdown

@Gaurav-Gosain Gaurav-Gosain commented May 9, 2026

Summary

Bumps the TUI dependencies from the old github.com/charmbracelet/... v1 modules to the new charm.land/.../v2 modules at the latest stable versions:

  • charm.land/bubbletea/v2 v2.0.6
  • charm.land/bubbles/v2 v2.1.0
  • charm.land/lipgloss/v2 v2.0.3

github.com/charmbracelet/x/term is 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/jsonview package, which is the sole consumer of bubbletea/bubbles/lipgloss in this repo. The other 4 files modified are go.mod and go.sum for the dep bump, and the test file for the import path swap.

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(w), WithHeight(h))
  • Width/Height fields replaced with SetWidth/SetHeight methods on viewport and help
  • lipgloss.Color is now a function returning image/color.Color, so the arrayColor/stringColor/objectColor values move from const to var, and createTable's bgColor parameter is retyped from lipgloss.Color to color.Color

Reference for the full set of v2 breaking changes: the upgrade guides shipped with each module (UPGRADE_GUIDE_V2.md).

Test plan

  • `go build ./...` clean
  • `go vet ./...` clean
  • `go mod tidy` is idempotent
  • `go test ./internal/jsonview/...` all pass

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.
@Gaurav-Gosain Gaurav-Gosain requested a review from a team as a code owner May 9, 2026 16:10
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.
@meowgorithm
Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants