From f903279e8a872cd7c417f2f57bf306bfb3f3cb87 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 8 Mar 2026 11:26:11 +0200 Subject: dashboard: clamp icicle selection by rendered tile count --- internal/tui/dashboard/icicle.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'internal/tui/dashboard/icicle.go') diff --git a/internal/tui/dashboard/icicle.go b/internal/tui/dashboard/icicle.go index 3761fc8..92c4834 100644 --- a/internal/tui/dashboard/icicle.go +++ b/internal/tui/dashboard/icicle.go @@ -79,6 +79,37 @@ func renderFilesIcicle(snap *statsengine.Snapshot, width, height int, metric bub return strings.Join(lines, "\n") } +func filesIcicleTileCount(snap *statsengine.Snapshot, width, height int, metric bubbleMetric) int { + if snap == nil { + return 0 + } + if width <= 0 { + width = 80 + } + if height <= 0 { + height = 18 + } + + dirs := aggregateFilesByDir(snap.Files()) + if len(dirs) == 0 { + return 0 + } + root := buildIcicleTree(dirs) + children := sortedIcicleChildren(root, metric) + if len(children) == 0 { + return 0 + } + + chartHeight := height - 2 + if chartHeight < 4 { + chartHeight = 4 + } + + tiles := make([]icicleTile, 0, 64) + layoutIcicle(children, 0, width, 0, chartHeight, 0, metric, &tiles) + return len(tiles) +} + func buildIcicleTree(dirs []DirSnapshot) *icicleNode { root := &icicleNode{ name: "/", -- cgit v1.2.3