summaryrefslogtreecommitdiff
path: root/internal/tmux
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-16 03:54:28 +0200
committerPaul Buetow <paul@buetow.org>2026-03-16 03:54:28 +0200
commit93dfe3798e03e74766b229418cde364a5ef29ae9 (patch)
tree4438058be9bee9a9b8682148a1f8417a530fac2f /internal/tmux
parent8d9d903852a2cd28034e00e116a7bfcc14783108 (diff)
Replace custom stringsTrim with strings.TrimSpace
Remove duplicate stringsTrim implementations in stats and tmux packages, replacing all call sites with the standard library strings.TrimSpace. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/tmux')
-rw-r--r--internal/tmux/status.go21
-rw-r--r--internal/tmux/status_coverage_test.go6
2 files changed, 6 insertions, 21 deletions
diff --git a/internal/tmux/status.go b/internal/tmux/status.go
index dcc0714..2f8cff6 100644
--- a/internal/tmux/status.go
+++ b/internal/tmux/status.go
@@ -76,7 +76,7 @@ func FormatGlobalStatusColored(globalReqs int64, globalRPM float64, globalIn, gl
gout := textutil.HumanBytes(globalOut)
head := fmt.Sprintf("%sΣ@%s %s↑%s%s %s↓%s%s %.1frpm", baseFGToken, humanWindow(window), arrowUpToken, baseFGToken, gin, arrowDownToken, baseFGToken, gout, globalRPM)
// Narrow modes: only show Σ head
- if narrowEnabled() || stringsTrim(scopeProvider) == "" || stringsTrim(scopeModel) == "" {
+ if narrowEnabled() || strings.TrimSpace(scopeProvider) == "" || strings.TrimSpace(scopeModel) == "" {
return head
}
tail := fmt.Sprintf(" | %s:%s %.1frpm %dr", scopeProvider, scopeModel, scopeRPM, scopeReqs)
@@ -108,7 +108,7 @@ func humanWindow(d time.Duration) string {
// narrowEnabled returns true when HEXAI_TMUX_STATUS_NARROW is truthy (1/true/yes/on).
func narrowEnabled() bool {
- v := strings.ToLower(stringsTrim(os.Getenv("HEXAI_TMUX_STATUS_NARROW")))
+ v := strings.ToLower(strings.TrimSpace(os.Getenv("HEXAI_TMUX_STATUS_NARROW")))
if v == "" {
return false
}
@@ -122,7 +122,7 @@ func narrowEnabled() bool {
// maxStatusLen returns HEXAI_TMUX_STATUS_MAXLEN parsed as int; 0 disables.
func maxStatusLen() int {
- v := stringsTrim(os.Getenv("HEXAI_TMUX_STATUS_MAXLEN"))
+ v := strings.TrimSpace(os.Getenv("HEXAI_TMUX_STATUS_MAXLEN"))
if v == "" {
return 0
}
@@ -146,21 +146,6 @@ func truncateStatus(s string, n int) string {
return s[:n-1] + "…"
}
-func stringsTrim(s string) string {
- i := 0
- j := len(s)
- for i < j && (s[i] == ' ' || s[i] == '\t' || s[i] == '\n' || s[i] == '\r') {
- i++
- }
- for j > i && (s[j-1] == ' ' || s[j-1] == '\t' || s[j-1] == '\n' || s[j-1] == '\r') {
- j--
- }
- if i == 0 && j == len(s) {
- return s
- }
- return s[i:j]
-}
-
// FormatLLMStartStatus renders a short colored heartbeat at start/initialize time.
// Example: "LLM:openai:gpt-4.1 ⏳"
func FormatLLMStartStatus(provider, model string) string {
diff --git a/internal/tmux/status_coverage_test.go b/internal/tmux/status_coverage_test.go
index 8f7c034..0c76ee6 100644
--- a/internal/tmux/status_coverage_test.go
+++ b/internal/tmux/status_coverage_test.go
@@ -141,7 +141,7 @@ func TestTruncateStatus(t *testing.T) {
}
}
-// --- stringsTrim ---
+// --- strings.TrimSpace ---
func TestStringsTrim(t *testing.T) {
tests := []struct {
@@ -163,9 +163,9 @@ func TestStringsTrim(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- got := stringsTrim(tt.s)
+ got := strings.TrimSpace(tt.s)
if got != tt.want {
- t.Errorf("stringsTrim(%q) = %q, want %q", tt.s, got, tt.want)
+ t.Errorf("strings.TrimSpace(%q) = %q, want %q", tt.s, got, tt.want)
}
})
}