feat: Migrate to Charmbracelet Bubbletea and Bubbles libraries to v2.#757
feat: Migrate to Charmbracelet Bubbletea and Bubbles libraries to v2.#757marwan562 wants to merge 5 commits intogoharbor:mainfrom
Conversation
|
DCO is failing btw |
Signed-off-by: marwan562 <mixing.gamer546@gmail.com>
7e8f6ee to
bd7d04d
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #757 +/- ##
=========================================
- Coverage 10.99% 7.79% -3.20%
=========================================
Files 173 270 +97
Lines 8671 13173 +4502
=========================================
+ Hits 953 1027 +74
- Misses 7612 12033 +4421
- Partials 106 113 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
From the list in the issue, can you tell us which of the list items applied to harbor, which didnt, and which are completed? |
|
Hey @NucleoFusion! Here's a breakdown of every item from the upgrade guide mapped to this PR: Bubbletea v2 upgrade checklist
Bonus (viewport API also changed in v2, handled in this PR):
Summary: All 6 applicable items are complete. The remaining 6 are not applicable to harbor-cli as those patterns simply don't exist in the codebase. |
NucleoFusion
left a comment
There was a problem hiding this comment.
huh has been updated to v2 as well
please change the imports for those too
Run a go mod tidy as well if you can
I also seem to forgot to mention this in the original issue, but if we can, we should also replace
switch msg.String() {
case "ctrl+c":
// more
}With
switch msg.Code {
case tea.KeyCtrlC:
// more
}Signed-off-by: marwan562 <mixing.gamer546@gmail.com>
… commands. Signed-off-by: marwan562 <mixing.gamer546@gmail.com>
Signed-off-by: marwan562 <mixing.gamer546@gmail.com>
|
Leave it as string() then |
|
Ok I leave it as String(), I thought we finished our upgrade (bubbletea, huh to v2). |
|
Yep, it seems to be there |
|
For sure 😊 |
NucleoFusion
left a comment
There was a problem hiding this comment.
The current PR state results in malformed output when using the models
This is due to the new nature of model render state to be kept in the view instead of the model itself.
Due to this the previous model structure of Init(),
func (m Model) Init() tea.Cmd {
return tea.Quit
}Doesnt work anymore, because the program quits before the full output is done.
We need to find a solution for this. I will let you know soon. If you have any proposed solutions on how to make this work. Please do tell.
|
Hey @NucleoFusion, I've looked into the issue and I think I have a solution. Instead of returning type doneMsg struct{}
func (m Model) Init() tea.Cmd {
return func() tea.Msg {
return doneMsg{}
}
}
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg.(type) {
case doneMsg:
return m, tea.Quit
}
return m, nil
}This way |
|
@marwan562 I believe I tried something similar. Have you tried running |
|
Hey @NucleoFusion, you're right to flag that — I haven't fully tested it against Thinking about it more, I realize the The correct fix for those models should be:
So the fix is actually two different patterns depending on the model type:
I'll test |
|
The issue is not the API response. The issue is that somehow view() and Init() run concurrently or something. Which makes it a race condition or something and the View() interprets the tea.Quit before it does the whole render. Also look into how you can split this PR up, into separates. For example, updating lipgloss in one, bubbles in another and bubbletea in another. Check the plausibility of it and let me know. |
Fix AppliedThe race condition is fixed in commit df61f7a. Root cause confirmed: The Fix: Removed the PR Splitting FeasibilityHere is the analysis on splitting into separate PRs: lipgloss v1 -> v2 (possible as standalone)
bubbletea v1 -> v2 + bubbles v1 -> v2 (must stay together)
huh v1 -> v2 (possible as standalone)
Proposed split:
This is feasible since the commits are already separated this way ( |
…a v2 The tablelist.Model wrapper caused a race condition in bubbletea v2 where tea.Quit fired before View() completed its render cycle, resulting in malformed or missing output. Fix: remove the Model wrapper entirely. NewModel() now returns table.Model directly, and a new Render() helper applies BaseStyle and returns a string. All 41 view files updated to call fmt.Print(tablelist.Render(m)) instead of running a tea.Program. Interactive selection views (using selection.NewModel) are unaffected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: marwan562 <mixing.gamer546@gmail.com>
df61f7a to
0da05be
Compare
|
Hey @NucleoFusion, I've finished all the fixes, updates, and tests. I also tested Let me know if you'd like me to test anything else or if there's anything you want me to change before we move forward with splitting the PR! |
|
Lets keep this PR on hold for now |
|
Well, if you need anything to update or change in this PR, we can go ahead and move forward on it. Just let me know 👍 |


Description
Upgrade CLI to support bubbletea v2
Type of Change
Please select the relevant type.