Model disappearing then i have to restart it to view it again
guidoenr opened this issue · 1 comments
Describe the bug
I am using bubble tea to show a display containing X jobs (we could call these JOBS as operations done in graphql which take an estimated 3 to 7 minutes, all these jobs are executed concurrently).
The model looks perfect - it shows what it should show.
But a bug occurs very sporadically which I am having a hard time determining and maybe you guys understand better what could be the cause - it basically consists in that the whole model "disappears" in my terminal at a random moment of the execution, and I have to close the model (exit) and then open it again so I can see the model content again - and then everything works normally. (sometimes I have to do this several times to be able to see the model again, such as i showed in the video)
(in the video you can see this bug perfectly and could even be better understood)
Setup
Please complete the following information along with version numbers, if applicable.
- OS: Ubuntu 22.04 | Kali Linux | PopOs (the bug happens in all of these O.S)
- Shell:
bash
- Terminal Emulator: python3
- Terminal Multiplexer: terminator
Venti
(this binary runs a tea.Model) typing the dash
command (you can see it in the video)
func (cmd *dashCmdStruct) run(args []string) error {
// suppress most logging to avoid messing up the display
rootCmd.log.SetLogLevel(rtlogger.ErrorLevel)
p := dash.NewProgram()
// run the model
model, err := p.Run()
if err != nil {
fmt.Println("Error running Dash:", err)
os.Exit(1)
}
// init the model
model.Init()
return nil
}
And here it his the Update function
func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var (
cmd tea.Cmd
cmds []tea.Cmd
)
switch msg := msg.(type) {
case tea.KeyMsg:
if m, cmd := m.handleKeyPress(msg); m != nil {
return m, cmd
}
case tea.WindowSizeMsg:
m.report.SetSize(msg.Width, msg.Height)
m.list.SetWidth(msg.Width)
m.list.SetHeight(msg.Height - 2) // -2 for the status bar
m.progress.Width = msg.Width - 4 // -4 for the borders
case []*testjob.Job:
return m.onJobsLoaded(msg)
case tickMsg:
cmd = m.progress.SetPercent(m.percentage)
return m, tea.Batch(tickCmd(), cmd, loadJobs())
// FrameMsg is sent when the progress bar wants to animate itself
case progress.FrameMsg:
progressModel, cmd := m.progress.Update(msg)
m.progress = progressModel.(progress.Model)
return m, cmd
case error:
return m.onError(msg)
case View:
return m.onViewChange(msg)
}
m.list, cmd = m.list.Update(msg)
cmds = append(cmds, cmd)
m.report.Viewport, cmd = m.report.Viewport.Update(msg)
cmds = append(cmds, cmd)
return m, tea.Batch(cmds...)
}
I will provide more code details if needed
Video triggering the bug:
https://github.com/charmbracelet/bubbletea/assets/47611900/8c4879a8-4a01-480f-9141-48f6d2d69a29
Hey guys, i think found the bug - i am able to keep the model displayed.
Sorry for opening this.