feat!: release v2 (#6545)

Co-authored-by: Artur <145776561+arturict@users.noreply.github.com>
Co-authored-by: arturict <arturict@users.noreply.github.com>
Co-authored-by: Thomas <thomas@ajnart.fr>
Co-authored-by: Afonso Jorge Ramos <afonsojorgeramos@gmail.com>
Co-authored-by: Danura30082 <danura30082+github@gmail.com>
Co-authored-by: Kushie <122986913+kushiemoon-dev@users.noreply.github.com>
Co-authored-by: ajnart <thomas@ajnart.fr>
Co-authored-by: ajnart <thomas@ajnart.dev>
Co-authored-by: chenjun <chenjun@foxmail.com>
Co-authored-by: Wikibear <wikibear@users.noreply.github.com>
Co-authored-by: Bergasha <bergasha@gmail.com>
Co-authored-by: leafyelin <43306196+leafyelin@users.noreply.github.com>
Co-authored-by: Lucas Araujo <lucas.lra@gmail.com>
Co-authored-by: GreenMonito <86085570+GreenMonito@users.noreply.github.com>
Co-authored-by: Nerdy-Technician <roffo@nerdy-technician.social>
Co-authored-by: Jun <34545896+jcstrong@users.noreply.github.com>
Co-authored-by: Edmond Abraham <54119952+gitedmond@users.noreply.github.com>
Co-authored-by: thrawnx <tight.bulb9384@fastmail.com>
Co-authored-by: Chris <58918656+nordada@users.noreply.github.com>
Co-authored-by: yi111 <153097222+Yi-111-a@users.noreply.github.com>
Co-authored-by: Yanis <naamaneyanis@gmail.com>
Co-authored-by: Wikibear <me@sej.de>
Co-authored-by: alessiottavo <93441886+alessiottavo@users.noreply.github.com>
This commit is contained in:
3286 files changed
+284386 -139176

No files matched your search

+200
View File
@@ -0,0 +1,200 @@
package ui
import (
"fmt"
"image/color"
"strings"
"charm.land/lipgloss/v2"
)
// Badges come in two weights. A chip is a filled pill used for the handful of
// states that must be seen at a glance across a busy table — running, demo,
// manage mode. Everything else is a glyph plus coloured text, which stays
// readable when a dozen of them share a row.
func chip(label string, background color.Color) string {
return lipgloss.NewStyle().Bold(true).Foreground(Ink).Background(background).Padding(0, 1).Render(label)
}
func glyph(symbol, label string, colour color.Color) string {
style := lipgloss.NewStyle().Foreground(colour)
if label == "" {
return style.Render(symbol)
}
return style.Render(symbol + " " + label)
}
// CI & Status badge glyphs (Nerd Fonts).
const (
IconPass = "\uf00c" //  nf-fa-check
IconFail = "\uf00d" //  nf-fa-times
IconPending = "\uf444" //  nf-oct-dot_fill
IconNone = "–"
IconLocal = "\uf1b2" //  nf-fa-cube
IconCloud = "\uf0c2" //  nf-fa-cloud
IconRunning = "\uf04b" //  nf-fa-play
IconStopped = "\uf04d" //  nf-fa-stop
IconPaused = "\uf04c" //  nf-fa-pause
IconBuild = "\uf0ad" //  nf-fa-wrench
IconData = "\uf1c0" //  nf-fa-database
IconDocker = "\uf308" //  nf-fa-docker
IconGitHub = "\uf09b" //  nf-fa-github
IconPR = "\uf407" //  nf-oct-git_pull_request
IconBranch = "\uf418" //  nf-oct-git_branch
IconTerminal = "\uf120" //  nf-fa-terminal
IconHealth = "\uf004" //  nf-fa-heart
IconPort = "\uf08e" //  nf-fa-external_link
IconUser = "\uf007" //  nf-fa-user
IconPin = "\uf435" //  nf-oct-pin
IconSearch = "\uf002" //  nf-fa-search
IconKey = "\uf084" //  nf-fa-key
)
type badgeSpec struct {
symbol string
label string
colour color.Color
}
var ciBadges = map[string]badgeSpec{
"SUCCESS": {IconPass, "checks pass", Success},
"FAILURE": {IconFail, "checks fail", Danger},
"PENDING": {IconPending, "checks running", Warning},
}
// CIBadge renders the GitHub check rollup of a pull request.
func CIBadge(state string, verbose bool) string {
spec, found := ciBadges[state]
if !found {
spec = badgeSpec{IconNone, "no checks", Faint}
}
label := spec.label
if !verbose {
label = ""
}
return glyph(spec.symbol, label, spec.colour)
}
// ImageState describes where a runnable image for a row can come from.
type ImageState int
const (
ImageUnknown ImageState = iota
ImageChecking
ImageRemote
ImageMissing
ImageLocal
ImageStale
ImageError
)
var imageBadges = map[ImageState]badgeSpec{
ImageLocal: {IconLocal, "local", Info},
ImageStale: {IconLocal, "local (outdated)", Muted},
ImageRemote: {IconCloud, "ghcr", Success},
ImageMissing: {"…", "not built", Faint},
ImageError: {"!", "check failed", Danger},
ImageChecking: {"?", "checking", Warning},
ImageUnknown: {"?", "checking", Warning},
}
// ImageBadge renders the preferred image availability for a row. A matching
// local build is shown first; the start action can still offer the registry
// image when both sources are available.
func ImageBadge(state ImageState, verbose bool) string {
spec, found := imageBadges[state]
if !found {
spec = badgeSpec{"?", "checking", Warning}
}
label := spec.label
if !verbose {
label = ""
}
return glyph(spec.symbol, label, spec.colour)
}
// RunningBadge renders container state, filled when the container is up so it
// stands out from every other marker in the row.
func RunningBadge(running bool, port string) string {
if !running {
return glyph(IconStopped, "", Faint)
}
if port == "" {
return chip(IconRunning+" UP", Success)
}
return chip(IconRunning+" :"+port, Success)
}
var stateBadges = map[string]badgeSpec{
"running": {IconRunning, "running", Success},
"restarting": {IconPending, "restarting", Warning},
"created": {IconPending, "created", Warning},
"paused": {IconPending, "paused", Warning},
"exited": {IconStopped, "exited", Danger},
"dead": {IconStopped, "dead", Danger},
}
// StateBadge renders a Docker container state string.
func StateBadge(state string) string {
if spec, found := stateBadges[state]; found {
return glyph(spec.symbol, spec.label, spec.colour)
}
return glyph(IconStopped, state, Faint)
}
var healthBadges = map[string]badgeSpec{
"healthy": {IconHealth, "healthy", Success},
"unhealthy": {IconFail, "unhealthy", Danger},
"starting": {IconPending, "starting", Warning},
}
// HealthBadge renders the healthcheck verdict Docker embeds in a status string.
func HealthBadge(health string) string {
if spec, found := healthBadges[health]; found {
return glyph(spec.symbol, spec.label, spec.colour)
}
return ""
}
// ModeBadge marks a non-default interaction mode in the header.
func ModeBadge(label string, colour color.Color) string { return chip(label, colour) }
var taskGlyphs = map[string]struct {
symbol string
colour color.Color
}{
"running": {IconPending, Warning},
"succeeded": {IconPass, Success},
"failed": {IconFail, Danger},
}
// TaskBadge renders the outcome of a background job.
func TaskBadge(state, kind string) string {
if spec, found := taskGlyphs[state]; found {
return glyph(spec.symbol, kind, spec.colour)
}
return glyph(IconNone, kind, Faint)
}
// Bar renders a fixed width progress bar. The bubbles progress component
// animates a single value with a spring; these bars are drawn many per frame
// for individual layers and steps, where an instant, exact bar reads better
// than a dozen independently easing ones.
func Bar(percent float64, width int, colour color.Color) string {
if width <= 0 {
return ""
}
if percent < 0 {
percent = 0
}
if percent > 1 {
percent = 1
}
filled := int(percent * float64(width))
empty := width - filled
return lipgloss.NewStyle().Foreground(colour).Render(strings.Repeat("█", filled)) +
lipgloss.NewStyle().Foreground(Faint).Render(strings.Repeat("░", empty))
}
// Percent formats a fraction for display next to a bar.
func Percent(value float64) string { return fmt.Sprintf("%3.0f%%", value*100) }
+138
View File
@@ -0,0 +1,138 @@
package ui
import "charm.land/bubbles/v2/key"
// KeyMap is the complete binding set. Bindings are declared once here so the
// help overlay, the footer hints, and the dispatcher can never drift apart —
// adding a key to the map is what makes it appear in the help.
type KeyMap struct {
Up key.Binding
Down key.Binding
Top key.Binding
Bottom key.Binding
Enter key.Binding
Filter key.Binding
Refresh key.Binding
Quit key.Binding
Help key.Binding
Dev key.Binding
Instances key.Binding
Cycle key.Binding
Sidebar key.Binding
SidebarTab key.Binding
Pin key.Binding
Follow key.Binding
PageUp key.Binding
PageDown key.Binding
Pull key.Binding
Build key.Binding
Demo key.Binding
Bots key.Binding
OpenPR key.Binding
OpenApp key.Binding
Copy key.Binding
Stop key.Binding
Restart key.Binding
Remove key.Binding
Manage key.Binding
Tasks key.Binding
Cancel key.Binding
ManageImage key.Binding
ManageData key.Binding
ManageBuild key.Binding
ManageStop key.Binding
ManagePrune key.Binding
ManageConfirm key.Binding
ManageAbort key.Binding
}
func DefaultKeyMap() KeyMap {
return KeyMap{
Up: key.NewBinding(key.WithKeys("up", "k"), key.WithHelp("↑/k", "up")),
Down: key.NewBinding(key.WithKeys("down", "j"), key.WithHelp("↓/j", "down")),
Top: key.NewBinding(key.WithKeys("home", "g"), key.WithHelp("g", "top")),
Bottom: key.NewBinding(key.WithKeys("end", "G"), key.WithHelp("G", "bottom")),
Enter: key.NewBinding(key.WithKeys("enter", " "), key.WithHelp("enter", "start/stop")),
Filter: key.NewBinding(key.WithKeys("/"), key.WithHelp("/", "filter")),
Refresh: key.NewBinding(key.WithKeys("r"), key.WithHelp("r", "refresh")),
Quit: key.NewBinding(key.WithKeys("q", "ctrl+c"), key.WithHelp("q", "quit")),
Help: key.NewBinding(key.WithKeys("?"), key.WithHelp("?", "help")),
Dev: key.NewBinding(key.WithKeys("1"), key.WithHelp("1", "development")),
Instances: key.NewBinding(key.WithKeys("2"), key.WithHelp("2", "instances")),
Cycle: key.NewBinding(key.WithKeys("d"), key.WithHelp("d", "switch screen")),
Sidebar: key.NewBinding(key.WithKeys("l"), key.WithHelp("l", "sidebar")),
SidebarTab: key.NewBinding(key.WithKeys("tab"), key.WithHelp("tab", "logs/build/ci")),
Pin: key.NewBinding(key.WithKeys("L"), key.WithHelp("L", "pin logs")),
Follow: key.NewBinding(key.WithKeys("f"), key.WithHelp("f", "follow")),
PageUp: key.NewBinding(key.WithKeys("pgup"), key.WithHelp("pgup", "scroll up")),
PageDown: key.NewBinding(key.WithKeys("pgdown"), key.WithHelp("pgdn", "scroll down")),
Pull: key.NewBinding(key.WithKeys("p"), key.WithHelp("p", "pull remote")),
Build: key.NewBinding(key.WithKeys("R"), key.WithHelp("R", "build locally")),
Demo: key.NewBinding(key.WithKeys("M"), key.WithHelp("M", "demo mode")),
Bots: key.NewBinding(key.WithKeys("b"), key.WithHelp("b", "bot PRs")),
OpenPR: key.NewBinding(key.WithKeys("o"), key.WithHelp("o", "open PR")),
OpenApp: key.NewBinding(key.WithKeys("a"), key.WithHelp("a", "open app")),
Copy: key.NewBinding(key.WithKeys("c"), key.WithHelp("c", "copy URL")),
Stop: key.NewBinding(key.WithKeys("s"), key.WithHelp("s", "stop")),
Restart: key.NewBinding(key.WithKeys("S"), key.WithHelp("S", "restart")),
Remove: key.NewBinding(key.WithKeys("x"), key.WithHelp("x", "remove")),
Manage: key.NewBinding(key.WithKeys("m"), key.WithHelp("m", "manage")),
Tasks: key.NewBinding(key.WithKeys("t"), key.WithHelp("t", "tasks")),
Cancel: key.NewBinding(key.WithKeys("esc"), key.WithHelp("esc", "clear filter")),
ManageImage: key.NewBinding(key.WithKeys("i"), key.WithHelp("i", "delete image")),
ManageData: key.NewBinding(key.WithKeys("d"), key.WithHelp("d", "delete data")),
ManageBuild: key.NewBinding(key.WithKeys("b"), key.WithHelp("b", "rebuild locally")),
ManageStop: key.NewBinding(key.WithKeys("c"), key.WithHelp("c", "remove container")),
ManagePrune: key.NewBinding(key.WithKeys("p"), key.WithHelp("p", "prune stopped")),
ManageConfirm: key.NewBinding(key.WithKeys("y", "enter"), key.WithHelp("y", "confirm")),
ManageAbort: key.NewBinding(key.WithKeys("n", "esc"), key.WithHelp("n", "cancel")),
}
}
// ShortHelp is the footer hint set, kept to what fits on two lines.
func (k KeyMap) ShortHelp() []key.Binding {
return []key.Binding{k.Up, k.Down, k.Enter, k.Filter, k.Sidebar, k.Manage, k.Tasks, k.Cycle, k.Help, k.Quit}
}
// FullHelp is the grouped set rendered by the help overlay.
func (k KeyMap) FullHelp() [][]key.Binding {
return [][]key.Binding{
{k.Up, k.Down, k.Top, k.Bottom, k.Filter, k.Refresh},
{k.Enter, k.Pull, k.Build, k.Demo, k.Bots},
{k.Sidebar, k.SidebarTab, k.Pin, k.Follow, k.PageUp, k.PageDown},
{k.Stop, k.Restart, k.Remove, k.OpenPR, k.OpenApp, k.Copy},
{k.Manage, k.Tasks, k.Dev, k.Instances, k.Cycle, k.Quit},
}
}
// DevHelp is the footer hint set for the development screen.
func (k KeyMap) DevHelp() []key.Binding {
return []key.Binding{k.Enter, k.Pull, k.Build, k.Demo, k.OpenPR, k.OpenApp, k.Bots}
}
// InstanceHelp is the footer hint set for the instances screen.
func (k KeyMap) InstanceHelp() []key.Binding {
return []key.Binding{k.Enter, k.Stop, k.Restart, k.Remove, k.Build, k.OpenApp, k.Copy}
}
// CommonHelp is the second footer line, shared by both screens.
func (k KeyMap) CommonHelp() []key.Binding {
return []key.Binding{k.Filter, k.Cancel, k.Sidebar, k.SidebarTab, k.Pin, k.Follow, k.Manage, k.Tasks, k.Cycle, k.Refresh, k.Help, k.Quit}
}
// ManageHelp is the binding set shown while manage mode is armed.
func (k KeyMap) ManageHelp() []key.Binding {
return []key.Binding{k.ManageBuild, k.ManageImage, k.ManageData, k.ManageStop, k.ManagePrune, k.ManageAbort}
}
+80
View File
@@ -0,0 +1,80 @@
// Package ui holds the CLI's visual vocabulary: one palette, one set of status
// badges, and one keymap, so every screen looks and behaves the same way.
package ui
import (
"image/color"
"strings"
"charm.land/lipgloss/v2"
"github.com/charmbracelet/x/ansi"
)
// The palette is intentionally small. Colour carries meaning here — green is
// healthy, red is broken, amber is in flight, cyan is local — so introducing
// extra hues would dilute the signal rather than add information.
var (
Accent = lipgloss.Color("212")
Success = lipgloss.Color("42")
Warning = lipgloss.Color("214")
Danger = lipgloss.Color("203")
Info = lipgloss.Color("81")
Muted = lipgloss.Color("241")
Faint = lipgloss.Color("238")
Text = lipgloss.Color("252")
Bright = lipgloss.Color("230")
Ink = lipgloss.Color("235")
)
var (
Title = lipgloss.NewStyle().Bold(true).Foreground(Accent)
Heading = lipgloss.NewStyle().Bold(true).Foreground(Bright)
Help = lipgloss.NewStyle().Foreground(Muted)
Dim = lipgloss.NewStyle().Foreground(Faint)
Body = lipgloss.NewStyle().Foreground(Text)
OK = lipgloss.NewStyle().Foreground(Success)
Alert = lipgloss.NewStyle().Foreground(Danger)
Pending = lipgloss.NewStyle().Foreground(Warning)
Local = lipgloss.NewStyle().Foreground(Info)
Selected = lipgloss.NewStyle().Bold(true).Foreground(Bright).Background(lipgloss.Color("57"))
)
// Panel frames the sidebar and overlays.
func Panel(title string, focused bool) lipgloss.Style {
var border color.Color = Faint
if focused {
border = Accent
}
return lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
BorderForeground(border).
Padding(0, 1)
}
// Rule draws a labelled separator across the given width.
func Rule(label string, width int) string {
if width < 8 {
return Dim.Render(Truncate(label, width))
}
prefix := "── " + label + " "
prefixWidth := lipgloss.Width(prefix)
if prefixWidth >= width {
return Dim.Render(Truncate(prefix, width))
}
fill := width - prefixWidth
return Dim.Render(prefix + strings.Repeat("─", fill))
}
// Blank reports whether a line would render as empty. Build tools emit lines
// that hold nothing but a colour reset; they are not empty as strings but they
// occupy a row for no reason, which turns a log panel into double-spaced text.
func Blank(line string) bool { return lipgloss.Width(strings.TrimSpace(line)) == 0 }
// Truncate shortens a string to display width, marking the cut with an ellipsis.
// It handles ANSI escape sequences and multi-byte runes correctly.
func Truncate(value string, width int) string {
if width <= 0 {
return ""
}
return ansi.Truncate(value, width, "…")
}