add feedback to tui

This commit is contained in:
Robin Olsen
2026-02-17 13:19:35 +01:00
parent 6ffcb5eb54
commit a5733bdaed
5 changed files with 87 additions and 28 deletions

View File

@@ -4,13 +4,17 @@ import (
"context"
"github.com/LazyBachelor/LazyPM/internal/service"
"github.com/LazyBachelor/LazyPM/pkg/task"
"github.com/LazyBachelor/LazyPM/pkg/tui/views"
tea "github.com/charmbracelet/bubbletea"
)
type TUIConfig = service.Config
type Tui struct{}
type Tui struct {
feedbackChan chan task.ValidationFeedback
quitChan chan bool
}
func NewTui() *Tui {
return &Tui{}
@@ -24,10 +28,24 @@ func (t *Tui) Run(ctx context.Context, config TUIConfig) error {
defer cleanup()
if _, err := tea.NewProgram(views.NewDashboardView(svc),
tea.WithAltScreen(), tea.WithMouseAllMotion()).Run(); err != nil {
p := tea.NewProgram(views.NewDashboardView(svc, t.feedbackChan, t.quitChan),
tea.WithAltScreen(), tea.WithMouseAllMotion())
if t.quitChan != nil {
go func() {
<-t.quitChan
p.Quit()
}()
}
if _, err := p.Run(); err != nil {
return err
}
return nil
}
func (t *Tui) SetChannels(feedbackChan chan task.ValidationFeedback, quitChan chan bool) {
t.feedbackChan = feedbackChan
t.quitChan = quitChan
}