summaryrefslogtreecommitdiff
path: root/internal/tui/flamegraph/model.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-26 22:38:24 +0300
committerPaul Buetow <paul@buetow.org>2026-05-26 22:38:24 +0300
commit66332e4012e3cfad79f9309a4fd7937f5ccf0d26 (patch)
tree1159da3ce3a82a7c22c4e18626dba5ce2c4ab3de /internal/tui/flamegraph/model.go
parentdbd2d5a9afc496b6e913885fea3922f3fed9c4a0 (diff)
flamegraph: add height metric controls/keybinding (so)
Diffstat (limited to 'internal/tui/flamegraph/model.go')
-rw-r--r--internal/tui/flamegraph/model.go29
1 files changed, 26 insertions, 3 deletions
diff --git a/internal/tui/flamegraph/model.go b/internal/tui/flamegraph/model.go
index 7fb3983..065a78a 100644
--- a/internal/tui/flamegraph/model.go
+++ b/internal/tui/flamegraph/model.go
@@ -194,6 +194,7 @@ type Model struct {
fieldPresets [][]string
fieldIndex int
countField string
+ heightField string
paused bool
@@ -244,13 +245,16 @@ func NewModel(liveTrie LiveTrieSource) Model {
{"tracepoint", "comm", "path"},
{"pid", "tracepoint", "path"},
{"comm", "path", "tracepoint"},
+ {"tracepoint", "comm", "pid"},
},
- isDark: true,
- keys: defaultFlameKeyMap(),
- countField: "count",
+ isDark: true,
+ keys: defaultFlameKeyMap(),
+ countField: "count",
+ heightField: "",
}
m.syncFieldPresetToTrie()
m.syncCountFieldToTrie()
+ m.syncHeightFieldToTrie()
return m
}
@@ -357,6 +361,8 @@ func (m *Model) handleModeKey(msg tea.KeyPressMsg) bool {
m.cycleFieldOrder()
case isCycleMetricKey(msg):
m.toggleCountField()
+ case isToggleHeightKey(msg):
+ m.toggleHeightField()
case isHelpToggleKey(msg):
m.toggleHelp()
case isZoomInKey(msg, m.keys):
@@ -455,6 +461,7 @@ func (m Model) ConsumesKey(msg tea.KeyPressMsg) bool {
isResetBaselineKey(msg),
isCycleOrderKey(msg),
isCycleMetricKey(msg),
+ isToggleHeightKey(msg),
isHelpToggleKey(msg):
return true
case isZoomInKey(msg, m.keys),
@@ -551,6 +558,7 @@ func (m *Model) SetLiveTrie(liveTrie LiveTrieSource) {
m.liveTrie = liveTrie
m.syncFieldPresetToTrie()
m.syncCountFieldToTrie()
+ m.syncHeightFieldToTrie()
m.lastVersion = 0
m.snapshot = nil
m.globalTotal = 0
@@ -593,6 +601,20 @@ func (m *Model) syncCountFieldToTrie() {
m.countField = field
}
+func (m *Model) syncHeightFieldToTrie() {
+ if m.liveTrie == nil {
+ m.heightField = ""
+ return
+ }
+ field := strings.TrimSpace(m.liveTrie.HeightField())
+ switch field {
+ case "", "count", "bytes", "duration":
+ m.heightField = field
+ default:
+ m.heightField = ""
+ }
+}
+
// RefreshFromLiveTrie loads a new snapshot synchronously and returns true when
// a new snapshot was applied. Retained as a simple facade for tests; the
// production TUI now uses RefreshFromLiveTrieCmd to do the heavy lifting on a
@@ -921,6 +943,7 @@ func isCycleOrderKey(msg tea.KeyPressMsg) bool { return keyString(msg) == "o" }
func isCycleMetricKey(msg tea.KeyPressMsg) bool {
return keyString(msg) == "b"
}
+func isToggleHeightKey(msg tea.KeyPressMsg) bool { return keyString(msg) == "v" }
func isHelpToggleKey(msg tea.KeyPressMsg) bool { return keyString(msg) == "?" }
func isZoomInKey(msg tea.KeyPressMsg, keys flameKeyMap) bool {