scaffold
scaffold copied to clipboard
fix(deps): update module github.com/charmbracelet/bubbles to v2
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| github.com/charmbracelet/bubbles | v0.20.1-0.20250320170029-54f28b650198 -> v2.0.0-beta.1 |
Release Notes
charmbracelet/bubbles (github.com/charmbracelet/bubbles)
v2.0.0-beta.1
Ready for Bubbles v2 Beta?
We're excited to share Bubbles v2.0.0-beta.1 with you! This release builds on the last alpha release and includes a few more API changes and improvements. As usual, the upgrade path is pretty straightforward, but let us know if you have any questions.
Bear in mind you’ll want to use this updates alongside v2.0.0-beta.1 versions of Bubble Tea and Lip Gloss.
### Collect them all
go get github.com/charmbracelet/[email protected]
go get github.com/charmbracelet/[email protected]
go get github.com/charmbracelet/[email protected]
Let’s dive in!
The Init you know and love is back
After spending time with many different forms of Init, we've decided the v1 signature is the right way to go after all. Init is a bit too redundant for our tastes given that initialization is already happening in New. Note that this change is in alignment with current shape of Init in Bubble Tea.
// Before in alpha.2
func (m Model) Init() (Model, tea.Cmd)
// After
func (m Model) Init() tea.Cmd
What’s Changed?
In general, we've made a lot of small changes to Bubbles for consistency and future proofing. There are a lot of changes here, but we've found upgrading pretty easy regardless. If you're having trouble with anything let us know in the discussions.
🥕 List
Styles.FilterCursorandStyles.FilterPrompthave been removed and consolidated into the newStyles.Filter
👟 Progress
- The
Model.EmptyColorandModel.FullColormembers have been changed fromstringtoimage/color.Color Model.Updatenow returns aModelinstead of atea.ModelWithColorProfilehas been removed (Bubble Tea now manages this automatically)WithSolidFillnow takes ancolor.Color(from theimagepackage) instead of astring
✏️ Textarea
The big change to textarea is that you now have the option to use a real cursor per Bubble Tea v2.0.0-beta1. The feature is opt-in, so by default if you don't do anything your programs will continue to use the easy-breezy virtual cursor.
To get an idea of how to use a real cursor with textarea see
the v2 textarea example.
Model.Cursoris now a function that returns a*tea.Cursor(formerly, it was the virtual cursor model)Model.SetCursorhas been renamed toModel.SetCursorColumnCursorStylehas been added to define the cursor styleModel.VirtualCursor(abool) has been added to define whether the textarea should render a virtual cursor; set tofalsewhen using a real cursorStyles.Cursorhas been added to define the cursor style
📜 Textinput
Most of the changes in textinput are to bring it to parity with textarea,
including support for a real cursor. For an example illustrating the use of
textinput with a real cursor see
the v2 textinput example.
Most styling has been moved into StyleState which contains styling for
focused and blurred states.
Model.CompletionStylehas been moved toStylesState.SuggestionModel.PlaceholderStylehas been moved toStylesState.PlaceholderModel.PromptStylehas been and moved toStyleState.PromptModel.TextStylehas been moved toStyleState.TextCursorStylehas been added to define the cursor styleModel.VirtualCursorwas added; use it to disable the virtual cursorModel.Styles(andStyles) was added to house all styling.StyleStatewas added to manage styling for focused and blurred statesModel.Cursoris now afunc() *tea.Cursorfor real cursor support (formerly, it was the virtual cursor model)DefaultStyleshas been addedDefaultDarkStyleshas been addedDefaultLightStyleshas been added
📦 Viewport
The new viewport now supports horizontal scrolling as well as setting a custom gutter column! You can also now scroll horizontally with the left and right arrow keys. Finally, you can now highlight parts of what's being viewed based on regex.
vp := viewport.New()
vp.SetContent("hello world")
// Show line numbers:
vp.LeftGutterFunc = func(info viewport.GutterContext) string {
if info.Soft {
return " │ "
}
if info.Index >= info.TotalLines {
return " ~ │ "
}
return fmt.Sprintf("%4d │ ", info.Index+1)
}
// Highlight things:
vp.SetHighlights(regexp.MustCompile("hello").FindAllStringIndex(vp.GetContent(), -1))
vp.HighlightNext() // highlight and navigate to next match
vp.HighlightPrevious() // highlight and navigate to previous match
vp.ClearHighlights() // clear all highlights
You may now also let viewport do the soft wrapping for you:
vp := viewport.New()
vp.SoftWrap = true
vp.SetContent("hello world from a very long line")
But, if you need more fine control on soft wrapping, you can also use the SetContentLines method. This method allows you to set "virtual lines", which may contain \n in them. These lines are automatically treated as soft wraps, and scrolling also takes then into consideration.
Like details?
Here’s the full changelog since v2.0.0-alpha.2
💝 That’s a wrap!
Feel free to reach out, ask questions, give feedback, and let us know how it's going. We’d love to know what you think.
Part of Charm.
Charm热爱开源 • Charm loves open source • نحنُ نحب المصادر المفتوحة
v2.0.0-alpha.2
Smells like Bubbles v2 Alpha 2!
Thanks for trying out Bubbles v2.0.0-alpha.2! This release was designed to work with Bubble Tea and Lip Gloss v2 alphas with the same tag, so make sure you catch ’em all:
go get github.com/charmbracelet/bubbletea/v2@​v2.0.0-alpha.2
go get github.com/charmbracelet/bubbles/v2@​v2.0.0-alpha.2
go get github.com/charmbracelet/lipgloss/v2@​v2.0.0-alpha.2
There are a lot of small API changes in this release, around two general ideas:
- Consistency across Bubbles
- Manual light/dark background management for Lip Gloss v2 (see below)
We've found upgrading pretty easy, especially with a linter, but let us know how it goes for you. Read on for the breakdown.
[!NOTE] When in doubt, check the examples for reference: they've all been updated for v2.
A Note on Light and Dark Styles
Some Bubbles, like help, offer defaults for light and dark background colors. Selecting one or the other now a manual process, and you have two options.
🎩 The Best Way
Ideally, you have Bubble Tea query the background color for you. This means that you'll be properly querying the correct input and outputs with your program, and the query will happen in lockstep with the application.
// Query for the background color.
func (m model) Init() (tea.Model, tea.Cmd) {
return m, tea.RequestBackgroundColor
}
// Listen for the response and initialize your styles accordigly.
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.BackgroundColorMsg:
// Initialize your styles now that you know the background color.
m.help = help.DefaultStyles(msg.IsDark())
return m, nil
}
}
If you're using Wish you must do it this way in to get the background color of the client.
🤠 The Quick Way
The quick way is to use detect the background color via the compat package in Lip Gloss. It's less recommended because it contains blocking I/O that operates independently of Bubble Tea and, when used with Wish it will not return the background color of the client (because it's running locally on the server).
import "github.com/charmbracelet/lipgloss/v2/compat"
var hasDarkBG = compat.HasDarkBackground()
func main() {
var m model
h := help.New()
h.Styles = help.DefaultStyles(hasDarkBG)
// And so on...
m.help = h
}
For details on the compat package see the Lip Gloss v2.0.0-alpha.2 release notes.
👀 Also Note
You can also just apply defaults manually.
h.Styles = help.DefaultLightStyles() // light mode!
h.Styles = help.DefaultDarkStyles() // jk dark mode
What’s Changed: the Laundry List
Filepicker
- Removed:
DefaultStylesWithRenderer(). Lip Gloss is pure now, so just useDefaultStyles(). Model.Heighthas been broken into a getter and setter; useModel.SetHeight(int)andModel.Height() intinstead
Help
help now defaults to using colors for dark backgrounds. You can manually change them with DefaultLightStyles() and DefaultDarkStyles():
h := help.New()
h.Styles = help.DefaultDarkStyles() // dark mode
h.Styles = help.DefaultLightStyles() // light mode
Or, just detect the background color and apply the appropriate set of styles accordingly:
func (m Model) Init() (tea.Model, tea.Cmd) {
// Ask for the background color.
return m, tea.RequestBackgroundColor
}
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.BackgroundColorMsg:
// We know the background color, so let’s update our styling.
m.help.Styles = help.DefaultStyles(msg.IsDark())
}
}
List
DefaultStyles()now takes a boolean to determine whether it should be rendered with light or dark styles:DefaultStyles(isDark bool)DefaultItemStyles()now takes a boolean to determine whether it should be rendered with light or dark styles:DefaultItemStyles(isDark bool)
Paginator
- The global variable
DefaultKeyMapis now a function:func DefaultKeyMap() KeyMap
Progress
Model.Widthhas been broken into a getter and setter; useModel.SetWidth(int)andModel.Width() intinstead
p := progress.New()
// Before
p.Width = 25
fmt.Printf("%w is a good width", p.Width)
// After
p.SetWidth(25)
fmt.Printf("%w is a good width", p.Width())
Stopwatch
NewWithInterval(time.Duration)has been removed. Pass anOptiontoNew()instead:New(WithInterval(time.Duration))
Table
Model.Widthhas been broken into a getter and setter; useModel.SetWidth(int)andModel.Width() intinsteadModel.Heighthas been broken into a getter and setter; useModel.SetHeight(int)andModel.Height() intinstead
Textarea
- The global variable
DefaultKeyMapis now a function:func DefaultKeyMap() KeyMap Model.FocusedStyleandModel.BlurredStylehave been replaced byModel.Styles.FocusedandModel.Styles.BlurredDefaultStyles() (blurred, focused Style)is nowDefaultStyles(isDark bool) Styles. Seehelpabove for an example on how to work with this.
Textinput
- The global variable
DefaultKeyMapis now a function:func DefaultKeyMap() KeyMap Model.Widthhas been broken into a getter and setter; useModel.SetWidth(int)andModel.Width() intinstead
Timer
NewWithInterval(time.Duration)has been removed. Pass anOptiontoNew()instead:New(time.Duration, WithInterval(time.Duration))
Viewport
Model.WidthandModel.Heighthave been replaced with getters and setters:
m := v.New()
// Before
vp.Width = 40
vp.Height = 80
fmt.Println("%d is my favorite width", vp.Width)
// After
vp.SetWidth(40)
vp.SetHeight(80)
fmt.Println("%d is my favorite width", vp.Width())
New()doesn’t have deafult args anymore:New(width, height int)is nowNew(...Option). To set an initial width and height do one of the following:
// Use functional arguments:
vp := viewport.New(viewport.WithWidth(40), viewport.WithHeight(80)
// Or just:
vp := viewport.New()
vp.SetWidth(40)
vp.SetHeight(80)
Changelog
- feat(textinput): expose matched suggestions and index by @luevano in https://github.com/charmbracelet/bubbles/pull/556
- fix: use atomic package for ids by @caarlos0 in https://github.com/charmbracelet/bubbles/pull/634
- docs(list): fix grammar in doc comment and README by @oahshtsua in https://github.com/charmbracelet/bubbles/pull/627
- chore: Remove duplicate and redundant code by @cuishuang in https://github.com/charmbracelet/bubbles/pull/626
- feat(list): implement GlobalIndex helper by @nobe4 in https://github.com/charmbracelet/bubbles/pull/574
- fix(help): wrong full help sep rendering by @luevano in https://github.com/charmbracelet/bubbles/pull/554
- chore(help): add small full help test by @meowgorithm in https://github.com/charmbracelet/bubbles/pull/636
- docs: update contributing guidelines by @bashbunni in https://github.com/charmbracelet/bubbles/pull/640
- (v2) refactor!: viewport: remove deprecated HighPerformanceRendering by @aymanbagabas in https://github.com/charmbracelet/bubbles/pull/619
- (v2) refactor!: remove deprecated references by @aymanbagabas in https://github.com/charmbracelet/bubbles/pull/620
- feat(deps): bump github.com/charmbracelet/lipgloss from 0.13.0 to 0.13.1 by @dependabot in https://github.com/charmbracelet/bubbles/pull/645
- chore(lint): fix and suppress all soft lint issues; update directives by @meowgorithm in https://github.com/charmbracelet/bubbles/pull/647
- (v2) tidying up by @meowgorithm in https://github.com/charmbracelet/bubbles/pull/649
- (v2) chore: minimal updates for Lip Gloss v2 by @meowgorithm in https://github.com/charmbracelet/bubbles/pull/652
- fix(ci): add lint and lint-sync workflows and update golangci.yml by @aymanbagabas in https://github.com/charmbracelet/bubbles/pull/651
- (v2) consistency and best practices by @meowgorithm in https://github.com/charmbracelet/bubbles/pull/656
- feat(deps): bump github.com/charmbracelet/lipgloss from 0.13.1 to 1.0.0 by @dependabot in https://github.com/charmbracelet/bubbles/pull/655
- Sync golangci-lint config by @github-actions in https://github.com/charmbracelet/bubbles/pull/660
- (v2) expose function for choosing light or dark styles by @meowgorithm in https://github.com/charmbracelet/bubbles/pull/663
- fix: debounce stopwatch and timer by @meowgorithm in https://github.com/charmbracelet/bubbles/pull/664
New Contributors
- @luevano made their first contribution in https://github.com/charmbracelet/bubbles/pull/556
- @oahshtsua made their first contribution in https://github.com/charmbracelet/bubbles/pull/627
- @cuishuang made their first contribution in https://github.com/charmbracelet/bubbles/pull/626
- @nobe4 made their first contribution in https://github.com/charmbracelet/bubbles/pull/574
- @github-actions made their first contribution in https://github.com/charmbracelet/bubbles/pull/660
Full Changelog: https://github.com/charmbracelet/bubbles/compare/v2.0.0-alpha.1...v2.0.0-alpha.2
💝 That’s a wrap!
Feel free to reach out, ask questions, give feedback, and let us know how it's going. We’d love to know what you think.
Part of Charm.
Charm热爱开源 • Charm loves open source • نحنُ نحب المصادر المفتوحة
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
- [ ] If you want to rebase/retry this PR, check this box
This PR was generated by Mend Renovate. View the repository job log.
ℹ Artifact update notice
File name: go.mod
In order to perform the update(s) described in the table above, Renovate ran the go get command, which resulted in the following additional change(s):
- 2 additional dependencies were updated
Details:
| Package | Change |
|---|---|
github.com/charmbracelet/colorprofile |
v0.2.3-0.20250311203215-f60798e515dc -> v0.3.0 |
github.com/charmbracelet/x/cellbuf |
v0.0.13-0.20250311204145-2c3ea96c31dd -> v0.0.13 |
[!IMPORTANT]
Review skipped
Ignore keyword(s) in the title.
:no_entry: Ignored keywords (1)
- (deps)
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
‼️ IMPORTANT Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai planto trigger planning for file edits and PR creation.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
