github charmbracelet/bubbletea v2.0.0-rc.1

pre-release11 hours ago

This release includes a big change in the module name, and several message type changes. These types changed from type aliases to structs to improve extensibility and allow for future enhancements without breaking changes:

  • github.com/charmbracelet/bubbletea/v2 - now moved to charm.land/bubbletea/v2
  • CursorPositionMsg - now a struct type
  • KeyboardEnhancementsMsg - now a struct type
  • PasteMsg - now a struct type
  • CapabilityMsg - now a struct type
  • TerminalVersionMsg - now struct types

Migration Guide

Charm Land!

// Before
import tea "github.com/charmbracelet/bubbletea/v2"

// After
import tea "charm.land/bubbletea/v2"

Or you can use this GNU sed oneliner in your project root 😉

find . -name \*.go | xargs -I{} sed -i 's/"github.com\/charmbracelet\/bubbletea\/v2"/"charm.land\/bubbletea\/v2"/' {}

CursorPositionMsg

// Before
case CursorPositionMsg:
    x, y := msg.X, msg.Y

// After (no change needed - fields remain the same)
case CursorPositionMsg:
    x, y := msg.X, msg.Y

KeyboardEnhancementsMsg

// Before
case KeyboardEnhancementsMsg:
    if msg&ansi.KittyDisambiguateEscapeCodes != 0 {
        // ...
    }

// After
case KeyboardEnhancementsMsg:
    if msg.Flags&ansi.KittyDisambiguateEscapeCodes != 0 {
        // ...
    }
    // Or use the helper methods:
    if msg.SupportsKeyDisambiguation() {
        // ...
    }

PasteMsg

// Before
case PasteMsg:
    content := string(msg)

// After
case PasteMsg:
    content := msg.Content
    // Or use the String() method:
    content := msg.String()

CapabilityMsg

// Before
case CapabilityMsg:
    switch msg {
    case "RGB", "Tc":
        // ...
    }

// After
case CapabilityMsg:
    switch msg.Content {
    case "RGB", "Tc":
        // ...
    }
    // Or use the String() method:
    switch msg.String() {
    case "RGB", "Tc":
        // ...
    }

TerminalVersionMsg

// Before
case TerminalVersionMsg:
    version := string(msg)

// After
case TerminalVersionMsg:
    version := msg.Name
    // Or use the String() method:
    version := msg.String()

Changelog

Docs

Other stuff


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on X, Discord, Slack, The Fediverse, Bluesky.

Don't miss a new bubbletea release

NewReleases is sending notifications on new releases.