You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a concurrent download manager using Bubble Tea and running into a weird progress bar synchronization issue. The bars complete at different percentages depending on how fast my workers finish, which suggests I'm missing something fundamental about progress reporting.
The Symptom:
// Simulate download functionfuncsimulateDownload(m*Model, namestring, totalint) {
fori:=0; i<=total; i++ {
select {
case<-m.Ctx.Done():
returndefault:
m.UpdateProgress(name, i)
time.Sleep(10*time.Millisecond) // Changing the time here will affect the final outcome of the progress bar.
}
}
}
When I adjust the time.Sleep duration in my progress updater:
Sleep(10ms) →
Sleep(50ms) →
Sleep(200ms) →
What I've Verified:
✔ All worker goroutines complete their tasks
✔ Progress messages make it to Bubble Tea
✔ The math in my percentage calculation looks correct
Core Question:
How should I properly synchronize:
Actual work completion with progress reporting?
Concurrent updates with Bubble Tea's render cycle?
I suspect this is either:
a) A timing issue between my workers and the TUI, or
b) That I'm using SetPercent incorrectly for concurrent scenarios
Has anyone implemented something similar? Would especially appreciate:
Patterns for coordinating multiple progress updaters
How to avoid render cycle conflicts
Best practices for "true" percentage reporting
Here's a minimal example demonstrating the problem:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on a concurrent download manager using Bubble Tea and running into a weird progress bar synchronization issue. The bars complete at different percentages depending on how fast my workers finish, which suggests I'm missing something fundamental about progress reporting.
The Symptom:
When I adjust the
time.Sleep
duration in my progress updater:Sleep(10ms)
→Sleep(50ms)
→Sleep(200ms)
→What I've Verified:
✔ All worker goroutines complete their tasks
✔ Progress messages make it to Bubble Tea
✔ The math in my percentage calculation looks correct
Core Question:
How should I properly synchronize:
I suspect this is either:
a) A timing issue between my workers and the TUI, or
b) That I'm using SetPercent incorrectly for concurrent scenarios
Has anyone implemented something similar? Would especially appreciate:
Here's a minimal example demonstrating the problem:
Code
Thanks in advance for any insights! This has me stumped after several hours of tweaking.
Beta Was this translation helpful? Give feedback.
All reactions