diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-25 09:23:19 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-25 09:23:19 +0200 |
| commit | 1279ffb8f2efba54ff005cce91ba65c149cb1ee6 (patch) | |
| tree | 102483e8d836501b3b935e0674d6608fbe9f4f1f /internal/tui/dashboard/files.go | |
| parent | b3625cc67c81b4c1bd654a9fcdaf624d76306b07 (diff) | |
Improve TUI layout and increase sparkline height
Diffstat (limited to 'internal/tui/dashboard/files.go')
| -rw-r--r-- | internal/tui/dashboard/files.go | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/internal/tui/dashboard/files.go b/internal/tui/dashboard/files.go index 945869e..faade8d 100644 --- a/internal/tui/dashboard/files.go +++ b/internal/tui/dashboard/files.go @@ -17,18 +17,19 @@ func renderFilesWithOffset(snap *statsengine.Snapshot, width, height, offset int return "Files: waiting for stats..." } - rows := fileRows(snap.Files()) + pathWidth := filePathWidth(width) + rows := fileRows(snap.Files(), pathWidth) if len(rows) == 0 { return "Files: no data" } columns := []table.Column{ - {Title: "Path", Width: filePathWidth(width)}, {Title: "Accesses", Width: 8}, {Title: "Read", Width: 9}, {Title: "Write", Width: 9}, {Title: "Avg Latency", Width: 11}, {Title: "Max Latency", Width: 11}, + {Title: "Path", Width: pathWidth}, } tbl := table.New( @@ -43,16 +44,16 @@ func renderFilesWithOffset(snap *statsengine.Snapshot, width, height, offset int return tbl.View() + fmt.Sprintf("\nRow %d/%d", cursor+1, len(rows)) } -func fileRows(files []statsengine.FileSnapshot) []table.Row { +func fileRows(files []statsengine.FileSnapshot, pathWidth int) []table.Row { rows := make([]table.Row, 0, len(files)) for _, f := range files { rows = append(rows, table.Row{ - truncatePathMiddle(f.Path, 48), strconv.FormatUint(f.Accesses, 10), formatBytes(float64(f.BytesRead)), formatBytes(float64(f.BytesWritten)), formatDurationNs(f.AvgLatencyNs), formatDurationUintNs(f.MaxLatencyNs), + truncatePathMiddle(f.Path, pathWidth), }) } return rows @@ -62,15 +63,12 @@ func filePathWidth(width int) int { if width <= 0 { return 24 } - // Reserve enough room for non-path columns and table separators so - // latency columns remain visible even on narrower terminals. - w := width - 70 + // Keep fixed metrics visible and let path consume the remaining space. + // Fixed columns sum to 48 chars; reserve extra for separators/padding. + w := width - 58 if w < 14 { return 14 } - if w > 52 { - return 52 - } return w } |
