summaryrefslogtreecommitdiff
path: root/internal/tui
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-25 21:57:30 +0200
committerPaul Buetow <paul@buetow.org>2026-02-25 21:57:30 +0200
commit67e10f34c92e93343adbd690b3b21e455e863bd3 (patch)
tree5de8f76cea00ea7c70703cb215cb5eb12fd17fa3 /internal/tui
parent92dbc37ed6d4b1758fae3fa7ae02dc58b8f81d4d (diff)
Fix probes bulk toggles and stabilize modal row rendering
Diffstat (limited to 'internal/tui')
-rw-r--r--internal/tui/probes/model.go24
1 files changed, 23 insertions, 1 deletions
diff --git a/internal/tui/probes/model.go b/internal/tui/probes/model.go
index 5715d03..dffa30f 100644
--- a/internal/tui/probes/model.go
+++ b/internal/tui/probes/model.go
@@ -4,6 +4,7 @@ import (
"fmt"
"ior/internal/probemanager"
"strings"
+ "unicode/utf8"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
@@ -266,7 +267,7 @@ func (m Model) View(width, height int) string {
}
line := fmt.Sprintf("%s%s %-24s", prefix, check, p.Syscall)
if p.Error != "" {
- line += " ! " + p.Error
+ line += " ! " + truncateText(sanitizeOneLine(p.Error), 28)
}
lines = append(lines, line)
}
@@ -313,3 +314,24 @@ func bulkToggleCmd(manager Manager, probes []probemanager.ProbeState, sourceActi
return ProbeToggledMsg{Err: firstErr}
}
}
+
+func sanitizeOneLine(s string) string {
+ s = strings.ReplaceAll(s, "\n", " ")
+ s = strings.ReplaceAll(s, "\r", " ")
+ s = strings.ReplaceAll(s, "\t", " ")
+ return s
+}
+
+func truncateText(s string, limit int) string {
+ if limit <= 0 {
+ return ""
+ }
+ if utf8.RuneCountInString(s) <= limit {
+ return s
+ }
+ runes := []rune(s)
+ if limit <= 3 {
+ return string(runes[:limit])
+ }
+ return string(runes[:limit-3]) + "..."
+}