summaryrefslogtreecommitdiff
path: root/internal/tui/dashboard/icicle.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-08 11:26:11 +0200
committerPaul Buetow <paul@buetow.org>2026-03-08 11:26:11 +0200
commitf903279e8a872cd7c417f2f57bf306bfb3f3cb87 (patch)
tree03f68465d68cee8919f45f90c6cbc2ebde2a9b17 /internal/tui/dashboard/icicle.go
parent9cbf9ec8e9eac92431b9a742c1b625888cb69dfa (diff)
dashboard: clamp icicle selection by rendered tile count
Diffstat (limited to 'internal/tui/dashboard/icicle.go')
-rw-r--r--internal/tui/dashboard/icicle.go31
1 files changed, 31 insertions, 0 deletions
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: "/",