diff --git a/go.mod b/go.mod index 8274ece..333ad11 100644 --- a/go.mod +++ b/go.mod @@ -2,11 +2,7 @@ module github.com/moneycaringcoder/gitstream-tui go 1.26.1 -require ( - github.com/blitui/blit v0.2.24 - github.com/charmbracelet/bubbletea v1.3.10 - github.com/charmbracelet/x/ansi v0.11.6 -) +require github.com/blitui/blit v0.2.24 require ( github.com/alecthomas/chroma/v2 v2.20.0 // indirect @@ -15,6 +11,7 @@ require ( github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/charmbracelet/bubbles v1.0.0 // indirect + github.com/charmbracelet/bubbletea v1.3.10 // indirect github.com/charmbracelet/colorprofile v0.4.1 // indirect github.com/charmbracelet/glamour v1.0.0 // indirect github.com/charmbracelet/keygen v0.5.3 // indirect @@ -22,6 +19,7 @@ require ( github.com/charmbracelet/log v0.4.1 // indirect github.com/charmbracelet/ssh v0.0.0-20250128164007-98fd5ae11894 // indirect github.com/charmbracelet/wish v1.4.7 // indirect + github.com/charmbracelet/x/ansi v0.11.6 // indirect github.com/charmbracelet/x/cellbuf v0.0.15 // indirect github.com/charmbracelet/x/conpty v0.1.0 // indirect github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 // indirect diff --git a/internal/ui/debug.go b/internal/ui/debug.go index c9a0f02..ead99f8 100644 --- a/internal/ui/debug.go +++ b/internal/ui/debug.go @@ -4,8 +4,6 @@ import ( "sort" "strings" - tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/x/ansi" blit "github.com/blitui/blit" "github.com/blitui/blit/charts" ) @@ -32,9 +30,9 @@ func NewDebugOverlay(debugLog *DebugLog) *DebugOverlay { } } -func (d *DebugOverlay) Init() tea.Cmd { return nil } +func (d *DebugOverlay) Init() blit.Cmd { return nil } -func (d *DebugOverlay) Update(msg tea.Msg, ctx blit.Context) (blit.Component, tea.Cmd) { +func (d *DebugOverlay) Update(msg blit.Msg, ctx blit.Context) (blit.Component, blit.Cmd) { comp, cmd := d.logViewer.Update(msg, ctx) if lv, ok := comp.(*blit.LogViewer); ok { d.logViewer = lv @@ -122,8 +120,8 @@ func (d *DebugOverlay) View() string { lines = append(lines, "") } for i, line := range lines { - if ansi.StringWidth(line) > d.width { - lines[i] = ansi.Truncate(line, d.width, "") + if blit.StringWidth(line) > d.width { + lines[i] = blit.TruncateWith(line, d.width, "") } } diff --git a/internal/ui/panel.go b/internal/ui/panel.go index a983ccc..139e183 100644 --- a/internal/ui/panel.go +++ b/internal/ui/panel.go @@ -5,7 +5,6 @@ import ( "sort" "strings" - tea "github.com/charmbracelet/bubbletea" blit "github.com/blitui/blit" "github.com/moneycaringcoder/gitstream-tui/internal/gitstatus" ) @@ -47,11 +46,11 @@ func NewStatusPanel() *StatusPanel { return p } -func (p *StatusPanel) Init() tea.Cmd { return nil } +func (p *StatusPanel) Init() blit.Cmd { return nil } -func (p *StatusPanel) Update(msg tea.Msg, ctx blit.Context) (blit.Component, tea.Cmd) { +func (p *StatusPanel) Update(msg blit.Msg, ctx blit.Context) (blit.Component, blit.Cmd) { switch msg := msg.(type) { - case tea.KeyMsg: + case blit.KeyMsg: if msg.String() == "enter" || msg.String() == " " { idx := p.listView.CursorIndex() if remote, ok := p.headerMap[idx]; ok { diff --git a/internal/ui/polling.go b/internal/ui/polling.go index ef9af7a..a944de4 100644 --- a/internal/ui/polling.go +++ b/internal/ui/polling.go @@ -4,7 +4,6 @@ import ( "os/exec" "sync" - tea "github.com/charmbracelet/bubbletea" blit "github.com/blitui/blit" "github.com/moneycaringcoder/gitstream-tui/internal/config" "github.com/moneycaringcoder/gitstream-tui/internal/discovery" @@ -51,8 +50,8 @@ func trimNewline(s string) string { // pollEvents uses blit.HTTPResource to fetch GitHub events with ETag caching, // rate-limit tracking, and response fallback. -func pollEvents(cfg *config.Config, debugLog *DebugLog, initial bool) tea.Cmd { - return func() tea.Msg { +func pollEvents(cfg *config.Config, debugLog *DebugLog, initial bool) blit.Cmd { + return func() blit.Msg { token := githubToken() repos := cfg.Repos() pages := 1 @@ -161,15 +160,15 @@ func pollEvents(cfg *config.Config, debugLog *DebugLog, initial bool) tea.Cmd { } } -func discoverRepos(cfg *config.Config) tea.Cmd { - return func() tea.Msg { +func discoverRepos(cfg *config.Config) blit.Cmd { + return func() blit.Msg { repos := discovery.Discover(cfg.Repos(), cfg.ExplicitPaths()) return discoveryMsg{repos: repos} } } -func pollGitStatus(repos []discovery.LocalRepo) tea.Cmd { - return func() tea.Msg { +func pollGitStatus(repos []discovery.LocalRepo) blit.Cmd { + return func() blit.Msg { var wg sync.WaitGroup statuses := make([]gitstatus.RepoStatus, len(repos)) for i, r := range repos { diff --git a/internal/ui/stream.go b/internal/ui/stream.go index 9ad1695..352faec 100644 --- a/internal/ui/stream.go +++ b/internal/ui/stream.go @@ -6,7 +6,6 @@ import ( "strings" "time" - tea "github.com/charmbracelet/bubbletea" blit "github.com/blitui/blit" "github.com/moneycaringcoder/gitstream-tui/internal/config" "github.com/moneycaringcoder/gitstream-tui/internal/discovery" @@ -125,28 +124,28 @@ func NewEventStream(cfg *config.Config, debugLog *DebugLog) *EventStream { s.poller = blit.NewPoller( time.Duration(cfg.Interval)*time.Second, - func() tea.Cmd { - cmds := []tea.Cmd{pollEvents(cfg, debugLog, false)} + func() blit.Cmd { + cmds := []blit.Cmd{pollEvents(cfg, debugLog, false)} if len(s.localRepos) > 0 { cmds = append(cmds, pollGitStatus(s.localRepos)) } - return tea.Batch(cmds...) + return blit.Batch(cmds...) }, ) return s } -func (s *EventStream) Init() tea.Cmd { - return tea.Batch( +func (s *EventStream) Init() blit.Cmd { + return blit.Batch( pollEvents(s.cfg, s.debugLog, true), discoverRepos(s.cfg), ) } -func (s *EventStream) Update(msg tea.Msg, ctx blit.Context) (blit.Component, tea.Cmd) { +func (s *EventStream) Update(msg blit.Msg, ctx blit.Context) (blit.Component, blit.Cmd) { switch msg := msg.(type) { - case tea.KeyMsg: + case blit.KeyMsg: // Enter opens detail overlay instead of browser if msg.String() == "enter" && s.DetailOverlay != nil { idx := s.table.CursorIndex() @@ -170,7 +169,7 @@ func (s *EventStream) Update(msg tea.Msg, ctx blit.Context) (blit.Component, tea idx := s.table.CursorIndex() if idx >= 0 && idx < len(s.filteredEvents) { if url := s.filteredEvents[idx].Event.URL(); url != "" { - return s, tea.Batch( + return s, blit.Batch( blit.CopyToClipboardCmd(url), blit.ToastSuccess("Copied", url), blit.Consumed(), @@ -227,7 +226,7 @@ func (s *EventStream) Update(msg tea.Msg, ctx blit.Context) (blit.Component, tea return s, nil } -func (s *EventStream) handleEvents(msg eventsMsg) (blit.Component, tea.Cmd) { +func (s *EventStream) handleEvents(msg eventsMsg) (blit.Component, blit.Cmd) { for _, e := range msg.errors { s.debugLog.Error("%s", e) } @@ -264,7 +263,7 @@ func (s *EventStream) handleEvents(msg eventsMsg) (blit.Component, tea.Cmd) { } } - var cmds []tea.Cmd + var cmds []blit.Cmd if newCount > 0 && !s.isAtNewEdge() { cmds = append(cmds, blit.ToastInfo("New events", @@ -285,10 +284,10 @@ func (s *EventStream) handleEvents(msg eventsMsg) (blit.Component, tea.Cmd) { } } - return s, tea.Batch(cmds...) + return s, blit.Batch(cmds...) } -func (s *EventStream) handleGitStatus(msg gitStatusMsg) (blit.Component, tea.Cmd) { +func (s *EventStream) handleGitStatus(msg gitStatusMsg) (blit.Component, blit.Cmd) { now := time.Now() newLocal := 0 for _, st := range msg.statuses {