From 647a573e7ccb6bb48b780b1637fa9ba394ca4ba2 Mon Sep 17 00:00:00 2001 From: furiosa Date: Sun, 25 Jan 2026 13:12:20 -0800 Subject: [PATCH] fix(statusline): limit max rigs displayed to prevent overflow When many rigs are registered, the tmux statusline would truncate or overflow. This adds a configurable maximum (default 5) with an overflow indicator showing how many rigs are hidden (e.g., "+3"). Running rigs are prioritized (shown first) due to existing sort order. Configure via GT_MAX_RIGS_DISPLAY env var: - Default: 5 rigs shown - Set to 0 for unlimited - Set to any positive number for custom limit Fixes: h-4wtnc Co-Authored-By: Claude Opus 4.5 --- internal/cmd/statusline.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/internal/cmd/statusline.go b/internal/cmd/statusline.go index a14b40a8..eac8a357 100644 --- a/internal/cmd/statusline.go +++ b/internal/cmd/statusline.go @@ -5,6 +5,7 @@ import ( "os" "path/filepath" "sort" + "strconv" "strings" "github.com/spf13/cobra" @@ -320,6 +321,20 @@ func runMayorStatusLine(t *tmux.Tmux) error { return rigs[i].name < rigs[j].name }) + // Truncate to max rigs if there are too many to display + // Default: 5, configurable via GT_MAX_RIGS_DISPLAY env var (0 = unlimited) + maxRigs := 5 + if envMax := os.Getenv("GT_MAX_RIGS_DISPLAY"); envMax != "" { + if parsed, err := strconv.Atoi(envMax); err == nil && parsed >= 0 { + maxRigs = parsed + } + } + overflow := 0 + if maxRigs > 0 && len(rigs) > maxRigs { + overflow = len(rigs) - maxRigs + rigs = rigs[:maxRigs] + } + // Build display with group separators var rigParts []string var lastGroup string @@ -366,6 +381,11 @@ func runMayorStatusLine(t *tmux.Tmux) error { rigParts = append(rigParts, led+space+rig.name) } + // Add overflow indicator if rigs were truncated + if overflow > 0 { + rigParts = append(rigParts, fmt.Sprintf("+%d", overflow)) + } + if len(rigParts) > 0 { parts = append(parts, strings.Join(rigParts, " ")) }