Skip to content
This repository was archived by the owner on Apr 13, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 116 additions & 44 deletions cmd/gitstream/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,25 @@ func main() {
Group: "Polling",
Hint: "How often to poll GitHub for new events (min 5)",
Get: func() string { return strconv.Itoa(cfg.Interval) },
Set: func(v string) error {
Validate: func(v string) error {
n, err := strconv.Atoi(v)
if err != nil || n < 5 {
return fmt.Errorf("must be a number >= 5")
}
cfg.Interval = n
config.Save(cfg)
return nil
},
Set: func(v string) error {
n, _ := strconv.Atoi(v)
cfg.Interval = n
return config.Save(cfg)
},
},
{
Label: "Add repo",
Group: "Repos",
Hint: "Add a new repo to watch (owner/repo format)",
Get: func() string { return "" },
Set: func(v string) error {
Validate: func(v string) error {
v = strings.TrimSpace(v)
if v == "" || !strings.Contains(v, "/") {
return fmt.Errorf("must be owner/repo format")
Expand All @@ -158,33 +161,38 @@ func main() {
return fmt.Errorf("repo already exists")
}
}
cfg.RepoEntries = append(cfg.RepoEntries, config.RepoEntry{Name: v})
config.Save(cfg)
return nil
},
Set: func(v string) error {
v = strings.TrimSpace(v)
cfg.RepoEntries = append(cfg.RepoEntries, config.RepoEntry{Name: v})
return config.Save(cfg)
},
},
{
Label: "Remove repo",
Group: "Repos",
Hint: "Remove a watched repo (owner/repo format)",
Get: func() string { return "" },
Set: func(v string) error {
Validate: func(v string) error {
v = strings.TrimSpace(v)
filtered := make([]config.RepoEntry, 0, len(cfg.RepoEntries))
found := false
for _, r := range cfg.RepoEntries {
if r.Name == v {
found = true
continue
return nil
}
filtered = append(filtered, r)
}
if !found {
return fmt.Errorf("repo not found")
return fmt.Errorf("repo not found")
},
Set: func(v string) error {
v = strings.TrimSpace(v)
filtered := make([]config.RepoEntry, 0, len(cfg.RepoEntries))
for _, r := range cfg.RepoEntries {
if r.Name != v {
filtered = append(filtered, r)
}
}
cfg.RepoEntries = filtered
config.Save(cfg)
return nil
return config.Save(cfg)
},
},
})
Expand All @@ -193,7 +201,7 @@ func main() {
// deadlocking — bubbletea's p.msgs is unbuffered, and Signal.Set triggers
// bus.schedule → p.Send from the UI goroutine which would block forever.
leftSig := blit.NewSignal(
" ? help s sort t type c config D debug p pause r refresh 1-5 tab 0 clear")
" ? help s sort t type c config D debug p pause r refresh y copy 1-5 tab 0 clear")
rightSig := blit.NewSignal[string]("")
updateStatusRight := func() {
var parts []string
Expand Down Expand Up @@ -326,7 +334,8 @@ func main() {
},
})

app := blit.NewApp(
var app *blit.App
app = blit.NewApp(
blit.WithTheme(resolveTheme(cfg.Theme)),
blit.WithLayout(&blit.DualPane{
Main: tabs,
Expand All @@ -340,42 +349,84 @@ func main() {
}),
blit.WithStatusBarSignal(leftSig, rightSig),
blit.WithHelp(),
blit.WithOverlay("Settings", "c", configEditor),
blit.WithOverlay("Debug", "D", debugOverlay),
blit.WithOverlay("Detail", "", detailOverlay),
blit.WithOverlay("Theme", "ctrl+t", themePicker),
blit.WithOverlay("Command", ":", cmdBar),
blit.WithSlotOverlay("Settings", "c", configEditor),
blit.WithSlotOverlay("Debug", "D", debugOverlay),
blit.WithSlotOverlay("Detail", "", detailOverlay),
blit.WithSlotOverlay("Theme", "ctrl+t", themePicker),
blit.WithSlotOverlay("Command", ":", cmdBar),
// Global keybindings
blit.WithKeyBind(blit.KeyBind{
Key: "p", Label: "Pause/resume", Group: "CONTROLS",
Handler: func() { stream.TogglePause(); updateStatusRight() },
Handler: func() {
stream.TogglePause()
updateStatusRight()
if stream.IsPaused() {
app.Send(blit.ToastMsg{Severity: blit.SeverityInfo, Title: "Paused", Duration: 3 * time.Second})
} else {
app.Send(blit.ToastMsg{Severity: blit.SeverityInfo, Title: "Resumed", Duration: 3 * time.Second})
}
},
}),
blit.WithKeyBind(blit.KeyBind{
Key: "r", Label: "Refresh now", Group: "CONTROLS",
Handler: func() { stream.ForceRefresh() },
Handler: func() {
stream.ForceRefresh()
app.Send(blit.ToastMsg{Severity: blit.SeverityInfo, Title: "Refreshing…", Duration: 3 * time.Second})
},
}),
blit.WithKeyBind(blit.KeyBind{
Key: "s", Label: "Toggle sort", Group: "CONTROLS",
Handler: func() { stream.ToggleSort(); updateStatusRight() },
Handler: func() {
stream.ToggleSort()
updateStatusRight()
if stream.IsNewestFirst() {
app.Send(blit.ToastMsg{Severity: blit.SeverityInfo, Title: "Newest first", Duration: 3 * time.Second})
} else {
app.Send(blit.ToastMsg{Severity: blit.SeverityInfo, Title: "Oldest first", Duration: 3 * time.Second})
}
},
}),
blit.WithKeyBind(blit.KeyBind{
Key: "t", Label: "Type filter →", Group: "FILTER",
Handler: func() { stream.CycleTypeFilter(true); updateStatusRight() },
Handler: func() {
stream.CycleTypeFilter(true)
updateStatusRight()
if f := stream.TypeFilter(); f != "" {
ev := github.Event{Type: f}
app.Send(blit.ToastMsg{Severity: blit.SeverityInfo, Title: "Filter: " + ev.Label(), Duration: 3 * time.Second})
} else {
app.Send(blit.ToastMsg{Severity: blit.SeverityInfo, Title: "Filter: All", Duration: 3 * time.Second})
}
},
}),
blit.WithKeyBind(blit.KeyBind{
Key: "T", Label: "Type filter ←", Group: "FILTER",
Handler: func() { stream.CycleTypeFilter(false); updateStatusRight() },
Handler: func() {
stream.CycleTypeFilter(false)
updateStatusRight()
if f := stream.TypeFilter(); f != "" {
ev := github.Event{Type: f}
app.Send(blit.ToastMsg{Severity: blit.SeverityInfo, Title: "Filter: " + ev.Label(), Duration: 3 * time.Second})
} else {
app.Send(blit.ToastMsg{Severity: blit.SeverityInfo, Title: "Filter: All", Duration: 3 * time.Second})
}
},
}),
blit.WithKeyBind(blit.KeyBind{
Key: "0", Label: "Clear filters", Group: "FILTER",
Handler: func() { stream.ClearFilters(); updateStatusRight() },
Handler: func() {
stream.ClearFilters()
updateStatusRight()
app.Send(blit.ToastMsg{Severity: blit.SeverityInfo, Title: "Filters cleared", Duration: 3 * time.Second})
},
}),
blit.WithMouseSupport(),
blit.WithTickInterval(time.Second),
blit.WithTickInterval(200*time.Millisecond),
blit.WithAutoUpdate(updatewire.New(version)),
blit.WithDevConsole(),
blit.WithAnimations(true),
)


if err := app.Run(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
Expand Down Expand Up @@ -407,19 +458,28 @@ Keybindings (in TUI):
Tab Switch focus
Enter Event detail
o Open in browser
y Copy URL to clipboard

Config: ~/.config/gitstream/config.yaml
`)
}

func renderEventDetail(de ui.DisplayEvent, w int, theme blit.Theme) string {
ev := de.Event
labelStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#888888"))
valStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#ffffff"))
color := ui.EventColor(ev.Type)

// Breadcrumb trail: gitstream > repo > event type
bc := blit.NewBreadcrumbs([]string{"gitstream", ev.Repo.Name, ev.Label()})
bc.SetSize(w, 1)
bc.SetTheme(theme)

labelStyle := lipgloss.NewStyle().Foreground(theme.Muted)
valStyle := lipgloss.NewStyle().Foreground(theme.Text)
color := ui.EventColor(ev.Type, theme)
typeStyle := lipgloss.NewStyle().Foreground(color).Bold(true)

lines := []string{
bc.View(),
"",
labelStyle.Render("Type: ") + typeStyle.Render(ev.Label()),
labelStyle.Render("Repo: ") + valStyle.Render(ev.Repo.Name),
labelStyle.Render("Actor: ") + valStyle.Render(ev.Actor.Login),
Expand All @@ -435,7 +495,6 @@ func renderEventDetail(de ui.DisplayEvent, w int, theme blit.Theme) string {
detail := ev.Detail()
if detail != "" {
lines = append(lines, labelStyle.Render("Detail:"))
// Word-wrap detail to width
maxW := w - 2
if maxW < 20 {
maxW = 20
Expand All @@ -453,6 +512,7 @@ func renderEventDetail(de ui.DisplayEvent, w int, theme blit.Theme) string {
if len(ev.Payload.Commits) > 0 {
lines = append(lines, "")
lines = append(lines, labelStyle.Render("Commits:"))
shaStyle := lipgloss.NewStyle().Foreground(theme.Warn)
for _, c := range ev.Payload.Commits {
sha := c.SHA
if len(sha) > 7 {
Expand All @@ -466,7 +526,7 @@ func renderEventDetail(de ui.DisplayEvent, w int, theme blit.Theme) string {
if maxMsg > 0 && len(msg) > maxMsg {
msg = msg[:maxMsg-1] + "…"
}
lines = append(lines, " "+lipgloss.NewStyle().Foreground(lipgloss.Color("#ffaa00")).Render(sha)+" "+valStyle.Render(msg))
lines = append(lines, " "+shaStyle.Render(sha)+" "+valStyle.Render(msg))
}
}

Expand Down Expand Up @@ -508,9 +568,11 @@ func renderEventDetail(de ui.DisplayEvent, w int, theme blit.Theme) string {
if cd := ev.CompareData; cd != nil {
lines = append(lines, "")
lines = append(lines, labelStyle.Render(fmt.Sprintf("Files changed: %d, Commits: %d", len(cd.Files), cd.TotalCommits)))
addStyle := lipgloss.NewStyle().Foreground(theme.Positive)
delStyle := lipgloss.NewStyle().Foreground(theme.Negative)
for _, f := range cd.Files {
adds := lipgloss.NewStyle().Foreground(lipgloss.Color("#22c55e")).Render(fmt.Sprintf("+%d", f.Additions))
dels := lipgloss.NewStyle().Foreground(lipgloss.Color("#ef4444")).Render(fmt.Sprintf("-%d", f.Deletions))
adds := addStyle.Render(fmt.Sprintf("+%d", f.Additions))
dels := delStyle.Render(fmt.Sprintf("-%d", f.Deletions))
lines = append(lines, " "+adds+" "+dels+" "+valStyle.Render(f.Filename))
}
}
Expand All @@ -519,12 +581,22 @@ func renderEventDetail(de ui.DisplayEvent, w int, theme blit.Theme) string {
}

func resolveTheme(name string) blit.Theme {
if name == "" {
return blit.DefaultTheme()
if name != "" {
presets := blit.Presets()
if t, ok := presets[name]; ok {
return t
}
}
presets := blit.Presets()
if t, ok := presets[name]; ok {
return t
t := blit.DefaultTheme()
t.Extra = map[string]lipgloss.Color{
"info": "#06b6d4",
"create": "#22c55e",
"delete": "#ef4444",
"review": "#a855f7",
"comment": "#6b7280",
"issue": "#eab308",
"release": "#f97316",
"local": "#a78bfa",
}
return blit.DefaultTheme()
return t
}
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/moneycaringcoder/gitstream-tui
go 1.26.1

require (
github.com/blitui/blit v0.1.0
github.com/blitui/blit v0.1.2
github.com/charmbracelet/bubbletea v1.3.10
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834
gopkg.in/yaml.v3 v3.0.1
github.com/charmbracelet/x/ansi v0.11.6
)

require (
Expand All @@ -22,7 +22,6 @@ 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
Expand Down Expand Up @@ -62,4 +61,5 @@ require (
golang.org/x/sys v0.43.0 // indirect
golang.org/x/term v0.42.0 // indirect
golang.org/x/text v0.36.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3v
github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/blitui/blit v0.1.0 h1:AfQnTZQHTi7YkRfYUiDfl3dmkuPtSMEmZCilDAuRO0Y=
github.com/blitui/blit v0.1.0/go.mod h1:OQ3XhjGhDneebNJs/ldXqRRXKG1H3+XrYWefdHDD+LY=
github.com/blitui/blit v0.1.2 h1:2TZ836XZ9i8EOA9S8jrTtXvA9O7PqHwCih65fxA5LRY=
github.com/blitui/blit v0.1.2/go.mod h1:OQ3XhjGhDneebNJs/ldXqRRXKG1H3+XrYWefdHDD+LY=
github.com/charmbracelet/bubbles v1.0.0 h1:12J8/ak/uCZEMQ6KU7pcfwceyjLlWsDLAxB5fXonfvc=
github.com/charmbracelet/bubbles v1.0.0/go.mod h1:9d/Zd5GdnauMI5ivUIVisuEm3ave1XwXtD1ckyV6r3E=
github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw=
Expand Down
Loading
Loading